Skip to content

Commit 443aa83

Browse files
committed
Export include directories with target
- add BUILD_INTERFACE for finding modules in build directory - add INSTALL_INTERFACE to associate include directory with target - add namespace to exported target - jsonfortran::jsonfortran target instead of jsonfortran - jsonfortran::jsonfortran-static target instead of jsonfortran-static
1 parent 77c9f99 commit 443aa83

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
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:${CMAKE_CURRENT_BINARY_DIR}/include>
183+
$<INSTALL_INTERFACE:${INSTALL_MOD_DIR}>)
184+
target_include_directories(${LIB_NAME}-static
185+
PUBLIC
186+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
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"

0 commit comments

Comments
 (0)