Commit d8788faa authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'cmake-warn-no-src-build-dir'

20861d75 Merge branch 'backport-cmake-warn-no-src-build-dir'
68b51fb1 cmake: Convert no source/build dir error to warning
6b85eea3 Help: Add 3.13.4 release note for no source/build dir error/warning
2395b1b2 cmake: Convert no source/build dir error to warning
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2839
parents fd54b859 20861d75
Pipeline #128274 passed with stage
in 0 seconds
......@@ -252,3 +252,29 @@ Changes made since CMake 3.13.0 include the following.
directories to the ``moc`` tool for :prop_tgt:`AUTOMOC`. This has
been reverted due to regressing existing builds and will need
further investigation before being re-introduced in a later release.
3.13.3
------
* The :generator:`Visual Studio 15 2017` generator has been fixed to work
when VS 2019 is installed.
* CMake now checks that at least one of the source or binary directory
is specified when running CMake and issues an error if both are missing.
This has always been a documented requirement, but the implementation
previously accidentally accepted cases in which neither are specified
so long as some other argument is given, and silently used the current
working directory as the source and build tree.
3.13.4
------
* The error added by 3.13.3 in cases that neither a source or binary
directory is specified has been downgraded to a warning. While this
was never intended, documented, nor supported behavior, some projects
relied on it. The error has been downgraded to a warning for the
remainder of the 3.13.x release series to allow a transition period,
but it may become a fatal error again in a later release. Scripts
relying on the old behavior can be trivially fixed by specifying
the path to the source tree (even if just ``.``) explicitly and
continue to work with all versions of CMake.
......@@ -810,8 +810,11 @@ void cmake::SetArgs(const std::vector<std::string>& args)
if (this->CurrentWorkingMode == cmake::NORMAL_MODE && !haveSourceDir &&
!haveBinaryDir) {
cmSystemTools::Error("No source or binary directory provided");
return;
this->IssueMessage(
MessageType::WARNING,
"No source or binary directory provided. Both will be assumed to be "
"the same as the current working directory, but note that this "
"warning will become a fatal error in future CMake releases.");
}
if (!haveSourceDir) {
......
......@@ -56,12 +56,22 @@ run_cmake_command(cache-empty-entry
${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-empty-entry/)
function(run_ExplicitDirs)
set(source_dir ${RunCMake_BINARY_DIR}/ExplicitDirsMissing)
file(REMOVE_RECURSE "${source_dir}")
file(MAKE_DIRECTORY "${source_dir}")
file(WRITE ${source_dir}/CMakeLists.txt [=[
cmake_minimum_required(VERSION 3.13)
project(ExplicitDirsMissing LANGUAGES NONE)
]=])
run_cmake_command(no-S-B ${CMAKE_COMMAND} -E chdir ${source_dir}
${CMAKE_COMMAND} -DFOO=BAR)
set(source_dir ${RunCMake_SOURCE_DIR}/ExplicitDirs)
set(binary_dir ${RunCMake_BINARY_DIR}/ExplicitDirs-build)
file(REMOVE_RECURSE "${binary_dir}")
file(MAKE_DIRECTORY "${binary_dir}")
run_cmake_command(no-S-B ${CMAKE_COMMAND} -DFOO=BAR)
run_cmake_command(S-arg ${CMAKE_COMMAND} -S ${source_dir} ${binary_dir})
run_cmake_command(S-arg-reverse-order ${CMAKE_COMMAND} ${binary_dir} -S${source_dir} )
run_cmake_command(S-no-arg ${CMAKE_COMMAND} -S )
......
CMake Error: No source or binary directory provided
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.
Markdown is supported
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