CMakeLists.txt 10.2 KB
Newer Older
1
#
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#  _______ _    _ _____  _____     _____  _____                 
# |__   __| |  | |_   _|/ ____|   |_   _|/ ____|       /\       
#    | |  | |__| | | | | (___       | | | (___        /  \      
#    | |  |  __  | | |  \___ \      | |  \___ \      / /\ \     
#    | |  | |  | |_| |_ ____) |    _| |_ ____) |    / ____ \    
#    |_|__|_|_ |_|_____|_____/__  |_____|_____/    /_/  _ \_\   
#   |__   __| |  | |__   __/ __ \|  __ \|_   _|   /\   | |      
#      | |  | |  | |  | | | |  | | |__) | | |    /  \  | |      
#      | |  | |  | |  | | | |  | |  _  /  | |   / /\ \ | |      
#      | |  | |__| |  | | | |__| | | \ \ _| |_ / ____ \| |____  
#      |_|   \____/   |_|  \____/|_|  \_\_____/_/    \_\______| 
#
#
#    _____  ______          _____      _______ _    _ ______       
#   |  __ \|  ____|   /\   |  __ \    |__   __| |  | |  ____|      
#   | |__) | |__     /  \  | |  | |      | |  | |__| | |__         
#   |  _  /|  __|   / /\ \ | |  | |      | |  |  __  |  __|        
#   | | \ \| |____ / ____ \| |__| |      | |  | |  | | |____       
#   |_|__\_\______/_/_ __\_\_____/__ _   |_|__|_|_ |_|______|_ _ _ 
#  / ____/ __ \|  \/  |  \/  |  ____| \ | |__   __/ ____| | | | | |
# | |   | |  | | \  / | \  / | |__  |  \| |  | | | (___   | | | | |
# | |   | |  | | |\/| | |\/| |  __| | . ` |  | |  \___ \  | | | | |
# | |___| |__| | |  | | |  | | |____| |\  |  | |  ____) | |_|_|_|_|
#  \_____\____/|_|  |_|_|  |_|______|_| \_|  |_| |_____/  (_|_|_|_)
#                                                                  
#
#
# This is a CMake makefile.  CMake is a tool that helps you build C++ programs.
# You can download CMake from http://www.cmake.org.  This CMakeLists.txt file
# you are reading builds dlib's example programs. 
32
33
34
#


35
cmake_minimum_required(VERSION 2.8.12)
36
37
# Every project needs a name.  We call this the "examples" project.
project(examples)
38

39

40
41
# Tell cmake we will need dlib.  This command will pull in dlib and compile it
# into your project.  Note that you don't need to compile or install dlib.  All
Davis King's avatar
Davis King committed
42
# cmake needs is the dlib source code folder and it will take care of everything.
43
add_subdirectory(../dlib dlib_build)
44

Davis King's avatar
Davis King committed
45
# If you have cmake 3.14 or newer you can even use FetchContent instead of
46
47
48
49
50
51
52
53
54
55
# add_subdirectory() to pull in dlib as a dependency.  So instead of using the
# above add_subdirectory() command, you could use the following three commands
# to make dlib available:
#  include(FetchContent)
#  FetchContent_Declare(dlib
#      GIT_REPOSITORY https://github.com/davisking/dlib.git
#      GIT_TAG        v19.18
#  )
#  FetchContent_MakeAvailable(dlib)

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

# The next thing we need to do is tell CMake about the code you want to
# compile.  We do this with the add_executable() statement which takes the name
# of the output executable and then a list of .cpp files to compile.  Here we
# are going to compile one of the dlib example programs which has only one .cpp
# file, assignment_learning_ex.cpp.  If your program consisted of multiple .cpp
# files you would simply list them here in the add_executable() statement.  
add_executable(assignment_learning_ex assignment_learning_ex.cpp)
# Finally, you need to tell CMake that this program, assignment_learning_ex,
# depends on dlib.  You do that with this statement: 
target_link_libraries(assignment_learning_ex dlib::dlib)



# To compile this program all you need to do is ask cmake.  You would type
# these commands from within the directory containing this CMakeLists.txt
# file:
#   mkdir build
cclough's avatar
cclough committed
74
#   cd build
75
76
77
78
#   cmake ..
#   cmake --build . --config Release
#
# The cmake .. command looks in the parent folder for a file named
Davis King's avatar
Davis King committed
79
80
81
82
# CMakeLists.txt, reads it, and sets up everything needed to build program.
# Also, note that CMake can generate Visual Studio or XCode project files.  So
# if instead you had written:
#   cd build
83
#   cmake .. -G Xcode
84
#
85
86
87
88
89
# You would be able to open the resulting Xcode project and compile and edit
# the example programs within the Xcode IDE.  CMake can generate a lot of
# different types of IDE projects.  Run the cmake -h command to see a list of
# arguments to -G to see what kinds of projects cmake can generate for you.  It
# probably includes your favorite IDE in the list.
90
91


92
93


94
95
96
97
98
99
100
#################################################################################
#################################################################################
#  A CMakeLists.txt file can compile more than just one program.  So below we
#  tell it to compile the other dlib example programs using pretty much the
#  same CMake commands we used above.
#################################################################################
#################################################################################
101
102


Davis King's avatar
Davis King committed
103
# Since there are a lot of examples I'm going to use a macro to simplify this
104
105
# CMakeLists.txt file.  However, usually you will create only one executable in
# your cmake projects and use the syntax shown above.
106
107
108
109
macro(add_example name)
   add_executable(${name} ${name}.cpp)
   target_link_libraries(${name} dlib::dlib )
endmacro()
110

111
# if an example requires GUI, call this macro to check DLIB_NO_GUI_SUPPORT to include or exclude
112
macro(add_gui_example name)
113
114
115
116
117
   if (DLIB_NO_GUI_SUPPORT)
      message("No GUI support, so we won't build the ${name} example.")
   else()
      add_example(${name})
   endif()
118
endmacro()
119

120
121
122
# The deep learning toolkit requires a compiler with essentially complete C++11
# support.  However, versions of Visual Studio prior to October 2016 didn't
# provide enough C++11 support to compile the DNN tooling, but were good enough
123
124
125
126
127
128
129
130
131
132
133
134
135
# to compile the rest of dlib.  So new versions of Visual Studio 2015 will
# work.  However, Visual Studio 2017 had some C++11 support regressions, so it
# wasn't until December 2017 that Visual Studio 2017 had good enough C++11
# support to compile the DNN examples.  So if you are using Visual Studio, make
# sure you have an updated version if you want to compile the DNN code.
#
# Also note that Visual Studio users should give the -T host=x64 option so that
# CMake will instruct Visual Studio to use its 64bit toolchain.  If you don't
# do this then by default Visual Studio uses a 32bit toolchain, WHICH RESTRICTS
# THE COMPILER TO ONLY 2GB OF RAM, causing it to run out of RAM and crash when
# compiling some of the DNN examples.  So generate your project with a statement
# like this:
#   cmake .. -G "Visual Studio 14 2015 Win64" -T host=x64 
136
if (NOT USING_OLD_VISUAL_STUDIO_COMPILER)
137
   add_example(dnn_metric_learning_ex)
138
   add_gui_example(dnn_face_recognition_ex)
Davis King's avatar
Davis King committed
139
140
   add_example(dnn_introduction_ex)
   add_example(dnn_introduction2_ex)
141
   add_example(dnn_introduction3_ex)
Fm's avatar
Fm committed
142
   add_example(dnn_inception_ex)
143
   add_gui_example(dnn_mmod_ex)
144
   add_gui_example(dnn_mmod_face_detection_ex)
145
   add_gui_example(random_cropper_ex)
146
   add_gui_example(dnn_mmod_dog_hipsterizer)
147
   add_gui_example(dnn_imagenet_ex)
148
   add_gui_example(dnn_mmod_find_cars_ex)
Davis King's avatar
Davis King committed
149
   add_gui_example(dnn_mmod_find_cars2_ex)
150
   add_example(dnn_mmod_train_find_cars_ex)
151
   add_gui_example(dnn_semantic_segmentation_ex)
Juha Reunanen's avatar
Juha Reunanen committed
152
   add_gui_example(dnn_instance_segmentation_ex)
153
   add_example(dnn_imagenet_train_ex)
154
   add_example(dnn_semantic_segmentation_train_ex)
Juha Reunanen's avatar
Juha Reunanen committed
155
   add_example(dnn_instance_segmentation_train_ex)
156
   add_example(dnn_metric_learning_on_images_ex)
Davis King's avatar
Davis King committed
157
   add_gui_example(dnn_dcgan_train_ex)
Davis King's avatar
Davis King committed
158
endif()
159

160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176

if (DLIB_NO_GUI_SUPPORT)
   message("No GUI support, so we won't build the webcam_face_pose_ex example.")
else()
   find_package(OpenCV QUIET)
   if (OpenCV_FOUND)
      include_directories(${OpenCV_INCLUDE_DIRS})

      add_executable(webcam_face_pose_ex webcam_face_pose_ex.cpp)
      target_link_libraries(webcam_face_pose_ex dlib::dlib ${OpenCV_LIBS} )
   else()
      message("OpenCV not found, so we won't build the webcam_face_pose_ex example.")
   endif()
endif()



177
#here we apply our macros 
178
add_gui_example(3d_point_cloud_ex)
179
180
add_example(bayes_net_ex)
add_example(bayes_net_from_disk_ex)
181
add_gui_example(bayes_net_gui_ex)
182
add_example(bridge_ex)
Davis King's avatar
Davis King committed
183
add_example(bsp_ex)
184
add_example(compress_stream_ex)
185
add_example(config_reader_ex)
186
add_example(custom_trainer_ex)
187
add_example(dir_nav_ex)
188
add_example(empirical_kernel_map_ex)
189
190
191
192
add_gui_example(face_detection_ex)
add_gui_example(face_landmark_detection_ex)
add_gui_example(fhog_ex)
add_gui_example(fhog_object_detector_ex)
193
add_example(file_to_code_ex)
194
add_example(graph_labeling_ex)
195
196
197
add_gui_example(gui_api_ex)
add_gui_example(hough_transform_ex)
add_gui_example(image_ex)
Davis King's avatar
Davis King committed
198
add_example(integrate_function_adapt_simp_ex)
199
add_example(iosockstream_ex)
Davis King's avatar
Davis King committed
200
add_example(kcentroid_ex)
201
add_example(kkmeans_ex)
Davis King's avatar
Davis King committed
202
add_example(krls_ex)
203
add_example(krls_filter_ex)
204
205
add_example(krr_classification_ex)
add_example(krr_regression_ex)
206
add_example(learning_to_track_ex)
207
add_example(least_squares_ex)
208
add_example(linear_manifold_regularizer_ex)
209
add_example(logger_custom_output_ex)
210
211
212
add_example(logger_ex)
add_example(logger_ex_2)
add_example(matrix_ex)
213
add_example(matrix_expressions_ex)
214
add_example(max_cost_assignment_ex)
215
216
add_example(member_function_pointer_ex)
add_example(mlp_ex)
217
add_example(model_selection_ex)
218
add_gui_example(mpc_ex)
219
add_example(multiclass_classification_ex)
220
add_example(multithreaded_object_ex)
221
222
223
add_gui_example(object_detector_advanced_ex)
add_gui_example(object_detector_ex)
add_gui_example(one_class_classifiers_ex)
Davis King's avatar
Davis King committed
224
add_example(optimization_ex)
225
add_example(parallel_for_ex)
226
add_example(pipe_ex)
227
add_example(pipe_ex_2)
Davis King's avatar
Davis King committed
228
add_example(quantum_computing_ex)
229
add_example(queue_ex)
Davis King's avatar
Davis King committed
230
add_example(rank_features_ex)
Davis King's avatar
Davis King committed
231
add_example(running_stats_ex)
Davis King's avatar
Davis King committed
232
add_example(rvm_ex)
Davis King's avatar
Davis King committed
233
add_example(rvm_regression_ex)
234
add_example(sequence_labeler_ex)
235
add_example(sequence_segmenter_ex)
236
add_example(server_http_ex)
237
add_example(server_iostream_ex)
238
239
240
add_example(sockets_ex)
add_example(sockstreambuf_ex)
add_example(std_allocator_ex)
241
add_gui_example(surf_ex)
242
add_example(svm_c_ex)
243
add_example(svm_ex)
244
add_example(svm_pegasos_ex)
245
add_example(svm_rank_ex)
Davis King's avatar
Davis King committed
246
add_example(svm_sparse_ex)
247
add_example(svm_struct_ex)
Davis King's avatar
Davis King committed
248
add_example(svr_ex)
249
add_example(thread_function_ex)
Davis King's avatar
Davis King committed
250
add_example(thread_pool_ex)
251
add_example(threaded_object_ex)
252
253
add_example(threads_ex)
add_example(timer_ex)
254
add_gui_example(train_object_detector)
255
add_example(train_shape_predictor_ex)
256
add_example(using_custom_kernels_ex)
257
add_gui_example(video_tracking_ex)
258
add_example(xml_parser_ex)
259
260


261
262
263
264
if (DLIB_LINK_WITH_SQLITE3)
   add_example(sqlite_ex)
endif()

265