Skip to content

Commit 01179b1

Browse files
committed
Set the CACHE variable only once
1 parent 3a80ca5 commit 01179b1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

flang/runtime/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ if (NOT DEFINED MSVC)
261261

262262
INSTALL_WITH_TOOLCHAIN
263263
)
264-
target_link_libraries(FortranRuntime PRIVATE ${FORTRAN_MODULE_OBJECTS})
265264
else()
266265
add_flang_library(FortranRuntime
267266
${sources}

flang/tools/f18/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ set(MODULES ${MODULES_WITH_IMPLEMENTATION} ${MODULES_WITHOUT_IMPLEMENTATION})
3333

3434
# Init variable to hold extra object files coming from the Fortran modules;
3535
# these module files will be contributed from the CMakeLists in flang/tools/f18.
36-
unset(FORTRAN_MODULE_OBJECTS CACHE)
36+
set(module_objects "")
3737

3838
# Create module files directly from the top-level module source directory.
3939
# If CMAKE_CROSSCOMPILING, then the newly built flang-new executable was
@@ -102,10 +102,15 @@ if (NOT CMAKE_CROSSCOMPILING)
102102
# If a module has been compiled into an object file, add the file to
103103
# the link line for the FortranRuntime library.
104104
if(include_in_link)
105-
set(FORTRAN_MODULE_OBJECTS "${FORTRAN_MODULE_OBJECTS}" "${object_output}" CACHE INTERNAL "")
105+
set(module_objects ${module_} ${object_output})
106106
endif()
107107
endforeach()
108108

109+
# Set a CACHE variable that is visible to the CMakeLists.txt in runtime/, so that
110+
# the compiled Fortran modules can be added to the link line of the FortranRuntime
111+
# library.
112+
set(FORTRAN_MODULE_OBJECTS ${module_objects} CACHE INTERNAL "")
113+
109114
# Special case for omp_lib.mod, because its source comes from openmp/runtime/src/include.
110115
# It also produces two module files: omp_lib.mod and omp_lib_kinds.mod. Compile these
111116
# files only if OpenMP support has been configured.

0 commit comments

Comments
 (0)