[Cmake-commits] CMake branch, next, updated. v3.7.0-rc2-818-gb45687a
Brad King
brad.king at kitware.com
Fri Oct 28 16:03:33 EDT 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via b45687a47df2c5bd075f0316eb753c1a786c08b3 (commit)
via f648b9be6347046583ee795f42e39713f248a608 (commit)
via e7480d670b9a20bc5d8b17db5a9427fafb212e85 (commit)
from 7d270027fec3938cdbf68e8e0f8df9741cf07c0c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b45687a47df2c5bd075f0316eb753c1a786c08b3
commit b45687a47df2c5bd075f0316eb753c1a786c08b3
Merge: 7d27002 f648b9b
Author: Brad King <brad.king at kitware.com>
AuthorDate: Fri Oct 28 16:03:31 2016 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Oct 28 16:03:31 2016 -0400
Merge topic 'custom-command-CROSSCOMPILING_EMULATOR' into next
f648b9be Tests: Check that CROSSCOMPILING_EMULATOR is not used on imported targets
e7480d67 Fix custom command target substitution with CROSSCOMPILING_EMULATOR
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f648b9be6347046583ee795f42e39713f248a608
commit f648b9be6347046583ee795f42e39713f248a608
Author: Brad King <brad.king at kitware.com>
AuthorDate: Fri Oct 28 14:45:15 2016 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Fri Oct 28 15:08:08 2016 -0400
Tests: Check that CROSSCOMPILING_EMULATOR is not used on imported targets
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake
index 67fa30f..c4db11b 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake
@@ -4,7 +4,15 @@ set(CMAKE_CROSSCOMPILING 1)
add_executable(generated_exe_emulator_expected simple_src_exiterror.cxx)
# Executable: Return error code equal to 0
-add_executable(generated_exe_emulator_unexpected simple_src_exitsuccess.cxx)
+add_executable(generated_exe_emulator_unexpected generated_exe_emulator_unexpected.cxx)
+# Place the executable in a predictable location.
+set_property(TARGET generated_exe_emulator_unexpected PROPERTY RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}>)
+
+# Executable: Imported version of above. Fake the imported target to use the above.
+add_executable(generated_exe_emulator_unexpected_imported IMPORTED)
+set_property(TARGET generated_exe_emulator_unexpected_imported PROPERTY IMPORTED_LOCATION
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_exe_emulator_unexpected${CMAKE_EXECUTABLE_SUFFIX}")
+add_dependencies(generated_exe_emulator_unexpected_imported generated_exe_emulator_unexpected)
# DoesNotUseEmulator
add_custom_command(OUTPUT output1
@@ -22,6 +30,12 @@ add_custom_command(OUTPUT output3
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3
DEPENDS generated_exe_emulator_unexpected)
+# DoesNotUseEmulator: The command will fail if emulator is prepended
+add_custom_command(OUTPUT outputImp
+ COMMAND generated_exe_emulator_unexpected_imported
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/outputImp
+ )
+
# UsesEmulator: The command only succeeds if the emulator is prepended
# to the command.
add_custom_command(OUTPUT output4
@@ -34,5 +48,6 @@ add_custom_target(ensure_build ALL
${CMAKE_CURRENT_BINARY_DIR}/output1
${CMAKE_CURRENT_BINARY_DIR}/output2
${CMAKE_CURRENT_BINARY_DIR}/output3
+ ${CMAKE_CURRENT_BINARY_DIR}/outputImp
${CMAKE_CURRENT_BINARY_DIR}/output4
)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake
index ced569f..5b01abc 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake
@@ -4,7 +4,15 @@ set(CMAKE_CROSSCOMPILING 1)
add_executable(generated_exe_emulator_expected simple_src_exiterror.cxx)
# Executable: Return error code equal to 0
-add_executable(generated_exe_emulator_unexpected simple_src_exitsuccess.cxx)
+add_executable(generated_exe_emulator_unexpected generated_exe_emulator_unexpected.cxx)
+# Place the executable in a predictable location.
+set_property(TARGET generated_exe_emulator_unexpected PROPERTY RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}>)
+
+# Executable: Imported version of above. Fake the imported target to use the above.
+add_executable(generated_exe_emulator_unexpected_imported IMPORTED)
+set_property(TARGET generated_exe_emulator_unexpected_imported PROPERTY IMPORTED_LOCATION
+ "${CMAKE_CURRENT_BINARY_DIR}/generated_exe_emulator_unexpected${CMAKE_EXECUTABLE_SUFFIX}")
+add_dependencies(generated_exe_emulator_unexpected_imported generated_exe_emulator_unexpected)
# DoesNotUseEmulator
add_custom_target(generate_output1 ALL
@@ -22,6 +30,12 @@ add_custom_target(generate_output3 ALL
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3
DEPENDS generated_exe_emulator_unexpected)
+# DoesNotUseEmulator: The command will fail if emulator is prepended
+add_custom_target(generate_outputImp ALL
+ COMMAND generated_exe_emulator_unexpected_imported
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/outputImp
+ )
+
# UsesEmulator: The command only succeeds if the emulator is prepended
# to the command.
add_custom_target(generate_output4 ALL
diff --git a/Tests/RunCMake/CrosscompilingEmulator/generated_exe_emulator_unexpected.cxx b/Tests/RunCMake/CrosscompilingEmulator/generated_exe_emulator_unexpected.cxx
new file mode 100644
index 0000000..233f432
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/generated_exe_emulator_unexpected.cxx
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+int main(int argc, const char* argv[])
+{
+ for (int i = 1; i < argc; ++i) {
+ fprintf(stderr, "unexpected argument: '%s'\n", argv[i]);
+ }
+ return argc == 1 ? 0 : 1;
+}
diff --git a/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx b/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx
deleted file mode 100644
index a3dd891..0000000
--- a/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx
+++ /dev/null
@@ -1,4 +0,0 @@
-int main(int, char**)
-{
- return 0;
-}
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e7480d670b9a20bc5d8b17db5a9427fafb212e85
commit e7480d670b9a20bc5d8b17db5a9427fafb212e85
Author: Brad King <brad.king at kitware.com>
AuthorDate: Fri Oct 28 11:33:02 2016 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Fri Oct 28 15:08:03 2016 -0400
Fix custom command target substitution with CROSSCOMPILING_EMULATOR
In commit v3.6.0-rc1~88^2 (CustomCommandGenerator: Add support for
CROSSCOMPILING_EMULATOR, 2016-05-04) logic was introduced to substitute
a target's `CROSSCOMPILING_EMULATOR` for argv0 in a custom command.
However, it broke the case when the argv0 was a target name and now
fails to expand the target name to its location at the same time as
inserting the emulator. Fix the latter case.
Inspired-by: Brian Maher <brian at brimworks.com>
Closes: #16288
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 2125f1b..8bd3a89 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -38,32 +38,44 @@ unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const
return static_cast<unsigned int>(this->CC.GetCommandLines().size());
}
-bool cmCustomCommandGenerator::UseCrossCompilingEmulator(unsigned int c) const
+const char* cmCustomCommandGenerator::GetCrossCompilingEmulator(
+ unsigned int c) const
{
+ if (!this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING")) {
+ return CM_NULLPTR;
+ }
std::string const& argv0 = this->CC.GetCommandLines()[c][0];
cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0);
- if (target && target->GetType() == cmStateEnums::EXECUTABLE) {
- return target->GetProperty("CROSSCOMPILING_EMULATOR") != CM_NULLPTR;
+ if (target && target->GetType() == cmStateEnums::EXECUTABLE &&
+ !target->IsImported()) {
+ return target->GetProperty("CROSSCOMPILING_EMULATOR");
}
- return false;
+ return CM_NULLPTR;
}
-std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const
+const char* cmCustomCommandGenerator::GetArgv0Location(unsigned int c) const
{
std::string const& argv0 = this->CC.GetCommandLines()[c][0];
cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0);
if (target && target->GetType() == cmStateEnums::EXECUTABLE &&
(target->IsImported() ||
+ target->GetProperty("CROSSCOMPILING_EMULATOR") ||
!this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"))) {
return target->GetLocation(this->Config);
}
- if (target && target->GetType() == cmStateEnums::EXECUTABLE) {
- const char* emulator = target->GetProperty("CROSSCOMPILING_EMULATOR");
- if (emulator) {
- return std::string(emulator);
- }
+ return CM_NULLPTR;
+}
+
+std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const
+{
+ if (const char* emulator = this->GetCrossCompilingEmulator(c)) {
+ return std::string(emulator);
+ }
+ if (const char* location = this->GetArgv0Location(c)) {
+ return std::string(location);
}
+ std::string const& argv0 = this->CC.GetCommandLines()[c][0];
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(argv0);
std::string exe = cge->Evaluate(this->LG, this->Config);
@@ -99,13 +111,20 @@ void cmCustomCommandGenerator::AppendArguments(unsigned int c,
std::string& cmd) const
{
unsigned int offset = 1;
- if (this->UseCrossCompilingEmulator(c)) {
+ if (this->GetCrossCompilingEmulator(c) != CM_NULLPTR) {
offset = 0;
}
cmCustomCommandLine const& commandLine = this->CC.GetCommandLines()[c];
for (unsigned int j = offset; j < commandLine.size(); ++j) {
- std::string arg =
- this->GE->Parse(commandLine[j])->Evaluate(this->LG, this->Config);
+ std::string arg;
+ if (const char* location =
+ j == 0 ? this->GetArgv0Location(c) : CM_NULLPTR) {
+ // GetCommand returned the emulator instead of the argv0 location,
+ // so transform the latter now.
+ arg = location;
+ } else {
+ arg = this->GE->Parse(commandLine[j])->Evaluate(this->LG, this->Config);
+ }
cmd += " ";
if (this->OldStyle) {
cmd += escapeForShellOldStyle(arg);
diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h
index 23cc596..8983c54 100644
--- a/Source/cmCustomCommandGenerator.h
+++ b/Source/cmCustomCommandGenerator.h
@@ -23,6 +23,9 @@ class cmCustomCommandGenerator
mutable bool DependsDone;
mutable std::vector<std::string> Depends;
+ const char* GetCrossCompilingEmulator(unsigned int c) const;
+ const char* GetArgv0Location(unsigned int c) const;
+
public:
cmCustomCommandGenerator(cmCustomCommand const& cc,
const std::string& config, cmLocalGenerator* lg);
@@ -30,7 +33,6 @@ public:
cmCustomCommand const& GetCC() const { return this->CC; }
unsigned int GetNumberOfCommands() const;
std::string GetCommand(unsigned int c) const;
- bool UseCrossCompilingEmulator(unsigned int c) const;
void AppendArguments(unsigned int c, std::string& cmd) const;
const char* GetComment() const;
std::string GetWorkingDirectory() const;
diff --git a/Tests/RunCMake/pseudo_emulator_custom_command.c b/Tests/RunCMake/pseudo_emulator_custom_command.c
index 760e83c..3a94795 100644
--- a/Tests/RunCMake/pseudo_emulator_custom_command.c
+++ b/Tests/RunCMake/pseudo_emulator_custom_command.c
@@ -14,7 +14,8 @@
int main(int argc, const char* argv[])
{
const char* substring_failure = "generated_exe_emulator_unexpected";
- const char* substring_success = "generated_exe_emulator_expected";
+ // Require a slash to make sure it is a path and not a target name.
+ const char* substring_success = "/generated_exe_emulator_expected";
const char* str = argv[1];
if (argc < 2) {
return EXIT_FAILURE;
-----------------------------------------------------------------------
Summary of changes:
Source/cmCustomCommandGenerator.cxx | 45 ++++++++++++++------
Source/cmCustomCommandGenerator.h | 4 +-
.../CrosscompilingEmulator/AddCustomCommand.cmake | 17 +++++++-
.../CrosscompilingEmulator/AddCustomTarget.cmake | 16 ++++++-
.../generated_exe_emulator_unexpected.cxx | 9 ++++
.../simple_src_exitsuccess.cxx | 4 --
Tests/RunCMake/pseudo_emulator_custom_command.c | 3 +-
7 files changed, 77 insertions(+), 21 deletions(-)
create mode 100644 Tests/RunCMake/CrosscompilingEmulator/generated_exe_emulator_unexpected.cxx
delete mode 100644 Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list