90 lines · plain
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 environments8 # 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_library_exists(quadmath sinq "" FOUND_QUADMATH_LIB)25if (FLANG_INCLUDE_QUADMATH_H AND FOUND_QUADMATH_LIB)26 configure_file("${FLANG_SOURCE_DIR}/cmake/quadmath_wrapper.h.in" "${CMAKE_CURRENT_BINARY_DIR}/quadmath_wrapper.h")27 add_compile_definitions(HAS_QUADMATHLIB)28 set(QUADMATHLIB quadmath)29endif ()30 31add_flang_library(FortranEvaluate32 call.cpp33 characteristics.cpp34 check-expression.cpp35 common.cpp36 complex.cpp37 constant.cpp38 expression.cpp39 fold.cpp40 fold-character.cpp41 fold-complex.cpp42 fold-designator.cpp43 fold-integer.cpp44 fold-logical.cpp45 fold-real.cpp46 fold-reduction.cpp47 formatting.cpp48 host.cpp49 initial-image.cpp50 integer.cpp51 intrinsics.cpp52 intrinsics-library.cpp53 logical.cpp54 real.cpp55 shape.cpp56 static-data.cpp57 target.cpp58 tools.cpp59 type.cpp60 variable.cpp61 62 LINK_LIBS63 FortranSupport64 FortranDecimal65 FortranParser66 ${LIBPGMATH}67 ${QUADMATHLIB}68 69 LINK_COMPONENTS70 Support71 72 DEPENDS73 acc_gen74 omp_gen75)76 77target_precompile_headers(FortranEvaluate PRIVATE78 [["flang/Evaluate/common.h"]]79 [["flang/Evaluate/call.h"]]80 [["flang/Evaluate/traverse.h"]]81 [["flang/Evaluate/shape.h"]]82 [["flang/Evaluate/characteristics.h"]]83 [["flang/Evaluate/variable.h"]]84 [["flang/Evaluate/real.h"]]85 [["flang/Evaluate/type.h"]]86 [["flang/Evaluate/integer.h"]]87 [["flang/Evaluate/expression.h"]]88 [["flang/Evaluate/tools.h"]]89)90