4d5cea46c939dffb1a98437c328538a13995d6ff
[platform/upstream/llvm.git] / flang / runtime / CMakeLists.txt
1 #===-- runtime/CMakeLists.txt ----------------------------------------------===#
2 #
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
6 #
7 #===------------------------------------------------------------------------===#
8
9 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
10   cmake_minimum_required(VERSION 3.13.4)
11
12   project(FlangRuntime C CXX)
13
14   set(CMAKE_CXX_STANDARD 17)
15   set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
16   set(CMAKE_CXX_EXTENSIONS OFF)
17
18   set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
19
20   set(LLVM_COMMON_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../cmake")
21   set(LLVM_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../llvm/cmake")
22
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"
29     "${LLVM_CMAKE_UTILS}"
30     "${LLVM_CMAKE_UTILS}/modules"
31     )
32
33   include(AddLLVM)
34   include(AddFlang)
35
36   include(TestBigEndian)
37   test_big_endian(IS_BIGENDIAN)
38   if (IS_BIGENDIAN)
39     add_compile_definitions(FLANG_BIG_ENDIAN=1)
40   else ()
41     add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
42   endif ()
43   include_directories(BEFORE
44     ${FLANG_SOURCE_DIR}/include)
45 endif()
46
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(
53   "#include <string.h>
54    int main() {
55      char buf[4096];
56      return strerror_s(buf, 4096, 0);
57    }
58   "
59   HAVE_DECL_STRERROR_S)
60
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.")
63 endif()
64
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})
70
71 add_subdirectory(FortranMain)
72
73 add_flang_library(FortranRuntime
74   ISO_Fortran_binding.cpp
75   allocatable.cpp
76   assign.cpp
77   buffer.cpp
78   command.cpp
79   complex-reduction.c
80   copy.cpp
81   character.cpp
82   connection.cpp
83   derived.cpp
84   derived-api.cpp
85   descriptor.cpp
86   descriptor-io.cpp
87   dot-product.cpp
88   edit-input.cpp
89   edit-output.cpp
90   environment.cpp
91   extensions.cpp
92   extrema.cpp
93   file.cpp
94   findloc.cpp
95   format.cpp
96   inquiry.cpp
97   internal-unit.cpp
98   iostat.cpp
99   io-api.cpp
100   io-error.cpp
101   io-stmt.cpp
102   main.cpp
103   matmul.cpp
104   memory.cpp
105   misc-intrinsic.cpp
106   namelist.cpp
107   numeric.cpp
108   ragged.cpp
109   random.cpp
110   reduction.cpp
111   pointer.cpp
112   product.cpp
113   stat.cpp
114   stop.cpp
115   sum.cpp
116   support.cpp
117   terminator.cpp
118   time-intrinsic.cpp
119   tools.cpp
120   transformational.cpp
121   type-code.cpp
122   type-info.cpp
123   unit.cpp
124   unit-map.cpp
125   utf.cpp
126
127   LINK_LIBS
128   FortranDecimal
129
130   INSTALL_WITH_TOOLCHAIN
131 )