Skip to content

Commit

Permalink
Export CMake targets
Browse files Browse the repository at this point in the history
This exports both the shared and static library targets. A downstream
project can use then use them as follows:

```cmake
find_package(NuRaft REQUIRED)
target_link_libraries(downstream_target PRIVATE NuRaft::static_lib)
```

Closes #450
  • Loading branch information
JosiahWI committed Jul 19, 2023
1 parent bb890f2 commit 9d72d13
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
23 changes: 20 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,25 @@ endif()


# === Install Targets ===
install(TARGETS static_lib ARCHIVE DESTINATION lib)
install(TARGETS shared_lib LIBRARY DESTINATION lib)
install(TARGETS shared_lib static_lib
EXPORT nuraft-targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libnuraft DESTINATION include)


install(EXPORT nuraft-targets
FILE NuRaftTargets.cmake
NAMESPACE NuRaft::
DESTINATION lib/cmake/NuRaft
)

include(CMakePackageConfigHelpers)
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/NuRaftConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/NuRaftConfig.cmake"
INSTALL_DESTINATION lib/cmake/NuRaft
)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/NuRaftConfig.cmake"
DESTINATION lib/cmake/NuRaft
)
11 changes: 11 additions & 0 deletions NuRaftConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

set(DISABLE_OPENSSL @DISABLE_OPENSSL@)

if (NOT DISABLE_OPENSSL)
find_dependency(OpenSSL)
endif ()

include("${CMAKE_CURRENT_LIST_DIR}/NuRaftTargets.cmake")

0 comments on commit 9d72d13

Please sign in to comment.