Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cmake exported targets #206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 3.14.0)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

project(geometry-central)
set(PROJECT_VERSION 0.1.0)

### Policy settings
cmake_policy(SET CMP0054 NEW) # don't implicitly dereference inside if()
Expand Down Expand Up @@ -51,15 +54,16 @@ SET(GC_HAVE_SUITESPARSE ${GC_HAVE_SUITESPARSE} PARENT_SCOPE)
add_subdirectory(src)

# install
install(
TARGETS geometry-central
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib)

configure_package_config_file(geometry-central-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/geometry-central-config.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/geometry-central/cmake)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/geometry-centralConfigVersion.cmake COMPATIBILITY SameMajorVersion)
install(TARGETS geometry-central eigen nanort nanoflann happly EXPORT geometry-central-targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

install(EXPORT geometry-central-targets FILE geometry-centralTargets.cmake DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/geometry-central/cmake)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/geometry-central-config.cmake DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/geometry-central/cmake)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include/
DESTINATION include
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.ipp")
3 changes: 3 additions & 0 deletions geometry-central-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@PACKAGE_INIT@
get_filename_component(LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
include(${LIST_DIR}/@[email protected])
5 changes: 4 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ SET(HEADERS
add_library(geometry-central ${SRCS} ${HEADERS})

# Includes from this project
target_include_directories(geometry-central PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../include")
target_include_directories(geometry-central PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
)

# Add all includes and link libraries from dependencies, which were populated in deps/CMakeLists.txt
target_link_libraries(geometry-central PUBLIC ${GC_DEP_LIBS})
Expand Down