HelperMacros.cmake revision f5c7ca101be6b6abe17c6c28e971c86617f6c782
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick# A macro to replace slashes and spaces in a string with underscores
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nickmacro(SANITIZE_PATH _string_var)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce string(REGEX REPLACE "[\\/ ]+" "_" ${_string_var} ${${_string_var}})
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nickmacro(inkscape_source_group
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce # Group by location on disk
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce source_group("Source Files" FILES CMakeLists.txt)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce foreach(_SRC ${sources})
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce get_filename_component(_SRC_EXT ${_SRC} EXT)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce if((${_SRC_EXT} MATCHES ".h") OR (${_SRC_EXT} MATCHES ".hpp"))
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce source_group("Header Files" FILES ${_SRC})
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce source_group("Source Files" FILES ${_SRC})
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce endforeach()
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce unset(_SRC)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce unset(_SRC_EXT)
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick# only MSVC uses SOURCE_GROUP
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nickmacro(add_inkscape_lib
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce add_library(${name} ${sources})
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce # works fine without having the includes
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce # listed is helpful for IDE's (QtCreator/MSVC)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce 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
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce foreach(_SRC ${ARGV})
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce get_filename_component(_ABS_SRC ${_SRC} ABSOLUTE)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce set_property(GLOBAL APPEND PROPERTY inkscape_global_SRC ${_ABS_SRC})
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce endforeach()
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce unset(_SRC)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce unset(_ABS_SRC)
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nick# A macro to append to the global source property
7765ee8964c8ffd7faee9baa0412abeb1ef5b0a4Nickmacro (add_inkscape_library
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce foreach(_SRC ${ARGV})
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce get_filename_component(_ABS_SRC ${_SRC} ABSOLUTE)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce set_property(GLOBAL APPEND PROPERTY inkscape_global_SRC ${_ABS_SRC})
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce endforeach()
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce unset(_SRC)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce unset(_ABS_SRC)
c43e8c459ef8a48adf6b336c1a8a13cfe0415065Campbell Bartonmacro(INKSCAPE_PKG_CONFIG_FIND PREFIX MODNAME VERSION PATH_NAME PATH_SUFFIXE LIB_NAME)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce if(VERSION)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce pkg_check_modules(_${PREFIX} ${MODNAME}${VERSION})
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce else(VERSION)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce pkg_check_modules(_${PREFIX} ${MODNAME})
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce endif(VERSION)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce find_path(${PREFIX}_INCLUDE_DIR
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce ${PATH_NAME}
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce ${_${PREFIX}_INCLUDEDIR}
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce $ENV{DEVLIBS_PATH}//include//
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce PATH_SUFFIXES
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce ${PATH_SUFFIXE}
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce find_library(${PREFIX}_LIBRARY
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce ${LIB_NAME}
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce ${_${PREFIX}_LIBDIR}
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce if (${PREFIX}_LIBRARY)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce set(${PREFIX}_FOUND TRUE)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce set(${PREFIX}_VERSION ${_${PREFIX}_VERSION})
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce endif (${PREFIX}_LIBRARY)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce set(${PREFIX}_INCLUDE_DIRS
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce ${${PREFIX}_INCLUDE_DIR}
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce if (${PREFIX}_FOUND)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce set(${PREFIX}_LIBRARIES
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce ${${PREFIX}_LIBRARIES}
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce ${${PREFIX}_LIBRARY}
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce endif (${PREFIX}_FOUND)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce if (${PREFIX}_INCLUDE_DIRS AND ${PREFIX}_LIBRARIES)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce set(${PREFIX}_FOUND TRUE)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce endif (${PREFIX}_INCLUDE_DIRS AND ${PREFIX}_LIBRARIES)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce if (${PREFIX}_FOUND)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce if (NOT ${PREFIX}_FIND_QUIETLY)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce message(STATUS "Found ${MODNAME}: ${${PREFIX}_LIBRARIES}")
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce endif (NOT ${PREFIX}_FIND_QUIETLY)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce else (${PREFIX}_FOUND)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce if (${PREFIX}_FIND_REQUIRED)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce message(FATAL_ERROR "Could not find ${MODNAME}")
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce endif (${PREFIX}_FIND_REQUIRED)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce endif (${PREFIX}_FOUND)
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce # show the <PREFIX>_INCLUDE_DIRS and <PREFIX>_LIBRARIES variables only in the advanced view
f5c7ca101be6b6abe17c6c28e971c86617f6c782bryce mark_as_advanced(${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARIES)