[llvm] 2868e26 - [cmake] Some NFC changes in preparation for accomodating `Ninja Multi-Config`
Argyrios Kyrtzidis via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 25 11:47:21 PST 2022
Author: Argyrios Kyrtzidis
Date: 2022-01-25T11:46:44-08:00
New Revision: 2868e2677b609ed0a1b0e441d5084a8956137816
URL: https://github.com/llvm/llvm-project/commit/2868e2677b609ed0a1b0e441d5084a8956137816
DIFF: https://github.com/llvm/llvm-project/commit/2868e2677b609ed0a1b0e441d5084a8956137816.diff
LOG: [cmake] Some NFC changes in preparation for accomodating `Ninja Multi-Config`
* Use `MATCHES` so that `Ninja Multi-Config` generator also satisfies the Ninja check
* Pull out a couple of values into variables, inside `function(tablegen project ofn)`, NFC
Differential Revision: https://reviews.llvm.org/D118100
Added:
Modified:
llvm/cmake/config-ix.cmake
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/cmake/modules/TableGen.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 7e9d76d6c5648..a138d372d3b29 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -602,7 +602,7 @@ find_program(GOLD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.gold ld.gold
set(LLVM_BINUTILS_INCDIR "" CACHE PATH
"PATH to binutils/include containing plugin-api.h for gold plugin.")
-if(CMAKE_GENERATOR STREQUAL "Ninja")
+if(CMAKE_GENERATOR MATCHES "Ninja")
execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} --version
OUTPUT_VARIABLE NINJA_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
@@ -610,7 +610,7 @@ if(CMAKE_GENERATOR STREQUAL "Ninja")
message(STATUS "Ninja version: ${NINJA_VERSION}")
endif()
-if(CMAKE_GENERATOR STREQUAL "Ninja" AND
+if(CMAKE_GENERATOR MATCHES "Ninja" AND
NOT "${NINJA_VERSION}" VERSION_LESS "1.9.0" AND
CMAKE_HOST_APPLE AND CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER "15.6.0")
set(LLVM_TOUCH_STATIC_LIBRARIES ON)
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index c2feecc21a802..fcaa8f20bf941 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -34,7 +34,7 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO)
set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING
"Define the maximum number of concurrent compilation jobs (Ninja only).")
if(LLVM_PARALLEL_COMPILE_JOBS)
- if(NOT CMAKE_GENERATOR STREQUAL "Ninja")
+ if(NOT CMAKE_GENERATOR MATCHES "Ninja")
message(WARNING "Job pooling is only available with Ninja generators.")
else()
set_property(GLOBAL APPEND PROPERTY JOB_POOLS compile_job_pool=${LLVM_PARALLEL_COMPILE_JOBS})
@@ -44,7 +44,7 @@ endif()
set(LLVM_PARALLEL_LINK_JOBS "" CACHE STRING
"Define the maximum number of concurrent link jobs (Ninja only).")
-if(CMAKE_GENERATOR STREQUAL "Ninja")
+if(CMAKE_GENERATOR MATCHES "Ninja")
if(NOT LLVM_PARALLEL_LINK_JOBS AND uppercase_LLVM_ENABLE_LTO STREQUAL "THIN")
message(STATUS "ThinLTO provides its own parallel linking - limiting parallel link jobs to 2.")
set(LLVM_PARALLEL_LINK_JOBS "2")
@@ -920,7 +920,7 @@ add_definitions( -D__STDC_LIMIT_MACROS )
# clang and gcc don't default-print colored diagnostics when invoked from Ninja.
if (UNIX AND
- CMAKE_GENERATOR STREQUAL "Ninja" AND
+ CMAKE_GENERATOR MATCHES "Ninja" AND
(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9))))
@@ -928,7 +928,7 @@ if (UNIX AND
endif()
# lld doesn't print colored diagnostics when invoked from Ninja
-if (UNIX AND CMAKE_GENERATOR STREQUAL "Ninja")
+if (UNIX AND CMAKE_GENERATOR MATCHES "Ninja")
include(LLVMCheckLinkerFlag)
llvm_check_linker_flag(CXX "-Wl,--color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
append_if(LINKER_SUPPORTS_COLOR_DIAGNOSTICS "-Wl,--color-diagnostics"
diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
index 6d6513c5ab459..59fd0d3b07336 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -10,7 +10,7 @@ function(tablegen project ofn)
endif()
# Use depfile instead of globbing arbitrary *.td(s) for Ninja.
- if(CMAKE_GENERATOR STREQUAL "Ninja")
+ if(CMAKE_GENERATOR MATCHES "Ninja")
# Make output path relative to build.ninja, assuming located on
# ${CMAKE_BINARY_DIR}.
# CMake emits build targets as relative paths but Ninja doesn't identify
@@ -93,8 +93,11 @@ function(tablegen project ofn)
get_directory_property(tblgen_includes INCLUDE_DIRECTORIES)
list(TRANSFORM tblgen_includes PREPEND -I)
+ set(tablegen_exe ${${project}_TABLEGEN_EXE})
+ set(tablegen_depends ${${project}_TABLEGEN_TARGET} ${tablegen_exe})
+
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
- COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND ${tablegen_exe} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
${tblgen_includes}
${LLVM_TABLEGEN_FLAGS}
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
@@ -103,7 +106,7 @@ function(tablegen project ofn)
# The file in LLVM_TARGET_DEFINITIONS may be not in the current
# directory and local_tds may not contain it, so we must
# explicitly list it here:
- DEPENDS ${${project}_TABLEGEN_TARGET} ${${project}_TABLEGEN_EXE}
+ DEPENDS ${tablegen_depends}
${local_tds} ${global_tds}
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
${LLVM_TARGET_DEPENDS}
@@ -137,7 +140,7 @@ macro(add_tablegen target project)
set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
# CMake doesn't let compilation units depend on their dependent libraries on some generators.
- if(NOT CMAKE_GENERATOR STREQUAL "Ninja" AND NOT XCODE)
+ if(NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT XCODE)
# FIXME: It leaks to user, callee of add_tablegen.
set(LLVM_ENABLE_OBJLIB ON)
endif()
More information about the llvm-commits
mailing list