[flang-commits] [flang] b75a3c9 - [flang] Allow configuring building the flang runtime standalone
Martin Storsjö via flang-commits
flang-commits at lists.llvm.org
Tue Aug 23 07:26:19 PDT 2022
Author: Martin Storsjö
Date: 2022-08-23T17:25:21+03:00
New Revision: b75a3c9f31c1ffdc9856aee32991d8129b372ee7
URL: https://github.com/llvm/llvm-project/commit/b75a3c9f31c1ffdc9856aee32991d8129b372ee7
DIFF: https://github.com/llvm/llvm-project/commit/b75a3c9f31c1ffdc9856aee32991d8129b372ee7.diff
LOG: [flang] Allow configuring building the flang runtime standalone
This allows building the flang runtime and libFortranDecimal standalone,
without setting up the full llvm build, by pointing cmake to these
directories.
This is the other one out of two essential steps for building the flang runtimes
for a foreign target, i.e. setting up cross compiling with flang.
Differential Revision: https://reviews.llvm.org/D130352
Added:
Modified:
flang/lib/Decimal/CMakeLists.txt
flang/runtime/CMakeLists.txt
Removed:
################################################################################
diff --git a/flang/lib/Decimal/CMakeLists.txt b/flang/lib/Decimal/CMakeLists.txt
index 3430fa5913819..f30614ee1f8ae 100644
--- a/flang/lib/Decimal/CMakeLists.txt
+++ b/flang/lib/Decimal/CMakeLists.txt
@@ -1,3 +1,40 @@
+if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ cmake_minimum_required(VERSION 3.13.4)
+
+ project(FortranDecimal C CXX)
+
+ set(CMAKE_CXX_STANDARD 17)
+ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
+ set(CMAKE_CXX_EXTENSIONS OFF)
+
+ set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
+
+ set(LLVM_COMMON_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../cmake")
+ set(LLVM_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../llvm/cmake")
+
+ # Add path for custom modules
+ list(INSERT CMAKE_MODULE_PATH 0
+ "${FLANG_SOURCE_DIR}/cmake"
+ "${FLANG_SOURCE_DIR}/cmake/modules"
+ "${LLVM_COMMON_CMAKE_UTILS}"
+ "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+ "${LLVM_CMAKE_UTILS}"
+ "${LLVM_CMAKE_UTILS}/modules"
+ )
+
+ include(AddLLVM)
+ include(AddFlang)
+
+ include(TestBigEndian)
+ test_big_endian(IS_BIGENDIAN)
+ if (IS_BIGENDIAN)
+ add_compile_definitions(FLANG_BIG_ENDIAN=1)
+ else ()
+ add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
+ endif ()
+ include_directories(BEFORE
+ ${FLANG_SOURCE_DIR}/include)
+endif()
add_flang_library(FortranDecimal INSTALL_WITH_TOOLCHAIN
binary-to-decimal.cpp
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index 5c61cebf3c709..4d5cea46c939d 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -6,6 +6,44 @@
#
#===------------------------------------------------------------------------===#
+if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ cmake_minimum_required(VERSION 3.13.4)
+
+ project(FlangRuntime C CXX)
+
+ set(CMAKE_CXX_STANDARD 17)
+ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
+ set(CMAKE_CXX_EXTENSIONS OFF)
+
+ set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
+
+ set(LLVM_COMMON_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../cmake")
+ set(LLVM_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../llvm/cmake")
+
+ # Add path for custom modules
+ list(INSERT CMAKE_MODULE_PATH 0
+ "${FLANG_SOURCE_DIR}/cmake"
+ "${FLANG_SOURCE_DIR}/cmake/modules"
+ "${LLVM_COMMON_CMAKE_UTILS}"
+ "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+ "${LLVM_CMAKE_UTILS}"
+ "${LLVM_CMAKE_UTILS}/modules"
+ )
+
+ include(AddLLVM)
+ include(AddFlang)
+
+ include(TestBigEndian)
+ test_big_endian(IS_BIGENDIAN)
+ if (IS_BIGENDIAN)
+ add_compile_definitions(FLANG_BIG_ENDIAN=1)
+ else ()
+ add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
+ endif ()
+ include_directories(BEFORE
+ ${FLANG_SOURCE_DIR}/include)
+endif()
+
include(CheckCXXSymbolExists)
include(CheckCXXSourceCompiles)
check_cxx_symbol_exists(strerror string.h HAVE_STRERROR)
More information about the flang-commits
mailing list