这个是自己写的一个测试用例:
目录树:
CMakeLists.txt
build/
include/
|__say.h
lib
|__say.c
|__CMakeLists.txt
src
|__CMakeLists.txt
|__hello.c
具体代码:
./CMakeLists.txt
project(h)
add_subdirectory(src)
add_subdirectory(lib)
./bin/CMakeList.txt
include_directories(../include)
add_library(sayhello say.c)
./src/CMakeList.txt
include_directory(../include)
add_executable(hello hello.c)
target_link_libraries(hello sayhello)
cmake ..
make
则生成bin和src
src下有hello程序
bin下有libsayhello.a