diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -602,7 +602,7 @@ 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 @@ 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 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -34,7 +34,7 @@ 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 @@ 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 @@ # 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 @@ 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 --- a/llvm/cmake/modules/TableGen.cmake +++ b/llvm/cmake/modules/TableGen.cmake @@ -10,7 +10,7 @@ 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 @@ 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 @@ # 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 @@ 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()