[Bf-blender-cvs] [92f0597] master: CMake: remove setting of policy CMP0043 to OLD.

Stephen Kelly noreply at git.blender.org
Mon Nov 9 20:37:38 CET 2015


Commit: 92f059774d30faf73a695138456f57de49a9b5e4
Author: Stephen Kelly
Date:   Tue Nov 10 06:30:26 2015 +1100
Branches: master
https://developer.blender.org/rB92f059774d30faf73a695138456f57de49a9b5e4

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.

===================================================================

M	CMakeLists.txt

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1b5a0ed..1204cd4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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




More information about the Bf-blender-cvs mailing list