-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcommon.cmake
More file actions
60 lines (53 loc) · 2.12 KB
/
common.cmake
File metadata and controls
60 lines (53 loc) · 2.12 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
#
# enables multithreading compilation
#
add_compile_options(/MP)
#
# includes cauldron's helper cmakes
#
include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/cauldron/common.cmake)
#
# Add manifest so the app uses the right DPI settings
#
function(addManifest PROJECT_NAME)
IF (MSVC)
IF (CMAKE_MAJOR_VERSION LESS 3)
MESSAGE(WARNING "CMake version 3.0 or newer is required use build variable TARGET_FILE")
ELSE()
ADD_CUSTOM_COMMAND(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\dpiawarescaling.manifest\" -inputresource:\"$<TARGET_FILE:${PROJECT_NAME}>\"\;\#1 -outputresource:\"$<TARGET_FILE:${PROJECT_NAME}>\"\;\#1
COMMENT "Adding display aware manifest..."
)
ENDIF()
ENDIF(MSVC)
endfunction()
#
# Same as copyCommand() but you can give a target name
# This custom target will depend on all those copied files
# Then the target can be properly set as a dependency of other executable or library
# Usage example:
# add_library(my_lib ...)
# set(media_src ${CMAKE_CURRENT_SOURCE_DIR}/../../media/brdfLut.dds )
# copyTargetCommand("${media_src}" ${CMAKE_HOME_DIRECTORY}/bin copied_media_src)
# add_dependencies(my_lib copied_media_src)
#
function(copyTargetCommand list dest returned_target_name)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
foreach(fullFileName ${list})
get_filename_component(file ${fullFileName} NAME)
message("Generating custom command for ${fullFileName}")
add_custom_command(
OUTPUT ${dest}/${file}
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${dest}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${fullFileName} ${dest}
MAIN_DEPENDENCY ${fullFileName}
COMMENT "Updating ${file} into ${dest}"
)
list(APPEND dest_list ${dest}/${file})
endforeach()
add_custom_target(${returned_target_name} DEPENDS "${dest_list}")
set_target_properties(${returned_target_name} PROPERTIES FOLDER CopyTargets)
endfunction()