现在的位置: 首页 > 综合 > 正文

cmake 示例1

2013年10月10日 ⁄ 综合 ⁄ 共 444字 ⁄ 字号 评论关闭

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

目录树:

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

抱歉!评论已关闭.