Skip to content

Commit a1ac1cd

Browse files
authored
Merge pull request #109 from isuruf/revert-106-revert-105-cleanup
CMake: Cleanup depedency issues
2 parents 5a984bd + 7af4074 commit a1ac1cd

File tree

2 files changed

+25
-80
lines changed

2 files changed

+25
-80
lines changed

CMakeLists.txt

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

363363
# Direct module files to build include directory
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)
364+
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include)
368365

369366
# Install Fortran module files
370-
install(DIRECTORY ${FLANG_MODULE_DIRECTORY_SHARED}/
367+
install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/
371368
DESTINATION include
372369
)
373370

runtime/flang/CMakeLists.txt

Lines changed: 23 additions & 75 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_COMMON
276+
SET(FTN_SUPPORT
277277
bcopy.c
278278
bcopys.c
279279
buffer.c
@@ -475,118 +475,55 @@ SET(FTN_SUPPORT_COMMON
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
485478
ieee_arithmetic.F95
486479
ieee_exceptions.F95
487480
iso_c_bind.F95
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-
)
481+
)
501482

502483
add_flang_library(flang_static
503484
${FTN_INTRINSICS}
504-
${FTN_SUPPORT_COMMON}
505-
${FTN_SUPPORT_STATIC}
485+
${FTN_SUPPORT}
506486
${SHARED_SOURCES}
507487
)
508488

489+
set_target_properties(flang_static
490+
PROPERTIES
491+
Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include-static
492+
)
493+
509494
if (MSVC)
510495
set_property(TARGET flang_static PROPERTY OUTPUT_NAME libflang)
511496
else()
512497
set_property(TARGET flang_static PROPERTY OUTPUT_NAME flang)
513498
endif()
514499

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()
533500
add_library(iso_c_bind OBJECT
534501
iso_c_bind.F95
535502
)
503+
536504
add_library(ieee_arithmetic OBJECT
537505
ieee_arithmetic.F95
538506
ieee_exceptions.F95
539507
)
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()
551508

552509
set(SHARED_LIBRARY TRUE)
553510

554511
add_flang_library(flang_shared
555512
${FTN_INTRINSICS}
556-
${FTN_SUPPORT_COMMON}
557-
${FTN_SUPPORT_SHARED}
513+
${FTN_SUPPORT}
558514
${SHARED_SOURCES}
559515
)
516+
560517
set_property(TARGET flang_shared PROPERTY OUTPUT_NAME flang)
561518
target_link_libraries(flang_shared flangrti_shared)
519+
562520
# Resolve symbols against libm and librt
563521
if (NOT MSVC)
564522
target_link_libraries(flang_shared rt m)
565523
else()
566524
set_target_properties(flang_shared PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
567525
endif()
568-
set_target_properties(flang_shared PROPERTIES Fortran_MODULE_DIRECTORY ${FLANG_MODULE_DIRECTORY_SHARED})
569-
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-
)
577526

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()
590527
set(SHARED_LIBRARY FALSE)
591528

592529
set_property(
@@ -650,14 +587,25 @@ target_include_directories(flang_shared
650587
add_dependencies(flang_static
651588
flang1
652589
flang2
590+
ieee_arithmetic
653591
)
654592

655593
# Make sure the compiler is built before we bootstrap
656594
add_dependencies(flang_shared
657595
flang1
658596
flang2
597+
ieee_arithmetic
659598
)
660599

600+
add_dependencies(iso_c_bind
601+
flang1
602+
flang2
603+
)
604+
605+
add_dependencies(ieee_arithmetic
606+
iso_c_bind
607+
)
608+
661609
if (NOT MSVC)
662610
target_compile_options(flang_static PRIVATE -fPIC)
663611
target_compile_options(flang_shared PRIVATE -fPIC)

0 commit comments

Comments
 (0)