Skip to content

Instantly share code, notes, and snippets.

@breakin
Created December 30, 2018 21:29
Show Gist options
  • Save breakin/e1052a5c9f2a65bb8df504ffe0458aff to your computer and use it in GitHub Desktop.
Save breakin/e1052a5c9f2a65bb8df504ffe0458aff to your computer and use it in GitHub Desktop.
cmake 3.12
This is for cmake 3.12+ to retain old behaviour:
https://cmake.org/cmake/help/v3.13/policy/CMP0077.html?highlight=policy#policy:CMP0077
By adding the following lines to a root CMakeLists.txt it is easier to use it from another cmake project (using add_subdirectory).
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
That way it is possible to hide and set option variables from the outer Cmake-script like it use to be possible before cmake 3.12.
This can't be set in the project that calls add_subdirectory since cmake_minimum_required resets policies.
@breakin
Copy link
Author

breakin commented Dec 30, 2018

If I have a project A that does add_subdirectory(meshoptimizer) it is nice to be able to just set say variable BUILD_DEMO first.
In old cmake it made the variable disappear as a cached variable to the outside (and show up in say cmake-gui).

As of cmake 3.12 you have to activate new behaviour for CMP077 in meshoptimzier to retain this behaviour.

If it is not set the BUILD_DEMO-variable from outside will be ignored and the varaible will be cached and show up in cmake-gui.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment