From 5932f0be4f36f97fcd3ab61a559379a2a1291371 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 11 Mar 2020 11:45:46 -0400 Subject: ASM: Fix depfile flags for GNU 'as' tool The GNU `as --help` shows `--MD ` as an option to generate depfiles as needed by Ninja. There is no `-MT ` flag but fortunately the generated files automatically account for the `-o ` flag. Issue: #20426 --- Modules/Compiler/GNU-ASM.cmake | 4 ++++ Tests/RunCMake/BuildDepends/GNU-AS-stdout.txt | 4 ++++ Tests/RunCMake/BuildDepends/GNU-AS.cmake | 13 +++++++++++++ Tests/RunCMake/BuildDepends/GNU-AS.step1.cmake | 1 + Tests/RunCMake/BuildDepends/GNU-AS.step2.cmake | 1 + Tests/RunCMake/BuildDepends/RunCMakeTest.cmake | 5 +++++ Tests/RunCMake/BuildDepends/gnu_as.s | 1 + Tests/RunCMake/CMakeLists.txt | 15 ++++++++++++++- 8 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/BuildDepends/GNU-AS-stdout.txt create mode 100644 Tests/RunCMake/BuildDepends/GNU-AS.cmake create mode 100644 Tests/RunCMake/BuildDepends/GNU-AS.step1.cmake create mode 100644 Tests/RunCMake/BuildDepends/GNU-AS.step2.cmake create mode 100644 Tests/RunCMake/BuildDepends/gnu_as.s diff --git a/Modules/Compiler/GNU-ASM.cmake b/Modules/Compiler/GNU-ASM.cmake index e07401d..ac241ed 100644 --- a/Modules/Compiler/GNU-ASM.cmake +++ b/Modules/Compiler/GNU-ASM.cmake @@ -4,3 +4,7 @@ include(Compiler/GNU) set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;S;asm) __compiler_gnu(ASM) + +if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH STREQUAL "GNU assembler") + set(CMAKE_DEPFILE_FLAGS_ASM${ASM_DIALECT} "--MD ") +endif() diff --git a/Tests/RunCMake/BuildDepends/GNU-AS-stdout.txt b/Tests/RunCMake/BuildDepends/GNU-AS-stdout.txt new file mode 100644 index 0000000..c4326ae --- /dev/null +++ b/Tests/RunCMake/BuildDepends/GNU-AS-stdout.txt @@ -0,0 +1,4 @@ +-- The ASM compiler identification is GNU +-- Found assembler: [^ +]*/as(\.exe)? +-- CMAKE_ASM_COMPILER_ID_VENDOR_MATCH='GNU assembler' diff --git a/Tests/RunCMake/BuildDepends/GNU-AS.cmake b/Tests/RunCMake/BuildDepends/GNU-AS.cmake new file mode 100644 index 0000000..21921ef --- /dev/null +++ b/Tests/RunCMake/BuildDepends/GNU-AS.cmake @@ -0,0 +1,13 @@ +enable_language(ASM) + +# Validate undocumented implementation detail. +message(STATUS "CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH='${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH}'") + +add_library(gnu_as STATIC gnu_as.s) +target_include_directories(gnu_as PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$>.cmake CONTENT " +set(check_pairs + \"$|${CMAKE_CURRENT_BINARY_DIR}/gnu_as.inc\" + ) +") diff --git a/Tests/RunCMake/BuildDepends/GNU-AS.step1.cmake b/Tests/RunCMake/BuildDepends/GNU-AS.step1.cmake new file mode 100644 index 0000000..15a5e96 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/GNU-AS.step1.cmake @@ -0,0 +1 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/gnu_as.inc" "") diff --git a/Tests/RunCMake/BuildDepends/GNU-AS.step2.cmake b/Tests/RunCMake/BuildDepends/GNU-AS.step2.cmake new file mode 100644 index 0000000..15a5e96 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/GNU-AS.step2.cmake @@ -0,0 +1 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/gnu_as.inc" "") diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 14ae243..753417d 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -103,3 +103,8 @@ endfunction() if(RunCMake_GENERATOR STREQUAL "Xcode") run_ReGeneration(regenerate-project) endif() + +if(CMake_TEST_BuildDepends_GNU_AS) + set(ENV{ASM} "${CMake_TEST_BuildDepends_GNU_AS}") + run_BuildDepends(GNU-AS) +endif() diff --git a/Tests/RunCMake/BuildDepends/gnu_as.s b/Tests/RunCMake/BuildDepends/gnu_as.s new file mode 100644 index 0000000..a2e7dfb --- /dev/null +++ b/Tests/RunCMake/BuildDepends/gnu_as.s @@ -0,0 +1 @@ +.include "gnu_as.inc" diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 4b5475e..f99f704 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -169,7 +169,20 @@ if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND) set(autogen_with_qt5 TRUE) endif () add_RunCMake_test(Autogen -Dwith_qt5=${autogen_with_qt5}) -add_RunCMake_test(BuildDepends) +if(NOT DEFINED CMake_TEST_BuildDepends_GNU_AS + AND CMAKE_C_COMPILER_ID STREQUAL "GNU" + AND CMAKE_GENERATOR MATCHES "^Ninja" + ) + execute_process(COMMAND "${CMAKE_C_COMPILER}" -print-prog-name=as + RESULT_VARIABLE _gnu_res + OUTPUT_VARIABLE _gnu_as OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) + if(_gnu_res EQUAL 0 AND _gnu_as) + set(CMake_TEST_BuildDepends_GNU_AS "${_gnu_as}") + endif() +endif() +add_RunCMake_test(BuildDepends + -DCMake_TEST_BuildDepends_GNU_AS=${CMake_TEST_BuildDepends_GNU_AS} + ) if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(Byproducts) endif() -- cgit v0.12