I’m currently learning in-deep CMake and I found something I don’t understand.
I have this script:
cmake_minimum_required(VERSION 4.2)
project(CmakeLearn VERSION 1.0 LANGUAGES CXX)
# check that CMAKE_BUILD_TYPE is defined
set(BUILD_TYPES "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
if(NOT (CMAKE_BUILD_TYPE IN_LIST BUILD_TYPES))
message(FATAL_ERROR "CMAKE_BUILD_TYPE is not defined! Please set it to Debug, Release, RelWithDebInfo, or MinSizeRel.")
endif()
set(SOURCE_FILES
"src/main.cpp"
)
add_executable(MyApp ${SOURCE_FILES})
target_include_directories(MyApp PRIVATE ./include)
set(CACHE{MYAPP_ADVANCED_CVAR}
TYPE STRING
HELP "This cache variable is hidden"
VALUE "I'm hidding")
#mark_as_advanced(MYAPP_ADVANCED_CVAR)
If I execute it in the GUI I see these non-advanced variables:
- CMAKE_BUILD_TYPE
- CMAKE_INSTALL_PREFIX
- MYAPP_ADVANCED_CVAR
If I uncomment the last line to mark MYAPP_ADVANCED_CVAR as advanced it changes to this:
- CMAKE_INSTALL_PREFIX
I don’t understand why the CMAKE_BUILD_TYPE disappears from the non-advanced list of variables.
Also, shouldn’t CMAKE_INSTALL_PREFIX be an advanced variable?
I’m using CMake 4.2.1 in Ubuntu 20.