Commit 53bb51fc authored by Brad King's avatar Brad King 💬 Committed by Kitware Robot
Browse files

Merge topic 'ctest-no-make-i'

226df303 CTest: Stop telling 'make' to ignore errors with -i
28e7a135 Help: Fix build_command alternative signature docs
231601b6 build_command: Choose configuration consistently across signatures
parents 70d48e12 226df303
......@@ -19,7 +19,8 @@ Sets the given ``<variable>`` to a command-line string of the form::
where ``<cmake>`` is the location of the :manual:`cmake(1)` command-line
tool, and ``<config>`` and ``<target>`` are the values provided to the
``CONFIGURATION`` and ``TARGET`` options, if any. The trailing ``-- -i``
option is added for Makefile generators.
option is added for :ref:`Makefile Generators` if policy :policy:`CMP0061`
is not set to ``NEW``.
When invoked, this ``cmake --build`` command line will launch the
underlying build system tool.
......@@ -32,7 +33,7 @@ This second signature is deprecated, but still available for backwards
compatibility. Use the first signature instead.
It sets the given ``<cachevariable>`` to a command-line string as
above but without the ``--config`` or ``--target`` options.
above but without the ``--target`` option.
The ``<makecommand>`` is ignored but should be the full path to
msdev, devenv, nmake, make or one of the end user build tools
for legacy invocations.
......
......@@ -118,3 +118,4 @@ All Policies
/policy/CMP0058
/policy/CMP0059
/policy/CMP0060
/policy/CMP0061
CMP0061
-------
CTest does not by default tell ``make`` to ignore errors (``-i``).
The :command:`ctest_build` and :command:`build_command` commands no
longer generate build commands for :ref:`Makefile Generators` with
the ``-i`` option. Previously this was done to help build as much
of tested projects as possible. However, this behavior is not
consistent with other generators and also causes the return code
of the ``make`` tool to be meaningless.
Of course users may still add this option manually by setting
:variable:`CTEST_BUILD_COMMAND` or the ``MAKECOMMAND`` cache entry.
See the :ref:`CTest Build Step` ``MakeCommand`` setting documentation
for their effects.
The ``OLD`` behavior for this policy is to add ``-i`` to ``make``
calls in CTest. The ``NEW`` behavior for this policy is to not
add ``-i``.
This policy was introduced in CMake version 3.3. Unlike most policies,
CMake version |release| does *not* warn when this policy is not set and
simply uses OLD behavior.
ctest-no-make-i
---------------
* The :command:`ctest_build` and :command:`build_command` commands
no longer tell ``make`` tools to ignore errors with the ``-i`` option.
Previously this was done for :ref:`Makefile Generators` but not others.
See policy :policy:`CMP0061`.
......@@ -141,7 +141,8 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
= this->GlobalGenerator->
GenerateCMakeBuildCommand(cmakeBuildTarget ? cmakeBuildTarget : "",
cmakeBuildConfiguration,
cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "", true);
cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "",
this->Makefile->IgnoreErrorsCMP0061());
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"SetMakeCommand:" << buildCommand << "\n", this->Quiet);
this->CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str(),
......
......@@ -106,7 +106,8 @@ bool cmBuildCommand
}
std::string makecommand = this->Makefile->GetGlobalGenerator()
->GenerateCMakeBuildCommand(target, configuration, "", true);
->GenerateCMakeBuildCommand(target, configuration, "",
this->Makefile->IgnoreErrorsCMP0061());
this->Makefile->AddDefinition(variable, makecommand.c_str());
......@@ -129,13 +130,14 @@ bool cmBuildCommand
std::string configType = "Release";
const char* cfg = getenv("CMAKE_CONFIG_TYPE");
if ( cfg )
if ( cfg && *cfg )
{
configType = cfg;
}
std::string makecommand = this->Makefile->GetGlobalGenerator()
->GenerateCMakeBuildCommand("", configType, "", true);
->GenerateCMakeBuildCommand("", configType, "",
this->Makefile->IgnoreErrorsCMP0061());
if(cacheValue)
{
......
......@@ -53,6 +53,8 @@ public:
virtual std::string GetName() const {return "build_command";}
cmTypeMacro(cmBuildCommand, cmCommand);
private:
bool IgnoreErrors() const;
};
#endif
......@@ -4942,6 +4942,26 @@ void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm)
}
}
//----------------------------------------------------------------------------
bool cmMakefile::IgnoreErrorsCMP0061() const
{
bool ignoreErrors = true;
switch (this->GetPolicyStatus(cmPolicies::CMP0061))
{
case cmPolicies::WARN:
// No warning for this policy!
case cmPolicies::OLD:
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
ignoreErrors = false;
break;
}
return ignoreErrors;
}
//----------------------------------------------------------------------------
#define FEATURE_STRING(F) , #F
static const char * const C_FEATURES[] = {
0
......
......@@ -415,6 +415,8 @@ public:
bool HasCMP0054AlreadyBeenReported(
cmListFileContext context) const;
bool IgnoreErrorsCMP0061() const;
const char* GetHomeDirectory() const;
const char* GetHomeOutputDirectory() const;
......
......@@ -208,6 +208,9 @@ class cmPolicy;
3, 3, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0060, \
"Link libraries by full path even in implicit directories.", \
3, 3, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0061, \
"CTest does not by default tell make to ignore errors (-i).", \
3, 3, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
......
^[^
]+ --build \. --config "Release"
[^
]+ --build \. --config "Release" --target "MyTarget"
[^
]+ --build \. --config "Debug"
[^
]+ --build \. --config "Debug" --target "MyTarget"
[^
]+ --build \. --config "Release"$
cmake_policy(SET CMP0061 NEW)
include(CMP0061Common.cmake)
^[^
]+ --build \. --config "Release" -- -i
[^
]+ --build \. --config "Release" --target "MyTarget" -- -i
[^
]+ --build \. --config "Debug" -- -i
[^
]+ --build \. --config "Debug" --target "MyTarget" -- -i
[^
]+ --build \. --config "Release" -- -i$
cmake_policy(SET CMP0061 OLD)
include(CMP0061Common.cmake)
^[^
]+ --build \. --config "Release"
[^
]+ --build \. --config "Release" --target "MyTarget"
[^
]+ --build \. --config "Debug"
[^
]+ --build \. --config "Debug" --target "MyTarget"
[^
]+ --build \. --config "Release"$
cmake_policy(SET CMP0061 OLD)
include(CMP0061Common.cmake)
build_command(command)
message("${command}")
build_command(command TARGET MyTarget)
message("${command}")
build_command(command CONFIGURATION Debug)
message("${command}")
build_command(command CONFIGURATION Debug TARGET MyTarget)
message("${command}")
build_command(cache_command "${CMAKE_MAKE_PROGRAM}")
message("${cache_command}")
include(RunCMake)
unset(ENV{CMAKE_CONFIG_TYPE})
run_cmake(ErrorsOFF)
run_cmake(ErrorsON)
......@@ -6,3 +7,10 @@ run_cmake(ErrorsON)
set(RunCMake_TEST_OPTIONS -DNoProject=1)
run_cmake(BeforeProject)
unset(RunCMake_TEST_OPTIONS)
run_cmake(CMP0061-NEW)
if(RunCMake_GENERATOR MATCHES "Make")
run_cmake(CMP0061-OLD-make)
else()
run_cmake(CMP0061-OLD-other)
endif()
^(Error\(s\) when building project
)?ctest_build returned zero$
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment