Commit bdbedcf1 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'fix-install-for-object-libs'

b61faf89 Fix install rules and usage requirements for interface+object libs
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !42
parents b90172c5 b61faf89
......@@ -28,14 +28,13 @@
# requirements.
# ${KWSYS_NAMESPACE}_objects
# - An OBJECT library for the built kwsys objects.
# Note: This is omitted from the install rules
# ${KWSYS_NAMESPACE}_private
# - An INTERFACE library combining both that is
# appropriate for use with PRIVATE linking in
# target_link_libraries. Because of how interface
# properties propagate, this target is not suitable
# for use with PUBLIC or INTERFACE linking.
# Note: only the ${KWSYS_NAMESPACE} library will be
# installed
#
# Example:
#
......@@ -819,6 +818,7 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
SET(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE})
SET(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE}_objects)
SET(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE}_private)
SET(KWSYS_TARGET_INSTALL ${KWSYS_TARGET_INTERFACE} ${KWSYS_TARGET_LINK})
SET(KWSYS_LINK_DEPENDENCY INTERFACE)
ADD_LIBRARY(${KWSYS_TARGET_OBJECT} OBJECT
${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
......@@ -836,6 +836,7 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
SET(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE})
SET(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE})
SET(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE})
set(KWSYS_TARGET_INSTALL ${KWSYS_TARGET_LINK})
SET(KWSYS_LINK_DEPENDENCY PUBLIC)
ADD_LIBRARY(${KWSYS_TARGET_INTERFACE} ${KWSYS_LIBRARY_TYPE}
${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
......@@ -887,12 +888,16 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
# Set up include usage requirement
IF(COMMAND TARGET_INCLUDE_DIRECTORIES)
TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_INTERFACE} INTERFACE
${CMAKE_CURRENT_BINARY_DIR})
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
IF(KWSYS_INSTALL_INCLUDE_DIR)
TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_INTERFACE} INTERFACE
$<INSTALL_INTERFACE:${KWSYS_INSTALL_INCLUDE_DIR}>)
ENDIF()
ENDIF()
# Create an install target for the library.
IF(KWSYS_INSTALL_LIBRARY_RULE)
INSTALL(TARGETS ${KWSYS_TARGET_INTERFACE} ${KWSYS_INSTALL_LIBRARY_RULE})
INSTALL(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_LIBRARY_RULE})
ENDIF()
ENDIF()
......@@ -902,6 +907,8 @@ IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
SET(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c)
SET(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c_objects)
SET(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c_private)
SET(KWSYS_TARGET_C_INSTALL
${KWSYS_TARGET_C_INTERFACE} ${KWSYS_TARGET_C_LINK})
SET(KWSYS_LINK_DEPENDENCY INTERFACE)
ADD_LIBRARY(${KWSYS_TARGET_C_OBJECT} OBJECT ${KWSYS_C_SRCS})
IF(KWSYS_BUILD_SHARED)
......@@ -918,6 +925,7 @@ IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
SET(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c)
SET(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c)
SET(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c)
SET(KWSYS_TARGET_C_INSTALL ${KWSYS_TARGET_C_LINK})
SET(KWSYS_LINK_DEPENDENCY PUBLIC)
ADD_LIBRARY(${KWSYS_TARGET_C_INTERFACE} ${KWSYS_LIBRARY_TYPE}
${KWSYS_C_SRCS})
......@@ -931,10 +939,20 @@ IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
${KWSYS_PROPERTIES_C})
ENDIF()
# Set up include usage requirement
IF(COMMAND TARGET_INCLUDE_DIRECTORIES)
TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_C_INTERFACE} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
IF(KWSYS_INSTALL_INCLUDE_DIR)
TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_C_INTERFACE} INTERFACE
$<INSTALL_INTERFACE:${KWSYS_INSTALL_INCLUDE_DIR}>)
ENDIF()
ENDIF()
# Create an install target for the library.
IF(KWSYS_INSTALL_LIBRARY_RULE)
INSTALL(TARGETS ${KWSYS_TARGET_C_INTERFACE} ${KWSYS_INSTALL_LIBRARY_RULE})
ENDIF()
INSTALL(TARGETS ${KWSYS_TARGET_C_INSTALL})
ENDIF()
ENDIF()
# For building kwsys itself, we use a macro defined on the command
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment