summaryrefslogtreecommitdiffstats
path: root/CMakeScripts/HelperMacros.cmake
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-06-13 05:39:42 +0000
committerCampbell Barton <ideasman42@gmail.com>2011-06-13 05:39:42 +0000
commitb7a4f23ed217a36eaaefe8f707bcc1b968d1e562 (patch)
tree3ea6133fa6ac3a5cc836501a2daf8424112e797f /CMakeScripts/HelperMacros.cmake
parentReplace deprecated GTK_WIDGET_(UN)SET_FLAGS macros (diff)
downloadinkscape-b7a4f23ed217a36eaaefe8f707bcc1b968d1e562.tar.gz
inkscape-b7a4f23ed217a36eaaefe8f707bcc1b968d1e562.zip
cmake:
- group source/headers per library (for some IDE's) - include headers with source listing (also for IDE's) - remove unneeded Find modules (bzr r10281)
Diffstat (limited to 'CMakeScripts/HelperMacros.cmake')
-rw-r--r--CMakeScripts/HelperMacros.cmake76
1 files changed, 64 insertions, 12 deletions
diff --git a/CMakeScripts/HelperMacros.cmake b/CMakeScripts/HelperMacros.cmake
index dd8c25f00..592e962c7 100644
--- a/CMakeScripts/HelperMacros.cmake
+++ b/CMakeScripts/HelperMacros.cmake
@@ -1,13 +1,65 @@
# A macro to replace slashes and spaces in a string with underscores
-MACRO(SANITIZE_PATH _string_var)
- STRING(REGEX REPLACE "[\\/ ]+" "_" ${_string_var} ${${_string_var}})
-ENDMACRO(SANITIZE_PATH _string_var)
-
-# A macro to prepend a given string onto the beginning of each string in a list
-MACRO(PREPEND _list _str)
- SET(_temp_list ${${_list}})
- SET(${_list})
- FOREACH(x ${_temp_list})
- SET(${_list} ${${_list}} ${_str}${x})
- ENDFOREACH(x)
-ENDMACRO(PREPEND _list _str)
+macro(SANITIZE_PATH _string_var)
+ string(REGEX REPLACE "[\\/ ]+" "_" ${_string_var} ${${_string_var}})
+endmacro()
+
+
+macro(inkscape_source_group
+ sources)
+
+ # Group by location on disk
+ source_group("Source Files" FILES CMakeLists.txt)
+
+ foreach(_SRC ${sources})
+ get_filename_component(_SRC_EXT ${_SRC} EXT)
+ if(${_SRC_EXT} MATCHES ".h" OR ${_SRC_EXT} MATCHES ".hpp")
+ source_group("Header Files" FILES ${_SRC})
+ else()
+ source_group("Source Files" FILES ${_SRC})
+ endif()
+ endforeach()
+
+ unset(_SRC)
+ unset(_SRC_EXT)
+endmacro()
+
+
+# only MSVC uses SOURCE_GROUP
+macro(add_inkscape_lib
+ name
+ sources)
+
+ add_library(${name} ${sources})
+
+ # works fine without having the includes
+ # listed is helpful for IDE's (QtCreator/MSVC)
+ inkscape_source_group("${sources}")
+
+endmacro()
+
+
+# A macro to append to the global source property
+set_property(GLOBAL PROPERTY inkscape_global_SRC "")
+
+macro (add_inkscape_source
+ sources)
+
+ foreach(_SRC ${ARGV})
+ get_filename_component(_ABS_SRC ${_SRC} ABSOLUTE)
+ set_property(GLOBAL APPEND PROPERTY inkscape_global_SRC ${_ABS_SRC})
+ endforeach()
+ unset(_SRC)
+ unset(_ABS_SRC)
+endmacro()
+
+# A macro to append to the global source property
+macro (add_inkscape_library
+ sources)
+
+ foreach(_SRC ${ARGV})
+ get_filename_component(_ABS_SRC ${_SRC} ABSOLUTE)
+ set_property(GLOBAL APPEND PROPERTY inkscape_global_SRC ${_ABS_SRC})
+ endforeach()
+ unset(_SRC)
+ unset(_ABS_SRC)
+endmacro()