xref: /llvm-project/flang/lib/Evaluate/CMakeLists.txt (revision 6d0d4113dfb94ae83a99d7bdf51f7c619f5eca15)
1include(CheckLibraryExists)
2
3if (LIBPGMATH_DIR)
4  # If pgmath library is found, it can be used for constant folding.
5  find_library(LIBPGMATH pgmath PATHS ${LIBPGMATH_DIR})
6  if(LIBPGMATH)
7    # pgmath uses _Complex, so only enable linking pgmath with flang in environments
8    # that support it (MSVC is OK, pgmath uses _Fcomplex/_Dcomplex there).
9    if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU|MSVC")
10      check_cxx_compiler_flag("-Werror -Wc99-extensions" HAS_WC99_EXTENSIONS_FLAG)
11      if (HAS_WC99_EXTENSIONS_FLAG)
12        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c99-extensions")
13      endif()
14      add_compile_definitions(LINK_WITH_LIBPGMATH)
15      message(STATUS "Found libpgmath: ${LIBPGMATH}")
16    else()
17      message(STATUS "Libpgmath will not be used because C99 complex is not supported.")
18    endif()
19  else()
20    message(STATUS "Libpgmath not found in: ${LIBPGMATH_DIR}")
21  endif()
22endif()
23
24check_include_file(quadmath.h FOUND_QUADMATH_HEADER)
25check_library_exists(quadmath sinq "" FOUND_QUADMATH_LIB)
26if(FOUND_QUADMATH_HEADER AND FOUND_QUADMATH_LIB)
27  add_compile_definitions(HAS_QUADMATHLIB)
28  set(QUADMATHLIB quadmath)
29endif()
30
31add_flang_library(FortranEvaluate
32  call.cpp
33  characteristics.cpp
34  check-expression.cpp
35  common.cpp
36  complex.cpp
37  constant.cpp
38  expression.cpp
39  fold.cpp
40  fold-character.cpp
41  fold-complex.cpp
42  fold-designator.cpp
43  fold-integer.cpp
44  fold-logical.cpp
45  fold-real.cpp
46  fold-reduction.cpp
47  formatting.cpp
48  host.cpp
49  initial-image.cpp
50  integer.cpp
51  intrinsics.cpp
52  intrinsics-library.cpp
53  logical.cpp
54  real.cpp
55  shape.cpp
56  static-data.cpp
57  target.cpp
58  tools.cpp
59  type.cpp
60  variable.cpp
61
62  LINK_LIBS
63  FortranCommon
64  FortranDecimal
65  FortranParser
66  ${LIBPGMATH}
67  ${QUADMATHLIB}
68
69  LINK_COMPONENTS
70  Support
71
72  DEPENDS
73  acc_gen
74  omp_gen
75)
76