summaryrefslogtreecommitdiffstats
path: root/CMakeScripts/HelperMacros.cmake
blob: 7cd2333bcaf8f6fee4d7faa70d2df3f5672e4c79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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()


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()