[flang] Add cpowi function to runtime and use instead of pgmath
[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-powi.cpp
80   complex-reduction.c
81   copy.cpp
82   character.cpp
83   connection.cpp
84   derived.cpp
85   derived-api.cpp
86   descriptor.cpp
87   descriptor-io.cpp
88   dot-product.cpp
89   edit-input.cpp
90   edit-output.cpp
91   environment.cpp
92   extensions.cpp
93   extrema.cpp
94   file.cpp
95   findloc.cpp
96   format.cpp
97   inquiry.cpp
98   internal-unit.cpp
99   iostat.cpp
100   io-api.cpp
101   io-error.cpp
102   io-stmt.cpp
103   main.cpp
104   matmul.cpp
105   memory.cpp
106   misc-intrinsic.cpp
107   namelist.cpp
108   numeric.cpp
109   ragged.cpp
110   random.cpp
111   reduction.cpp
112   pointer.cpp
113   product.cpp
114   stat.cpp
115   stop.cpp
116   sum.cpp
117   support.cpp
118   terminator.cpp
119   time-intrinsic.cpp
120   tools.cpp
121   transformational.cpp
122   type-code.cpp
123   type-info.cpp
124   unit.cpp
125   unit-map.cpp
126   utf.cpp
127
128   LINK_LIBS
129   FortranDecimal
130
131   INSTALL_WITH_TOOLCHAIN
132 )