[Bf-blender-cvs] [0802e9cf54f] master: Use compiler check for -fmacro-prefix-map

Ankit Meel noreply at git.blender.org
Wed Nov 4 16:31:17 CET 2020


Commit: 0802e9cf54f6858c8ad3ea91910eab6a51486b0a
Author: Ankit Meel
Date:   Wed Nov 4 21:00:29 2020 +0530
Branches: master
https://developer.blender.org/rB0802e9cf54f6858c8ad3ea91910eab6a51486b0a

Use compiler check for -fmacro-prefix-map

Use a more reliable method to check the availability of the flag than
compiler versions. Some compilers have different behaviors for
C and C++.

Reviewed By: campbellbarton, ChrisLend

Differential Revision: https://developer.blender.org/D9446

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

M	CMakeLists.txt

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ce5feb1b385..aba2fa806b0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1662,15 +1662,14 @@ endif()
 
 if(WITH_COMPILER_SHORT_FILE_MACRO)
   # Use '-fmacro-prefix-map' for Clang and GCC (MSVC doesn't support this).
-  if((CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.4) OR
-     (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0) OR
-     (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
-  )
-
+  ADD_CHECK_C_COMPILER_FLAG(C_PREFIX_MAP_FLAGS C_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar)
+  ADD_CHECK_CXX_COMPILER_FLAG(CXX_PREFIX_MAP_FLAGS CXX_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar)
+  if(C_MACRO_PREFIX_MAP AND CXX_MACRO_PREFIX_MAP)
     if(APPLE)
       if(XCODE AND ${XCODE_VERSION} VERSION_LESS 12.0)
-      # Developers may have say LLVM Clang-10.0.1 toolchain with Xcode-11.
-        message_first_run(WARNING
+      # Developers may have say LLVM Clang-10.0.1 toolchain (which supports the flag)
+      # with Xcode-11 (the Clang of which doesn't support the flag).
+        message(WARNING
           "-fmacro-prefix-map flag is NOT supported by Clang shipped with Xcode-${XCODE_VERSION}."
           " Some Xcode functionality in Product menu may not work. Disabling WITH_COMPILER_SHORT_FILE_MACRO."
         )
@@ -1688,8 +1687,8 @@ if(WITH_COMPILER_SHORT_FILE_MACRO)
       unset(_bin_dir)
     endif()
   else()
-    message_first_run(WARNING
-      "-fmacro-prefix-map flag is NOT supported by ${CMAKE_C_COMPILER_ID} version-${CMAKE_C_COMPILER_VERSION}."
+    message(WARNING
+      "-fmacro-prefix-map flag is NOT supported by C/C++ compiler."
       " Disabling WITH_COMPILER_SHORT_FILE_MACRO."
     )
     set(WITH_COMPILER_SHORT_FILE_MACRO OFF)



More information about the Bf-blender-cvs mailing list