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?
An IMPORTED executable target references an executable file located outside the project. No rules are generated to build it, and the IMPORTED target property is True . The target name has scope in the directory in which it is created and below, but the GLOBAL option extends visibility.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With