inconsistent behaviour of option variables and policy CMP0012
I am using an option variable from a CMakeLists.txt in a package configuration file and its value is changed from 1 to ON by cmake, which then triggers the warning wrt. CMP0012 (and results in the wrong package configuration for dependent packages):
- in CMakeLists.txt
OPTION( MARLINTRK_USE_GEAR "Set to OFF to not provide Gear backward compatibility " 1)
- in packageConfig.cmake.in
IF( @MARLINTRK_USE_GEAR@ )
SET( MarlinTrk_DEFINITIONS "-D MARLINTRK_BACKWARD_GEAR_WRAPPERS" )
ENDIF()
- which is expanded in the packageConfig.cmake file as
IF( ON )
SET( MarlinTrk_DEFINITIONS "-D MARLINTRK_BACKWARD_GEAR_WRAPPERS" )
ENDIF()
-
this then causes dependent packages to not have the correct DEFINITIONS for the package
-
observed with cmake version 3.3.2 and 3.6.3