From 7bf5bc518a4a4c35be84274db5b058e3fb01df3b Mon Sep 17 00:00:00 2001 From: Axel Isouard Date: Fri, 27 Jan 2017 22:35:26 +0100 Subject: [PATCH] Add TARGET_OS and TARGET_CPU variables --- CMakeLists.txt | 2 ++ CMakeModules/LibWebRTCSubsystem.cmake | 39 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 CMakeModules/LibWebRTCSubsystem.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c2cfc6..3d8b78b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,8 @@ option(BUILD_TESTS "Build test binaries" OFF) option(BUILD_SAMPLES "Build samples binaries" OFF) set(NINJA_ARGS "" CACHE STRING "Ninja arguments to pass before compiling WebRTC") +include(LibWebRTCSubsystem) + # # Versioning # diff --git a/CMakeModules/LibWebRTCSubsystem.cmake b/CMakeModules/LibWebRTCSubsystem.cmake new file mode 100644 index 0000000..929276b --- /dev/null +++ b/CMakeModules/LibWebRTCSubsystem.cmake @@ -0,0 +1,39 @@ +# +# Subsystem +# + +set(TARGET_OS "" CACHE STRING "Target OS, used as --target_os argument") +set(TARGET_OS_LIST android chromeos ios linux nacl mac win) + +if (TARGET_OS STREQUAL "") + if (CMAKE_SYSTEM_NAME MATCHES "Linux") + set(TARGET_OS "linux") + elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") + set(TARGET_OS "mac") + elseif (CMAKE_SYSTEM_NAME MATCHES "Windows") + set(TARGET_OS "win") + endif () +endif (TARGET_OS STREQUAL "") + +if (NOT ${TARGET_OS} IN_LIST TARGET_OS_LIST) + message(FATAL_ERROR "Unknown value '${TARGET_OS}' for variable TARGET_OS, the following values are supported: ${TARGET_OS_LIST}") +endif (NOT ${TARGET_OS} IN_LIST TARGET_OS_LIST) + +set(TARGET_CPU "" CACHE STRING "Target CPU, used as --target_cpu argument") +set(TARGET_CPU_LIST x86 x64 arm arm64 mipsel) + +if (TARGET_CPU STREQUAL "") + if (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") + set(TARGET_CPU "x86") + elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^x86.64$") + set(TARGET_CPU "x64") + elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") + set(TARGET_CPU "x64") + else () + set(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR}) + endif (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") +endif (TARGET_CPU STREQUAL "") + +if (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST) + message(FATAL_ERROR "Unknown value '${TARGET_CPU}' for variable TARGET_CPU, the following values are supported: ${TARGET_CPU_LIST}") +endif (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST)