From c248a437c47b4419fd955d4b1f406f7c8b9dcd74 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 11 Feb 2014 17:41:24 +0100 Subject: Add policy CMP0049 to avoid variable expansion in source lists --- Help/manual/cmake-policies.7.rst | 1 + Help/policy/CMP0049.rst | 23 ++++++++++++++++++ Help/release/3.0.rst | 5 ++++ Source/cmPolicies.cxx | 5 ++++ Source/cmPolicies.h | 1 + Source/cmTarget.cxx | 32 ++++++++++++++++++++++++++ Tests/RunCMake/CMP0049/CMP0049-NEW-result.txt | 1 + Tests/RunCMake/CMP0049/CMP0049-NEW-stderr.txt | 6 +++++ Tests/RunCMake/CMP0049/CMP0049-NEW.cmake | 5 ++++ Tests/RunCMake/CMP0049/CMP0049-OLD-result.txt | 1 + Tests/RunCMake/CMP0049/CMP0049-OLD-stderr.txt | 1 + Tests/RunCMake/CMP0049/CMP0049-OLD.cmake | 5 ++++ Tests/RunCMake/CMP0049/CMP0049-WARN-result.txt | 1 + Tests/RunCMake/CMP0049/CMP0049-WARN-stderr.txt | 11 +++++++++ Tests/RunCMake/CMP0049/CMP0049-WARN.cmake | 3 +++ Tests/RunCMake/CMP0049/CMakeLists.txt | 3 +++ Tests/RunCMake/CMP0049/RunCMakeTest.cmake | 5 ++++ Tests/RunCMake/CMP0049/empty.cpp | 7 ++++++ Tests/RunCMake/CMakeLists.txt | 1 + 19 files changed, 117 insertions(+) create mode 100644 Help/policy/CMP0049.rst create mode 100644 Tests/RunCMake/CMP0049/CMP0049-NEW-result.txt create mode 100644 Tests/RunCMake/CMP0049/CMP0049-NEW-stderr.txt create mode 100644 Tests/RunCMake/CMP0049/CMP0049-NEW.cmake create mode 100644 Tests/RunCMake/CMP0049/CMP0049-OLD-result.txt create mode 100644 Tests/RunCMake/CMP0049/CMP0049-OLD-stderr.txt create mode 100644 Tests/RunCMake/CMP0049/CMP0049-OLD.cmake create mode 100644 Tests/RunCMake/CMP0049/CMP0049-WARN-result.txt create mode 100644 Tests/RunCMake/CMP0049/CMP0049-WARN-stderr.txt create mode 100644 Tests/RunCMake/CMP0049/CMP0049-WARN.cmake create mode 100644 Tests/RunCMake/CMP0049/CMakeLists.txt create mode 100644 Tests/RunCMake/CMP0049/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/CMP0049/empty.cpp diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 972a9f8..c097697 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -100,3 +100,4 @@ All Policies /policy/CMP0046 /policy/CMP0047 /policy/CMP0048 + /policy/CMP0049 diff --git a/Help/policy/CMP0049.rst b/Help/policy/CMP0049.rst new file mode 100644 index 0000000..5c8d4a8 --- /dev/null +++ b/Help/policy/CMP0049.rst @@ -0,0 +1,23 @@ +CMP0049 +------- + +Do not expand variables in target source entries. + +CMake 2.8.12 and lower performed and extra layer of variable expansion +when evaluating source file names: + +.. code-block:: cmake + + set(a_source foo.c) + add_executable(foo \${a_source}) + +This was undocumented behavior. + +The OLD behavior for this policy is to expand such variables when processing +the target sources. The NEW behavior for this policy is to issue an error +if such variables need to be expanded. + +This policy was introduced in CMake version 3.0. +CMake version |release| warns when the policy is not set and uses +OLD behavior. Use the cmake_policy command to set it to OLD or +NEW explicitly. diff --git a/Help/release/3.0.rst b/Help/release/3.0.rst index bef7715..39f906a 100644 --- a/Help/release/3.0.rst +++ b/Help/release/3.0.rst @@ -322,6 +322,11 @@ New Diagnostics messages up front and stops processing when no working compiler is known to be available. +* Target sources specified with the :command:`add_library` or + :command:`add_executable` command learned to reject items which + require an undocumented extra layer of variable expansion. + See policy :policy:`CMP0049`. + Deprecated and Removed Features =============================== diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 9cfa1e4..78453db 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -333,6 +333,11 @@ cmPolicies::cmPolicies() CMP0048, "CMP0048", "project() command manages VERSION variables.", 3,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0049, "CMP0049", + "Do not expand variables in target source entries.", + 3,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index f9a4768..9523650 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -102,6 +102,7 @@ public: CMP0046, ///< Error on non-existent dependency in add_dependencies CMP0047, ///< Use QCC compiler id for the qcc drivers on QNX. CMP0048, ///< project() command manages VERSION variables + CMP0049, ///< Do not expand variables in target source entries /** \brief Always the last entry. * diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d440f7c..3e96b69 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -590,6 +590,38 @@ cmSourceFile* cmTarget::AddSource(const char* s) // For backwards compatibility replace varibles in source names. // This should eventually be removed. this->Makefile->ExpandVariablesInString(src); + if (src != s) + { + cmOStringStream e; + bool noMessage = false; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0049)) + { + case cmPolicies::WARN: + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0049)) << "\n"; + break; + case cmPolicies::OLD: + noMessage = true; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + messageType = cmake::FATAL_ERROR; + } + if (!noMessage) + { + e << "Legacy variable expansion in source file \"" + << s << "\" expanded to \"" << src << "\" in target \"" + << this->GetName() << "\". This behavior will be removed in a " + "future version of CMake."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + if (messageType == cmake::FATAL_ERROR) + { + return 0; + } + } + } cmSourceFile* sf = this->Makefile->GetOrCreateSource(src.c_str()); this->AddSourceFile(sf); diff --git a/Tests/RunCMake/CMP0049/CMP0049-NEW-result.txt b/Tests/RunCMake/CMP0049/CMP0049-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0049/CMP0049-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0049/CMP0049-NEW-stderr.txt b/Tests/RunCMake/CMP0049/CMP0049-NEW-stderr.txt new file mode 100644 index 0000000..ff787e8 --- /dev/null +++ b/Tests/RunCMake/CMP0049/CMP0049-NEW-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at CMP0049-NEW.cmake:5 \(add_library\): + Legacy variable expansion in source file "\${tgt_srcs}" expanded to + "empty.cpp" in target "tgt". This behavior will be removed in a future + version of CMake. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0049/CMP0049-NEW.cmake b/Tests/RunCMake/CMP0049/CMP0049-NEW.cmake new file mode 100644 index 0000000..85b5aa8 --- /dev/null +++ b/Tests/RunCMake/CMP0049/CMP0049-NEW.cmake @@ -0,0 +1,5 @@ + +cmake_policy(SET CMP0049 NEW) + +set(tgt_srcs empty.cpp) +add_library(tgt \${tgt_srcs}) diff --git a/Tests/RunCMake/CMP0049/CMP0049-OLD-result.txt b/Tests/RunCMake/CMP0049/CMP0049-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0049/CMP0049-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0049/CMP0049-OLD-stderr.txt b/Tests/RunCMake/CMP0049/CMP0049-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0049/CMP0049-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0049/CMP0049-OLD.cmake b/Tests/RunCMake/CMP0049/CMP0049-OLD.cmake new file mode 100644 index 0000000..ae6fd3b --- /dev/null +++ b/Tests/RunCMake/CMP0049/CMP0049-OLD.cmake @@ -0,0 +1,5 @@ + +cmake_policy(SET CMP0049 OLD) + +set(tgt_srcs empty.cpp) +add_library(tgt \${tgt_srcs}) diff --git a/Tests/RunCMake/CMP0049/CMP0049-WARN-result.txt b/Tests/RunCMake/CMP0049/CMP0049-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0049/CMP0049-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0049/CMP0049-WARN-stderr.txt b/Tests/RunCMake/CMP0049/CMP0049-WARN-stderr.txt new file mode 100644 index 0000000..0cf5ce3 --- /dev/null +++ b/Tests/RunCMake/CMP0049/CMP0049-WARN-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) at CMP0049-WARN.cmake:3 \(add_library\): + Policy CMP0049 is not set: Do not expand variables in target source + entries. Run "cmake --help-policy CMP0049" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + Legacy variable expansion in source file "\${tgt_srcs}" expanded to + "empty.cpp" in target "tgt". This behavior will be removed in a future + version of CMake. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0049/CMP0049-WARN.cmake b/Tests/RunCMake/CMP0049/CMP0049-WARN.cmake new file mode 100644 index 0000000..ada082e --- /dev/null +++ b/Tests/RunCMake/CMP0049/CMP0049-WARN.cmake @@ -0,0 +1,3 @@ + +set(tgt_srcs empty.cpp) +add_library(tgt \${tgt_srcs}) diff --git a/Tests/RunCMake/CMP0049/CMakeLists.txt b/Tests/RunCMake/CMP0049/CMakeLists.txt new file mode 100644 index 0000000..2f10cb0 --- /dev/null +++ b/Tests/RunCMake/CMP0049/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0049/RunCMakeTest.cmake b/Tests/RunCMake/CMP0049/RunCMakeTest.cmake new file mode 100644 index 0000000..a8aa9d9 --- /dev/null +++ b/Tests/RunCMake/CMP0049/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0049-OLD) +run_cmake(CMP0049-NEW) +run_cmake(CMP0049-WARN) diff --git a/Tests/RunCMake/CMP0049/empty.cpp b/Tests/RunCMake/CMP0049/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CMP0049/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index c29b736..ef6f69d 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -32,6 +32,7 @@ endif() add_RunCMake_test(CMP0043) add_RunCMake_test(CMP0045) add_RunCMake_test(CMP0046) +add_RunCMake_test(CMP0049) add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) -- cgit v0.12 From f2eee72facb9b4a658e1205bbe9113a808e76775 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 11 Feb 2014 18:39:55 +0100 Subject: add_custom_command: Disallow use of SOURCE signatures. Add CMP0050 to control this behavior. --- Help/manual/cmake-policies.7.rst | 1 + Help/policy/CMP0050.rst | 18 ++++++++++++++++ Help/release/3.0.rst | 3 +++ Source/cmAddCustomCommandCommand.cxx | 30 ++++++++++++++++++++++++++ Source/cmPolicies.cxx | 5 +++++ Source/cmPolicies.h | 1 + Tests/RunCMake/CMP0050/CMP0050-NEW-result.txt | 1 + Tests/RunCMake/CMP0050/CMP0050-NEW-stderr.txt | 4 ++++ Tests/RunCMake/CMP0050/CMP0050-NEW.cmake | 13 +++++++++++ Tests/RunCMake/CMP0050/CMP0050-OLD-result.txt | 1 + Tests/RunCMake/CMP0050/CMP0050-OLD-stderr.txt | 1 + Tests/RunCMake/CMP0050/CMP0050-OLD.cmake | 13 +++++++++++ Tests/RunCMake/CMP0050/CMP0050-WARN-result.txt | 1 + Tests/RunCMake/CMP0050/CMP0050-WARN-stderr.txt | 9 ++++++++ Tests/RunCMake/CMP0050/CMP0050-WARN.cmake | 11 ++++++++++ Tests/RunCMake/CMP0050/CMakeLists.txt | 3 +++ Tests/RunCMake/CMP0050/RunCMakeTest.cmake | 5 +++++ Tests/RunCMake/CMP0050/empty.cpp | 10 +++++++++ Tests/RunCMake/CMP0050/input.h.in | 2 ++ Tests/RunCMake/CMakeLists.txt | 1 + 20 files changed, 133 insertions(+) create mode 100644 Help/policy/CMP0050.rst create mode 100644 Tests/RunCMake/CMP0050/CMP0050-NEW-result.txt create mode 100644 Tests/RunCMake/CMP0050/CMP0050-NEW-stderr.txt create mode 100644 Tests/RunCMake/CMP0050/CMP0050-NEW.cmake create mode 100644 Tests/RunCMake/CMP0050/CMP0050-OLD-result.txt create mode 100644 Tests/RunCMake/CMP0050/CMP0050-OLD-stderr.txt create mode 100644 Tests/RunCMake/CMP0050/CMP0050-OLD.cmake create mode 100644 Tests/RunCMake/CMP0050/CMP0050-WARN-result.txt create mode 100644 Tests/RunCMake/CMP0050/CMP0050-WARN-stderr.txt create mode 100644 Tests/RunCMake/CMP0050/CMP0050-WARN.cmake create mode 100644 Tests/RunCMake/CMP0050/CMakeLists.txt create mode 100644 Tests/RunCMake/CMP0050/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/CMP0050/empty.cpp create mode 100644 Tests/RunCMake/CMP0050/input.h.in diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index c097697..8650a58 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -101,3 +101,4 @@ All Policies /policy/CMP0047 /policy/CMP0048 /policy/CMP0049 + /policy/CMP0050 diff --git a/Help/policy/CMP0050.rst b/Help/policy/CMP0050.rst new file mode 100644 index 0000000..76ae0aa --- /dev/null +++ b/Help/policy/CMP0050.rst @@ -0,0 +1,18 @@ +CMP0050 +------- + +Disallow add_custom_command SOURCE signatures. + +CMake 2.8.12 and lower allowed a signature for :command:`add_custom_command` +which specified an input to a command. This was undocumented behavior. +Modern use of CMake associates custom commands with their output, rather +than their input. + +The OLD behavior for this policy is to allow the use of +:command:`add_custom_command` SOURCE signatures. The NEW behavior for this +policy is to issue an error if such a signature is used. + +This policy was introduced in CMake version 3.0. +CMake version |release| warns when the policy is not set and uses +OLD behavior. Use the cmake_policy command to set it to OLD or +NEW explicitly. diff --git a/Help/release/3.0.rst b/Help/release/3.0.rst index 39f906a..45f7635 100644 --- a/Help/release/3.0.rst +++ b/Help/release/3.0.rst @@ -327,6 +327,9 @@ New Diagnostics require an undocumented extra layer of variable expansion. See policy :policy:`CMP0049`. +* Use of :command:`add_custom_command` undocumented ``SOURCE`` + signatures now results in an error. See policy :policy:`CMP0050`. + Deprecated and Removed Features =============================== diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 5634849..3de04f5 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -344,6 +344,36 @@ bool cmAddCustomCommandCommand } else { + bool issueMessage = true; + cmOStringStream e; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0050)) + { + case cmPolicies::WARN: + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0050)) << "\n"; + break; + case cmPolicies::OLD: + issueMessage = false; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + messageType = cmake::FATAL_ERROR; + break; + } + + if (issueMessage) + { + e << "The SOURCE signatures of add_custom_command are no longer " + "supported."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + // Use the old-style mode for backward compatibility. this->Makefile->AddCustomCommandOldStyle(target.c_str(), outputs, depends, source.c_str(), commandLines, diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 78453db..93072f5 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -338,6 +338,11 @@ cmPolicies::cmPolicies() CMP0049, "CMP0049", "Do not expand variables in target source entries.", 3,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0050, "CMP0050", + "Disallow add_custom_command SOURCE signatures.", + 3,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 9523650..b77235d 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -103,6 +103,7 @@ public: CMP0047, ///< Use QCC compiler id for the qcc drivers on QNX. CMP0048, ///< project() command manages VERSION variables CMP0049, ///< Do not expand variables in target source entries + CMP0050, ///< Disallow add_custom_command SOURCE signatures /** \brief Always the last entry. * diff --git a/Tests/RunCMake/CMP0050/CMP0050-NEW-result.txt b/Tests/RunCMake/CMP0050/CMP0050-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0050/CMP0050-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0050/CMP0050-NEW-stderr.txt b/Tests/RunCMake/CMP0050/CMP0050-NEW-stderr.txt new file mode 100644 index 0000000..e913b3f --- /dev/null +++ b/Tests/RunCMake/CMP0050/CMP0050-NEW-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CMP0050-NEW.cmake:5 \(add_custom_command\): + The SOURCE signatures of add_custom_command are no longer supported. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0050/CMP0050-NEW.cmake b/Tests/RunCMake/CMP0050/CMP0050-NEW.cmake new file mode 100644 index 0000000..cdc65b8 --- /dev/null +++ b/Tests/RunCMake/CMP0050/CMP0050-NEW.cmake @@ -0,0 +1,13 @@ + +cmake_policy(SET CMP0050 NEW) + +add_library(empty empty.cpp) +add_custom_command( + TARGET empty + SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/input.h.in + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/input.h.in + ${CMAKE_CURRENT_BINARY_DIR}/input.h + OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/input.h + DEPENDS ${CMAKE_COMMAND} +) diff --git a/Tests/RunCMake/CMP0050/CMP0050-OLD-result.txt b/Tests/RunCMake/CMP0050/CMP0050-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0050/CMP0050-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0050/CMP0050-OLD-stderr.txt b/Tests/RunCMake/CMP0050/CMP0050-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0050/CMP0050-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0050/CMP0050-OLD.cmake b/Tests/RunCMake/CMP0050/CMP0050-OLD.cmake new file mode 100644 index 0000000..efb37e5 --- /dev/null +++ b/Tests/RunCMake/CMP0050/CMP0050-OLD.cmake @@ -0,0 +1,13 @@ + +cmake_policy(SET CMP0050 OLD) + +add_library(empty empty.cpp) +add_custom_command( + TARGET empty + SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/input.h.in + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/input.h.in + ${CMAKE_CURRENT_BINARY_DIR}/input.h + OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/input.h + DEPENDS ${CMAKE_COMMAND} +) diff --git a/Tests/RunCMake/CMP0050/CMP0050-WARN-result.txt b/Tests/RunCMake/CMP0050/CMP0050-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0050/CMP0050-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0050/CMP0050-WARN-stderr.txt b/Tests/RunCMake/CMP0050/CMP0050-WARN-stderr.txt new file mode 100644 index 0000000..c88d595 --- /dev/null +++ b/Tests/RunCMake/CMP0050/CMP0050-WARN-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning \(dev\) at CMP0050-WARN.cmake:3 \(add_custom_command\): + Policy CMP0050 is not set: Disallow add_custom_command SOURCE signatures. + Run "cmake --help-policy CMP0050" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The SOURCE signatures of add_custom_command are no longer supported. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0050/CMP0050-WARN.cmake b/Tests/RunCMake/CMP0050/CMP0050-WARN.cmake new file mode 100644 index 0000000..e57230e --- /dev/null +++ b/Tests/RunCMake/CMP0050/CMP0050-WARN.cmake @@ -0,0 +1,11 @@ + +add_library(empty empty.cpp) +add_custom_command( + TARGET empty + SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/input.h.in + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/input.h.in + ${CMAKE_CURRENT_BINARY_DIR}/input.h + OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/input.h + DEPENDS ${CMAKE_COMMAND} +) diff --git a/Tests/RunCMake/CMP0050/CMakeLists.txt b/Tests/RunCMake/CMP0050/CMakeLists.txt new file mode 100644 index 0000000..2f10cb0 --- /dev/null +++ b/Tests/RunCMake/CMP0050/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0050/RunCMakeTest.cmake b/Tests/RunCMake/CMP0050/RunCMakeTest.cmake new file mode 100644 index 0000000..b7de284 --- /dev/null +++ b/Tests/RunCMake/CMP0050/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0050-OLD) +run_cmake(CMP0050-NEW) +run_cmake(CMP0050-WARN) diff --git a/Tests/RunCMake/CMP0050/empty.cpp b/Tests/RunCMake/CMP0050/empty.cpp new file mode 100644 index 0000000..182ea29 --- /dev/null +++ b/Tests/RunCMake/CMP0050/empty.cpp @@ -0,0 +1,10 @@ + +#include "input.h" + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/CMP0050/input.h.in b/Tests/RunCMake/CMP0050/input.h.in new file mode 100644 index 0000000..d8c5d26 --- /dev/null +++ b/Tests/RunCMake/CMP0050/input.h.in @@ -0,0 +1,2 @@ + +#define INPUT diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index ef6f69d..9bb097b 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -33,6 +33,7 @@ add_RunCMake_test(CMP0043) add_RunCMake_test(CMP0045) add_RunCMake_test(CMP0046) add_RunCMake_test(CMP0049) +add_RunCMake_test(CMP0050) add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) -- cgit v0.12