summaryrefslogtreecommitdiffstats
path: root/project/cmake/scripts/common/projectmacros.cmake
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2016-11-24 21:27:41 +0100
committermanuel <manuel@mausz.at>2016-11-24 21:27:41 +0100
commit8cdf8dec703d882b46ca50a769fabb95ffc48e2c (patch)
treef7fe8233508f79d3dc94f8f445ce6342e7dfbdbb /project/cmake/scripts/common/projectmacros.cmake
parent5823b05feb29a59510c32a9c28ca18b50b9b6399 (diff)
downloadkodi-pvr-build-8cdf8dec703d882b46ca50a769fabb95ffc48e2c.tar.gz
kodi-pvr-build-8cdf8dec703d882b46ca50a769fabb95ffc48e2c.tar.bz2
kodi-pvr-build-8cdf8dec703d882b46ca50a769fabb95ffc48e2c.zip
sync with upstream
Diffstat (limited to 'project/cmake/scripts/common/projectmacros.cmake')
-rw-r--r--project/cmake/scripts/common/projectmacros.cmake87
1 files changed, 0 insertions, 87 deletions
diff --git a/project/cmake/scripts/common/projectmacros.cmake b/project/cmake/scripts/common/projectmacros.cmake
deleted file mode 100644
index 7ce4ee9..0000000
--- a/project/cmake/scripts/common/projectmacros.cmake
+++ /dev/null
@@ -1,87 +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} PATH)
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# relative relative base path in build tree
27# On return:
28# xbt is added to ${XBT_FILES}, data added to ${install_data}, mirror in build tree
29function(copy_skin_to_buildtree skin relative)
30 file(GLOB_RECURSE FILES ${skin}/*)
31 file(GLOB_RECURSE MEDIA_FILES ${skin}/media/*)
32 list(REMOVE_ITEM FILES ${MEDIA_FILES})
33 foreach(file ${FILES})
34 copy_file_to_buildtree(${file} ${relative})
35 endforeach()
36 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${dest}/media)
37 string(REPLACE "${relative}/" "" dest ${skin})
38 pack_xbt(${skin}/media ${CMAKE_BINARY_DIR}/${dest}/media/Textures.xbt)
39
40 file(GLOB THEMES RELATIVE ${skin}/themes ${skin}/themes/*)
41 foreach(theme ${THEMES})
42 pack_xbt(${skin}/themes/${theme} ${CMAKE_BINARY_DIR}/${dest}/media/${theme}.xbt)
43 endforeach()
44
45 set(XBT_FILES ${XBT_FILES} PARENT_SCOPE)
46 set(install_data ${install_data} PARENT_SCOPE)
47endfunction()
48
49# Get GTest tests as CMake tests.
50# Copied from FindGTest.cmake
51# Thanks to Daniel Blezek <blezek@gmail.com> for the GTEST_ADD_TESTS code
52function(GTEST_ADD_TESTS executable extra_args)
53 if(NOT ARGN)
54 message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS")
55 endif()
56 foreach(source ${ARGN})
57 file(READ "${source}" contents)
58 string(REGEX MATCHALL "TEST_?[F]?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
59 foreach(hit ${found_tests})
60 string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*" "\\1.\\2" test_name ${hit})
61 add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args})
62 endforeach()
63 # Groups parametrized tests under a single ctest entry
64 string(REGEX MATCHALL "INSTANTIATE_TEST_CASE_P\\(([^,]+), *([^,]+)" found_tests2 ${contents})
65 foreach(hit ${found_tests2})
66 string(SUBSTRING ${hit} 24 -1 test_name)
67 string(REPLACE "," ";" test_name "${test_name}")
68 list(GET test_name 0 filter_name)
69 list(GET test_name 1 test_prefix)
70 string(STRIP ${test_prefix} test_prefix)
71 add_test(${test_prefix}.${filter_name} ${executable} --gtest_filter=${filter_name}* ${extra_args})
72 endforeach()
73 endforeach()
74endfunction()
75
76function(whole_archive output)
77 if(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
78 set(${output} -Wl,--whole-archive ${ARGN} -Wl,--no-whole-archive PARENT_SCOPE)
79 elseif(CMAKE_CXX_COMPILER_ID STREQUAL AppleClang)
80 foreach(library ${ARGN})
81 list(APPEND ${output} -Wl,-force_load ${library})
82 set(${output} ${${output}} PARENT_SCOPE)
83 endforeach()
84 else()
85 set(${output} ${ARGN} PARENT_SCOPE)
86 endif()
87endfunction()