Skip to content

Commit

Permalink
Merge pull request #100 from ZedThree/export-targets
Browse files Browse the repository at this point in the history
Export CMake targets so build directory can be used directly
  • Loading branch information
WardF authored Jan 5, 2021
2 parents c244f2d + ad3e509 commit 162d78a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 12 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,10 @@ INSTALL(PROGRAMS ${NCXX_BINARY_DIR}/ncxx4-config
#####
# Build test_common.sh
#####
SET(EXTRA_DIST ${EXTRA_DIST} ${CMAKE_SOURCE_DIR}/test_common.in)
SET(TOPSRCDIR "${CMAKE_SOURCE_DIR}")
SET(TOPBUILDDIR "${CMAKE_BINARY_DIR}")
configure_file(${CMAKE_SOURCE_DIR}/test_common.in ${CMAKE_BINARY_DIR}/test_common.sh @ONLY NEWLINE_STYLE LF)
SET(EXTRA_DIST ${EXTRA_DIST} ${CMAKE_CURRENT_SOURCE_DIR}/test_common.in)
SET(TOPSRCDIR "${CMAKE_CURRENT_SOURCE_DIR}")
SET(TOPBUILDDIR "${CMAKE_CURRENT_BINARY_DIR}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_common.in ${CMAKE_CURRENT_BINARY_DIR}/test_common.sh @ONLY NEWLINE_STYLE LF)

#####
# Options
Expand All @@ -646,6 +646,12 @@ install(
DESTINATION ${ConfigPackageLocation}
)

export(
EXPORT netcdf-cxx4Targets
FILE netcdf-cxx4Targets.cmake
NAMESPACE netCDF::
)

configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/netCDFCxxConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/netCDFCxxConfig.cmake"
Expand All @@ -666,8 +672,8 @@ IF(NC_HAS_DEF_VAR_FILTER)
# Build cxx4/findplugin.sh
#####
SET(ISCMAKE "1")
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cxx4/findplugin.in ${CMAKE_BINARY_DIR}/cxx4/findplugin.sh @ONLY NEWLINE_STYLE LF)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/examples/findplugin.in ${CMAKE_BINARY_DIR}/examples/findplugin.sh @ONLY NEWLINE_STYLE LF)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cxx4/findplugin.in ${CMAKE_CURRENT_BINARY_DIR}/cxx4/findplugin.sh @ONLY NEWLINE_STYLE LF)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/examples/findplugin.in ${CMAKE_CURRENT_BINARY_DIR}/examples/findplugin.sh @ONLY NEWLINE_STYLE LF)

ADD_SUBDIRECTORY(plugins)
ENDIF(NC_HAS_DEF_VAR_FILTER)
Expand Down
1 change: 1 addition & 0 deletions cxx4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SET(ALL_TLL_LIBS ${HDF5_C_LIBRARY_hdf5})
SET(ALL_TLL_LIBS ${ALL_TLL_LIBS} ${EXTRA_DEPS} PARENT_SCOPE)

ADD_LIBRARY(netcdf-cxx4 ${CXX_SOURCES})
add_library(netCDF::netcdf-cxx4 ALIAS netcdf-cxx4)

TARGET_INCLUDE_DIRECTORIES(netcdf-cxx4 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
Expand Down

0 comments on commit 162d78a

Please sign in to comment.