[Orxonox-commit 5524] r10187 - code/trunk/cmake/tools

landauf at orxonox.net landauf at orxonox.net
Sat Jan 10 14:48:02 CET 2015


Author: landauf
Date: 2015-01-10 14:48:02 +0100 (Sat, 10 Jan 2015)
New Revision: 10187

Modified:
   code/trunk/cmake/tools/PrecompiledHeaderFiles.cmake
Log:
fixed dependency issue in cmake script (which also fixes a bunch of warnings with cmake 3.1). I hope this works because I don't really understand why it was done like that before.

Modified: code/trunk/cmake/tools/PrecompiledHeaderFiles.cmake
===================================================================
--- code/trunk/cmake/tools/PrecompiledHeaderFiles.cmake	2015-01-10 13:35:30 UTC (rev 10186)
+++ code/trunk/cmake/tools/PrecompiledHeaderFiles.cmake	2015-01-10 13:48:02 UTC (rev 10187)
@@ -97,21 +97,9 @@
 
   ELSEIF(CMAKE_COMPILER_IS_GNU)
 
-    SET(_pch_file "${CMAKE_CURRENT_BINARY_DIR}/${_pch_header_filename}.gch")
-    SET(_pch_dep_helper_file "${CMAKE_CURRENT_BINARY_DIR}/${_target_name}PCHDependencyHelper.h")
-
     # Append the gch-dir to make sure gcc finds the pch file
     INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
 
-    # Get compiler flags of the source files (target does not yet exist!)
-    # This is just the best possible opportunity to address this dependency issue
-    GET_GCC_COMPILER_FLAGS(${_target_name} _pch_gcc_flags)
-    # Make sure we recompile the pch file even if only the flags change
-    IF(NOT "${_pch_gcc_flags}" STREQUAL "${_INTERNAL_${_target_name}_PCH_GCC_FLAGS}" OR NOT EXISTS "${_pch_dep_helper_file}")
-      SET(_INTERNAL_${_target_name}_PCH_GCC_FLAGS "${_pch_gcc_flags}" CACHE INTERNAL "")
-      FILE(WRITE ${_pch_dep_helper_file} "/* ${_pch_gcc_flags} */")
-    ENDIF()
-
     # Set Compile flags for the other source files
     FOREACH(_file ${_source_files})
       GET_SOURCE_FILE_PROPERTY(_is_header ${_file} HEADER_FILE_ONLY)
@@ -135,15 +123,24 @@
     # This macro is only necessary for GCC
     IF(CMAKE_COMPILER_IS_GNU)
 
+      SET(_pch_file "${CMAKE_CURRENT_BINARY_DIR}/${_pch_header_filename}.gch")
+      SET(_pch_dep_helper_file "${CMAKE_CURRENT_BINARY_DIR}/${_target_name}PCHDependencyHelper.h")
+
       # Workaround for distcc
       IF(CMAKE_CXX_COMPILER_ARG1)
         # remove leading space in compiler argument
         STRING(REGEX REPLACE "^ +" "" _pch_cmake_cxx_compiler_arg1 "${CMAKE_CXX_COMPILER_ARG1}")
       ENDIF()
 
-      # Get compiler flags of the source files again (target exists this time)
+      # Get compiler flags of the source files
       GET_GCC_COMPILER_FLAGS(${_target_name} _pch_gcc_flags)
 
+      # Make sure we recompile the pch file even if only the flags change
+      IF(NOT "${_pch_gcc_flags}" STREQUAL "${_INTERNAL_${_target_name}_PCH_GCC_FLAGS}" OR NOT EXISTS "${_pch_dep_helper_file}")
+        SET(_INTERNAL_${_target_name}_PCH_GCC_FLAGS "${_pch_gcc_flags}" CACHE INTERNAL "")
+        FILE(WRITE ${_pch_dep_helper_file} "/* ${_pch_gcc_flags} */")
+      ENDIF()
+
       # Compile the header file
       ADD_CUSTOM_COMMAND(
         OUTPUT ${_pch_file}




More information about the Orxonox-commit mailing list