diff --git a/flang/lib/Decimal/CMakeLists.txt b/flang/lib/Decimal/CMakeLists.txt --- 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 --- 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)