[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / tools / f18 / CMakeLists.txt
blob71de5e71ae5e3186049293d78a6fb8ab12ebb34b
1 set(LLVM_LINK_COMPONENTS
2   FrontendOpenACC
3   FrontendOpenMP
4   Support
5   )
7 set(MODULES
8   "__fortran_builtins"
9   "__fortran_ieee_exceptions"
10   "__fortran_type_info"
11   "__fortran_ppc_intrinsics"
12   "ieee_arithmetic"
13   "ieee_exceptions"
14   "ieee_features"
15   "iso_c_binding"
16   "iso_fortran_env"
17   "omp_lib"
18   "__fortran_builtins"
19   "__fortran_type_info"
22 # Create module files directly from the top-level module source directory.
23 # If CMAKE_CROSSCOMPILING, then the newly built flang-new executable was
24 # cross compiled, and thus can't be executed on the build system and thus
25 # can't be used for generating module files.
26 if (NOT CMAKE_CROSSCOMPILING)
27   foreach(filename ${MODULES})
28     set(base ${FLANG_INTRINSIC_MODULES_DIR}/${filename})
29     if(${filename} STREQUAL "__fortran_builtins")
30       set(depends "")
31     elseif(${filename} STREQUAL "__fortran_ppc_intrinsics")
32       set(depends "")
33     else()
34       set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_builtins.mod)
35       if(NOT ${filename} STREQUAL "__fortran_type_info")
36         set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_type_info.mod)
37       endif()
38       if(${filename} STREQUAL "ieee_arithmetic" OR
39          ${filename} STREQUAL "ieee_exceptions")
40         set(depends ${FLANG_INTRINSIC_MODULES_DIR}/__fortran_ieee_exceptions.mod)
41       endif()
42     endif()
43     add_custom_command(OUTPUT ${base}.mod
44       COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
45       COMMAND flang-new -fc1 -cpp -fsyntax-only -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
46         ${FLANG_SOURCE_DIR}/module/${filename}.f90
47       DEPENDS flang-new ${FLANG_SOURCE_DIR}/module/${filename}.f90 ${depends}
48     )
49     add_custom_command(OUTPUT ${base}.f18.mod
50       DEPENDS ${base}.mod
51       COMMAND ${CMAKE_COMMAND} -E copy ${base}.mod ${base}.f18.mod)
52     list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod)
53     install(FILES ${base}.mod ${base}.f18.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
54   endforeach()
55 endif()
57 add_custom_target(module_files ALL DEPENDS ${MODULE_FILES})
59 # This flang shell script will only work in a POSIX shell.
60 if (NOT WIN32)
61   configure_file(
62     ${CMAKE_CURRENT_SOURCE_DIR}/flang-to-external-fc.in
63     ${CMAKE_BINARY_DIR}/bin/flang-to-external-fc
64     @ONLY
65   )
66   add_custom_target(flang-to-external-fc ALL DEPENDS ${CMAKE_BINARY_DIR}/bin/flang-to-external-fc)
67   install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/flang-to-external-fc DESTINATION "${CMAKE_INSTALL_BINDIR}")
68 endif()
70 # TODO Move this to a more suitable location
71 file(COPY ${FLANG_SOURCE_DIR}/module/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)