Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake check if the main project was called

Tags:

cmake

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?

like image 598
Dejwi Avatar asked Nov 08 '12 12:11

Dejwi


1 Answers

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()
like image 195
arrowd Avatar answered Nov 15 '22 08:11

arrowd