Skip to content

Commit 15dcd92

Browse files
authored
Revert "CMake: Cleanup depedency issues"
1 parent cc46713 commit 15dcd92

File tree

2 files changed

+81
-19
lines changed

2 files changed

+81
-19
lines changed

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,13 @@ include_directories(BEFORE
361361
)
362362

363363
# Direct module files to build include directory
364-
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include)
364+
set(FLANG_MODULE_DIRECTORY_SHARED ${CMAKE_CURRENT_BINARY_DIR}/include)
365+
# mod files in the following differs only by the timestamp. This is needed to
366+
# ensure that flang can be built parallelly. It is discarded after flang is built
367+
set(FLANG_MODULE_DIRECTORY_STATIC ${CMAKE_CURRENT_BINARY_DIR}/include-static)
365368

366369
# Install Fortran module files
367-
install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/
370+
install(DIRECTORY ${FLANG_MODULE_DIRECTORY_SHARED}/
368371
DESTINATION include
369372
)
370373

runtime/flang/CMakeLists.txt

Lines changed: 76 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ SET(FTN_INTRINSICS
273273
wait3f.c
274274
)
275275

276-
SET(FTN_SUPPORT
276+
SET(FTN_SUPPORT_COMMON
277277
bcopy.c
278278
bcopys.c
279279
buffer.c
@@ -475,14 +475,34 @@ SET(FTN_SUPPORT
475475
xfer.c
476476
init.c
477477
xfer_rpm1.c
478+
)
479+
480+
foreach(FTN_FILE ieee_arithmetic ieee_exceptions iso_c_bind)
481+
configure_file(${FTN_FILE}.F95 ${FTN_FILE}_static.F95 COPYONLY)
482+
endforeach()
483+
484+
SET(FTN_SUPPORT_SHARED
478485
ieee_arithmetic.F95
479486
ieee_exceptions.F95
480487
iso_c_bind.F95
481-
)
488+
)
489+
490+
SET(FTN_SUPPORT_STATIC
491+
ieee_arithmetic_static.F95
492+
ieee_exceptions_static.F95
493+
iso_c_bind_static.F95
494+
)
495+
496+
SET(FTN_SUPPORT
497+
${FTN_SUPPORT_STATIC}
498+
${FTN_SUPPORT_SHARED}
499+
${FTN_SUPPORT_COMMON}
500+
)
482501

483502
add_flang_library(flang_static
484503
${FTN_INTRINSICS}
485-
${FTN_SUPPORT}
504+
${FTN_SUPPORT_COMMON}
505+
${FTN_SUPPORT_STATIC}
486506
${SHARED_SOURCES}
487507
)
488508

@@ -492,33 +512,81 @@ else()
492512
set_property(TARGET flang_static PROPERTY OUTPUT_NAME flang)
493513
endif()
494514

515+
set_target_properties(flang_static PROPERTIES Fortran_MODULE_DIRECTORY ${FLANG_MODULE_DIRECTORY_STATIC})
516+
517+
if (NOT "${CMAKE_GENERATOR}" STREQUAL "Ninja")
518+
# State the module that the source is producing
519+
set_source_files_properties(
520+
iso_c_bind_static.F95
521+
PROPERTIES
522+
OBJECT_OUTPUTS ${FLANG_MODULE_DIRECTORY_STATIC}/iso_c_binding.mod
523+
)
524+
525+
# State a dependency on the module
526+
set_source_files_properties(
527+
ieee_arithmetic_static.F95
528+
ieee_exceptions_static.F95
529+
PROPERTIES
530+
OBJECT_DEPENDS ${FLANG_MODULE_DIRECTORY_STATIC}/iso_c_binding.mod
531+
)
532+
else()
495533
add_library(iso_c_bind OBJECT
496534
iso_c_bind.F95
497535
)
498-
499536
add_library(ieee_arithmetic OBJECT
500537
ieee_arithmetic.F95
501538
ieee_exceptions.F95
502539
)
540+
add_dependencies(iso_c_bind
541+
flang1
542+
flang2
543+
)
544+
add_dependencies(ieee_arithmetic
545+
iso_c_bind
546+
)
547+
add_dependencies(flang_static
548+
ieee_arithmetic
549+
)
550+
endif()
503551

504552
set(SHARED_LIBRARY TRUE)
505553

506554
add_flang_library(flang_shared
507555
${FTN_INTRINSICS}
508-
${FTN_SUPPORT}
556+
${FTN_SUPPORT_COMMON}
557+
${FTN_SUPPORT_SHARED}
509558
${SHARED_SOURCES}
510559
)
511-
512560
set_property(TARGET flang_shared PROPERTY OUTPUT_NAME flang)
513561
target_link_libraries(flang_shared flangrti_shared)
514-
515562
# Resolve symbols against libm and librt
516563
if (NOT MSVC)
517564
target_link_libraries(flang_shared rt m)
518565
else()
519566
set_target_properties(flang_shared PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
520567
endif()
568+
set_target_properties(flang_shared PROPERTIES Fortran_MODULE_DIRECTORY ${FLANG_MODULE_DIRECTORY_SHARED})
521569

570+
if (NOT "${CMAKE_GENERATOR}" STREQUAL "Ninja")
571+
# State the module that the source is producing
572+
set_source_files_properties(
573+
iso_c_bind.F95
574+
PROPERTIES
575+
OBJECT_OUTPUTS ${FLANG_MODULE_DIRECTORY_SHARED}/iso_c_binding.mod
576+
)
577+
578+
# State a dependency on the module
579+
set_source_files_properties(
580+
ieee_arithmetic.F95
581+
ieee_exceptions.F95
582+
PROPERTIES
583+
OBJECT_DEPENDS ${FLANG_MODULE_DIRECTORY_SHARED}/iso_c_binding.mod
584+
)
585+
else()
586+
add_dependencies(flang_shared
587+
ieee_arithmetic
588+
)
589+
endif()
522590
set(SHARED_LIBRARY FALSE)
523591

524592
set_property(
@@ -582,22 +650,13 @@ target_include_directories(flang_shared
582650
add_dependencies(flang_static
583651
flang1
584652
flang2
585-
ieee_arithmetic
586653
)
587654

588655
# Make sure the compiler is built before we bootstrap
589656
add_dependencies(flang_shared
590-
flang_static
591-
)
592-
593-
add_dependencies(iso_c_bind
594657
flang1
595658
flang2
596-
)
597-
598-
add_dependencies(ieee_arithmetic
599-
iso_c_bind
600-
)
659+
)
601660

602661
if (NOT MSVC)
603662
target_compile_options(flang_static PRIVATE -fPIC)

0 commit comments

Comments
 (0)