cmakebuild-settings

How to do I control which CMake options appear only in "advanced mode"?


I use CMake 3.x in (more than) one of my projects. When I ccmake ., I get a terminal screen with various options to configure - supposedly, the ones a user might want to set manually before building. If I press t I enter "advanced mode", and numerous other options are visible.

Great, right? Except that some options in the non-advanced mode are such which I feel would be a better fit for the advanced mode and not be visible always (in my case it's the results of FindCUDA.cmake).

How can I make certain options only appear in advanced mode?


Solution

  • For make CACHE variable to be appeared in GUI (like ccmake) only in advanced mode, use command mark_as_advanced:

    mark_as_advanced(my_cache_var)
    

    Normally, mark_as_advanced is called by the script, which creates the variable. E.g. "Find" script marks as advanced some of variables obtained via find_path or find_library.

    But it is correct to mark as "advanced" a variable created by some other script.