CMake: remove setting of policy CMP0043 to OLD.

CMake 3.0 ignores the suffixed COMPILE_DEFINITIONS_<CONFIG> variants if policy
CMP0043 is NEW, preferring instead to consume the unsuffixed COMPILE_DEFINITONS
property and evaluate generator expressions in it.

Setting the policy to OLD causes CMake 3.0 to not ignore those properties.

Use the suffixed properties for compatibility only for CMake versions older
than 3.0 using an explicit version check.  Use the non-suffixed property with
generator expressions otherwise.

These definitions should mostly not be needed at all - CMake already sets
NDEBUG in suffixed CMAKE_CXX_FLAGS_<CONFIG> variables.  The _DEBUG macro is
non-standard, but is used in several places in blender (usually in an OR
combination with the DEBUG macro).  Additionally, blender overwrites (instead
of appending to) the CMAKE_CXX_FLAGS_<CONFIG> variables on WIN32.

Rather than try to fundamentally change how debug-macros are handled in
blender, change the buildsystem to keep the same behavior without requiring the
CMP0043 policy set to OLD.
This commit is contained in:
Stephen Kelly 2015-11-10 06:30:26 +11:00 committed by Campbell Barton
parent edc780c3b0
commit 92f059774d
1 changed files with 15 additions and 9 deletions

View File

@ -47,11 +47,6 @@ endif()
cmake_minimum_required(VERSION 2.8)
if(NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
# keep until CMake-3.0 is min requirement
cmake_policy(SET CMP0043 OLD)
endif()
if(NOT EXECUTABLE_OUTPUT_PATH)
set(FIRST_RUN TRUE)
else()
@ -68,10 +63,21 @@ set(CMAKE_BUILD_TYPE_INIT "Release")
# set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
# global compile definitions since add_definitions() adds for all.
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG _DEBUG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE NDEBUG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL NDEBUG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO NDEBUG)
if(NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
$<$<CONFIG:Debug>:DEBUG;_DEBUG>
$<$<CONFIG:Release>:NDEBUG>
$<$<CONFIG:MinSizeRel>:NDEBUG>
$<$<CONFIG:RelWithDebInfo>:NDEBUG>
)
else()
# keep until CMake-3.0 is min requirement
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG _DEBUG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE NDEBUG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL NDEBUG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO NDEBUG)
endif()
#-----------------------------------------------------------------------------
# Set policy