1,文件目录
.
├── CMakeLists.txt
└── src
├── CMakeLists.txt
├── lib
│ ├── hello.h
│ ├── libhello.a
│ └── libhello.so
└── main.cpp
2,cmakeLists.txt
cmake_minimum_required (VERSION 2.6)
link_directories(${PROJECT_SOURCE_DIR}/src/lib)
MESSAGE(STATUS "This is SOURCE dir" ${PROJECT_SOURCE_DIR})
SET(SRC_LIST main.cpp)
ADD_EXECUTABLE(main ${SRC_LIST})
TARGET_LINK_LIBRARIES(main libhello.so)
3,main.cpp
#include "lib/hello.h"
int main(int argc, char *argv[])
{
HelloFunc();
}