Fix target include dirs

* Add include path of own header files for build
  and external use via imported target. Previously
  only include dirs required for external libs were
  added.
* Using global include dirs is no longer required.
* When PUBLIC_SHARED_INCLUDE_DIRS is empty, adding
  "${PUBLIC_SHARED_INCLUDE_DIRS}" to public include dirs
  does not leave INTERFACE_INCLUDE_DIRECTORIES property
  empty. Instead the source dir is added. So just don't
  use quotes here.
testing/bash_completion_debugging v4.9.0
Martchus 5 years ago
parent 99cc68bdee
commit 942c14ce3d
  1. 8
      cmake/modules/AppTarget.cmake
  2. 26
      cmake/modules/LibraryTarget.cmake
  3. 16
      cmake/modules/TestTarget.cmake
  4. 2
      cmake/templates/Config.cmake.in

@ -43,8 +43,12 @@ target_link_libraries(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
PRIVATE "${PRIVATE_LIBRARIES}"
)
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
PUBLIC "${PUBLIC_SHARED_INCLUDE_DIRS}"
PRIVATE "${PRIVATE_SHARED_INCLUDE_DIRS}"
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}>
${PUBLIC_SHARED_INCLUDE_DIRS}
PRIVATE
"${PRIVATE_SHARED_INCLUDE_DIRS}"
)
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
PUBLIC "${META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS}"

@ -125,7 +125,10 @@ if(BUILD_SHARED_LIBS)
INTERFACE ${ACTUAL_ADDITIONAL_LINK_FLAGS} "${PUBLIC_LIBRARIES}" "${PRIVATE_LIBRARIES}"
)
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
INTERFACE "${PUBLIC_SHARED_INCLUDE_DIRS}" "${PRIVATE_SHARED_INCLUDE_DIRS}"
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}>
${PUBLIC_SHARED_INCLUDE_DIRS}
)
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
INTERFACE "${META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS}" "${META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS}"
@ -140,8 +143,12 @@ if(BUILD_SHARED_LIBS)
PRIVATE "${PRIVATE_LIBRARIES}"
)
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
PUBLIC "${PUBLIC_SHARED_INCLUDE_DIRS}"
PRIVATE "${PRIVATE_SHARED_INCLUDE_DIRS}"
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}>
${PUBLIC_SHARED_INCLUDE_DIRS}
PRIVATE
"${PRIVATE_SHARED_INCLUDE_DIRS}"
)
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
PUBLIC "${META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS}"
@ -176,7 +183,10 @@ if(BUILD_STATIC_LIBS)
INTERFACE ${ACTUAL_ADDITIONAL_LINK_FLAGS} "${PUBLIC_STATIC_LIBRARIES}" "${PRIVATE_STATIC_LIBRARIES}"
)
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_static
INTERFACE "${PUBLIC_STATIC_INCLUDE_DIRS}" "${PRIVATE_STATIC_INCLUDE_DIRS}"
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}>
${PUBLIC_STATIC_INCLUDE_DIRS}
)
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_static
INTERFACE "${META_PUBLIC_STATIC_LIB_COMPILE_DEFINITIONS}" "${META_PRIVATE_STATIC_LIB_COMPILE_DEFINITIONS}"
@ -191,8 +201,12 @@ if(BUILD_STATIC_LIBS)
PRIVATE "${PRIVATE_STATIC_LIBRARIES}"
)
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_static
PUBLIC "${PUBLIC_STATIC_INCLUDE_DIRS}"
PRIVATE "${PRIVATE_STATIC_INCLUDE_DIRS}"
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}>
${PUBLIC_STATIC_INCLUDE_DIRS}
PRIVATE
"${PRIVATE_STATIC_INCLUDE_DIRS}"
)
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_static
PUBLIC "${META_PUBLIC_STATIC_LIB_COMPILE_DEFINITIONS}"

@ -74,6 +74,14 @@ if(CPP_UNIT_LIB OR META_NO_CPP_UNIT)
PUBLIC ${ACTUAL_ADDITIONAL_LINK_FLAGS} "${PUBLIC_LIBRARIES}"
PRIVATE "${PRIVATE_LIBRARIES}"
)
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_testlib
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}>
${PUBLIC_SHARED_INCLUDE_DIRS}
PRIVATE
"${PRIVATE_SHARED_INCLUDE_DIRS}"
)
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_testlib
PUBLIC "${META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS}"
PRIVATE "${META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS}"
@ -109,8 +117,12 @@ if(CPP_UNIT_LIB OR META_NO_CPP_UNIT)
PRIVATE "${TEST_LIBRARIES}" "${PRIVATE_LIBRARIES}"
)
target_include_directories(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests
PUBLIC "${PUBLIC_SHARED_INCLUDE_DIRS}"
PRIVATE "${PRIVATE_SHARED_INCLUDE_DIRS}"
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${HEADER_INSTALL_DESTINATION}>
${PUBLIC_SHARED_INCLUDE_DIRS}
PRIVATE
"${PRIVATE_SHARED_INCLUDE_DIRS}"
)
target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests
PUBLIC "${META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS}"

@ -63,8 +63,6 @@ endif()
macro(use_@META_PROJECT_VARNAME@)
# make CMake modules of the project available
list(APPEND CMAKE_MODULE_PATH ${@META_PROJECT_VARNAME_UPPER@_MODULE_DIRS})
# add include directories
include_directories(BEFORE SYSTEM ${@META_PROJECT_VARNAME_UPPER@_INCLUDE_DIRS})
# link against library (also "link" against header-only libs to get compile defs and interface link libs)
link_directories(${@META_PROJECT_VARNAME_UPPER@_LIB_DIR})
include(3rdParty)

Loading…
Cancel
Save