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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM