1 set(LLVM_LINK_COMPONENTS
9 "__fortran_ieee_exceptions"
25 # Create module files directly from the top-level module source directory.
26 # If CMAKE_CROSSCOMPILING, then the newly built flang-new executable was
27 # cross compiled, and thus can't be executed on the build system and thus
28 # can't be used for generating module files.
29 if (NOT CMAKE_CROSSCOMPILING)
30 foreach(filename ${MODULES})
31 set(base ${FLANG_INTRINSIC_MODULES_DIR}/${filename})
32 if(${filename} STREQUAL "__fortran_builtins")
34 elseif(${filename} STREQUAL "__ppc_types")
36 elseif(${filename} STREQUAL "__ppc_intrinsics" OR
37 ${filename} STREQUAL "mma")
38 set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__ppc_types.mod)
40 set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_builtins.mod)
41 if(NOT ${filename} STREQUAL "__fortran_type_info")
42 set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_type_info.mod)
44 if(${filename} STREQUAL "ieee_arithmetic" OR
45 ${filename} STREQUAL "ieee_exceptions")
46 set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_ieee_exceptions.mod)
50 # The module contains PPC vector types that needs the PPC target.
52 if(${filename} STREQUAL "__ppc_intrinsics" OR
53 ${filename} STREQUAL "mma")
54 set(opts "--target=ppc64le")
57 add_custom_command(OUTPUT ${base}.mod
58 COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
59 COMMAND flang-new -cpp -fsyntax-only ${opts} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
60 ${FLANG_SOURCE_DIR}/module/${filename}.f90
61 DEPENDS flang-new ${FLANG_SOURCE_DIR}/module/${filename}.f90 ${depends}
63 add_custom_command(OUTPUT ${base}.f18.mod
65 COMMAND ${CMAKE_COMMAND} -E copy ${base}.mod ${base}.f18.mod)
66 list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod)
67 install(FILES ${base}.mod ${base}.f18.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
71 add_custom_target(module_files ALL DEPENDS ${MODULE_FILES})
73 # This flang shell script will only work in a POSIX shell.
76 ${CMAKE_CURRENT_SOURCE_DIR}/flang-to-external-fc.in
77 ${CMAKE_BINARY_DIR}/bin/flang-to-external-fc
80 add_custom_target(flang-to-external-fc ALL DEPENDS ${CMAKE_BINARY_DIR}/bin/flang-to-external-fc)
81 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/flang-to-external-fc DESTINATION "${CMAKE_INSTALL_BINDIR}")
84 # TODO Move this to a more suitable location
85 file(COPY ${FLANG_SOURCE_DIR}/module/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
86 install(FILES ${CMAKE_BINARY_DIR}/include/flang/OpenMP/omp_lib.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang/OpenMP")