-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
64 lines (56 loc) · 1.52 KB
/
CMakeLists.txt
File metadata and controls
64 lines (56 loc) · 1.52 KB
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
cmake_minimum_required(VERSION 3.7)
project(glug_math_suite)
# add the library subproject
enable_testing()
add_subdirectory(glug_math)
# add the "examples" target to build all examples
add_subdirectory(example EXCLUDE_FROM_ALL)
get_property(
EXAMPLE_TARGETS
DIRECTORY
example
PROPERTY
BUILDSYSTEM_TARGETS
)
add_custom_target(
examples
DEPENDS
${EXAMPLE_TARGETS}
)
# copy the library to the example build directory
add_custom_target(
copy_lib_to_examples
)
add_custom_command(
TARGET
copy_lib_to_examples POST_BUILD
COMMAND
${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:glug::math> example
)
add_dependencies(examples copy_lib_to_examples)
foreach(EXAMPLE_TARGET IN LISTS EXAMPLE_TARGETS)
add_dependencies(${EXAMPLE_TARGET} copy_lib_to_examples)
endforeach()
# create a custom "install-examples" target to install the examples without being part of ALL
add_custom_target(
install-examples
DEPENDS
${EXAMPLE_TARGETS}
)
foreach(EXAMPLE_TARGET IN LISTS EXAMPLE_TARGETS)
add_custom_command(
TARGET
install-examples
COMMAND
${CMAKE_COMMAND} -E copy
$<TARGET_FILE:${EXAMPLE_TARGET}> ${CMAKE_INSTALL_PREFIX}/examples/$<TARGET_FILE_NAME:${EXAMPLE_TARGET}>
)
endforeach()
add_custom_command(
TARGET
install-examples
COMMAND
${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:glug::math> ${CMAKE_INSTALL_PREFIX}/examples/$<TARGET_FILE_NAME:glug_math>
)