2

I am using CMake for my project and I am relying on a number of different third-party libraries, who themselves use CMake.

Many of them provide Options in their main CMake such as -

option(GLM_QUIET "No CMake Message" OFF)
option(BUILD_SHARED_LIBS "Build shared library" ON)
option(BUILD_STATIC_LIBS "Build static library" ON)
option(GLM_TEST_ENABLE_CXX_98 "Enable C++ 98" OFF)

option ( ASSIMP_BUILD_ASSIMP_TOOLS
  "If the supplementary tools for Assimp are built in addition to the library."
  ON
)
option ( ASSIMP_BUILD_SAMPLES
  "If the official samples are built as well (needs Glut)."
  OFF
)

I want to set some of these options to be different than their original values when I include them by default.

I tried setting them like this before including the main CMakes -

SET( ASSIMP_BUILD_ASSIMP_TOOLS OFF )

But then I get this error from CMake:

CMake Warning (dev) at Thirdparty/glm/CMakeLists.txt:14 (option):
  Policy CMP0077 is not set: option() honors normal variables.  Run "cmake
  --help-policy CMP0077" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  For compatibility with older versions of CMake, option is clearing the
  normal variable 'ASSIMP_BUILD_ASSIMP_TOOLS '.
This warning is for project developers.  Use -Wno-dev to suppress it.

If I try to do this -

OPTION( ASSIMP_BUILD_ASSIMP_TOOLS OFF )

It just quietly ignores it.

What is the correct way to deal with this?

KaiserJohaan
  • 9,028
  • 20
  • 112
  • 199
  • You either set the variable as a cache entry or enable CMP0077 to enable the new behavior and `SET( ASSIMP_BUILD_ASSIMP_TOOLS OFF )` should have worked as expected. – fdk1342 Jun 28 '19 at 13:48

0 Answers0