HelperMacros.cmake revision 7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick# A macro to replace slashes and spaces in a string with underscores
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nickmacro(SANITIZE_PATH _string_var)
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick string(REGEX REPLACE "[\\/ ]+" "_" ${_string_var} ${${_string_var}})
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nickmacro(inkscape_source_group
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick # Group by location on disk
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick source_group("Source Files" FILES CMakeLists.txt)
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick foreach(_SRC ${sources})
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick get_filename_component(_SRC_EXT ${_SRC} EXT)
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick if((${_SRC_EXT} MATCHES ".h") OR (${_SRC_EXT} MATCHES ".hpp"))
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick source_group("Header Files" FILES ${_SRC})
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick source_group("Source Files" FILES ${_SRC})
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick endforeach()
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick unset(_SRC)
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick unset(_SRC_EXT)
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick# only MSVC uses SOURCE_GROUP
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nickmacro(add_inkscape_lib
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick add_library(${name} ${sources})
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick # works fine without having the includes
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick # listed is helpful for IDE's (QtCreator/MSVC)
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick inkscape_source_group("${sources}")
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick# A macro to append to the global source property
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nickset_property(GLOBAL PROPERTY inkscape_global_SRC "")
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nickmacro (add_inkscape_source
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick foreach(_SRC ${ARGV})
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick get_filename_component(_ABS_SRC ${_SRC} ABSOLUTE)
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick set_property(GLOBAL APPEND PROPERTY inkscape_global_SRC ${_ABS_SRC})
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick endforeach()
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick unset(_SRC)
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick unset(_ABS_SRC)
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick# A macro to append to the global source property
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nickmacro (add_inkscape_library
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick foreach(_SRC ${ARGV})
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick get_filename_component(_ABS_SRC ${_SRC} ABSOLUTE)
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick set_property(GLOBAL APPEND PROPERTY inkscape_global_SRC ${_ABS_SRC})
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick endforeach()
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick unset(_SRC)
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick unset(_ABS_SRC)