Skip to content

Commit

Permalink
Support header only libraries like 2d and geometry.
Browse files Browse the repository at this point in the history
  • Loading branch information
larshg committed Apr 22, 2024
1 parent abeac82 commit 56487fd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
1 change: 1 addition & 0 deletions 2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ set(impl_incs
)

set(LIB_NAME "pcl_${SUBSYS_NAME}")
PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME})
PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSYS_NAME} DESC ${SUBSYS_DESC} PCL_DEPS ${SUBSYS_DEPS} HEADER_ONLY)

#Install include files
Expand Down
61 changes: 36 additions & 25 deletions cmake/pcl_targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -192,38 +192,49 @@ function(PCL_ADD_LIBRARY _name)
message(FATAL_ERROR "PCL_ADD_LIBRARY requires parameter COMPONENT.")
endif()

add_library(${_name} ${PCL_LIB_TYPE} ${ARGS_SOURCES})
PCL_ADD_VERSION_INFO(${_name})
target_compile_features(${_name} PUBLIC ${PCL_CXX_COMPILE_FEATURES})
if(NOT ARGS_SOURCES)
add_library(${_name} INTERFACE)

target_include_directories(${_name} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_ROOT}>
)

target_include_directories(${_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_ROOT}>
)
else()
add_library(${_name} ${PCL_LIB_TYPE} ${ARGS_SOURCES})
PCL_ADD_VERSION_INFO(${_name})
target_compile_features(${_name} PUBLIC ${PCL_CXX_COMPILE_FEATURES})

target_include_directories(${_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_ROOT}>
)

target_link_libraries(${_name} Threads::Threads)
if(TARGET OpenMP::OpenMP_CXX)
target_link_libraries(${_name} OpenMP::OpenMP_CXX)
endif()

target_link_libraries(${_name} Threads::Threads)
if(TARGET OpenMP::OpenMP_CXX)
target_link_libraries(${_name} OpenMP::OpenMP_CXX)
endif()
if((UNIX AND NOT ANDROID) OR MINGW)
target_link_libraries(${_name} m ${ATOMIC_LIBRARY})
endif()

if((UNIX AND NOT ANDROID) OR MINGW)
target_link_libraries(${_name} m ${ATOMIC_LIBRARY})
endif()
if(MINGW)
target_link_libraries(${_name} gomp)
endif()

if(MINGW)
target_link_libraries(${_name} gomp)
endif()
if(MSVC)
target_link_libraries(${_name} delayimp.lib) # because delay load is enabled for openmp.dll
endif()

set_target_properties(${_name} PROPERTIES
VERSION ${PCL_VERSION}
SOVERSION ${PCL_VERSION_MAJOR}.${PCL_VERSION_MINOR}
DEFINE_SYMBOL "PCLAPI_EXPORTS")

if(MSVC)
target_link_libraries(${_name} delayimp.lib) # because delay load is enabled for openmp.dll
set_target_properties(${_name} PROPERTIES FOLDER "Libraries")
endif()

set_target_properties(${_name} PROPERTIES
VERSION ${PCL_VERSION}
SOVERSION ${PCL_VERSION_MAJOR}.${PCL_VERSION_MINOR}
DEFINE_SYMBOL "PCLAPI_EXPORTS")
set_target_properties(${_name} PROPERTIES FOLDER "Libraries")

install(TARGETS ${_name}
RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT pcl_${ARGS_COMPONENT}
LIBRARY DESTINATION ${LIB_INSTALL_DIR} COMPONENT pcl_${ARGS_COMPONENT}
Expand Down
3 changes: 1 addition & 2 deletions geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ set(impl_incs


set(LIB_NAME "pcl_${SUBSYS_NAME}")

add_library(${LIB_NAME} INTERFACE)
PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME})
target_link_libraries(${LIB_NAME} INTERFACE Boost::boost pcl_common)

PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSYS_NAME} DESC ${SUBSYS_DESC} PCL_DEPS ${SUBSYS_DEPS} HEADER_ONLY)
Expand Down

0 comments on commit 56487fd

Please sign in to comment.