Skip to content

Commit c6c00e0

Browse files
committed
Add Fortran include dir to export target. Fixes #501
1 parent 5934b42 commit c6c00e0

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ if (WITH_FORTRAN)
114114
enable_language(Fortran)
115115
set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/fortran")
116116
set(CALIPER_Fortran_CMAKE_MSG "Yes, using ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_Fortran_COMPILER_VERSION}")
117+
set(CALIPER_HAVE_FORTRAN TRUE)
117118
endif()
118119

119120
if (BUILD_TESTING)

examples/apps/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ if (WITH_FORTRAN)
4545
foreach(app ${CALIPER_Fortran_EXAMPLE_APPS})
4646
add_executable(${app} ${app}.f)
4747
set_source_files_properties(${app}.f PROPERTIES Fortran_FORMAT FREE)
48-
target_include_directories(${app} PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY})
4948
target_link_libraries(${app} caliper)
5049
endforeach()
5150
endif()

src/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ set_target_properties(caliper PROPERTIES VERSION ${CALIPER_VERSION})
3636

3737
target_compile_features(caliper PUBLIC cxx_std_11)
3838

39+
if (CALIPER_HAVE_FORTRAN)
40+
target_include_directories(
41+
caliper
42+
PUBLIC
43+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/caliper/fortran>"
44+
)
45+
endif()
46+
3947
if (CALIPER_HAVE_MPI)
4048
target_link_libraries(caliper PUBLIC ${MPI_CXX_LIBRARIES})
4149
endif()

src/interface/c_fortran/CMakeLists.txt

+12-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@ set(CALIPER_INTERFACE_SOURCES
77
wrapScopeAnnotation.cpp
88
utilCaliper.cpp)
99

10-
if (WITH_FORTRAN)
10+
if (CALIPER_HAVE_FORTRAN)
1111
list(APPEND CALIPER_INTERFACE_SOURCES
1212
wrapfcaliper.F)
13-
set_source_files_properties(wrapfcaliper.F PROPERTIES Fortran_FORMAT FREE)
13+
set_source_files_properties(wrapfcaliper.F PROPERTIES Fortran_FORMAT FREE)
1414
endif()
1515

1616
add_library(caliper-interface OBJECT ${CALIPER_INTERFACE_SOURCES})
17-
target_compile_features(caliper-interface PUBLIC cxx_std_11)
17+
target_compile_features(caliper-interface PUBLIC cxx_std_11)
18+
19+
if (CALIPER_HAVE_FORTRAN)
20+
target_include_directories(
21+
caliper-interface
22+
PUBLIC
23+
"$<BUILD_INTERFACE:${CMAKE_Fortran_MODULE_DIRECTORY}>"
24+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/caliper/fortran>"
25+
)
26+
endif()

test/ci_app_tests/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ if (WITH_FORTRAN)
124124
foreach(app ${CALIPER_CI_Fortran_TEST_APPS})
125125
add_executable(${app} ${app}.f)
126126
set_source_files_properties(${app}.f PROPERTIES Fortran_FORMAT FREE)
127-
target_include_directories(${app} PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY})
128127
target_link_libraries(${app} caliper)
129128
endforeach()
130129

0 commit comments

Comments
 (0)