enable_language: Establish target platform identification variables earlier

Set target platform identification variables like `APPLE` and `LINUX`
as soon as the target system is identified.  This makes them available
during toolchain and binutils selection.

Fixes: #23333
This commit is contained in:
Brad King 2023-06-06 15:36:54 -04:00
parent 1d916bf3d2
commit 1373373823
67 changed files with 85 additions and 64 deletions

View File

@ -6,19 +6,6 @@
# It is included after the compiler has been determined, so
# we know things like the compiler name and if the compiler is gnu.
# before cmake 2.6 these variables were set in cmMakefile.cxx. This is still
# done to keep scripts and custom language and compiler modules working.
# But they are reset here and set again in the platform files for the target
# platform, so they can be used for testing the target platform instead
# of testing the host platform.
set(APPLE )
set(UNIX )
set(CYGWIN )
set(MSYS )
set(WIN32 )
set(BSD )
set(LINUX )
function(_cmake_record_install_prefix )
set(_CMAKE_SYSTEM_PREFIX_PATH_INSTALL_PREFIX_VALUE "${CMAKE_INSTALL_PREFIX}" PARENT_SCOPE)
set(_CMAKE_SYSTEM_PREFIX_PATH_STAGING_PREFIX_VALUE "${CMAKE_STAGING_PREFIX}" PARENT_SCOPE)

View File

@ -5,6 +5,19 @@
# This file is included by cmGlobalGenerator::EnableLanguage.
# It is included before the compiler has been determined.
# before cmake 2.6 these variables were set in cmMakefile.cxx. This is still
# done to keep scripts and custom language and compiler modules working.
# But they are reset here and set again in the platform files for the target
# platform, so they can be used for testing the target platform instead
# of testing the host platform.
unset(APPLE)
unset(UNIX)
unset(CYGWIN)
unset(MSYS)
unset(WIN32)
unset(BSD)
unset(LINUX)
# The CMAKE_EFFECTIVE_SYSTEM_NAME is used to load compiler and compiler
# wrapper configuration files. By default it equals to CMAKE_SYSTEM_NAME
# but could be overridden in the ${CMAKE_SYSTEM_NAME}-Initialize files.

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -23,6 +23,11 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1)
return()
endif()
include(Platform/Linux-Initialize)
unset(LINUX)
set(ANDROID 1)
set(CMAKE_BUILD_TYPE_INIT "RelWithDebInfo")
if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)

View File

@ -4,11 +4,6 @@ if(CMAKE_ANDROID_NDK)
include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/pre/Android.cmake OPTIONAL)
endif()
include(Platform/Linux)
unset(LINUX)
set(ANDROID 1)
# Natively compiling on an Android host doesn't need these flags to be reset.
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android")
return()

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1,2 @@
set(BEOS 1)
set(UNIX 1)

View File

@ -1,5 +1,3 @@
set(BEOS 1)
set(CMAKE_DL_LIBS root be)
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE")

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -49,11 +49,6 @@ set(CMAKE_SYSTEM_IGNORE_PATH
/usr/X11R7/lib /usr/X11R7/lib64 /usr/X11R7/include
)
#
# Indicate that this is a unix-like system
#
set(UNIX 1)
#
# Library prefixes, suffixes, extra libs.
#

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -39,11 +39,6 @@ set(CMAKE_SYSTEM_IGNORE_PATH
/usr/X11R7/lib /usr/X11R7/lib64 /usr/X11R7/include
)
#
# Indicate that this is a unix-like system
#
set(UNIX 1)
#
# Library prefixes, suffixes, extra libs.
#

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1,2 @@
set(CYGWIN 1)
set(UNIX 1)

View File

@ -1,5 +1,3 @@
set(CYGWIN 1)
set(CMAKE_SHARED_LIBRARY_PREFIX "cyg")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
set(CMAKE_SHARED_MODULE_PREFIX "cyg")

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1,4 @@
# CrayLinuxEnvironment: loaded by users cross-compiling on a Cray front-end
# node by specifying "-DCMAKE_SYSTEM_NAME=CrayLinuxEnvironment" to cmake
set(UNIX 1)

View File

@ -1,8 +1,6 @@
# CrayLinuxEnvironment: loaded by users cross-compiling on a Cray front-end
# node by specifying "-DCMAKE_SYSTEM_NAME=CrayLinuxEnvironment" to cmake
set(UNIX 1)
if(DEFINED ENV{CRAYOS_VERSION})
set(CMAKE_SYSTEM_VERSION "$ENV{CRAYOS_VERSION}")
elseif(DEFINED ENV{XTOS_VERSION})

View File

@ -0,0 +1 @@
set(DOS 1)

View File

@ -1,5 +1,3 @@
set(DOS 1)
set(CMAKE_STATIC_LIBRARY_PREFIX "")
set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib")
set(CMAKE_SHARED_LIBRARY_PREFIX "")

View File

@ -1,3 +1,6 @@
set(APPLE 1)
set(UNIX 1)
# Ask xcode-select where to find /Developer or fall back to ancient location.
execute_process(COMMAND xcode-select -print-path
OUTPUT_VARIABLE _stdout

View File

@ -1,5 +1,3 @@
set(APPLE 1)
if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
if(NOT DEFINED CMAKE_MACOSX_BUNDLE)
set(CMAKE_MACOSX_BUNDLE ON)

View File

@ -0,0 +1,2 @@
include(Platform/FreeBSD-Initialize)
set(BSD "DragonFlyBSD")

View File

@ -3,7 +3,6 @@
# see http://archive.netbsd.se/?ml=dfbsd-users&a=2007-07&m=4678361
include(Platform/FreeBSD)
set(BSD "DragonFlyBSD")
# DragonFly BSD requires -z origin to enable $ORIGIN expansion in RPATH.
# This is not required for FreeBSD since 10.2-RELEASE.

View File

@ -0,0 +1,2 @@
set(BSD "FreeBSD")
set(UNIX 1)

View File

@ -1,4 +1,3 @@
set(BSD "FreeBSD")
set(CMAKE_DL_LIBS "")
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE")

View File

@ -0,0 +1 @@
set(FUCHSIA 1)

View File

@ -1,5 +1,3 @@
set(FUCHSIA 1)
set(CMAKE_DL_LIBS "")
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE")

View File

@ -1 +1,3 @@
set(UNIX 1)
set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-gnu[a-z0-9_]*")

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1,2 @@
set(HAIKU 1)
set(UNIX 1)

View File

@ -1,6 +1,3 @@
set(HAIKU 1)
set(UNIX 1)
set(CMAKE_DL_LIBS "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")

View File

@ -1,2 +1,5 @@
set(LINUX 1)
set(UNIX 1)
# Match multiarch library directory names.
set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*")

View File

@ -1,4 +1,3 @@
set(LINUX 1)
set(CMAKE_DL_LIBS "dl")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1,2 @@
set(MSYS 1)
include(Platform/CYGWIN-Initialize)

View File

@ -1,4 +1,3 @@
set(MSYS 1)
include(Platform/CYGWIN)
set(CMAKE_SHARED_LIBRARY_PREFIX "msys-")
set(CMAKE_SHARED_MODULE_PREFIX "msys-")

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1,2 @@
set(BSD "NetBSD")
set(UNIX 1)

View File

@ -1,4 +1,3 @@
set(BSD "NetBSD")
set(CMAKE_DL_LIBS "")
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE")

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1,2 @@
include(Platform/NetBSD-Initialize)
set(BSD "OpenBSD")

View File

@ -1,5 +1,4 @@
include(Platform/NetBSD)
set(BSD "OpenBSD")
# On OpenBSD, the compile time linker does not share it's configuration with
# the runtime linker. This will extract the library search paths from the

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -1,2 +1,3 @@
set(QNXNTO 1)
include(Platform/GNU-Initialize)
unset(CMAKE_LIBRARY_ARCHITECTURE_REGEX)

View File

@ -1,5 +1,3 @@
set(QNXNTO 1)
include(Platform/GNU)
set(CMAKE_DL_LIBS "")

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1,2 @@
set(SERENITYOS 1)
set(UNIX 1)

View File

@ -1,6 +1,3 @@
set(SERENITYOS 1)
set(CMAKE_DL_LIBS "")
set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -12,6 +12,9 @@ if(__UNIX_PATHS_INCLUDED)
endif()
set(__UNIX_PATHS_INCLUDED 1)
# Since CMake 3.27, the Platform/<os>-Initialize modules set UNIX
# if the corresponding Platform/<os> modules includes UnixPaths.
# Retain the setting here to support externally-maintained platform modules.
set(UNIX 1)
# also add the install directory of the running cmake to the search directories

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1 @@
set(WIN32 1)

View File

@ -1,13 +1,3 @@
set(WIN32 1)
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsCE")
set(WINCE 1)
elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone")
set(WINDOWS_PHONE 1)
elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
set(WINDOWS_STORE 1)
endif()
set(CMAKE_STATIC_LIBRARY_PREFIX "")
set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib")
set(CMAKE_SHARED_LIBRARY_PREFIX "") # lib

View File

@ -0,0 +1,2 @@
include(Platform/Windows-Initialize)
set(WINCE 1)

View File

@ -0,0 +1,2 @@
include(Platform/Windows-Initialize)
set(WINDOWS_PHONE 1)

View File

@ -0,0 +1,2 @@
include(Platform/Windows-Initialize)
set(WINDOWS_STORE 1)

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1 @@
set(UNIX 1)

View File

@ -0,0 +1 @@
set(UNIX 1)