summaryrefslogtreecommitdiffstats
path: root/project/cmake/scripts/common/ProjectMacros.cmake
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2017-06-04 16:57:49 +0200
committermanuel <manuel@mausz.at>2017-06-04 16:57:49 +0200
commitf44ecaa4f27e7538ddcad66d40e543bffa2d2d86 (patch)
treed8de60fc7e17edeb6f0921726c038ee54b281445 /project/cmake/scripts/common/ProjectMacros.cmake
parentae08c8b7221bc965ac40d70e53fc8fcddb050c46 (diff)
downloadkodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.tar.gz
kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.tar.bz2
kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.zip
sync with upstream
Diffstat (limited to 'project/cmake/scripts/common/ProjectMacros.cmake')
-rw-r--r--project/cmake/scripts/common/ProjectMacros.cmake89
1 files changed, 0 insertions, 89 deletions
diff --git a/project/cmake/scripts/common/ProjectMacros.cmake b/project/cmake/scripts/common/ProjectMacros.cmake
deleted file mode 100644
index e73ef90..0000000
--- a/project/cmake/scripts/common/ProjectMacros.cmake
+++ /dev/null
@@ -1,89 +0,0 @@
1# This script holds macros which are project specific
2
3# Pack a skin xbt file
4# Arguments:
5# input input directory to pack
6# output ouput xbt file
7# On return:
8# xbt is added to ${XBT_FILES}
9function(pack_xbt input output)
10 file(GLOB_RECURSE MEDIA_FILES ${input}/*)
11 get_filename_component(dir ${output} DIRECTORY)
12 add_custom_command(OUTPUT ${output}
13 COMMAND ${CMAKE_COMMAND} -E make_directory ${dir}
14 COMMAND TexturePacker::TexturePacker
15 ARGS -input ${input}
16 -output ${output}
17 -dupecheck
18 DEPENDS ${MEDIA_FILES})
19 list(APPEND XBT_FILES ${output})
20 set(XBT_FILES ${XBT_FILES} PARENT_SCOPE)
21endfunction()
22
23# Add a skin to installation list, mirroring it in build tree, packing textures
24# Arguments:
25# skin skin directory
26# On return:
27# xbt is added to ${XBT_FILES}, data added to ${install_data}, mirror in build tree
28function(copy_skin_to_buildtree skin)
29 file(GLOB_RECURSE FILES ${skin}/*)
30 file(GLOB_RECURSE MEDIA_FILES ${skin}/media/*)
31 list(REMOVE_ITEM FILES ${MEDIA_FILES})
32 foreach(file ${FILES})
33 copy_file_to_buildtree(${file})
34 endforeach()
35 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${dest}/media)
36 string(REPLACE "${CORE_SOURCE_DIR}/" "" dest ${skin})
37 pack_xbt(${skin}/media ${CMAKE_BINARY_DIR}/${dest}/media/Textures.xbt)
38
39 file(GLOB THEMES RELATIVE ${skin}/themes ${skin}/themes/*)
40 foreach(theme ${THEMES})
41 pack_xbt(${skin}/themes/${theme} ${CMAKE_BINARY_DIR}/${dest}/media/${theme}.xbt)
42 endforeach()
43
44 set(XBT_FILES ${XBT_FILES} PARENT_SCOPE)
45 set(install_data ${install_data} PARENT_SCOPE)
46endfunction()
47
48# Get GTest tests as CMake tests.
49# Copied from FindGTest.cmake
50# Thanks to Daniel Blezek <blezek@gmail.com> for the GTEST_ADD_TESTS code
51function(GTEST_ADD_TESTS executable extra_args)
52 if(NOT ARGN)
53 message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS")
54 endif()
55 foreach(source ${ARGN})
56 # This assumes that every source file passed in exists. Consider using
57 # SUPPORT_SOURCES for source files which do not contain tests and might
58 # have to be generated.
59 file(READ "${source}" contents)
60 string(REGEX MATCHALL "TEST_?[F]?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
61 foreach(hit ${found_tests})
62 string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*" "\\1.\\2" test_name ${hit})
63 add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args})
64 endforeach()
65 # Groups parametrized tests under a single ctest entry
66 string(REGEX MATCHALL "INSTANTIATE_TEST_CASE_P\\(([^,]+), *([^,]+)" found_tests2 ${contents})
67 foreach(hit ${found_tests2})
68 string(SUBSTRING ${hit} 24 -1 test_name)
69 string(REPLACE "," ";" test_name "${test_name}")
70 list(GET test_name 0 filter_name)
71 list(GET test_name 1 test_prefix)
72 string(STRIP ${test_prefix} test_prefix)
73 add_test(${test_prefix}.${filter_name} ${executable} --gtest_filter=${filter_name}* ${extra_args})
74 endforeach()
75 endforeach()
76endfunction()
77
78function(whole_archive output)
79 if(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
80 set(${output} -Wl,--whole-archive ${ARGN} -Wl,--no-whole-archive PARENT_SCOPE)
81 elseif(CMAKE_CXX_COMPILER_ID STREQUAL AppleClang)
82 foreach(library ${ARGN})
83 list(APPEND ${output} -Wl,-force_load ${library})
84 set(${output} ${${output}} PARENT_SCOPE)
85 endforeach()
86 else()
87 set(${output} ${ARGN} PARENT_SCOPE)
88 endif()
89endfunction()