Issue
Given I have defined an executable with its main source file in a CMakeList.txt
file:
ADD_EXECUTABLE(MyExampleApp main.cpp)
Can I add further source files to this executable after this line but in the same or an included CMakeList.txt
file?
Solution
Use target_sources
, available since cmake 3.1
eg.
target_sources(MyExampleApp PRIVATE ${extra_file})
https://cmake.org/cmake/help/v3.1/command/target_sources.html
Answered By - ACyclic