summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShlomi Fish <shlomif@gmail.com>2016-04-16 17:14:12 +0000
committerMarc Jeanmougin <marcjeanmougin@free.fr>2016-04-16 17:14:12 +0000
commit79c7cc29d83772771100d2a10900de15a66af0f7 (patch)
tree85f13e906b533e0c0d366693166a0da0f07a10e5
parentCMake build: builds with WITH_DBUS (diff)
downloadinkscape-79c7cc29d83772771100d2a10900de15a66af0f7.tar.gz
inkscape-79c7cc29d83772771100d2a10900de15a66af0f7.zip
CXX flags dedup on CMake builds
(bzr r14854)
-rw-r--r--CMakeLists.txt8
-rw-r--r--CMakeScripts/CanonicalizeFlagsVar.cmake11
2 files changed, 19 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6545ac44e..873e24c52 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -208,6 +208,14 @@ if(WITH_GTEST)
add_subdirectory(test EXCLUDE_FROM_ALL)
endif()
+# Canonicalize the flags to speed up recompilation using ccache/etc.
+# This should be the last thing we do:
+include(CMakeScripts/CanonicalizeFlagsVar.cmake)
+canonicalize_flags_var("${CMAKE_CXX_FLAGS}" _new_cxx)
+set(CMAKE_CXX_FLAGS "${_new_cxx}" CACHE STRING "" FORCE)
+# message(FATAL_ERROR "CMAKE_CXX_FLAGS = <${CMAKE_CXX_FLAGS}>")
+
+
# ----------------------------------------------------------------------
# Information Summary
# ----------------------------------------------------------------------
diff --git a/CMakeScripts/CanonicalizeFlagsVar.cmake b/CMakeScripts/CanonicalizeFlagsVar.cmake
new file mode 100644
index 000000000..ddc5b7b5d
--- /dev/null
+++ b/CMakeScripts/CanonicalizeFlagsVar.cmake
@@ -0,0 +1,11 @@
+# This file is copyright by Shlomi Fish, 2016.
+#
+# This file is licensed under the MIT/X11 license:
+# https://opensource.org/licenses/mit-license.php
+
+macro (canonicalize_flags_var in_val out_var)
+ string(REPLACE " " ";" _c "${in_val}")
+ list(REMOVE_DUPLICATES _c)
+ list(SORT _c)
+ string(REPLACE ";" " " "${out_var}" "${_c}")
+endmacro()