Add Source in a subdirectory to a cmake project

后端 未结 3 1216
南方客
南方客 2020-12-02 14:30

I have project which has not been divided into libraries, but the source is organized in a directory tree. I do not know how to tell cmake to go down a directory, then add

3条回答
  •  甜味超标
    2020-12-02 15:02

    Like the second part of arrowdodger's answer says: in project/source/folder1/CMakeLists.txt:

    set(SOURCE
       ${SOURCE}
       ${CMAKE_CURRENT_SOURCE_DIR}/file1.cpp
       ${CMAKE_CURRENT_SOURCE_DIR}/file2.cpp
       PARENT_SCOPE
    )
    set(HEADERS
       ${HEADERS}
       ${CMAKE_CURRENT_SOURCE_DIR}/file1.hpp
       ${CMAKE_CURRENT_SOURCE_DIR}/file2.hpp
       PARENT_SCOPE
    )
    

提交回复
热议问题