Skip to content

Commit 56487fd

Browse files
committed
Support header only libraries like 2d and geometry.
1 parent abeac82 commit 56487fd

3 files changed

Lines changed: 38 additions & 27 deletions

File tree

2d/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ set(impl_incs
3030
)
3131

3232
set(LIB_NAME "pcl_${SUBSYS_NAME}")
33+
PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME})
3334
PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSYS_NAME} DESC ${SUBSYS_DESC} PCL_DEPS ${SUBSYS_DEPS} HEADER_ONLY)
3435

3536
#Install include files

cmake/pcl_targets.cmake

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -192,38 +192,49 @@ function(PCL_ADD_LIBRARY _name)
192192
message(FATAL_ERROR "PCL_ADD_LIBRARY requires parameter COMPONENT.")
193193
endif()
194194

195-
add_library(${_name} ${PCL_LIB_TYPE} ${ARGS_SOURCES})
196-
PCL_ADD_VERSION_INFO(${_name})
197-
target_compile_features(${_name} PUBLIC ${PCL_CXX_COMPILE_FEATURES})
195+
if(NOT ARGS_SOURCES)
196+
add_library(${_name} INTERFACE)
197+
198+
target_include_directories(${_name} INTERFACE
199+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
200+
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_ROOT}>
201+
)
198202

199-
target_include_directories(${_name} PUBLIC
200-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
201-
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_ROOT}>
202-
)
203+
else()
204+
add_library(${_name} ${PCL_LIB_TYPE} ${ARGS_SOURCES})
205+
PCL_ADD_VERSION_INFO(${_name})
206+
target_compile_features(${_name} PUBLIC ${PCL_CXX_COMPILE_FEATURES})
207+
208+
target_include_directories(${_name} PUBLIC
209+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
210+
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_ROOT}>
211+
)
212+
213+
target_link_libraries(${_name} Threads::Threads)
214+
if(TARGET OpenMP::OpenMP_CXX)
215+
target_link_libraries(${_name} OpenMP::OpenMP_CXX)
216+
endif()
203217

204-
target_link_libraries(${_name} Threads::Threads)
205-
if(TARGET OpenMP::OpenMP_CXX)
206-
target_link_libraries(${_name} OpenMP::OpenMP_CXX)
207-
endif()
218+
if((UNIX AND NOT ANDROID) OR MINGW)
219+
target_link_libraries(${_name} m ${ATOMIC_LIBRARY})
220+
endif()
208221

209-
if((UNIX AND NOT ANDROID) OR MINGW)
210-
target_link_libraries(${_name} m ${ATOMIC_LIBRARY})
211-
endif()
222+
if(MINGW)
223+
target_link_libraries(${_name} gomp)
224+
endif()
212225

213-
if(MINGW)
214-
target_link_libraries(${_name} gomp)
215-
endif()
226+
if(MSVC)
227+
target_link_libraries(${_name} delayimp.lib) # because delay load is enabled for openmp.dll
228+
endif()
229+
230+
set_target_properties(${_name} PROPERTIES
231+
VERSION ${PCL_VERSION}
232+
SOVERSION ${PCL_VERSION_MAJOR}.${PCL_VERSION_MINOR}
233+
DEFINE_SYMBOL "PCLAPI_EXPORTS")
216234

217-
if(MSVC)
218-
target_link_libraries(${_name} delayimp.lib) # because delay load is enabled for openmp.dll
235+
set_target_properties(${_name} PROPERTIES FOLDER "Libraries")
219236
endif()
220237

221-
set_target_properties(${_name} PROPERTIES
222-
VERSION ${PCL_VERSION}
223-
SOVERSION ${PCL_VERSION_MAJOR}.${PCL_VERSION_MINOR}
224-
DEFINE_SYMBOL "PCLAPI_EXPORTS")
225-
set_target_properties(${_name} PROPERTIES FOLDER "Libraries")
226-
227238
install(TARGETS ${_name}
228239
RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT pcl_${ARGS_COMPONENT}
229240
LIBRARY DESTINATION ${LIB_INSTALL_DIR} COMPONENT pcl_${ARGS_COMPONENT}

geometry/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ set(impl_incs
3737

3838

3939
set(LIB_NAME "pcl_${SUBSYS_NAME}")
40-
41-
add_library(${LIB_NAME} INTERFACE)
40+
PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME})
4241
target_link_libraries(${LIB_NAME} INTERFACE Boost::boost pcl_common)
4342

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

0 commit comments

Comments
 (0)