summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2022-09-30 18:50:25 (GMT)
committerMatthew Woehlke <matthew.woehlke@kitware.com>2022-09-30 18:50:25 (GMT)
commit0f28653ba9dea36564dbd41388536982c56a96eb (patch)
treef1655de6a7ed6c16a41eec3eb918a42ab9f9f006
parentcadcb6a5f0e1ebaefd74f8c52151e410c57cfa96 (diff)
downloadCMake-0f28653ba9dea36564dbd41388536982c56a96eb.zip
CMake-0f28653ba9dea36564dbd41388536982c56a96eb.tar.gz
CMake-0f28653ba9dea36564dbd41388536982c56a96eb.tar.bz2
try_compile: Rename SOURCE_FROM_ARG -> SOURCE_FROM_CONTENT
Change the SOURCE_FROM_ARG keyword to try_compile to SOURCE_FROM_CONTENT (which we can do because it was recently added and hasn't been in a release yet). The new name should be clearer as to what it does, and also more consistent with the CONTENT arguments to some other commands. Also, fix a typo in an error message.
-rw-r--r--Help/command/try_compile.rst21
-rw-r--r--Help/command/try_run.rst8
-rw-r--r--Source/cmCoreTryCompile.cxx19
-rw-r--r--Source/cmCoreTryCompile.h2
-rw-r--r--Tests/RunCMake/try_compile/SourceFromBadName-stderr.txt2
-rw-r--r--Tests/RunCMake/try_compile/SourceFromBadName.cmake2
-rw-r--r--Tests/RunCMake/try_compile/SourceFromOneArg-stderr.txt2
-rw-r--r--Tests/RunCMake/try_compile/SourceFromOneArg.cmake2
-rw-r--r--Tests/RunCMake/try_compile/SourceFromThreeArgs-stderr.txt2
-rw-r--r--Tests/RunCMake/try_compile/SourceFromThreeArgs.cmake2
-rw-r--r--Tests/TryCompile/CMakeLists.txt10
11 files changed, 37 insertions, 35 deletions
diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst
index 6cb4f99..2f62917 100644
--- a/Help/command/try_compile.rst
+++ b/Help/command/try_compile.rst
@@ -59,10 +59,10 @@ Try Compiling Source Files
.. code-block:: cmake
try_compile(<resultVar>
- <SOURCES <srcfile...>] |
- SOURCE_FROM_ARG <name> <content>] |
- SOURCE_FROM_VAR <name> <var>] |
- SOURCE_FROM_FILE <name> <path> >...
+ <SOURCES <srcfile...>] |
+ SOURCE_FROM_CONTENT <name> <content>] |
+ SOURCE_FROM_VAR <name> <var>] |
+ SOURCE_FROM_FILE <name> <path> >...
[NO_CACHE]
[CMAKE_FLAGS <flags>...]
[COMPILE_DEFINITIONS <defs>...]
@@ -194,7 +194,7 @@ The options are:
``OUTPUT_VARIABLE <var>``
Store the output from the build process in the given variable.
-``SOURCE_FROM_ARG <name> <content>``
+``SOURCE_FROM_CONTENT <name> <content>``
.. versionadded:: 3.25
Write ``<content>`` to a file named ``<name>`` in the operation directory.
@@ -202,7 +202,7 @@ The options are:
the contents of the file are dynamically specified. The specified ``<name>``
is not allowed to contain path components.
- ``SOURCE_FROM_ARG`` may be specified multiple times.
+ ``SOURCE_FROM_CONTENT`` may be specified multiple times.
``SOURCE_FROM_FILE <name> <path>``
.. versionadded:: 3.25
@@ -218,10 +218,11 @@ The options are:
.. versionadded:: 3.25
Write the contents of ``<var>`` to a file named ``<name>`` in the operation
- directory. This is the same as ``SOURCE_FROM_ARG``, but takes the contents
- from the specified CMake variable, rather than directly, which may be useful
- when passing arguments through a function which wraps ``try_compile``. The
- specified ``<name>`` is not allowed to contain path components.
+ directory. This is the same as ``SOURCE_FROM_CONTENT``, but takes the
+ contents from the specified CMake variable, rather than directly, which may
+ be useful when passing arguments through a function which wraps
+ ``try_compile``. The specified ``<name>`` is not allowed to contain path
+ components.
``SOURCE_FROM_VAR`` may be specified multiple times.
diff --git a/Help/command/try_run.rst b/Help/command/try_run.rst
index 8393e1b..be7c734 100644
--- a/Help/command/try_run.rst
+++ b/Help/command/try_run.rst
@@ -13,10 +13,10 @@ Try Compiling and Running Source Files
.. code-block:: cmake
try_run(<runResultVar> <compileResultVar>
- <SOURCES <srcfile...>] |
- SOURCE_FROM_ARG <name> <content>] |
- SOURCE_FROM_VAR <name> <var>] |
- SOURCE_FROM_FILE <name> <path> >...
+ <SOURCES <srcfile...>] |
+ SOURCE_FROM_CONTENT <name> <content>] |
+ SOURCE_FROM_VAR <name> <var>] |
+ SOURCE_FROM_FILE <name> <path> >...
[NO_CACHE]
[CMAKE_FLAGS <flags>...]
[COMPILE_DEFINITIONS <defs>...]
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 323790e..cdf8efa 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -173,7 +173,7 @@ auto const TryCompileBaseSourcesArgParser =
auto const TryCompileBaseNewSourcesArgParser =
cmArgumentParser<Arguments>{ TryCompileBaseSourcesArgParser }
- .Bind("SOURCE_FROM_ARG"_s, &Arguments::SourceFromArg)
+ .Bind("SOURCE_FROM_CONTENT"_s, &Arguments::SourceFromContent)
.Bind("SOURCE_FROM_VAR"_s, &Arguments::SourceFromVar)
.Bind("SOURCE_FROM_FILE"_s, &Arguments::SourceFromFile)
/* keep semicolon on own line */;
@@ -402,10 +402,11 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments,
}
if (this->SrcFileSignature) {
- if (arguments.SourceFromArg && arguments.SourceFromArg->size() % 2) {
+ if (arguments.SourceFromContent &&
+ arguments.SourceFromContent->size() % 2) {
this->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
- "SOURCE_FROM_ARG requires exactly two arguments");
+ "SOURCE_FROM_CONTENT requires exactly two arguments");
return false;
}
if (arguments.SourceFromVar && arguments.SourceFromVar->size() % 2) {
@@ -476,12 +477,12 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments,
} else if (arguments.SourceDirectoryOrFile) {
sources.emplace_back(*arguments.SourceDirectoryOrFile);
}
- if (arguments.SourceFromArg) {
- auto const k = arguments.SourceFromArg->size();
+ if (arguments.SourceFromContent) {
+ auto const k = arguments.SourceFromContent->size();
for (auto i = decltype(k){ 0 }; i < k; i += 2) {
- const auto& name = (*arguments.SourceFromArg)[i + 0];
- const auto& content = (*arguments.SourceFromArg)[i + 1];
- auto out = this->WriteSource(name, content, "SOURCES_FROM_ARG");
+ const auto& name = (*arguments.SourceFromContent)[i + 0];
+ const auto& content = (*arguments.SourceFromContent)[i + 1];
+ auto out = this->WriteSource(name, content, "SOURCE_FROM_CONTENT");
if (out.empty()) {
return false;
}
@@ -494,7 +495,7 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments,
const auto& name = (*arguments.SourceFromVar)[i + 0];
const auto& var = (*arguments.SourceFromVar)[i + 1];
const auto& content = this->Makefile->GetDefinition(var);
- auto out = this->WriteSource(name, content, "SOURCES_FROM_VAR");
+ auto out = this->WriteSource(name, content, "SOURCE_FROM_VAR");
if (out.empty()) {
return false;
}
diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h
index d4c9466..3e1e12c 100644
--- a/Source/cmCoreTryCompile.h
+++ b/Source/cmCoreTryCompile.h
@@ -41,7 +41,7 @@ public:
cm::optional<std::string> TargetName;
cm::optional<ArgumentParser::NonEmpty<std::vector<std::string>>> Sources;
cm::optional<ArgumentParser::NonEmpty<std::vector<std::string>>>
- SourceFromArg;
+ SourceFromContent;
cm::optional<ArgumentParser::NonEmpty<std::vector<std::string>>>
SourceFromVar;
cm::optional<ArgumentParser::NonEmpty<std::vector<std::string>>>
diff --git a/Tests/RunCMake/try_compile/SourceFromBadName-stderr.txt b/Tests/RunCMake/try_compile/SourceFromBadName-stderr.txt
index ef6847c..041f3f1 100644
--- a/Tests/RunCMake/try_compile/SourceFromBadName-stderr.txt
+++ b/Tests/RunCMake/try_compile/SourceFromBadName-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at SourceFromBadName.cmake:[0-9]+ \(try_compile\):
- SOURCES_FROM_ARG given invalid filename "bad/name.c"
+ SOURCE_FROM_CONTENT given invalid filename "bad/name.c"
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/SourceFromBadName.cmake b/Tests/RunCMake/try_compile/SourceFromBadName.cmake
index e53a73f..44d92fd 100644
--- a/Tests/RunCMake/try_compile/SourceFromBadName.cmake
+++ b/Tests/RunCMake/try_compile/SourceFromBadName.cmake
@@ -1 +1 @@
-try_compile(RESULT SOURCE_FROM_ARG bad/name.c "int main();")
+try_compile(RESULT SOURCE_FROM_CONTENT bad/name.c "int main();")
diff --git a/Tests/RunCMake/try_compile/SourceFromOneArg-stderr.txt b/Tests/RunCMake/try_compile/SourceFromOneArg-stderr.txt
index bebe8bb..8b2248a 100644
--- a/Tests/RunCMake/try_compile/SourceFromOneArg-stderr.txt
+++ b/Tests/RunCMake/try_compile/SourceFromOneArg-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at SourceFromOneArg.cmake:[0-9]+ \(try_compile\):
- SOURCE_FROM_ARG requires exactly two arguments
+ SOURCE_FROM_CONTENT requires exactly two arguments
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/SourceFromOneArg.cmake b/Tests/RunCMake/try_compile/SourceFromOneArg.cmake
index 39ca11e..5a50499 100644
--- a/Tests/RunCMake/try_compile/SourceFromOneArg.cmake
+++ b/Tests/RunCMake/try_compile/SourceFromOneArg.cmake
@@ -1 +1 @@
-try_compile(RESULT SOURCE_FROM_ARG test.c)
+try_compile(RESULT SOURCE_FROM_CONTENT test.c)
diff --git a/Tests/RunCMake/try_compile/SourceFromThreeArgs-stderr.txt b/Tests/RunCMake/try_compile/SourceFromThreeArgs-stderr.txt
index 2cf201d..5f2ff61 100644
--- a/Tests/RunCMake/try_compile/SourceFromThreeArgs-stderr.txt
+++ b/Tests/RunCMake/try_compile/SourceFromThreeArgs-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at SourceFromThreeArgs.cmake:[0-9]+ \(try_compile\):
- SOURCE_FROM_ARG requires exactly two arguments
+ SOURCE_FROM_CONTENT requires exactly two arguments
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/SourceFromThreeArgs.cmake b/Tests/RunCMake/try_compile/SourceFromThreeArgs.cmake
index af6340d..196851a 100644
--- a/Tests/RunCMake/try_compile/SourceFromThreeArgs.cmake
+++ b/Tests/RunCMake/try_compile/SourceFromThreeArgs.cmake
@@ -1 +1 @@
-try_compile(RESULT SOURCE_FROM_ARG test.c "int" "main();")
+try_compile(RESULT SOURCE_FROM_CONTENT test.c "int" "main();")
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt
index 9396cfa..5f540e9 100644
--- a/Tests/TryCompile/CMakeLists.txt
+++ b/Tests/TryCompile/CMakeLists.txt
@@ -78,7 +78,7 @@ include(old_and_new_signature_tests.cmake)
# try to compile an empty source specified directly
try_compile(SHOULD_FAIL_DUE_TO_EMPTY_SOURCE
- SOURCE_FROM_ARG empty.c "")
+ SOURCE_FROM_CONTENT empty.c "")
if(SHOULD_FAIL_DUE_TO_EMPTY_SOURCE)
message(SEND_ERROR "Trying to compile an empty source succeeded?")
endif()
@@ -103,11 +103,11 @@ set(TRY_RUN_EXT_CODE
"int answer() { return 42; }\n")
try_run(SHOULD_EXIT_WITH_ERROR SHOULD_COMPILE
- SOURCE_FROM_ARG main.c "${TRY_RUN_MAIN_CODE}"
- SOURCE_FROM_ARG answer.c "${TRY_RUN_EXT_CODE}"
+ SOURCE_FROM_CONTENT main.c "${TRY_RUN_MAIN_CODE}"
+ SOURCE_FROM_CONTENT answer.c "${TRY_RUN_EXT_CODE}"
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT)
-EXPECT_COMPILED("SOURCE_FROM_ARG" SHOULD_COMPILE "${COMPILE_OUTPUT}")
-EXPECT_RUN_RESULT("SOURCE_FROM_ARG" SHOULD_EXIT_WITH_ERROR 42)
+EXPECT_COMPILED("SOURCE_FROM_CONTENT" SHOULD_COMPILE "${COMPILE_OUTPUT}")
+EXPECT_RUN_RESULT("SOURCE_FROM_CONTENT" SHOULD_EXIT_WITH_ERROR 42)
try_run(SHOULD_EXIT_WITH_ERROR SHOULD_COMPILE
SOURCE_FROM_VAR main.c TRY_RUN_MAIN_CODE