summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/manual/OPTIONS_BUILD.txt4
-rw-r--r--Help/manual/cmake-toolchains.7.rst4
-rw-r--r--Help/release/dev/cmake-toolchain-command.rst5
-rw-r--r--Help/variable/CMAKE_TOOLCHAIN_FILE.rst3
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake2
-rw-r--r--Modules/Compiler/Fujitsu-C.cmake6
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmQtAutoMocUic.cxx11
-rw-r--r--Source/cmake.cxx14
-rw-r--r--Source/cmake.h2
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake24
-rw-r--r--Tests/RunCMake/CommandLine/Toolchain/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CommandLine/Toolchain/toolchain.cmake2
-rw-r--r--Tests/RunCMake/CommandLine/toolchain-no-arg-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/toolchain-no-arg-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/toolchain-valid-abs-path-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/toolchain-valid-abs-path-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-stderr.txt1
21 files changed, 78 insertions, 12 deletions
diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt
index c4f9be8..c4f83f7 100644
--- a/Help/manual/OPTIONS_BUILD.txt
+++ b/Help/manual/OPTIONS_BUILD.txt
@@ -76,6 +76,10 @@
native build system to choose a compiler or SDK. See the
:variable:`CMAKE_GENERATOR_PLATFORM` variable for details.
+``--toolchain <path-to-file>``
+ Specify the cross compiling toolchain file, equivalant to setting
+ :variable:`CMAKE_TOOLCHAIN_FILE` variable.
+
``--install-prefix <directory>``
Specify the installation directory, used by the
:variable:`CMAKE_INSTALL_PREFIX` variable. Must be an absolute path.
diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst
index 1ededee..a941310 100644
--- a/Help/manual/cmake-toolchains.7.rst
+++ b/Help/manual/cmake-toolchains.7.rst
@@ -96,8 +96,8 @@ Cross Compiling
===============
If :manual:`cmake(1)` is invoked with the command line parameter
-``-DCMAKE_TOOLCHAIN_FILE=path/to/file``, the file will be loaded early to set
-values for the compilers.
+``--toolchain path/to/file`` or ``-DCMAKE_TOOLCHAIN_FILE=path/to/file``, the
+file will be loaded early to set values for the compilers.
The :variable:`CMAKE_CROSSCOMPILING` variable is set to true when CMake is
cross-compiling.
diff --git a/Help/release/dev/cmake-toolchain-command.rst b/Help/release/dev/cmake-toolchain-command.rst
new file mode 100644
index 0000000..111ca49
--- /dev/null
+++ b/Help/release/dev/cmake-toolchain-command.rst
@@ -0,0 +1,5 @@
+cmake-toolchain-command
+----------------------------
+
+* The :manual:`cmake(1)` command gained the ``--toolchain <path/to/file>``
+ command line option to specify a toolchain file.
diff --git a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst
index 168ee74..423da9c 100644
--- a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst
+++ b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst
@@ -7,3 +7,6 @@ This variable is specified on the command line when cross-compiling with CMake.
It is the path to a file which is read early in the CMake run and which
specifies locations for compilers and toolchain utilities, and other target
platform and compiler related information.
+
+Relative paths are allowed and are interpreted first as relative to the
+build directory, and if not found, relative to the soruce directory.
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index d7b7f26..519fe6b 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -223,6 +223,8 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
else()
set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU")
endif()
+ elseif("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xFujitsuClang")
+ set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU")
else()
set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "")
endif()
diff --git a/Modules/Compiler/Fujitsu-C.cmake b/Modules/Compiler/Fujitsu-C.cmake
index 0e0f1dc..dd31e43 100644
--- a/Modules/Compiler/Fujitsu-C.cmake
+++ b/Modules/Compiler/Fujitsu-C.cmake
@@ -4,9 +4,9 @@ include(Compiler/Fujitsu)
__compiler_fujitsu(C)
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4)
- set(CMAKE_C89_STANDARD_COMPILE_OPTION -std=c89)
- set(CMAKE_C89_EXTENSION_COMPILE_OPTION -std=gnu89)
- set(CMAKE_C89_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_C90_STANDARD_COMPILE_OPTION -std=c89)
+ set(CMAKE_C90_EXTENSION_COMPILE_OPTION -std=gnu89)
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION -std=c99)
set(CMAKE_C99_EXTENSION_COMPILE_OPTION -std=gnu99)
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 14ed182..985d944 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 20)
-set(CMake_VERSION_PATCH 20210415)
+set(CMake_VERSION_PATCH 20210416)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx
index c32c965..e2b1ae1 100644
--- a/Source/cmQtAutoMocUic.cxx
+++ b/Source/cmQtAutoMocUic.cxx
@@ -564,8 +564,7 @@ private:
// -- Generation
bool CreateDirectories();
// -- Support for depfiles
- static std::vector<std::string> dependenciesFromDepFile(
- const char* filePath);
+ std::vector<std::string> dependenciesFromDepFile(const char* filePath);
// -- Settings
BaseSettingsT BaseConst_;
@@ -2066,7 +2065,8 @@ void cmQtAutoMocUicT::JobCompileMocT::Process()
" does not exist.");
return;
}
- this->CacheEntry->Moc.Depends = dependenciesFromDepFile(depfile.c_str());
+ this->CacheEntry->Moc.Depends =
+ this->Gen()->dependenciesFromDepFile(depfile.c_str());
}
}
@@ -2223,12 +2223,12 @@ void cmQtAutoMocUicT::JobDepFilesMergeT::Process()
this->MessagePath(this->BaseConst().DepFile.c_str())));
}
auto processDepFile =
- [](const std::string& mocOutputFile) -> std::vector<std::string> {
+ [this](const std::string& mocOutputFile) -> std::vector<std::string> {
std::string f = mocOutputFile + ".d";
if (!cmSystemTools::FileExists(f)) {
return {};
}
- return dependenciesFromDepFile(f.c_str());
+ return this->Gen()->dependenciesFromDepFile(f.c_str());
};
std::vector<std::string> dependencies = this->initialDependencies();
@@ -2961,6 +2961,7 @@ bool cmQtAutoMocUicT::CreateDirectories()
std::vector<std::string> cmQtAutoMocUicT::dependenciesFromDepFile(
const char* filePath)
{
+ std::lock_guard<std::mutex> guard(this->CMakeLibMutex_);
auto const content = cmReadGccDepfile(filePath);
if (!content || content->empty()) {
return {};
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 1d4bbf4..3b8b70e 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -509,6 +509,16 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
return false;
};
+ auto ToolchainLambda = [&](std::string const& path, cmake* state) -> bool {
+ const std::string var = "CMAKE_TOOLCHAIN_FILE";
+ cmStateEnums::CacheEntryType type = cmStateEnums::FILEPATH;
+#ifndef CMAKE_BOOTSTRAP
+ state->UnprocessedPresetVariables.erase(var);
+#endif
+ state->ProcessCacheArg(var, path, type);
+ return true;
+ };
+
std::vector<CommandArgument> arguments = {
CommandArgument{ "-D", "-D must be followed with VAR=VALUE.",
CommandArgument::Values::One, DefineLambda },
@@ -530,6 +540,8 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
CommandArgument{ "-P", "-P must be followed by a file name.",
CommandArgument::Values::One, ScriptLambda },
+ CommandArgument{ "--toolchain", "No file specified for --toolchain",
+ CommandArgument::Values::One, ToolchainLambda },
CommandArgument{ "--install-prefix",
"No install directory specified for --install-prefix",
CommandArgument::Values::One, PrefixLambda },
@@ -835,6 +847,8 @@ void cmake::SetArgs(const std::vector<std::string>& args)
CommandArgument::Values::One, PlatformLambda },
CommandArgument{ "-T", "No toolset specified for -T",
CommandArgument::Values::One, ToolsetLamda },
+ CommandArgument{ "--toolchain", "No file specified for --toolchain",
+ CommandArgument::Values::One, IgnoreAndTrueLambda },
CommandArgument{ "--install-prefix",
"No install directory specified for --install-prefix",
CommandArgument::Values::One, IgnoreAndTrueLambda },
diff --git a/Source/cmake.h b/Source/cmake.h
index ab2ed21..9b29098 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -712,6 +712,8 @@ private:
"Specify toolset name if supported by generator." }, \
{ "-A <platform-name>", \
"Specify platform name if supported by generator." }, \
+ { "--toolchain <file>", \
+ "Specify toolchain file [CMAKE_TOOLCHAIN_FILE]." }, \
{ "--install-prefix <directory>", \
"Specify install directory [CMAKE_INSTALL_PREFIX]." }, \
{ "-Wdev", "Enable developer warnings." }, \
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index c497472..bf5a96e 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -61,7 +61,6 @@ run_cmake_command(build-bad-dir
run_cmake_command(build-bad-generator
${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-generator)
-
run_cmake_command(install-prefix-no-arg ${CMAKE_COMMAND} -B DummyBuildDir --install-prefix)
run_cmake_command(install-no-dir
@@ -153,6 +152,29 @@ project(ExplicitDirsMissing LANGUAGES NONE)
endfunction()
run_ExplicitDirs()
+function(run_Toolchain)
+ set(RunCMake_TEST_NO_SOURCE_DIR 1)
+ set(source_dir ${RunCMake_SOURCE_DIR}/Toolchain)
+
+ run_cmake_with_options(toolchain-no-arg -S ${source_dir} --toolchain=)
+ run_cmake_with_options(toolchain-valid-abs-path -S ${source_dir} --toolchain "${source_dir}/toolchain.cmake")
+ run_cmake_with_options(toolchain-valid-rel-src-path -S ${source_dir} --toolchain=toolchain.cmake)
+
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(binary_dir ${RunCMake_BINARY_DIR}/Toolchain-build)
+ set(RunCMake_TEST_BINARY_DIR "${binary_dir}")
+ file(REMOVE_RECURSE "${binary_dir}")
+
+ # Test that we both search the binary dir for toolchain files, and it takes
+ # precedence over source dir
+ file(WRITE ${binary_dir}/toolchain.cmake [=[
+set(CMAKE_SYSTEM_NAME Linux)
+set(toolchain_file binary_dir)
+]=])
+ run_cmake_with_options(toolchain-valid-rel-build-path ${CMAKE_COMMAND} -S ${source_dir} -B ${binary_dir} --toolchain toolchain.cmake)
+endfunction()
+run_Toolchain()
+
function(run_BuildDir)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BuildDir-build)
diff --git a/Tests/RunCMake/CommandLine/Toolchain/CMakeLists.txt b/Tests/RunCMake/CommandLine/Toolchain/CMakeLists.txt
new file mode 100644
index 0000000..80d42b8
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Toolchain/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.20)
+project(Toolchain LANGUAGES NONE)
+message(FATAL_ERROR "${toolchain_file}")
diff --git a/Tests/RunCMake/CommandLine/Toolchain/toolchain.cmake b/Tests/RunCMake/CommandLine/Toolchain/toolchain.cmake
new file mode 100644
index 0000000..719556c
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Toolchain/toolchain.cmake
@@ -0,0 +1,2 @@
+set(CMAKE_SYSTEM_NAME Linux)
+set(toolchain_file source_dir)
diff --git a/Tests/RunCMake/CommandLine/toolchain-no-arg-result.txt b/Tests/RunCMake/CommandLine/toolchain-no-arg-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/toolchain-no-arg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/toolchain-no-arg-stderr.txt b/Tests/RunCMake/CommandLine/toolchain-no-arg-stderr.txt
new file mode 100644
index 0000000..2fec517
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/toolchain-no-arg-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: No file specified for --toolchain
diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-result.txt b/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-stderr.txt b/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-stderr.txt
new file mode 100644
index 0000000..21d5db6
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-stderr.txt
@@ -0,0 +1 @@
+^CMake Error.*source_dir
diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-result.txt b/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-stderr.txt b/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-stderr.txt
new file mode 100644
index 0000000..1980051
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-stderr.txt
@@ -0,0 +1 @@
+^CMake Error.*binary_dir
diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-result.txt b/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-stderr.txt b/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-stderr.txt
new file mode 100644
index 0000000..21d5db6
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-stderr.txt
@@ -0,0 +1 @@
+^CMake Error.*source_dir