[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / runtime / CMakeLists.txt
blobe0c93c220e95a94e2537ade843ed71d7a9ea25f2
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)
11   if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
12     message(WARNING
13       "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
14       "minimum version of CMake required to build LLVM will become 3.20.0, and "
15       "using an older CMake will become an error. Please upgrade your CMake to "
16       "at least 3.20.0 now to avoid issues in the future!")
17   endif()
19   project(FlangRuntime C CXX)
21   set(CMAKE_CXX_STANDARD 17)
22   set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
23   set(CMAKE_CXX_EXTENSIONS OFF)
25   set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
27   set(LLVM_COMMON_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../cmake")
28   set(LLVM_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../llvm/cmake")
30   # Add path for custom modules
31   list(INSERT CMAKE_MODULE_PATH 0
32     "${FLANG_SOURCE_DIR}/cmake"
33     "${FLANG_SOURCE_DIR}/cmake/modules"
34     "${LLVM_COMMON_CMAKE_UTILS}"
35     "${LLVM_COMMON_CMAKE_UTILS}/Modules"
36     "${LLVM_CMAKE_UTILS}"
37     "${LLVM_CMAKE_UTILS}/modules"
38     )
40   include(AddLLVM)
41   include(AddFlang)
42   include(HandleLLVMOptions)
44   include(TestBigEndian)
45   test_big_endian(IS_BIGENDIAN)
46   if (IS_BIGENDIAN)
47     add_compile_definitions(FLANG_BIG_ENDIAN=1)
48   else ()
49     add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
50   endif ()
51   include_directories(BEFORE
52     ${FLANG_SOURCE_DIR}/include)
53 endif()
55 include(CheckCXXSymbolExists)
56 include(CheckCXXSourceCompiles)
57 check_cxx_symbol_exists(strerror string.h HAVE_STRERROR)
58 check_cxx_symbol_exists(strerror_r string.h HAVE_STRERROR_R)
59 # Can't use symbol exists here as the function is overloaded in C++
60 check_cxx_source_compiles(
61   "#include <string.h>
62    int main() {
63      char buf[4096];
64      return strerror_s(buf, 4096, 0);
65    }
66   "
67   HAVE_DECL_STRERROR_S)
69 check_cxx_compiler_flag(-fno-lto FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
70 if (FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
71   set(NO_LTO_FLAGS "-fno-lto")
72 else()
73   set(NO_LTO_FLAGS "")
74 endif()
76 if (NOT (HAVE_STRERROR OR HAVE_STRERROR_R OR HAVE_DECL_STRERROR_S))
77   message(FATAL_ERROR "None of strerror, strerror_r, strerror_s found.")
78 endif()
80 configure_file(config.h.cmake config.h)
81 # include_directories is used here instead of target_include_directories
82 # because add_flang_library creates multiple objects (STATIC/SHARED, OBJECT)
83 # with different names
84 include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR})
86 append(${NO_LTO_FLAGS} CMAKE_C_FLAGS)
87 append(${NO_LTO_FLAGS} CMAKE_CXX_FLAGS)
89 # Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
90 # to avoid an unwanted dependency on libstdc++/libc++.so.
91 add_definitions(-U_GLIBCXX_ASSERTIONS)
92 add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
94 add_subdirectory(FortranMain)
96 add_flang_library(FortranRuntime
97   ISO_Fortran_binding.cpp
98   allocatable.cpp
99   array-constructor.cpp
100   assign.cpp
101   buffer.cpp
102   command.cpp
103   complex-powi.cpp
104   complex-reduction.c
105   copy.cpp
106   character.cpp
107   connection.cpp
108   derived.cpp
109   derived-api.cpp
110   descriptor.cpp
111   descriptor-io.cpp
112   dot-product.cpp
113   edit-input.cpp
114   edit-output.cpp
115   environment.cpp
116   extensions.cpp
117   extrema.cpp
118   file.cpp
119   findloc.cpp
120   format.cpp
121   inquiry.cpp
122   internal-unit.cpp
123   iostat.cpp
124   io-api.cpp
125   io-error.cpp
126   io-stmt.cpp
127   main.cpp
128   matmul.cpp
129   memory.cpp
130   misc-intrinsic.cpp
131   namelist.cpp
132   numeric.cpp
133   ragged.cpp
134   random.cpp
135   reduction.cpp
136   pointer.cpp
137   product.cpp
138   stat.cpp
139   stop.cpp
140   sum.cpp
141   support.cpp
142   terminator.cpp
143   time-intrinsic.cpp
144   tools.cpp
145   transformational.cpp
146   type-code.cpp
147   type-info.cpp
148   unit.cpp
149   unit-map.cpp
150   utf.cpp
152   LINK_LIBS
153   FortranDecimal
155   INSTALL_WITH_TOOLCHAIN