Skip to content

Commit

Permalink
fix(cpp-client): deephavenConfig.cmake provides transitive dependenci…
Browse files Browse the repository at this point in the history
…es (deephaven#5792)

I modified the deephaven_enterprise C++ client cmake code to remove the
explicit requirements for dependencies that are only transitive and
PRIVATE from deephaven (core) C++ client cmake (eg, Immer). The new
config file allowed those to be removed in the DHE side.

The new code in the toplevel CMakeLists.txt for deephaven was inspired
by the cmake doc here:

https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-packages
and

https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-a-package-configuration-file
  • Loading branch information
jcferretti authored Jul 18, 2024
1 parent d9d1b71 commit f52012e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 10 deletions.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ mention the version explicitly. These files are listed below:
#
gradle.properties
R/rdeephaven/DESCRIPTION
cpp-client/deephaven/CMakeLists.txt
```

This leaves the files "ready" for the next regular release, and also ensures any build done from
Expand Down
2 changes: 2 additions & 0 deletions cpp-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def buildCppClientImage = Docker.registerDockerTask(project, 'cppClient') {
include 'cpp-tests-to-junit.sh'
include 'build-dependencies.sh'
include 'deephaven/CMakeLists.txt'
include 'deephaven/cmake/**'
include 'deephaven/dhcore/**'
include 'deephaven/dhclient/**'
include 'deephaven/examples/**'
Expand All @@ -87,6 +88,7 @@ def buildCppClientImage = Docker.registerDockerTask(project, 'cppClient') {
${prefix}/log
""")
copyFile('deephaven/CMakeLists.txt', "${prefix}/src/deephaven/")
copyFile('deephaven/cmake/', "${prefix}/src/deephaven/cmake/")
copyFile('deephaven/dhcore/', "${prefix}/src/deephaven/dhcore/")
copyFile('deephaven/dhclient/', "${prefix}/src/deephaven/dhclient/")
copyFile('deephaven/examples/', "${prefix}/src/deephaven/examples/")
Expand Down
38 changes: 35 additions & 3 deletions cpp-client/deephaven/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ endif()

project(deephaven)

set(deephaven_VERSION 0.36.0)
set(CMAKE_CXX_STANDARD 17)

# for CMAKE_INSTALL_{dir}
Expand Down Expand Up @@ -40,15 +41,46 @@ if(NOT DHCORE_ONLY)
)

install(TARGETS dhclient dhcore dhcore_static dhclient_tests
EXPORT deephavenConfig
EXPORT deephavenTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(EXPORT deephavenConfig
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/deephaven
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/deephaven/deephavenConfigVersion.cmake"
VERSION ${deephaven_VERSION}
COMPATIBILITY AnyNewerVersion
)

export(EXPORT deephavenTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/deephaven/deephavenTargets.cmake"
NAMESPACE deephaven::
)
configure_file(cmake/deephavenConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/deephaven/deephavenConfig.cmake"
COPYONLY
)

set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/deephaven)
install(EXPORT deephavenTargets
FILE
deephavenTargets.cmake
NAMESPACE
deephaven::
DESTINATION
${ConfigPackageLocation}
)
install(
FILES
cmake/deephavenConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/deephaven/deephavenConfigVersion.cmake"
DESTINATION
${ConfigPackageLocation}
COMPONENT
Devel
)

endif()
9 changes: 9 additions & 0 deletions cpp-client/deephaven/cmake/deephavenConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include(CMakeFindDependencyMacro)
find_dependency(Arrow 16.0.0)
find_dependency(ArrowFlight 16.0.0)
find_dependency(Immer)
find_dependency(Protobuf)
find_dependency(gRPC 1.63.0)
find_dependency(Threads)

include("${CMAKE_CURRENT_LIST_DIR}/deephavenTargets.cmake")
9 changes: 4 additions & 5 deletions cpp-client/deephaven/dhclient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include(GNUInstallDirs)

find_package(Arrow CONFIG REQUIRED)
find_package(ArrowFlight CONFIG REQUIRED HINTS ${Arrow_DIR})
find_package(Immer REQUIRED)
find_package(Immer CONFIG REQUIRED)
find_package(Protobuf CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)
find_package(Threads REQUIRED)
Expand Down Expand Up @@ -133,7 +133,6 @@ target_link_libraries(dhclient PUBLIC deephaven::dhcore)

target_link_libraries(dhclient PUBLIC ArrowFlight::arrow_flight_shared)
target_link_libraries(dhclient PUBLIC Arrow::arrow_shared)
target_link_libraries(dhclient PUBLIC immer)
target_link_libraries(dhclient PUBLIC protobuf::libprotobuf)
target_link_libraries(dhclient PUBLIC gRPC::grpc++)
target_link_libraries(dhclient PUBLIC Threads::Threads)
target_link_libraries(dhclient PRIVATE protobuf::libprotobuf)
target_link_libraries(dhclient PRIVATE gRPC::grpc++)
target_link_libraries(dhclient PRIVATE Threads::Threads)
4 changes: 2 additions & 2 deletions cpp-client/deephaven/dhcore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD 17)
# for CMAKE_INSTALL_{dir}
include(GNUInstallDirs)

find_package(Immer REQUIRED)
find_package(Immer CONFIG REQUIRED)

set(ALL_FILES
src/types.cc
Expand Down Expand Up @@ -142,5 +142,5 @@ foreach (whichlib dhcore dhcore_static)
target_include_directories(${whichlib} PRIVATE flatbuf)
target_include_directories(${whichlib} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/public>)

target_link_libraries(${whichlib} PUBLIC immer)
target_link_libraries(${whichlib} PRIVATE immer)
endforeach()

0 comments on commit f52012e

Please sign in to comment.