From 8c7b7df788851358392e4a00faf00bc2a674c3a6 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 9 Dec 2019 12:48:00 +0100 Subject: bootstrap: Add target_link_options command --- Source/cmCommands.cxx | 4 ++-- bootstrap | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index ff73b27..6f19697 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -78,6 +78,7 @@ #include "cmTargetCompileOptionsCommand.h" #include "cmTargetIncludeDirectoriesCommand.h" #include "cmTargetLinkLibrariesCommand.h" +#include "cmTargetLinkOptionsCommand.h" #include "cmTargetPrecompileHeadersCommand.h" #include "cmTargetSourcesCommand.h" #include "cmTryCompileCommand.h" @@ -107,7 +108,6 @@ # include "cmSourceGroupCommand.h" # include "cmSubdirDependsCommand.h" # include "cmTargetLinkDirectoriesCommand.h" -# include "cmTargetLinkOptionsCommand.h" # include "cmUseMangledMesaCommand.h" # include "cmUtilitySourceCommand.h" # include "cmVariableRequiresCommand.h" @@ -256,6 +256,7 @@ void GetProjectCommands(cmState* state) cmTargetIncludeDirectoriesCommand); state->AddBuiltinCommand("target_link_libraries", cmTargetLinkLibrariesCommand); + state->AddBuiltinCommand("target_link_options", cmTargetLinkOptionsCommand); state->AddBuiltinCommand("target_sources", cmTargetSourcesCommand); state->AddBuiltinCommand("try_compile", cm::make_unique()); @@ -276,7 +277,6 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("install_programs", cmInstallProgramsCommand); state->AddBuiltinCommand("add_link_options", cmAddLinkOptionsCommand); state->AddBuiltinCommand("link_libraries", cmLinkLibrariesCommand); - state->AddBuiltinCommand("target_link_options", cmTargetLinkOptionsCommand); state->AddBuiltinCommand("target_link_directories", cmTargetLinkDirectoriesCommand); state->AddBuiltinCommand("load_cache", cmLoadCacheCommand); diff --git a/bootstrap b/bootstrap index 883b165..1f8eaa5 100755 --- a/bootstrap +++ b/bootstrap @@ -435,6 +435,7 @@ CMAKE_CXX_SOURCES="\ cmTargetCompileOptionsCommand \ cmTargetIncludeDirectoriesCommand \ cmTargetLinkLibrariesCommand \ + cmTargetLinkOptionsCommand \ cmTargetPrecompileHeadersCommand \ cmTargetPropCommandBase \ cmTargetPropertyComputer \ -- cgit v0.12 From 958f858ad815024550b22eeaac02f183f8d646fd Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 9 Dec 2019 09:42:40 +0100 Subject: Check for support before adding bigtoc linker flag Fixes: #20076 --- CompileFlags.cmake | 12 ++++++++++-- Source/Modules/CheckCXXLinkerFlag.cmake | 29 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 Source/Modules/CheckCXXLinkerFlag.cmake diff --git a/CompileFlags.cmake b/CompileFlags.cmake index 91f2adf..053259f 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -54,12 +54,20 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^parisc") endif() # Workaround for TOC Overflow on ppc64 +set(bigTocFlag "") if(CMAKE_SYSTEM_NAME STREQUAL "AIX" AND CMAKE_SYSTEM_PROCESSOR MATCHES "powerpc") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-bbigtoc") + set(bigTocFlag "-Wl,-bbigtoc") elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-multi-toc") + set(bigTocFlag "-Wl,--no-multi-toc") +endif() +if(bigTocFlag) + include(CheckCXXLinkerFlag) + check_cxx_linker_flag(${bigTocFlag} BIG_TOC_FLAG_SUPPORTED) + if(BIG_TOC_FLAG_SUPPORTED) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${bigTocFlag}") + endif() endif() if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND diff --git a/Source/Modules/CheckCXXLinkerFlag.cmake b/Source/Modules/CheckCXXLinkerFlag.cmake new file mode 100644 index 0000000..6cb1ba3 --- /dev/null +++ b/Source/Modules/CheckCXXLinkerFlag.cmake @@ -0,0 +1,29 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include_guard(GLOBAL) +include(CheckCXXSourceCompiles) +include(CMakeCheckCompilerFlagCommonPatterns) + +function(check_cxx_linker_flag _flag _var) + if(CMAKE_VERSION VERSION_LESS "3.14") + set(CMAKE_REQUIRED_LIBRARIES "${_flag}") + else() + set(CMAKE_REQUIRED_LINK_OPTIONS "${_flag}") + endif() + + # Normalize locale during test compilation. + set(_locale_vars LC_ALL LC_MESSAGES LANG) + foreach(v IN LISTS _locale_vars) + set(_locale_vars_saved_${v} "$ENV{${v}}") + set(ENV{${v}} C) + endforeach() + check_compiler_flag_common_patterns(_common_patterns) + check_cxx_source_compiles("int main() { return 0; }" ${_var} + ${_common_patterns} + ) + foreach(v IN LISTS _locale_vars) + set(ENV{${v}} ${_locale_vars_saved_${v}}) + endforeach() + set(${_var} "${${_var}}" PARENT_SCOPE) +endfunction() -- cgit v0.12 From b35926e2606272ceac4191b207f51c531e0116a8 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 9 Dec 2019 09:42:40 +0100 Subject: Check for support before adding bigtoc linker flag Fixes: #20076 --- CompileFlags.cmake | 12 ++++++++++-- Source/Modules/CheckCXXLinkerFlag.cmake | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 Source/Modules/CheckCXXLinkerFlag.cmake diff --git a/CompileFlags.cmake b/CompileFlags.cmake index 91f2adf..053259f 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -54,12 +54,20 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^parisc") endif() # Workaround for TOC Overflow on ppc64 +set(bigTocFlag "") if(CMAKE_SYSTEM_NAME STREQUAL "AIX" AND CMAKE_SYSTEM_PROCESSOR MATCHES "powerpc") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-bbigtoc") + set(bigTocFlag "-Wl,-bbigtoc") elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-multi-toc") + set(bigTocFlag "-Wl,--no-multi-toc") +endif() +if(bigTocFlag) + include(CheckCXXLinkerFlag) + check_cxx_linker_flag(${bigTocFlag} BIG_TOC_FLAG_SUPPORTED) + if(BIG_TOC_FLAG_SUPPORTED) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${bigTocFlag}") + endif() endif() if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND diff --git a/Source/Modules/CheckCXXLinkerFlag.cmake b/Source/Modules/CheckCXXLinkerFlag.cmake new file mode 100644 index 0000000..9ad2ad6 --- /dev/null +++ b/Source/Modules/CheckCXXLinkerFlag.cmake @@ -0,0 +1,25 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include_guard(GLOBAL) +include(CheckCXXSourceCompiles) +include(CMakeCheckCompilerFlagCommonPatterns) + +function(check_cxx_linker_flag _flag _var) + set(CMAKE_REQUIRED_LIBRARIES "${_flag}") + + # Normalize locale during test compilation. + set(_locale_vars LC_ALL LC_MESSAGES LANG) + foreach(v IN LISTS _locale_vars) + set(_locale_vars_saved_${v} "$ENV{${v}}") + set(ENV{${v}} C) + endforeach() + check_compiler_flag_common_patterns(_common_patterns) + check_cxx_source_compiles("int main() { return 0; }" ${_var} + ${_common_patterns} + ) + foreach(v IN LISTS _locale_vars) + set(ENV{${v}} ${_locale_vars_saved_${v}}) + endforeach() + set(${_var} "${${_var}}" PARENT_SCOPE) +endfunction() -- cgit v0.12