summaryrefslogtreecommitdiffstats
path: root/project/cmake/scripts/windows/macros.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'project/cmake/scripts/windows/macros.cmake')
-rw-r--r--project/cmake/scripts/windows/macros.cmake145
1 files changed, 0 insertions, 145 deletions
diff --git a/project/cmake/scripts/windows/macros.cmake b/project/cmake/scripts/windows/macros.cmake
deleted file mode 100644
index 2b61875..0000000
--- a/project/cmake/scripts/windows/macros.cmake
+++ /dev/null
@@ -1,145 +0,0 @@
1function(core_link_library lib wraplib)
2# set(export -Wl,--unresolved-symbols=ignore-all
3# `cat ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/cores/dll-loader/exports/wrapper.def`
4# ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/cores/dll-loader/exports/CMakeFiles/wrapper.dir/wrapper.c.o)
5# set(check_arg "")
6# if(TARGET ${lib})
7# set(target ${lib})
8# set(link_lib ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${lib}/${lib}.a)
9# set(check_arg ${ARGV2})
10# set(data_arg ${ARGV3})
11# else()
12# set(target ${ARGV2})
13# set(link_lib ${lib})
14# set(check_arg ${ARGV3})
15# set(data_arg ${ARGV4})
16# endif()
17# if(check_arg STREQUAL "export")
18# set(export ${export}
19# -Wl,--version-script=${ARGV3})
20# elseif(check_arg STREQUAL "nowrap")
21# set(export ${data_arg})
22# elseif(check_arg STREQUAL "extras")
23# foreach(arg ${data_arg})
24# list(APPEND export ${arg})
25# endforeach()
26# endif()
27# get_filename_component(dir ${wraplib} PATH)
28# add_custom_command(OUTPUT ${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX}
29# COMMAND cmake -E make_directory ${dir}
30# COMMAND ${CMAKE_C_COMPILER}
31# ARGS -Wl,--whole-archive
32# ${link_lib}
33# -Wl,--no-whole-archive -lm
34# -shared -o ${CMAKE_BINARY_DIR}/${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX}
35# ${export}
36# DEPENDS ${target} wrapper.def wrapper)
37# list(APPEND WRAP_FILES ${wraplib}-${ARCH}${CMAKE_SHARED_MODULE_SUFFIX})
38# set(WRAP_FILES ${WRAP_FILES} PARENT_SCOPE)
39endfunction()
40
41function(find_soname lib)
42 # Windows uses hardcoded dlls in xbmc/DllPaths_win32.h.
43 # Therefore the output of this function is unused.
44endfunction()
45
46# Add precompiled header to target
47# Arguments:
48# target existing target that will be set up to compile with a precompiled header
49# pch_header the precompiled header file
50# pch_source the precompiled header source file
51# Optional Arguments:
52# PCH_TARGET build precompiled header as separate target with the given name
53# so that the same precompiled header can be used for multiple libraries
54# EXCLUDE_SOURCES if not all target sources shall use the precompiled header,
55# the relevant files can be listed here
56# On return:
57# Compiles the pch_source into a precompiled header and adds the header to
58# the given target
59function(add_precompiled_header target pch_header pch_source)
60 cmake_parse_arguments(PCH "" "PCH_TARGET" "EXCLUDE_SOURCES" ${ARGN})
61
62 if(PCH_PCH_TARGET)
63 set(pch_binary ${PRECOMPILEDHEADER_DIR}/${PCH_PCH_TARGET}.pch)
64 else()
65 set(pch_binary ${PRECOMPILEDHEADER_DIR}/${target}.pch)
66 endif()
67
68 # Set compile options and dependency for sources
69 get_target_property(sources ${target} SOURCES)
70 list(REMOVE_ITEM sources ${pch_source})
71 foreach(exclude_source IN LISTS PCH_EXCLUDE_SOURCES)
72 list(REMOVE_ITEM sources ${exclude_source})
73 endforeach()
74 set_source_files_properties(${sources}
75 PROPERTIES COMPILE_FLAGS "/Yu\"${pch_header}\" /Fp\"${pch_binary}\" /FI\"${pch_header}\""
76 OBJECT_DEPENDS "${pch_binary}")
77
78 # Set compile options for precompiled header
79 if(NOT PCH_PCH_TARGET OR NOT TARGET ${PCH_PCH_TARGET}_pch)
80 set_source_files_properties(${pch_source}
81 PROPERTIES COMPILE_FLAGS "/Yc\"${pch_header}\" /Fp\"${pch_binary}\""
82 OBJECT_OUTPUTS "${pch_binary}")
83 endif()
84
85 # Compile precompiled header
86 if(PCH_PCH_TARGET)
87 # As own target for usage in multiple libraries
88 if(NOT TARGET ${PCH_PCH_TARGET}_pch)
89 add_library(${PCH_PCH_TARGET}_pch STATIC ${pch_source})
90 set_target_properties(${PCH_PCH_TARGET}_pch PROPERTIES COMPILE_PDB_NAME vc140
91 COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR})
92 endif()
93 # From VS2012 onwards, precompiled headers have to be linked against (LNK2011).
94 target_link_libraries(${target} PUBLIC ${PCH_PCH_TARGET}_pch)
95 set_target_properties(${target} PROPERTIES COMPILE_PDB_NAME vc140
96 COMPILE_PDB_OUTPUT_DIRECTORY ${PRECOMPILEDHEADER_DIR})
97 else()
98 # As part of the target
99 target_sources(${target} PRIVATE ${pch_source})
100 endif()
101endfunction()
102
103# Adds an FX-compiled shader to a target
104# Creates a custom command that FX-compiles the given shader and adds the
105# generated header file to the given target.
106# Arguments:
107# target Target to add the FX-compiled shader to
108# hlsl HLSL shader input file
109# profile HLSL profile that specifies the shader model
110# entrypoint Shader entry point
111# On return:
112# FXC_FILE is set to the name of the generated header file.
113function(add_shader_dx target hlsl profile entrypoint)
114 get_filename_component(file ${hlsl} NAME_WE)
115 add_custom_command(OUTPUT ${file}.h
116 COMMAND ${FXC} /Fh ${file}.h
117 /E ${entrypoint}
118 /T ${profile}
119 /Vn ${file}
120 /Qstrip_reflect
121 ${hlsl}
122 DEPENDS ${hlsl}
123 COMMENT "FX compile ${hlsl}"
124 VERBATIM)
125 target_sources(${target} PRIVATE ${file}.h)
126 target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
127endfunction()
128
129# Copies the main dlls to the root of the buildtree
130# On return:
131# files added to ${install_data}, mirror in build tree
132function(copy_main_dlls_to_buildtree)
133 set(dir ${PROJECT_SOURCE_DIR}/../Win32BuildSetup/dependencies)
134 file(GLOB_RECURSE files ${dir}/*)
135 foreach(file ${files})
136 copy_file_to_buildtree(${file} ${dir})
137 endforeach()
138
139 if(D3DCOMPILER_DLL)
140 get_filename_component(d3dcompiler_dir ${D3DCOMPILER_DLL} DIRECTORY)
141 copy_file_to_buildtree(${D3DCOMPILER_DLL} ${d3dcompiler_dir})
142 endif()
143
144 set(install_data ${install_data} PARENT_SCOPE)
145endfunction()