[flang-commits] [PATCH] D124759: [flang] Install Fortran_main library
Dan Palermo via Phabricator via flang-commits
flang-commits at lists.llvm.org
Tue May 10 14:14:38 PDT 2022
dpalermo added a comment.
If the install logic in add_flang_library is moved into a separate macro (to avoid the "SHARED STATIC"), this problem is avoided and only the archive version of Fortran_main is built/installed:
diff --git a/flang/cmake/modules/AddFlang.cmake b/flang/cmake/modules/AddFlang.cmake
index 369e303e148a..4426f8628bf0 100644
--- a/flang/cmake/modules/AddFlang.cmake
+++ b/flang/cmake/modules/AddFlang.cmake
@@ -16,6 +16,27 @@ macro(add_flang_subdirectory name)
add_llvm_subdirectory(FLANG TOOL ${name})
endmacro()
+macro(install_flang_library name)
+ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libflang")
+ get_target_export_arg(${name} Flang export_to_flangtargets UMBRELLA flang-libraries)
+ install(TARGETS ${name}
+ COMPONENT ${name}
+ ${export_to_flangtargets}
+ LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+ ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
+
+ if (NOT LLVM_ENABLE_IDE)
+ add_llvm_install_targets(install-${name}
+ DEPENDS ${name}
+ COMPONENT ${name})
+ endif()
+
+ set_property(GLOBAL APPEND PROPERTY FLANG_LIBS ${name})
+ endif()
+ set_property(GLOBAL APPEND PROPERTY FLANG_EXPORTS ${name})
+endmacro()
+
macro(add_flang_library name)
cmake_parse_arguments(ARG
"SHARED"
@@ -64,25 +85,7 @@ macro(add_flang_library name)
llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
if (TARGET ${name})
-
- if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libflang")
- get_target_export_arg(${name} Flang export_to_flangtargets UMBRELLA flang-libraries)
- install(TARGETS ${name}
- COMPONENT ${name}
- ${export_to_flangtargets}
- LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
-
- if (NOT LLVM_ENABLE_IDE)
- add_llvm_install_targets(install-${name}
- DEPENDS ${name}
- COMPONENT ${name})
- endif()
-
- set_property(GLOBAL APPEND PROPERTY FLANG_LIBS ${name})
- endif()
- set_property(GLOBAL APPEND PROPERTY FLANG_EXPORTS ${name})
+ install_flang_library(${name})
else()
# Add empty "phony" target
add_custom_target(${name})
diff --git a/flang/runtime/FortranMain/CMakeLists.txt b/flang/runtime/FortranMain/CMakeLists.txt
index aa214cee31ff..2167e3fc918b 100644
--- a/flang/runtime/FortranMain/CMakeLists.txt
+++ b/flang/runtime/FortranMain/CMakeLists.txt
@@ -1,3 +1,5 @@
llvm_add_library(Fortran_main STATIC
Fortran_main.c
)
+
+install_flang_library(Fortran_main)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124759/new/
https://reviews.llvm.org/D124759
More information about the flang-commits
mailing list