How do I pass project specific variables down to subdirectory? I wonder if there is a "official" way of doing this:
# (CMAKE_BUILD_TYPE is one of None, Debug, Release, RelWithDebInfo)
# ...
# set specific build type for 'my_library'
set( CMAKE_BUILD_TYPE_COPY "${CMAKE_BUILD_TYPE}" )
set( CMAKE_BUILD_TYPE "Release" )
add_subdirectory( "my_library" )
set( CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_COPY} )
# continue with original build type
# ...
The library/subdirectory my_library
should always be buildt with type "Release"
, main project and other subdirectories should be buildt with type defined by configuration. I am not able to modify the CMakeLists.txt
of my_library
.