aboutsummaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
authormontellese <montellese@xbmc.org>2015-02-18 09:16:56 +0100
committermontellese <montellese@xbmc.org>2015-02-18 09:18:43 +0100
commitda86cd3a541bbc7206ea0b8a8a7c909be429c547 (patch)
tree962c5c1c35301da54532ceb6d2e31843a301ea2c /project
parent894a28fb46d13fbcb586f2727b31e27b486f79ac (diff)
cmake: extract target platform checking logic into check_target_platform.cmake
Diffstat (limited to 'project')
-rw-r--r--project/cmake/addons/CMakeLists.txt32
-rw-r--r--project/cmake/scripts/common/check_target_platform.cmake40
2 files changed, 43 insertions, 29 deletions
diff --git a/project/cmake/addons/CMakeLists.txt b/project/cmake/addons/CMakeLists.txt
index be08205410..8047f3cee2 100644
--- a/project/cmake/addons/CMakeLists.txt
+++ b/project/cmake/addons/CMakeLists.txt
@@ -13,6 +13,7 @@ if(NOT CORE_SYSTEM_NAME)
endif()
include(ExternalProject)
+include(${APP_ROOT}/project/cmake/scripts/common/check_target_platform.cmake)
### setup all the necessary paths
if(NOT APP_ROOT AND NOT XBMCROOT)
@@ -115,37 +116,10 @@ foreach(addon ${addons})
list(FIND ADDONS_TO_BUILD ${id} idx)
if(idx GREATER -1 OR ADDONS_TO_BUILD STREQUAL "all")
get_filename_component(dir ${addon} PATH)
- set(platform_found FALSE)
# check if the addon has a platforms.txt
- if(EXISTS ${dir}/platforms.txt)
- # get all the specified platforms
- file(STRINGS ${dir}/platforms.txt platforms)
- separate_arguments(platforms)
-
- # check if the addon should be built for the current platform
- foreach(platform ${platforms})
- if(${platform} STREQUAL "all" OR ${platform} STREQUAL ${CORE_SYSTEM_NAME})
- set(platform_found TRUE)
- else()
- # check if the platform is defined as "!<platform>"
- string(SUBSTRING ${platform} 0 1 platform_first)
- if(${platform_first} STREQUAL "!")
- # extract the platform
- string(LENGTH ${platform} platform_length)
- MATH(EXPR platform_length "${platform_length} - 1")
- string(SUBSTRING ${platform} 1 ${platform_length} platform)
-
- # check if the current platform does not match the extracted platform
- if (NOT ${platform} STREQUAL ${CORE_SYSTEM_NAME})
- set(platform_found TRUE)
- endif()
- endif()
- endif()
- endforeach()
- else()
- set(platform_found TRUE)
- endif()
+ set(platform_found FALSE)
+ check_target_platform(${dir} ${CORE_SYSTEM_NAME} platform_found)
if (${platform_found})
# make sure the output directory is clean
diff --git a/project/cmake/scripts/common/check_target_platform.cmake b/project/cmake/scripts/common/check_target_platform.cmake
new file mode 100644
index 0000000000..19a9d1410c
--- /dev/null
+++ b/project/cmake/scripts/common/check_target_platform.cmake
@@ -0,0 +1,40 @@
+# handle target platforms
+function(check_target_platform dir target_platform build)
+ # param[in] dir path/directory of the addon/dependency
+ # param[in] target_platform target platform of the build
+ # param[out] build Result whether the addon/dependency should be built for the specified target platform
+
+ set(${build} FALSE)
+ # check if the given directory exists and contains a platforms.txt
+ if(EXISTS ${dir} AND EXISTS ${dir}/platforms.txt)
+ # get all the specified platforms
+ file(STRINGS ${dir}/platforms.txt platforms)
+ separate_arguments(platforms)
+
+ # check if the addon/dependency should be built for the current platform
+ foreach(platform ${platforms})
+ if(${platform} STREQUAL "all" OR ${platform} STREQUAL ${target_platform})
+ set(${build} TRUE)
+ else()
+ # check if the platform is defined as "!<platform>"
+ string(SUBSTRING ${platform} 0 1 platform_first)
+ if(${platform_first} STREQUAL "!")
+ # extract the platform
+ string(LENGTH ${platform} platform_length)
+ MATH(EXPR platform_length "${platform_length} - 1")
+ string(SUBSTRING ${platform} 1 ${platform_length} platform)
+
+ # check if the current platform does not match the extracted platform
+ if (NOT ${platform} STREQUAL ${target_platform})
+ set(${build} TRUE)
+ endif()
+ endif()
+ endif()
+ endforeach()
+ else()
+ set(${build} TRUE)
+ endif()
+
+ # make the ${build} variable available to the calling script
+ set(${build} "${${build}}" PARENT_SCOPE)
+endfunction()