I have this code project can be built either independently or as a subproject of a larger repository (checking it our as a sub-repository). In the latter case, I have a top-level CMakeLists.txt
for the main project which has
add_subdirectory(${MY_SUBPROJ_SUBDIR})
now, I want the subproject to behave somewhat differently in case it's used via the add_directory()
. Obviously, I would be using a large if
instruction. But what condition do I check? How can CMake "tell", when running for some CMakeLists.txt
, whether it's a subdir file or the main file?