Can one add further source files to an executable once defined?

后端 未结 3 1844
故里飘歌
故里飘歌 2021-02-02 06:13

Given I have defined an executable with its main source file in a CMakeList.txt file:

ADD_EXECUTABLE(MyExampleApp main.cpp)

Can I

3条回答
  •  野的像风
    2021-02-02 06:28

    I think you may use:

    add_executable(MyExampleApp main.cpp)
    add_library(library STATIC ${ADDITIONAL_SOURCES})
    set_target_properties(library PROPERTIES
         LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
    target_link_libraries(MyExampleApp library)
    

提交回复
热议问题