Skip to content

Commit 99a8bd4

Browse files
Merge pull request #504 from awvwgk/cmake
Export include directories with target
2 parents cab6c11 + e0e81fc commit 99a8bd4

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@ if(JSON_FORTRAN_USE_OpenCoarrays)
177177
PRIVATE OpenCoarrays::caf_mpi_static)
178178
endif()
179179

180+
target_include_directories(${LIB_NAME}
181+
PUBLIC
182+
$<BUILD_INTERFACE:${MODULE_DIR}>
183+
$<INSTALL_INTERFACE:${INSTALL_MOD_DIR}>)
184+
target_include_directories(${LIB_NAME}-static
185+
PUBLIC
186+
$<BUILD_INTERFACE:${MODULE_DIR}>
187+
$<INSTALL_INTERFACE:${INSTALL_MOD_DIR}>)
180188
set_target_properties ( ${LIB_NAME}-static
181189
PROPERTIES
182190
OUTPUT_NAME ${LIB_NAME}
@@ -438,7 +446,9 @@ add_custom_target ( uninstall
438446
#-----------------------------------------------------
439447
# Publicize installed location to other CMake projects
440448
#-----------------------------------------------------
441-
install ( EXPORT ${PACKAGE_NAME}-targets DESTINATION "${EXPORT_INSTALL_DIR}" )
449+
install ( EXPORT ${PACKAGE_NAME}-targets
450+
NAMESPACE ${PACKAGE_NAME}::
451+
DESTINATION "${EXPORT_INSTALL_DIR}" )
442452

443453
include ( CMakePackageConfigHelpers ) # Standard CMake module
444454
write_basic_package_version_file( "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake"

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,14 @@ enable_language ( Fortran )
138138
project ( jf_test NONE )
139139
140140
find_package ( jsonfortran-${CMAKE_Fortran_COMPILER_ID} 8.2.5 REQUIRED )
141-
include_directories ( "${jsonfortran_INCLUDE_DIRS}" )
142141
143142
file ( GLOB JF_TEST_SRCS "src/tests/jf_test_*.F90" )
144143
foreach ( UNIT_TEST ${JF_TEST_SRCS} )
145144
get_filename_component ( TEST ${UNIT_TEST} NAME_WE )
146145
add_executable ( ${TEST} ${UNIT_TEST} )
147-
target_link_libraries ( ${TEST} jsonfortran-static )
146+
target_link_libraries ( ${TEST} jsonfortran::jsonfortran-static )
148147
# or for linking against the dynamic/shared library:
149-
# target_link_libraries ( ${TEST} jsonfortran ) # instead
148+
# target_link_libraries ( ${TEST} jsonfortran::jsonfortran ) # instead
150149
endforeach()
151150
```
152151

0 commit comments

Comments
 (0)