Skip to content

Commit 6cbfbd4

Browse files
committed
[cmake] install headers with explicit list
1 parent 69ba17d commit 6cbfbd4

File tree

2 files changed

+107
-14
lines changed

2 files changed

+107
-14
lines changed

cmake/cctagHelper.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# Function for installing the library headers preserving the (sub)-folder structure.
3+
# Apparently this cannot be achieved by setting PUBLIC_HEADERS (https://gitlab.kitware.com/cmake/cmake/issues/17790)
4+
#
5+
# Usage:
6+
# cctag_install_headers(PUBLIC_HEADERS [item1...]
7+
# INSTALL_FOLDER export_name)
8+
#
9+
# PUBLIC_HEADERS The list of headers.
10+
# INSTALL_FOLDER The install folder.
11+
#
12+
function(cctag_install_headers)
13+
set(options "")
14+
set(singleValues INSTALL_FOLDER)
15+
set(multipleValues PUBLIC_HEADERS)
16+
cmake_parse_arguments(INSTALLHEADERS "${options}" "${singleValues}" "${multipleValues}" ${ARGN})
17+
18+
foreach(header ${INSTALLHEADERS_PUBLIC_HEADERS})
19+
get_filename_component(dir ${header} DIRECTORY)
20+
# message("${dir} -- ${header} -- ${INSTALLHEADERS_INSTALL_FOLDER}")
21+
install(FILES ${header} DESTINATION ${INSTALLHEADERS_INSTALL_FOLDER}/${dir})
22+
endforeach(header)
23+
24+
endfunction()

src/CMakeLists.txt

Lines changed: 83 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,58 @@ set( CCTag_cpp
3737
./cctag/utils/Talk.cpp
3838
./cctag/utils/VisualDebug.cpp)
3939

40+
set( CCTag_HEADERS
41+
./cctag/Bresenham.hpp
42+
./cctag/CCTag.hpp
43+
./cctag/CCTagFlowComponent.hpp
44+
./cctag/CCTagMarkersBank.hpp
45+
./cctag/Candidate.hpp
46+
./cctag/Canny.hpp
47+
./cctag/Colors.hpp
48+
./cctag/DataSerialization.hpp
49+
./cctag/Detection.hpp
50+
./cctag/EdgePoint.hpp
51+
./cctag/EllipseGrowing.hpp
52+
./cctag/Fitting.hpp
53+
./cctag/ICCTag.hpp
54+
./cctag/Identification.hpp
55+
./cctag/ImageCut.hpp
56+
./cctag/ImagePyramid.hpp
57+
./cctag/Level.hpp
58+
./cctag/Multiresolution.hpp
59+
./cctag/Params.hpp
60+
./cctag/Statistic.hpp
61+
./cctag/SubPixEdgeOptimizer.hpp
62+
./cctag/Types.hpp
63+
./cctag/Vote.hpp
64+
./cctag/algebra/matrix/Operation.hpp
65+
./cctag/filter/cvRecode.hpp
66+
./cctag/filter/thinning.hpp
67+
./cctag/geometry/2DTransform.hpp
68+
./cctag/geometry/Circle.hpp
69+
./cctag/geometry/Distance.hpp
70+
./cctag/geometry/Ellipse.hpp
71+
./cctag/geometry/EllipseFromPoints.hpp
72+
./cctag/geometry/Point.hpp
73+
./cctag/optimization/conditioner.hpp
74+
./cctag/utils/Debug.hpp
75+
./cctag/utils/Defines.hpp
76+
./cctag/utils/Exceptions.hpp
77+
./cctag/utils/FileDebug.hpp
78+
./cctag/utils/LogTime.hpp
79+
./cctag/utils/Release.hpp
80+
./cctag/utils/Singleton.hpp
81+
./cctag/utils/Talk.hpp
82+
./cctag/utils/VisualDebug.hpp
83+
./cctag/utils/pcg_extras.hpp
84+
./cctag/utils/pcg_random.hpp
85+
./cctag/utils/pcg_uint128.hpp
86+
)
87+
88+
set(CUDA_cpp "")
89+
set(CUDA_cu "")
90+
set(CUDA_HEADERS "")
91+
4092
if(CCTAG_WITH_CUDA)
4193

4294
set(CUDA_cpp
@@ -77,6 +129,34 @@ if(CCTAG_WITH_CUDA)
77129
./cctag/cuda/tag_threads.cu
78130
./cctag/cuda/triple_point.cu)
79131

132+
set(CUDA_HEADERS
133+
./cctag/cuda/assist.h
134+
./cctag/cuda/cctag_cuda_runtime.h
135+
./cctag/cuda/clamp.h
136+
./cctag/cuda/cmp_list.h
137+
./cctag/cuda/debug_image.h
138+
./cctag/cuda/debug_is_on_edge.h
139+
./cctag/cuda/debug_macros.hpp
140+
./cctag/cuda/device_prop.hpp
141+
./cctag/cuda/edge_list.h
142+
./cctag/cuda/frame.h
143+
./cctag/cuda/frame_07_vote.h
144+
./cctag/cuda/framemeta.h
145+
./cctag/cuda/frameparam.h
146+
./cctag/cuda/geom_ellipse.h
147+
./cctag/cuda/geom_matrix.h
148+
./cctag/cuda/keep_time.hpp
149+
./cctag/cuda/nearby_point.h
150+
./cctag/cuda/onoff.h
151+
./cctag/cuda/pinned_counters.h
152+
./cctag/cuda/ptrstep.h
153+
./cctag/cuda/recursive_sweep.h
154+
./cctag/cuda/tag.h
155+
./cctag/cuda/tag_cut.h
156+
./cctag/cuda/tag_threads.h
157+
./cctag/cuda/triple_point.h
158+
)
159+
80160

81161
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-DCUB_CDP")
82162

@@ -125,8 +205,6 @@ if(CCTAG_WITH_CUDA)
125205

126206
else() # without CUDA
127207

128-
set(CUDA_cpp "")
129-
130208
message( STATUS "Declare CCTag library" )
131209
add_library(CCTag ${CCTag_cpp})
132210
set_target_properties(CCTag PROPERTIES VERSION ${PROJECT_VERSION})
@@ -235,18 +313,9 @@ install(TARGETS CCTag
235313
INCLUDES DESTINATION "${include_install_dir}")
236314

237315
# Headers:
238-
239-
240-
if(CCTAG_WITH_CUDA)
241-
install(DIRECTORY "cctag"
242-
DESTINATION "${include_install_dir}"
243-
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h")
244-
else()
245-
install(DIRECTORY "cctag"
246-
DESTINATION "${include_install_dir}"
247-
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h"
248-
PATTERN "cuda/*" EXCLUDE)
249-
endif()
316+
include(cctagHelper)
317+
cctag_install_headers(PUBLIC_HEADERS ${CCTag_HEADERS} ${CUDA_HEADERS}
318+
INSTALL_FOLDER ${include_install_dir})
250319

251320
# install the config and version generated files
252321
install( FILES "${cctag_config_header_name}"

0 commit comments

Comments
 (0)