summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/Modules/CheckCXXLinkerFlag.cmake29
-rw-r--r--Source/cmCommands.cxx4
2 files changed, 31 insertions, 2 deletions
diff --git a/Source/Modules/CheckCXXLinkerFlag.cmake b/Source/Modules/CheckCXXLinkerFlag.cmake
new file mode 100644
index 0000000000..6cb1ba3ac2
--- /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()
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 563e0f162a..896b6a98de 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"
@@ -257,6 +257,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<cmTryCompileCommand>());
@@ -277,7 +278,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("qt_wrap_cpp", cmQTWrapCPPCommand);