1 #===-- runtime/CMakeLists.txt ----------------------------------------------===#
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 # See https://llvm.org/LICENSE.txt for license information.
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 #===------------------------------------------------------------------------===#
9 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
10 cmake_minimum_required(VERSION 3.13.4)
12 project(FlangRuntime C CXX)
14 set(CMAKE_CXX_STANDARD 17)
15 set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
16 set(CMAKE_CXX_EXTENSIONS OFF)
18 set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
20 set(LLVM_COMMON_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../cmake")
21 set(LLVM_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../llvm/cmake")
23 # Add path for custom modules
24 list(INSERT CMAKE_MODULE_PATH 0
25 "${FLANG_SOURCE_DIR}/cmake"
26 "${FLANG_SOURCE_DIR}/cmake/modules"
27 "${LLVM_COMMON_CMAKE_UTILS}"
28 "${LLVM_COMMON_CMAKE_UTILS}/Modules"
30 "${LLVM_CMAKE_UTILS}/modules"
36 include(TestBigEndian)
37 test_big_endian(IS_BIGENDIAN)
39 add_compile_definitions(FLANG_BIG_ENDIAN=1)
41 add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
43 include_directories(BEFORE
44 ${FLANG_SOURCE_DIR}/include)
47 include(CheckCXXSymbolExists)
48 include(CheckCXXSourceCompiles)
49 check_cxx_symbol_exists(strerror string.h HAVE_STRERROR)
50 check_cxx_symbol_exists(strerror_r string.h HAVE_STRERROR_R)
51 # Can't use symbol exists here as the function is overloaded in C++
52 check_cxx_source_compiles(
56 return strerror_s(buf, 4096, 0);
61 if (NOT (HAVE_STRERROR OR HAVE_STRERROR_R OR HAVE_DECL_STRERROR_S))
62 message(FATAL_ERROR "None of strerror, strerror_r, strerror_s found.")
65 configure_file(config.h.cmake config.h)
66 # include_directories is used here instead of target_include_directories
67 # because add_flang_library creates multiple objects (STATIC/SHARED, OBJECT)
68 # with different names
69 include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR})
71 add_subdirectory(FortranMain)
73 add_flang_library(FortranRuntime
74 ISO_Fortran_binding.cpp
130 INSTALL_WITH_TOOLCHAIN