Skip to content

Commit

Permalink
Merge pull request #52 from IsabelParedes/static
Browse files Browse the repository at this point in the history
Enable static targets
  • Loading branch information
IsabelParedes authored Sep 9, 2024
2 parents 45dc81f + 6784c1b commit ad372ff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
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}/@PROJECT_NAME@Targets.cmake")
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 "")

0 comments on commit ad372ff

Please sign in to comment.