From 70688609412421c3efa168f9c210a9e4e06a5578 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 2 Oct 2015 09:36:52 -0400 Subject: [PATCH 1/2] Help: Improve CMAKE_SYSTEM_{NAME,VERSION} variable documentation Specify their meaning for host builds and when cross compiling. Sepcify their relationship in each case. --- Help/variable/CMAKE_SYSTEM_NAME.rst | 20 ++++++++++++++++---- Help/variable/CMAKE_SYSTEM_VERSION.rst | 21 +++++++++++++++++---- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Help/variable/CMAKE_SYSTEM_NAME.rst b/Help/variable/CMAKE_SYSTEM_NAME.rst index 0466da460d..c3a42e5b41 100644 --- a/Help/variable/CMAKE_SYSTEM_NAME.rst +++ b/Help/variable/CMAKE_SYSTEM_NAME.rst @@ -1,8 +1,20 @@ CMAKE_SYSTEM_NAME ----------------- -Name of the operating system CMake is building for. +The name of the operating system for which CMake is to build. +See the :variable:`CMAKE_SYSTEM_VERSION` variable for the OS version. -This is the name of the operating system on which CMake is targeting. This -variable is the same as :variable:`CMAKE_HOST_SYSTEM_NAME` if you build for the -host system instead of the target system when cross compiling. +System Name for Host Builds +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +``CMAKE_SYSTEM_NAME`` is by default set to the same value as the +:variable:`CMAKE_HOST_SYSTEM_NAME` variable so that the build +targets the host system. + +System Name for Cross Compiling +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +``CMAKE_SYSTEM_NAME`` may be set explicitly when first configuring a new build +tree in order to enable :ref:`cross compiling `. +In this case the :variable:`CMAKE_SYSTEM_VERSION` variable must also be +set explicitly. diff --git a/Help/variable/CMAKE_SYSTEM_VERSION.rst b/Help/variable/CMAKE_SYSTEM_VERSION.rst index 3b3cdc56a5..f388ccf6b2 100644 --- a/Help/variable/CMAKE_SYSTEM_VERSION.rst +++ b/Help/variable/CMAKE_SYSTEM_VERSION.rst @@ -1,8 +1,21 @@ CMAKE_SYSTEM_VERSION -------------------- -The operating system version CMake is building for. +The version of the operating system for which CMake is to build. +See the :variable:`CMAKE_SYSTEM_NAME` variable for the OS name. -This variable is the same as :variable:`CMAKE_HOST_SYSTEM_VERSION` if -you build for the host system instead of the target system when -cross compiling. +System Version for Host Builds +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When the :variable:`CMAKE_SYSTEM_NAME` variable takes its default value +then ``CMAKE_SYSTEM_VERSION`` is by default set to the same value as the +:variable:`CMAKE_HOST_SYSTEM_VERSION` variable so that the build targets +the host system version. + +System Version for Cross Compiling +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When the :variable:`CMAKE_SYSTEM_NAME` variable is set explicitly to +enable :ref:`cross compiling ` then the +value of ``CMAKE_SYSTEM_VERSION`` must also be set explicitly to specify +the target system version. From b31ac171a4acdc8d8eb1d08c5b5f61ec90a9dbaa Mon Sep 17 00:00:00 2001 From: Gilles Khouzam Date: Wed, 23 Sep 2015 14:27:07 -0700 Subject: [PATCH 2/2] Allow CMAKE_SYSTEM_VERSION to be set without CMAKE_SYSTEM_NAME Teach CMakeDetermineSystem to check for a CMAKE_SYSTEM_VERSION setting even when CMAKE_SYSTEM_NAME is not set. This will allow builds on the host OS to target other versions of the OS without full cross-compiling. --- Help/variable/CMAKE_SYSTEM_VERSION.rst | 7 +++++++ Modules/CMakeDetermineSystem.cmake | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Help/variable/CMAKE_SYSTEM_VERSION.rst b/Help/variable/CMAKE_SYSTEM_VERSION.rst index f388ccf6b2..aba8ca32b1 100644 --- a/Help/variable/CMAKE_SYSTEM_VERSION.rst +++ b/Help/variable/CMAKE_SYSTEM_VERSION.rst @@ -12,6 +12,13 @@ then ``CMAKE_SYSTEM_VERSION`` is by default set to the same value as the :variable:`CMAKE_HOST_SYSTEM_VERSION` variable so that the build targets the host system version. +In the case of a host build then ``CMAKE_SYSTEM_VERSION`` may be set +explicitly when first configuring a new build tree in order to enable +targeting the build for a different version of the host operating system +than is actually running on the host. This is allowed and not considered +cross compiling so long as the binaries built for the specified OS version +can still run on the host. + System Version for Cross Compiling ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index fa14641b50..d9f7579e3e 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -123,7 +123,9 @@ elseif(CMAKE_VS_WINCE_VERSION) set(PRESET_CMAKE_SYSTEM_NAME TRUE) else() set(CMAKE_SYSTEM_NAME "${CMAKE_HOST_SYSTEM_NAME}") - set(CMAKE_SYSTEM_VERSION "${CMAKE_HOST_SYSTEM_VERSION}") + if(NOT DEFINED CMAKE_SYSTEM_VERSION) + set(CMAKE_SYSTEM_VERSION "${CMAKE_HOST_SYSTEM_VERSION}") + endif() set(CMAKE_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}") set(CMAKE_CROSSCOMPILING FALSE) set(PRESET_CMAKE_SYSTEM_NAME FALSE)