summaryrefslogtreecommitdiffstats
path: root/CMakeScripts/HelperMacros.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
commitc853ffb5b2f75f5a889ed2e3ef89b818a736e87a (patch)
tree7d13a0883bb7936b84d6ecdd7bc332b41ed04bee /CMakeScripts/HelperMacros.cmake
parentInitial commit. (diff)
downloadinkscape-8a99dde12f4056f9f3e8c91d10a929dbb60d0ab9.tar.xz
inkscape-8a99dde12f4056f9f3e8c91d10a929dbb60d0ab9.zip
Adding upstream version 1.3+ds.upstream/1.3+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'CMakeScripts/HelperMacros.cmake')
-rw-r--r--CMakeScripts/HelperMacros.cmake130
1 files changed, 130 insertions, 0 deletions
diff --git a/CMakeScripts/HelperMacros.cmake b/CMakeScripts/HelperMacros.cmake
new file mode 100644
index 0000000..0f7d755
--- /dev/null
+++ b/CMakeScripts/HelperMacros.cmake
@@ -0,0 +1,130 @@
+# 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()
+
+
+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} STATIC ${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()
+
+macro(INKSCAPE_PKG_CONFIG_FIND PREFIX MODNAME VERSION PATH_NAME PATH_SUFFIXE LIB_NAME)
+ if(VERSION)
+ pkg_check_modules(_${PREFIX} ${MODNAME}${VERSION})
+ else(VERSION)
+ pkg_check_modules(_${PREFIX} ${MODNAME})
+ endif(VERSION)
+
+ find_path(${PREFIX}_INCLUDE_DIR
+ NAMES
+ ${PATH_NAME}
+ PATHS
+ ${_${PREFIX}_INCLUDEDIR}
+ /usr/include
+ /usr/local/include
+ /opt/local/include
+ /sw/include
+ $ENV{DEVLIBS_PATH}//include//
+ PATH_SUFFIXES
+ ${PATH_SUFFIXE}
+ )
+
+ find_library(${PREFIX}_LIBRARY
+ NAMES
+ ${LIB_NAME}
+ PATHS
+ ${_${PREFIX}_LIBDIR}
+ /usr/lib
+ /usr/local/lib
+ /opt/local/lib
+ /sw/lib
+ )
+
+ if (${PREFIX}_LIBRARY)
+ set(${PREFIX}_FOUND TRUE)
+ set(${PREFIX}_VERSION ${_${PREFIX}_VERSION})
+ endif (${PREFIX}_LIBRARY)
+
+ set(${PREFIX}_INCLUDE_DIRS
+ ${${PREFIX}_INCLUDE_DIR}
+ )
+
+ if (${PREFIX}_FOUND)
+ set(${PREFIX}_LIBRARIES
+ ${${PREFIX}_LIBRARIES}
+ ${${PREFIX}_LIBRARY}
+ )
+ endif (${PREFIX}_FOUND)
+
+ if (${PREFIX}_INCLUDE_DIRS AND ${PREFIX}_LIBRARIES)
+ set(${PREFIX}_FOUND TRUE)
+ endif (${PREFIX}_INCLUDE_DIRS AND ${PREFIX}_LIBRARIES)
+
+ if (${PREFIX}_FOUND)
+ if (NOT ${PREFIX}_FIND_QUIETLY)
+ message(STATUS "Found ${MODNAME}: ${${PREFIX}_LIBRARIES}")
+ endif (NOT ${PREFIX}_FIND_QUIETLY)
+ else (${PREFIX}_FOUND)
+ if (${PREFIX}_FIND_REQUIRED)
+ message(FATAL_ERROR "Could not find ${MODNAME}")
+ endif (${PREFIX}_FIND_REQUIRED)
+ endif (${PREFIX}_FOUND)
+
+ # show the <PREFIX>_INCLUDE_DIRS and <PREFIX>_LIBRARIES variables only in the advanced view
+ mark_as_advanced(${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARIES)
+endmacro()