diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -2,7 +2,6 @@ set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) -option(LINK_WITH_FIR "Link driver with FIR and LLVM" ON) option(FLANG_BUILD_NEW_DRIVER "Build the flang compiler driver" OFF) # Flang requires C++17. @@ -72,19 +71,17 @@ include(AddClang) endif() - if(LINK_WITH_FIR) - include(TableGen) - find_package(MLIR REQUIRED CONFIG) - # Use SYSTEM for the same reasons as for LLVM includes - include_directories(SYSTEM ${MLIR_INCLUDE_DIRS}) - # If the user specifies a relative path to MLIR_DIR, the calls to include - # MLIR modules fail. Append the absolute path to MLIR_DIR instead. - get_filename_component(MLIR_DIR_ABSOLUTE ${MLIR_DIR} REALPATH) - list(APPEND CMAKE_MODULE_PATH ${MLIR_DIR_ABSOLUTE}) - include(AddMLIR) - find_program(MLIR_TABLEGEN_EXE "mlir-tblgen" ${LLVM_TOOLS_BINARY_DIR} - NO_DEFAULT_PATH) - endif() + include(TableGen) + find_package(MLIR REQUIRED CONFIG) + # Use SYSTEM for the same reasons as for LLVM includes + include_directories(SYSTEM ${MLIR_INCLUDE_DIRS}) + # If the user specifies a relative path to MLIR_DIR, the calls to include + # MLIR modules fail. Append the absolute path to MLIR_DIR instead. + get_filename_component(MLIR_DIR_ABSOLUTE ${MLIR_DIR} REALPATH) + list(APPEND CMAKE_MODULE_PATH ${MLIR_DIR_ABSOLUTE}) + include(AddMLIR) + find_program(MLIR_TABLEGEN_EXE "mlir-tblgen" ${LLVM_TOOLS_BINARY_DIR} + NO_DEFAULT_PATH) option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF) @@ -186,14 +183,12 @@ endif() set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}") - if (LINK_WITH_FIR) - set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --src-root - set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --includedir - set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include) - set(MLIR_TABLEGEN_EXE $) - include_directories(SYSTEM ${MLIR_INCLUDE_DIR}) - include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR}) - endif() + set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --src-root + set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --includedir + set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include) + set(MLIR_TABLEGEN_EXE $) + include_directories(SYSTEM ${MLIR_INCLUDE_DIR}) + include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR}) endif() if(FLANG_BUILD_NEW_DRIVER) @@ -211,17 +206,15 @@ include_directories(SYSTEM ${CLANG_INCLUDE_DIR}) endif() -if(LINK_WITH_FIR) - # tco tool and FIR lib output directories - if(FLANG_STANDALONE_BUILD) - set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin) - set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib) - endif() - # Always build tco tool - set(LLVM_BUILD_TOOLS ON) - set(LLVM_COMMON_COMPONENTS Support) - message(STATUS "Linking driver with FIR and LLVM, using LLVM components: ${LLVM_COMMON_COMPONENTS}") +# tco tool and FIR lib output directories +if(FLANG_STANDALONE_BUILD) + set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin) + set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib) endif() +# Always build tco tool +set(LLVM_BUILD_TOOLS ON) +set(LLVM_COMMON_COMPONENTS Support) +message(STATUS "Linking driver with FIR and LLVM, using LLVM components: ${LLVM_COMMON_COMPONENTS}") # Add Flang-centric modules to cmake path. include_directories(BEFORE diff --git a/flang/include/flang/CMakeLists.txt b/flang/include/flang/CMakeLists.txt --- a/flang/include/flang/CMakeLists.txt +++ b/flang/include/flang/CMakeLists.txt @@ -1,3 +1 @@ -if(LINK_WITH_FIR) - add_subdirectory(Optimizer) -endif() +add_subdirectory(Optimizer) diff --git a/flang/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt --- a/flang/lib/CMakeLists.txt +++ b/flang/lib/CMakeLists.txt @@ -10,6 +10,4 @@ add_subdirectory(FrontendTool) endif() -if(LINK_WITH_FIR) - add_subdirectory(Optimizer) -endif() +add_subdirectory(Optimizer) diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt --- a/flang/test/CMakeLists.txt +++ b/flang/test/CMakeLists.txt @@ -37,9 +37,7 @@ f18 FileCheck count not module_files ) -if (LINK_WITH_FIR) - list(APPEND FLANG_TEST_DEPENDS tco) -endif() +list(APPEND FLANG_TEST_DEPENDS tco) if (FLANG_BUILD_NEW_DRIVER) list(APPEND FLANG_TEST_DEPENDS flang-new) diff --git a/flang/tools/CMakeLists.txt b/flang/tools/CMakeLists.txt --- a/flang/tools/CMakeLists.txt +++ b/flang/tools/CMakeLists.txt @@ -10,7 +10,5 @@ if(FLANG_BUILD_NEW_DRIVER) add_subdirectory(flang-driver) endif() -if(LINK_WITH_FIR) - add_subdirectory(tco) -endif() +add_subdirectory(tco) add_subdirectory(f18-parse-demo)