summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-11-17 18:13:57 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-11-17 18:16:02 (GMT)
commitc0619861c9b4455c785c64d1d7b8cfcf8de5b9ae (patch)
treeda63e197c8ca84deadd1c2b9240082b933c23f79
parent0b47e940cf4be6f806210214afba1b4a16011eeb (diff)
parentcfce067b3facbd54275fd323a54e32e161717b8e (diff)
downloadCMake-c0619861c9b4455c785c64d1d7b8cfcf8de5b9ae.zip
CMake-c0619861c9b4455c785c64d1d7b8cfcf8de5b9ae.tar.gz
CMake-c0619861c9b4455c785c64d1d7b8cfcf8de5b9ae.tar.bz2
Merge topic 'cmake-build-specify-makefile-name'
cfce067b3f Tests: Add RunCMake.Make case for conflicting Makefile names 378c047ae3 Makefiles: Explicitly tell 'make' tool what Makefile name to use Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5509
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx5
-rw-r--r--Tests/RunCMake/Make/MakefileConflict.cmake5
-rw-r--r--Tests/RunCMake/Make/RunCMakeTest.cmake8
3 files changed, 18 insertions, 0 deletions
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index c6c540b..9c3a533 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -589,6 +589,11 @@ cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
}
makeCommand.Add(this->SelectMakeProgram(makeProgram));
+ // Explicitly tell the make tool to use the Makefile written by
+ // cmLocalUnixMakefileGenerator3::WriteLocalMakefile
+ makeCommand.Add("-f");
+ makeCommand.Add("Makefile");
+
if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
if (jobs == cmake::DEFAULT_BUILD_PARALLEL_LEVEL) {
makeCommand.Add("-j");
diff --git a/Tests/RunCMake/Make/MakefileConflict.cmake b/Tests/RunCMake/Make/MakefileConflict.cmake
new file mode 100644
index 0000000..6a8406f
--- /dev/null
+++ b/Tests/RunCMake/Make/MakefileConflict.cmake
@@ -0,0 +1,5 @@
+add_custom_target(Custom)
+
+# Write a file that GNU make will prefer over "Makefile"
+# if 'cmake --build' does not explicitly specify it.
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/GNUmakefile" "")
diff --git a/Tests/RunCMake/Make/RunCMakeTest.cmake b/Tests/RunCMake/Make/RunCMakeTest.cmake
index 5562aca..b66e30e 100644
--- a/Tests/RunCMake/Make/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Make/RunCMakeTest.cmake
@@ -42,6 +42,14 @@ run_VerboseBuild()
run_cmake(CustomCommandDepfile-ERROR)
run_cmake(IncludeRegexSubdir)
+function(run_MakefileConflict)
+ run_cmake(MakefileConflict)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MakefileConflict-build)
+ run_cmake_command(MakefileConflict-build ${CMAKE_COMMAND} --build . --target Custom)
+endfunction()
+run_MakefileConflict()
+
function(run_CMP0113 val)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0113-${val}-build)
run_cmake(CMP0113-${val})