cmake 示例1

这个是自己写的一个测试用例:

目录树:

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)

到build下,
cmake ..
make
则生成bin和src
src下有hello程序
bin下有libsayhello.a


posted @ 2013-06-22 23:09  海滨银枪小霸王  阅读(98)  评论(0编辑  收藏  举报