I've got this kind of project directory design:
Main:
CMakeLists.txt
subproject1:
CMakeLists.txt
subproject2
CMakeLists.txt
How can I check in subproject1/CMakeLists.txt file if subproject1 cmake was called by the Main project, or as a standalone one?
Here you go:
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
# We are building as stand-alone project
project(subproject1)
...
else()
# We are building as part of Main project
endif()
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