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

Enable static targets #52

Merged
merged 2 commits into from
Sep 9, 2024
Merged
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
34 changes: 15 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -461,20 +461,18 @@ include(CMakePackageConfigHelpers)
set(XVEGA_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE STRING "install path for xvegaConfig.cmake")

# Install xvega
if (XVEGA_BUILD_SHARED OR XVEGA_BUILD_STATIC)
install(TARGETS ${XVEGA_TARGETS}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# This guarantees the headers' folders won't be flatten when
# installed
install(DIRECTORY ${XVEGA_INCLUDE_DIR}/xvega
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Makes the project importable from the build directory
export(EXPORT ${PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
endif ()
install(TARGETS ${XVEGA_TARGETS}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# This guarantees the headers' folders won't be flatten when
# installed
install(DIRECTORY ${XVEGA_INCLUDE_DIR}/xvega
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Makes the project importable from the build directory
export(EXPORT ${PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")

# Configure 'xvegaConfig.cmake' for a build tree
set(XVEGA_CONFIG_CODE "####### Expanded from \@XVEGA_CONFIG_CODE\@ #######\n")
Expand Down Expand Up @@ -503,8 +501,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${XVEGA_CMAKECONFIG_INSTALL_DIR})

if (XVEGA_BUILD_SHARED)
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}Targets.cmake
DESTINATION ${XVEGA_CMAKECONFIG_INSTALL_DIR})
endif ()
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}Targets.cmake
DESTINATION ${XVEGA_CMAKECONFIG_INSTALL_DIR})
12 changes: 10 additions & 2 deletions xvegaConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ find_dependency(xproperty @xproperty_REQUIRED_VERSION@)

if(NOT TARGET @PROJECT_NAME@)
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
get_target_property(@PROJECT_NAME@_INCLUDE_DIR @PROJECT_NAME@ INTERFACE_INCLUDE_DIRECTORIES)

if (TARGET xvega-static)
if (TARGET xvega AND xvega-static)
get_target_property(@PROJECT_NAME@_INCLUDE_DIR xvega INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(@PROJECT_NAME@_LIBRARY xvega LOCATION)
get_target_property(@PROJECT_NAME@_STATIC_LIBRARY xvega-static LOCATION)
elseif (TARGET xvega)
get_target_property(@PROJECT_NAME@_INCLUDE_DIR xvega INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(@PROJECT_NAME@_LIBRARY xvega LOCATION)
elseif (TARGET xvega-static)
get_target_property(@PROJECT_NAME@_INCLUDE_DIR xvega-static INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(@PROJECT_NAME@_STATIC_LIBRARY xvega-static LOCATION)
endif ()

endif()

set(@PROJECT_NAME@_LIBRARY "")