-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
546 lines (484 loc) · 26.7 KB
/
Copy pathCMakeLists.txt
File metadata and controls
546 lines (484 loc) · 26.7 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
# Reference: https://cmake.org/cmake/help/latest/guide/tutorial/index.html
cmake_minimum_required(VERSION 3.13) # For lgtm.com service
# set the project name and version
# Reference: https://stackoverflow.com/a/41651622/6667035
# Start with C and CXX, CUDA will be enabled conditionally
project(TinyDIP VERSION 1.0 LANGUAGES C CXX)
# print compile/link commands
# Reference: https://stackoverflow.com/a/3379246/6667035
set(CMAKE_VERBOSE_MAKEFILE on)
# --- RPATH Configuration for Custom GCC (e.g., GCC 17) ---
# Define the directory containing the new libgomp.so.1 and libstdc++.so.6
# Common locations: /usr/local/lib64, /opt/gcc-17/lib64, /opt/gcc-latest/lib64
set(CUSTOM_GCC_LIB_DIR "/usr/local/lib64" CACHE PATH "Path to custom GCC library directory")
# Use, i.e. do not skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# Use the install RPATH during the build phase as well
# This ensures that executables run directly from the build directory can find the libraries
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
# Set the RPATH to be used when installing
set(CMAKE_INSTALL_RPATH "${CUSTOM_GCC_LIB_DIR}")
# Add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# ---------------------------------------------------------
# --- CUDA Setup ---
# Option to enable/disable CUDA, default is ON
OPTION(ENABLE_CUDA "Enable CUDA support" ON)
# Disable CUDA on Apple platforms as it's not officially supported
if(APPLE)
message(STATUS "CUDA is not supported on macOS. Disabling CUDA build.")
set(ENABLE_CUDA OFF)
endif()
# Set C++ standard and build type early
IF (CMAKE_VERSION VERSION_LESS "3.8")
SET(CMAKE_CXX_STANDARD 14)
ELSEIF (CMAKE_VERSION VERSION_LESS "3.11")
SET(CMAKE_CXX_STANDARD 17)
ELSE()
# Using C++23 for host code
SET(CMAKE_CXX_STANDARD 23)
ENDIF()
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_BUILD_TYPE Debug) # Use standard casing Debug/Release etc.
if(ENABLE_CUDA)
message(STATUS "CUDA is enabled. Configuring CUDA support...")
# === ADDED: Explicitly set the CUDA compiler (nvcc) path ===
set(CMAKE_CUDA_COMPILER "/usr/local/cuda-13.3/bin/nvcc")
message(STATUS "Setting CUDA compiler (nvcc) to ${CMAKE_CUDA_COMPILER}")
# === END ADDED SECTION ===
# === ADDED: Explicitly set the host compiler nvcc should use ===
# Replace /usr/bin/g++-12 with the actual path to your CUDA-compatible g++
# (e.g., /usr/bin/g++-11, /usr/bin/g++-12 depending on CUDA version support)
set(CMAKE_CUDA_HOST_COMPILER /usr/bin/g++-15)
message(STATUS "Setting CUDA host compiler to ${CMAKE_CUDA_HOST_COMPILER}")
# === END ADDED SECTION ===
# Conditionally enable the CUDA language. This must be done after project().
enable_language(CUDA)
# Find the CUDA toolkit using the modern find_package approach
find_package(CUDA REQUIRED)
# Add a check to confirm CUDA was found
if(CUDA_FOUND)
message(STATUS "Found CUDA Toolkit: ${CUDA_TOOLKIT_ROOT_DIR} (version ${CUDA_VERSION_STRING})")
else()
message(FATAL_ERROR "CMake could not find the CUDA Toolkit. Please ensure it is installed and CUDACXX is in your PATH.")
endif()
# Reference: https://stackoverflow.com/a/43389168/6667035
include_directories("${CUDA_INCLUDE_DIRS}")
# Specify the C++ standard for CUDA *device* code
# NOTE: Set based on toolkit version for broader compatibility.
if(CUDA_VERSION VERSION_GREATER_EQUAL "11.6") # Basic C++20 support started around 11.6
set(CMAKE_CUDA_STANDARD 20)
elseif(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") # Basic C++17 support started around 11.0
set(CMAKE_CUDA_STANDARD 17)
else()
set(CMAKE_CUDA_STANDARD 14) # Default to C++14 for older toolkits
endif()
message(STATUS "Setting CUDA Device C++ Standard to: ${CMAKE_CUDA_STANDARD}")
set(CMAKE_CUDA_STANDARD_REQUIRED True)
# Set the target GPU architecture(s).
# sm_75 corresponds to the Turing architecture (e.g., RTX 20-series).
# Add other architectures if needed, e.g., set(CMAKE_CUDA_ARCHITECTURES 75 86)
set(CMAKE_CUDA_ARCHITECTURES 75)
# --- Set CUDA Compiler Flags ---
# These flags are passed directly to nvcc for device compilation
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -O3")
# Add other common nvcc flags. --use_fast_math is good with -O3. For coroutines, -fcoroutines is needed.
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --use_fast_math -fcoroutines -fstack-usage")
# -G is for device-side debug info.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G")
message(STATUS "Enabling CUDA device debugging (-G)")
endif()
# Note: Flags from CMAKE_CXX_FLAGS (like -fopenmp) are automatically
# passed to nvcc's host compiler (e.g., as -Xcompiler -fopenmp).
# --- End CUDA Compiler Flags Section ---
else() # If CUDA is not enabled, ensure CXX settings are still applied
message(STATUS "CUDA is disabled.")
# CXX Standard and Build Type already set above
endif()
# --- End CUDA Setup ---
## Reference: https://stackoverflow.com/a/45934279/6667035
#if(APPLE) # Reference: https://stackoverflow.com/a/40152725/6667035
# set(CMAKE_C_COMPILER "/usr/local/bin/gcc")
# set(CMAKE_CXX_COMPILER "/usr/local/bin/g++-15")
# Reference: https://developer.apple.com/forums/thread/737707
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-pie")
#endif()
if(UNIX AND NOT APPLE)
# for Linux, BSD, Solaris, Minix
# Only set specific paths if necessary, otherwise trust CMake detection
#if(EXISTS "/usr/bin/gcc")
# set(CMAKE_C_COMPILER "/usr/bin/gcc")
#endif()
#if(EXISTS "/usr/bin/g++")
# set(CMAKE_CXX_COMPILER "/usr/bin/g++")
#endif()
endif()
# Set CXX flags based on compiler
# Reference: https://stackoverflow.com/a/10055571/6667035
# Modified: Use MATCHES "Clang" instead of STREQUAL "Clang" to correctly catch AppleClang on macOS
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# using Clang or AppleClang
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -ffast-math") # Match standard with CMAKE_CXX_STANDARD
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
# Note: -std=c++2b is C++23. Already handled by CMAKE_CXX_STANDARD.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors -fopenmp -O3 -fdiagnostics-show-template-tree -fstats -fstack-usage")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# using Intel C++
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# using Visual Studio C++
# Removed deprecated /experimental:module
# Added /D_CRT_SECURE_NO_WARNINGS to suppress fopen warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast /Ox /Ob2 /Oi /Ot /GT /std:c++latest /Zm2000 /Zc:twoPhase- /D_HAS_STD_BYTE=0 /D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING /D_HAS_STD_BOOLEAN=0 /bigobj /openmp:llvm /D_CRT_SECURE_NO_WARNINGS")
endif()
# Append C++ standard flag if not automatically added by CMake (older versions might need this)
# Modern CMake (>=3.1) usually adds the flag based on CMAKE_CXX_STANDARD automatically.
# Check your CMake version and compiler documentation if needed. Example for GCC/Clang:
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CMAKE_CXX_STANDARD}")
# OpenMP part
# Reference: https://stackoverflow.com/a/12404666/6667035
# === ADDED: Help CMake find OpenMP (libomp) on macOS (Homebrew) ===
if(APPLE)
if(IS_DIRECTORY "/opt/homebrew/opt/libomp")
set(OpenMP_ROOT "/opt/homebrew/opt/libomp")
elseif(IS_DIRECTORY "/usr/local/opt/libomp")
set(OpenMP_ROOT "/usr/local/opt/libomp")
endif()
endif()
# === END ADDED ===
find_package(OpenMP)
if (OPENMP_FOUND)
message(STATUS "Found OpenMP, applying flags.")
# === ADDED: Fix for AppleClang unsupported option '-fopenmp' ===
if (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
# AppleClang requires -Xpreprocessor before -fopenmp
# and explicit linking to libomp (usually handled by find_package in newer CMake, but explicitly fixed here just in case)
if (NOT "${OpenMP_CXX_FLAGS}" MATCHES "-Xpreprocessor")
message(STATUS "Patching OpenMP flags for AppleClang...")
set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp")
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp")
set(OpenMP_EXE_LINKER_FLAGS "-lomp")
endif()
endif()
# === END ADDED ===
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
else()
message(WARNING "OpenMP not found. Parallel CPU execution might be limited.")
endif()
# TBB part
find_package(TBB REQUIRED)
message(STATUS "Found TBB: ${TBB_INCLUDE_DIRS} | ${TBB_LIBRARIES}")
if(APPLE)
if(IS_DIRECTORY "/opt/homebrew/lib")
link_directories("/opt/homebrew/lib")
message(STATUS "Manually added TBB link directory: /opt/homebrew/lib")
elseif(IS_DIRECTORY "/usr/local/lib")
link_directories("/usr/local/lib")
message(STATUS "Manually added TBB link directory: /usr/local/lib")
else()
message(WARNING "Could not find Homebrew TBB library directory. Build may fail.")
endif()
endif()
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
if (ENABLE_ASAN)
message(STATUS "AddressSanitizer enabled.")
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(/fsanitize=address)
# AddressSanitizer doesn't work with Edit and Continue (/ZI)
# set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<CONFIG:Debug>,/Zi,/Z7>") # Example for controlling debug info
elseif(NOT APPLE) # GCC/Clang and not apple
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
add_link_options(-fsanitize=address)
endif()
endif()
# add the executable
add_executable(TinyDIP main.cpp image_io.cpp)
add_executable(absTest test/absTest.cpp image_io.cpp)
add_executable(allOfTest test/allOfTest.cpp image_io.cpp)
add_executable(backgroundTest test/backgroundTest.cpp image_io.cpp)
add_executable(bicubicInterpolationTest test/bicubicInterpolationTest.cpp image_io.cpp)
add_executable(bilateralFilterTest test/bilateralFilterTest.cpp image_io.cpp)
add_executable(concatHorizontalTest test/concatHorizontalTest.cpp image_io.cpp)
add_executable(concatHorizontalTest2 test/concatHorizontalTest2.cpp image_io.cpp)
add_executable(concatTest test/concatTest.cpp image_io.cpp)
add_executable(concatVerticalTest test/concatVerticalTest.cpp image_io.cpp)
add_executable(concatVerticalTest2 test/concatVerticalTest2.cpp image_io.cpp)
add_executable(conv2Test test/conv2Test.cpp image_io.cpp)
add_executable(conv2Test2 test/conv2Test2.cpp image_io.cpp)
add_executable(conv2Test3 test/conv2Test3.cpp image_io.cpp)
add_executable(convnTest test/convnTest.cpp image_io.cpp)
add_executable(csvReadTest test/csvReadTest.cpp image_io.cpp)
add_executable(csvWriteTest test/csvWriteTest.cpp image_io.cpp)
add_executable(DiamondWheelAnalysis test/DiamondWheelAnalysis.cpp image_io.cpp)
add_executable(dbmpFileToCSV test/dbmpFileToCSV.cpp image_io.cpp)
add_executable(dct2Test test/dct2Test.cpp image_io.cpp)
add_executable(dct2Test2 test/dct2Test2.cpp image_io.cpp)
add_executable(dct2Test3 test/dct2Test3.cpp image_io.cpp)
add_executable(dct2Test4 test/dct2Test4.cpp image_io.cpp)
add_executable(dct3DetailTest test/dct3DetailTest.cpp image_io.cpp)
add_executable(dct3LargeImageTest test/dct3LargeImageTest.cpp image_io.cpp)
add_executable(dct3Test test/dct3Test.cpp image_io.cpp)
add_executable(dft2Test test/dft2Test.cpp image_io.cpp)
add_executable(differenceOfGaussianTest test/differenceOfGaussianTest.cpp image_io.cpp)
add_executable(doubleImageIOTest test/doubleImageIOTest.cpp image_io.cpp)
#add_executable(dictionaryBasedNonLocalMeanTest test/dictionaryBasedNonLocalMeanTest.cpp image_io.cpp)
add_executable(flipVerticalTest test/flipVerticalTest.cpp image_io.cpp)
add_executable(gaussianFigure2DTest test/gaussianFigure2DTest.cpp image_io.cpp)
add_executable(gaussianFisheyeTest test/gaussianFisheyeTest.cpp image_io.cpp)
add_executable(getNFromVariadicTemplatesTest test/getNFromVariadicTemplatesTest.cpp image_io.cpp)
add_executable(highlightRegionTest test/highlightRegionTest.cpp image_io.cpp)
add_executable(histogramTest test/histogramTest.cpp image_io.cpp)
add_executable(idct2Test test/idct2Test.cpp image_io.cpp)
add_executable(imageElementwiseAddTest test/imageElementwiseAddTest.cpp image_io.cpp)
add_executable(imageWriteTest test/imageWriteTest.cpp image_io.cpp)
add_executable(imgaussfiltTest test/imgaussfiltTest.cpp image_io.cpp)
add_executable(increaseIntensityTest test/increaseIntensityTest.cpp image_io.cpp)
add_executable(isIntegerTest test/isIntegerTest.cpp image_io.cpp)
add_executable(juliaFractalGeneratorTest test/juliaFractalGeneratorTest.cpp image_io.cpp)
add_executable(lanczosResamplingTest test/lanczosResamplingTest.cpp image_io.cpp)
add_executable(localDimmingTest test/localDimmingTest.cpp image_io.cpp)
add_executable(mandelbrotFractalGeneratorTest test/mandelbrotFractalGeneratorTest.cpp image_io.cpp)
add_executable(manhattanDistanceTest test/manhattanDistanceTest.cpp image_io.cpp)
#add_executable(meanTest test/meanTest.cpp image_io.cpp)
add_executable(multipliesParallelTest test/multipliesParallelTest.cpp image_io.cpp)
add_executable(multipliesWithImageVectorsTest test/multipliesWithImageVectorsTest.cpp image_io.cpp)
add_executable(offsetTest test/offsetTest.cpp image_io.cpp)
add_executable(otsuThresholdTest test/otsuThresholdTest.cpp image_io.cpp)
add_executable(paste2DTest test/paste2DTest.cpp image_io.cpp)
add_executable(phoenixFractalGeneratorTest test/phoenixFractalGeneratorTest.cpp image_io.cpp)
add_executable(plusTest test/plusTest.cpp image_io.cpp)
add_executable(pnmFileReadTest test/pnmFileReadTest.cpp image_io.cpp)
add_executable(pnmFileWriteTest test/pnmFileWriteTest.cpp image_io.cpp)
add_executable(powTest test/powTest.cpp image_io.cpp)
#add_executable(powParallelTest test/powParallelTest.cpp image_io.cpp)
add_executable(ppm2bmpTest test/ppm2bmpTest.cpp image_io.cpp)
add_executable(printDbmpFileTest test/printDbmpFileTest.cpp image_io.cpp)
add_executable(subimageTest test/subimageTest.cpp image_io.cpp)
add_executable(subimage2Test test/subimage2Test.cpp image_io.cpp)
add_executable(subimage2Test2 test/subimage2Test2.cpp image_io.cpp)
add_executable(rgb2hsvTest test/rgb2hsvTest.cpp image_io.cpp)
add_executable(randFunctionTest test/randFunctionTest.cpp image_io.cpp)
add_executable(idct3DetailTest test/idct3DetailTest.cpp image_io.cpp)
add_executable(pixelwiseOperationTest test/pixelwiseOperationTest.cpp image_io.cpp)
#add_executable(pixelwiseOperationParallelTest test/pixelwiseOperationParallelTest.cpp image_io.cpp)
add_executable(rainDictionaryAnalysis test/rainDictionaryAnalysis.cpp image_io.cpp)
add_executable(RANSAC_InlierVisualizationTest test/RANSAC_InlierVisualizationTest.cpp image_io.cpp)
add_executable(recursiveAllOfTest test/recursiveAllOfTest.cpp image_io.cpp)
add_executable(recursiveAnyOfTest test/recursiveAnyOfTest.cpp image_io.cpp)
add_executable(recursiveFindIfTest test/recursiveFindIfTest.cpp image_io.cpp)
add_executable(recursiveFoldRightAllTest test/recursiveFoldRightAllTest.cpp image_io.cpp)
add_executable(recursiveForeachTest test/recursiveForeachTest.cpp image_io.cpp)
add_executable(recursiveMinmaxTest test/recursiveMinmaxTest.cpp image_io.cpp)
add_executable(recursiveNoneOfTest test/recursiveNoneOfTest.cpp image_io.cpp)
add_executable(recursiveReduceTest test/recursiveReduceTest.cpp image_io.cpp)
add_executable(recursiveRemoveCopyTest test/recursiveRemoveCopyTest.cpp image_io.cpp)
add_executable(recursiveRemoveCopyIfTest test/recursiveRemoveCopyIfTest.cpp image_io.cpp)
add_executable(recursiveSizeTest test/recursiveSizeTest.cpp image_io.cpp)
#add_executable(recursiveTransformTest test/recursiveTransformTest.cpp image_io.cpp)
add_executable(recursiveTransformTypeTest test/recursiveTransformTypeTest.cpp image_io.cpp)
#add_executable(recursiveTransformReduceTest test/recursiveTransformReduceTest.cpp image_io.cpp)
add_executable(refineHomographyFunctionTest test/refineHomographyFunctionTest.cpp image_io.cpp)
add_executable(rotateShearTransformationCsvTest test/rotateShearTransformationCsvTest.cpp image_io.cpp)
add_executable(rotateShearTransformationPPMTest test/rotateShearTransformationPPMTest.cpp image_io.cpp)
add_executable(siftDrawMatches test/siftDrawMatches.cpp image_io.cpp)
add_executable(splitOverlapTest test/splitOverlapTest.cpp image_io.cpp)
add_executable(stitchingTest test/stitchingTest.cpp image_io.cpp)
add_executable(stitchingMultipleTest test/stitchingMultipleTest.cpp image_io.cpp)
#add_executable(sumTest test/sumTest.cpp image_io.cpp)
add_executable(testingRANSAC_MSAC_HomographyEstimation test/testingRANSAC_MSAC_HomographyEstimation.cpp image_io.cpp)
add_executable(transposeTest test/transposeTest.cpp image_io.cpp)
add_executable(windowedFilterTest test/windowedFilterTest.cpp image_io.cpp)
if(ENABLE_CUDA)
# === NEW EXECUTABLE FOR CUDA TEST ===
# CMake knows to compile .cu files with nvcc because CUDA was enabled.
add_executable(stitchingCudaTest test/stitchingCudaTest.cpp image_io.cpp image_operations_cuda.cu)
add_executable(warpPerspectiveCudaTest test/warpPerspectiveCudaTest.cpp image_io.cpp image_operations_cuda.cu)
add_executable(warpPerspectiveCudaTest2 test/warpPerspectiveCudaTest2.cpp image_io.cpp image_operations_cuda.cu)
endif()
# target_include_directories
# Add include directories needed by ALL targets (like TBB)
# target_include_directories(TinyDIP PUBLIC ${TBB_INCLUDE_DIRS}) # Example if TBB needed includes universally
if(APPLE)
target_include_directories(TinyDIP PRIVATE ${LLVM_INCLUDE_DIRS})
endif()
# target_link_libraries
# Reference: https://stackoverflow.com/a/39600062/6667035
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# using Clang
target_link_libraries(TinyDIP stdc++fs)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
target_link_libraries(TinyDIP stdc++fs)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# using Intel C++
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# using Visual Studio C++
endif()
target_link_libraries(TinyDIP -lm)
#target_link_libraries(TinyDIP -lomp)
target_link_libraries(TinyDIP -lpthread)
target_link_libraries(TinyDIP tbb)
target_link_libraries(absTest PUBLIC TBB::tbb)
target_link_libraries(allOfTest PUBLIC TBB::tbb)
target_link_libraries(backgroundTest PUBLIC TBB::tbb)
target_link_libraries(bicubicInterpolationTest PUBLIC TBB::tbb)
target_link_libraries(bilateralFilterTest PUBLIC TBB::tbb)
target_link_libraries(concatHorizontalTest PUBLIC TBB::tbb)
target_link_libraries(concatHorizontalTest2 PUBLIC TBB::tbb)
target_link_libraries(concatTest PUBLIC TBB::tbb)
target_link_libraries(concatVerticalTest PUBLIC TBB::tbb)
target_link_libraries(concatVerticalTest2 PUBLIC TBB::tbb)
target_link_libraries(conv2Test PUBLIC TBB::tbb)
target_link_libraries(conv2Test2 PUBLIC TBB::tbb)
target_link_libraries(conv2Test3 PUBLIC TBB::tbb)
target_link_libraries(convnTest PUBLIC TBB::tbb)
target_link_libraries(csvReadTest PUBLIC TBB::tbb)
target_link_libraries(csvWriteTest PUBLIC TBB::tbb)
target_link_libraries(dbmpFileToCSV PUBLIC TBB::tbb)
target_link_libraries(dct2Test PUBLIC TBB::tbb)
target_link_libraries(dct2Test2 PUBLIC TBB::tbb)
target_link_libraries(dct2Test3 PUBLIC TBB::tbb)
target_link_libraries(dct2Test4 PUBLIC TBB::tbb)
target_link_libraries(dct3DetailTest PUBLIC TBB::tbb)
target_link_libraries(dct3LargeImageTest PUBLIC TBB::tbb)
target_link_libraries(dct3Test PUBLIC TBB::tbb)
target_link_libraries(dft2Test PUBLIC TBB::tbb)
target_link_libraries(DiamondWheelAnalysis PUBLIC TBB::tbb)
target_link_libraries(differenceOfGaussianTest PUBLIC TBB::tbb)
target_link_libraries(doubleImageIOTest PUBLIC TBB::tbb)
#target_link_libraries(dictionaryBasedNonLocalMeanTest PUBLIC TBB::tbb)
target_link_libraries(flipVerticalTest PUBLIC TBB::tbb)
target_link_libraries(gaussianFigure2DTest PUBLIC TBB::tbb)
target_link_libraries(gaussianFisheyeTest PUBLIC TBB::tbb)
target_link_libraries(getNFromVariadicTemplatesTest PUBLIC TBB::tbb)
target_link_libraries(highlightRegionTest PUBLIC TBB::tbb)
target_link_libraries(histogramTest PUBLIC TBB::tbb)
target_link_libraries(idct2Test PUBLIC TBB::tbb)
target_link_libraries(imageElementwiseAddTest PUBLIC TBB::tbb)
target_link_libraries(imageWriteTest PUBLIC TBB::tbb)
target_link_libraries(imgaussfiltTest PUBLIC TBB::tbb)
target_link_libraries(increaseIntensityTest PUBLIC TBB::tbb)
target_link_libraries(isIntegerTest PUBLIC TBB::tbb)
target_link_libraries(juliaFractalGeneratorTest PUBLIC TBB::tbb)
target_link_libraries(lanczosResamplingTest PUBLIC TBB::tbb)
target_link_libraries(localDimmingTest PUBLIC TBB::tbb)
target_link_libraries(mandelbrotFractalGeneratorTest PUBLIC TBB::tbb)
target_link_libraries(manhattanDistanceTest PUBLIC TBB::tbb)
#target_link_libraries(meanTest PUBLIC TBB::tbb)
target_link_libraries(multipliesParallelTest PUBLIC TBB::tbb)
target_link_libraries(multipliesWithImageVectorsTest PUBLIC TBB::tbb)
target_link_libraries(offsetTest PUBLIC TBB::tbb)
target_link_libraries(otsuThresholdTest PUBLIC TBB::tbb)
target_link_libraries(paste2DTest PUBLIC TBB::tbb)
target_link_libraries(phoenixFractalGeneratorTest PUBLIC TBB::tbb)
target_link_libraries(plusTest PUBLIC TBB::tbb)
target_link_libraries(pnmFileReadTest PUBLIC TBB::tbb)
target_link_libraries(pnmFileWriteTest PUBLIC TBB::tbb)
target_link_libraries(powTest PUBLIC TBB::tbb)
#target_link_libraries(powParallelTest PUBLIC TBB::tbb)
target_link_libraries(ppm2bmpTest PUBLIC TBB::tbb)
target_link_libraries(printDbmpFileTest PUBLIC TBB::tbb)
target_link_libraries(subimageTest PUBLIC TBB::tbb)
target_link_libraries(subimage2Test PUBLIC TBB::tbb)
target_link_libraries(subimage2Test2 PUBLIC TBB::tbb)
target_link_libraries(rgb2hsvTest PUBLIC TBB::tbb)
target_link_libraries(randFunctionTest PUBLIC TBB::tbb)
target_link_libraries(idct3DetailTest PUBLIC TBB::tbb)
target_link_libraries(pixelwiseOperationTest PUBLIC TBB::tbb)
#target_link_libraries(pixelwiseOperationParallelTest PUBLIC TBB::tbb)
target_link_libraries(rainDictionaryAnalysis PUBLIC TBB::tbb)
target_link_libraries(RANSAC_InlierVisualizationTest PUBLIC TBB::tbb)
target_link_libraries(recursiveAllOfTest PUBLIC TBB::tbb)
target_link_libraries(recursiveAnyOfTest PUBLIC TBB::tbb)
target_link_libraries(recursiveFindIfTest PUBLIC TBB::tbb)
target_link_libraries(recursiveFoldRightAllTest PUBLIC TBB::tbb)
target_link_libraries(recursiveForeachTest PUBLIC TBB::tbb)
target_link_libraries(recursiveMinmaxTest PUBLIC TBB::tbb)
target_link_libraries(recursiveNoneOfTest PUBLIC TBB::tbb)
target_link_libraries(recursiveReduceTest PUBLIC TBB::tbb)
target_link_libraries(recursiveRemoveCopyTest PUBLIC TBB::tbb)
target_link_libraries(recursiveRemoveCopyIfTest PUBLIC TBB::tbb)
target_link_libraries(recursiveSizeTest PUBLIC TBB::tbb)
#target_link_libraries(recursiveTransformTest PUBLIC TBB::tbb)
target_link_libraries(recursiveTransformTypeTest PUBLIC TBB::tbb)
#target_link_libraries(recursiveTransformReduceTest PUBLIC TBB::tbb)
target_link_libraries(refineHomographyFunctionTest PUBLIC TBB::tbb)
target_link_libraries(rotateShearTransformationCsvTest PUBLIC TBB::tbb)
target_link_libraries(rotateShearTransformationPPMTest PUBLIC TBB::tbb)
target_link_libraries(siftDrawMatches PUBLIC TBB::tbb)
target_link_libraries(splitOverlapTest PUBLIC TBB::tbb)
target_link_libraries(stitchingTest PUBLIC TBB::tbb)
target_link_libraries(stitchingMultipleTest PUBLIC TBB::tbb)
#target_link_libraries(sumTest PUBLIC TBB::tbb)
target_link_libraries(testingRANSAC_MSAC_HomographyEstimation PUBLIC TBB::tbb)
target_link_libraries(transposeTest PUBLIC TBB::tbb)
target_link_libraries(windowedFilterTest PUBLIC TBB::tbb)
if(ENABLE_CUDA)
# === LINK LIBRARIES FOR CUDA TEST ===
# Explicitly link OpenMP::OpenMP_CXX to resolve libgomp symbols in mixed-language targets
target_link_libraries(stitchingCudaTest PUBLIC TBB::tbb OpenMP::OpenMP_CXX)
set_target_properties(stitchingCudaTest PROPERTIES
CUDA_HOST_COMPILER_STANDARD ${CMAKE_CXX_STANDARD}
CUDA_HOST_COMPILER_STANDARD_REQUIRED YES
)
message(STATUS "Setting CUDA Host C++ Standard for stitchingCudaTest to: ${CMAKE_CXX_STANDARD}")
# Explicitly link OpenMP for warpPerspectiveCudaTest
target_link_libraries(warpPerspectiveCudaTest PUBLIC TBB::tbb OpenMP::OpenMP_CXX)
set_target_properties(warpPerspectiveCudaTest PROPERTIES
CUDA_HOST_COMPILER_STANDARD ${CMAKE_CXX_STANDARD}
CUDA_HOST_COMPILER_STANDARD_REQUIRED YES
)
message(STATUS "Setting CUDA Host C++ Standard for warpPerspectiveCudaTest to: ${CMAKE_CXX_STANDARD}")
# Explicitly link OpenMP for warpPerspectiveCudaTest2
target_link_libraries(warpPerspectiveCudaTest2 PUBLIC TBB::tbb OpenMP::OpenMP_CXX)
set_target_properties(warpPerspectiveCudaTest2 PROPERTIES
CUDA_HOST_COMPILER_STANDARD ${CMAKE_CXX_STANDARD}
CUDA_HOST_COMPILER_STANDARD_REQUIRED YES
)
message(STATUS "Setting CUDA Host C++ Standard for warpPerspectiveCudaTest2 to: ${CMAKE_CXX_STANDARD}")
endif()
if(APPLE)
string(REPLACE "-Xclang" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
# Add boost library
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Reference: https://github.com/Microsoft/vcpkg/issues/4188
# Vcpkg default for x64-windows is Shared (Dynamic) and Multithreaded.
# We should let Vcpkg/CMake handle the selection or explicitly match Vcpkg.
# Removing Boost_USE_STATIC_LIBS etc. to allow automatic detection of vcpkg's shared libs.
# Fix package name case (BOOST -> Boost) and remove version constraint
# Change component 'test' to 'unit_test_framework' which is the standard name
find_package(Boost REQUIRED COMPONENTS iterator serialization unit_test_framework)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
# Link against imported targets or libraries variable
# Note: Boost::boost is header-only, for components use Boost::component_name
target_link_libraries(TinyDIP Boost::boost ${Boost_LIBRARIES})
endif()
endif()
# Add opencv library
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
target_link_libraries( TinyDIP ${OpenCV_LIBS} )
# Reference: https://stackoverflow.com/a/31390758/6667035
macro(print_all_variables)
message(STATUS "print_all_variables------------------------------------------{")
get_cmake_property(_variableNames VARIABLES)
list(SORT _variableNames) # Sort for easier reading
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
message(STATUS "print_all_variables------------------------------------------}")
endmacro()
# Use the macro only if CMake version supports cmake_language and build type is Debug
IF (CMAKE_VERSION VERSION_GREATER_EQUAL "3.18" AND CMAKE_BUILD_TYPE STREQUAL "Debug")
cmake_language(CALL print_all_variables)
ENDIF()
include(GNUInstallDirs)
install(TARGETS TinyDIP
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)