cmake 同时编译多个cpp文件

cmake_minimum_required(VERSION 2.8)
project(coding)
file(GLOB_RECURSE EXTRA_FILES */*)
add_custom_target(${PROJECT_NAME}_OTHER_FILES ALL WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} SOURCES ${EXTRA_FILES})
file(GLOB_RECURSE code_sources "src/*.cpp")
foreach(code_src ${code_sources})
    get_filename_component(mexecutable ${code_src} NAME_WE)
    add_executable(${mexecutable} ${code_src})
endforeach()

一篇博客很好:

http://www.cnblogs.com/dverdon/p/4574221.html

https://stackoverflow.com/questions/6921695/how-can-i-build-a-c-project-with-multiple-interdependent-subdirectories

posted @ 2017-06-26 19:59  每天一点积累  阅读(4071)  评论(0编辑  收藏  举报