Skip to content

Commit 1b86782

Browse files
committed
Use modern properties of targets
- Also pass compiler flags for coarrays for utility library
1 parent 3e38b22 commit 1b86782

File tree

3 files changed

+39
-15
lines changed

3 files changed

+39
-15
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,10 @@ function(caf_compile_executable target main_depend)
525525
COMMAND "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/caf"
526526
${includes} ${localDefs} ${config_Fortran_flags}
527527
-o "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target}"
528-
"${CMAKE_CURRENT_SOURCE_DIR}/${main_depend}" ${ARGN}
529-
DEPENDS "${main_depend}" ${ARGN} caf_mpi_static
528+
"${CMAKE_CURRENT_SOURCE_DIR}/${main_depend}"
529+
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libopencoarrays_test_utilities.a"
530+
${ARGN}
531+
DEPENDS "${main_depend}" ${ARGN} caf_mpi_static opencoarrays_test_utilities
530532
VERBATIM
531533
)
532534
add_custom_target("build_${target}" ALL

src/tests/unit/teams/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
caf_compile_executable(team_number team-number.f90)
22
caf_compile_executable(teams_subset teams_subset.f90)
3-
target_link_libraries(teams_subset opencoarrays_test_utilities)
43
caf_compile_executable(get_communicator get-communicator.f90)

src/tests/utilities/CMakeLists.txt

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ check_fortran_source_compiles("
1515
HAVE_ERROR_STOP_IN_PURE
1616
SRC_EXT ".f90"
1717
)
18-
if(HAVE_ERROR_STOP_IN_PURE)
19-
add_definitions(-DHAVE_ERROR_STOP_IN_PURE)
20-
endif()
2118

2219
# Check support for Fortran 2018 variable stop code
2320
check_fortran_source_compiles("
@@ -29,14 +26,46 @@ check_fortran_source_compiles("
2926
"
3027
HAVE_VARIABLE_STOP_CODE
3128
SRC_EXT ".f90")
32-
if(HAVE_VARIABLE_STOP_CODE)
33-
add_definitions(-DHAVE_VARIABLE_STOP_CODE)
34-
endif()
3529

3630
if ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU" )
3731
set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
3832
endif()
3933

34+
add_library( oc_test_interfaces OBJECT
35+
object_interface.f90
36+
assertions_interface.F90
37+
)
38+
add_library( opencoarrays_test_utilities
39+
assertions_implementation.F90
40+
$<TARGET_OBJECTS:oc_test_interfaces>
41+
)
42+
set_target_properties(opencoarrays_test_utilities
43+
PROPERTIES
44+
Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}")
45+
set_target_properties(oc_test_interfaces
46+
PROPERTIES
47+
Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}")
48+
49+
target_compile_options(oc_test_interfaces
50+
PUBLIC
51+
"-fcoarray=lib")
52+
target_compile_options(opencoarrays_test_utilities
53+
PUBLIC
54+
"-fcoarray=lib")
55+
56+
if(HAVE_ERROR_STOP_IN_PURE)
57+
target_compile_definitions(oc_test_interfaces
58+
PUBLIC -DHAVE_ERROR_STOP_IN_PURE)
59+
target_compile_definitions(opencoarrays_test_utilities
60+
PUBLIC -DHAVE_ERROR_STOP_IN_PURE)
61+
endif()
62+
if(HAVE_VARIABLE_STOP_CODE)
63+
target_compile_definitions(oc_test_interfaces
64+
PUBLIC -DHAVE_VARIABLE_STOP_CODE)
65+
target_compile_definitions(opencoarrays_test_utilities
66+
PUBLIC -DHAVE_VARIABLE_STOP_CODE)
67+
endif()
68+
4069
#Toggle C preprocessor macro for turning assertions on or off
4170
if(NO_ASSERTIONS)
4271
target_compile_definitions( opencoarrays_test_utilities
@@ -47,9 +76,3 @@ else()
4776
PUBLIC "-DUSE_ASSERTIONS=.true."
4877
)
4978
endif()
50-
51-
add_library( opencoarrays_test_utilities
52-
object_interface.f90
53-
assertions_interface.F90
54-
assertions_implementation.F90
55-
)

0 commit comments

Comments
 (0)