-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
executable file
·643 lines (594 loc) · 16 KB
/
CMakeLists.txt
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
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
##-*****************************************************************************
## Copyright 2012-present Mikael Sundell and the other authors and contributors.
## All Rights Reserved.
##
## Master CMakeLists.txt for 3rdparty
##
## Run 'make help' to list helpful options.
##
##-*****************************************************************************
cmake_minimum_required( VERSION 3.0 )
# project configuration
message( STATUS "Project configuration" )
project( 3rdparty )
# general configuration
message( STATUS "General configuration" )
# build variables
set( build_dir
${PROJECT_BINARY_DIR}
CACHE
STRING
"Build dir"
)
set( build_base
ON
CACHE
BOOL
"Build libs"
)
set( build_libs
OFF
CACHE
BOOL
"Build libs"
)
set( build_extras
OFF
CACHE
BOOL
"Build extras"
)
set( build_autotools
OFF
CACHE
BOOL
"Build autotools"
)
set( build_tests
OFF
CACHE
BOOL
"Build tests"
)
set( build_media
OFF
CACHE
BOOL
"Build media"
)
set( build_summary
OFF
CACHE
BOOL
"Build help"
)
# cmake variables
set( CMAKE_SHARED_LIBS
ON
CACHE
BOOL
"Build 3rdparty shared libraries"
)
set( CMAKE_VERBOSE_MAKEFILE
ON
CACHE
BOOL
"Build verbose debug or release version"
)
set( CMAKE_BUILD_TYPE
Debug
CACHE
STRING
"Build debug or release version"
)
# test
if( ${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
MESSAGE( FATAL_ERROR "Not allowed to run in-source build!" )
endif()
# define system
# cmake defines APPLE, UNIX and WIN32
if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
SET( LINUX TRUE )
endif()
# define properties
# vcc use folders
set_property( GLOBAL PROPERTY USE_FOLDERS ON )
# define repo
set( repo_url https://mikaelsundell.s3-eu-west-1.amazonaws.com/3rdparty )
# define build dirs
set( build_bin_dir ${build_dir}/bin )
set( build_inc_dir ${build_dir}/include )
set( build_lib_dir ${build_dir}/lib )
set( build_framework_dir ${build_dir}/lib )
set( build_ninja_dir ${build_dir}/ninja )
set( build_sitepackages_dir ${build_dir}/site-packages )
set( build_pkgconfig_dir ${build_dir}/pkgconfig )
set( build_plugins_dir ${build_dir}/plugins )
set( build_python_dir ${build_dir}/python )
set( build_test_dir ${build_dir}/test )
set( build_media_dir ${build_dir}/media )
set( build_cmake_dir ${build_dir}/cmake )
IF( APPLE )
set( build_prefix_lib ${build_lib_dir} )
set( build_prefix_framework ${build_framework_dir} )
set( build_prefix_plugins ${build_plugins_dir} )
ENDIF()
# define other dirs
set( build_modules_dir ${PROJECT_SOURCE_DIR}/src/cmake)
set( build_scripts_dir ${PROJECT_SOURCE_DIR}/src/scripts)
# define cmake
set( build_cmake "build_cmake" )
# define commands
if( CMAKE_VERBOSE_MAKEFILE )
SET( untar tar -xpvf )
else()
SET( untar tar -xpf )
endif()
if( CMAKE_VERBOSE_MAKEFILE )
SET( unzip unzip -o )
else()
SET( unzip unzip -oq )
endif()
# test if wget is present
exec_program( command ARGS -v wget OUTPUT_VARIABLE wget )
if ( wget )
SET( download wget -N --verbose )
else()
# -C skips the file if it's already downloaded
set( download curl -OJL --verbose )
endif()
# FIXME(mikael.sundell@gmail.com): cmake currently does not handle wildcards
# SET( copy cmake -E copy )
set( copy cp -f )
set( copy_dir ${CMAKE_COMMAND} -E copy_directory )
set( make_dir ${CMAKE_COMMAND} -E make_directory )
# define modules
list(
APPEND CMAKE_MODULE_PATH
${build_modules_dir}
)
include (buildutils)
# define prefix
set( shared_lib_prefix ${CMAKE_SHARED_LIBRARY_PREFIX} )
set( static_lib_prefix ${CMAKE_STATIC_LIBRARY_PREFIX} )
if( CMAKE_SHARED_LIBS )
set( lib_prefix ${shared_lib_prefix} )
else()
set( lib_prefix ${static_lib_prefix} )
endif()
# define suffix
set( shared_lib_suffix ${CMAKE_SHARED_LIBRARY_SUFFIX} )
set( static_lib_suffix ${CMAKE_STATIC_LIBRARY_SUFFIX} )
if( CMAKE_SHARED_LIBS )
set( lib_suffix ${shared_lib_suffix} )
else()
set( lib_suffix ${static_lib_suffix} )
endif()
# define site-package suffix
set( sitepackage_suffix ".so" )
# define arch
set( lib_arch ${CMAKE_SYSTEM_PROCESSOR} )
# define cpus
if( UNIX )
if( APPLE )
find_program( cmd_sysctl "sysctl")
if( cmd_sysctl )
execute_process( COMMAND ${cmd_sysctl} -n hw.physicalcpu OUTPUT_VARIABLE cpus )
string( REGEX MATCH "([0-9]+)" num_cpus "${cpus}" )
endif()
else()
set( cpuinfo_file "/proc/cpuinfo" )
if( exists "${cpuinfo_file}" )
file( STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$" )
list( LENGTH procs num_cpus )
endif()
endif()
endif()
set( build_flags ${build_flags} -j${num_cpus} --load-average=${num_cpus} )
# define python3
if ( UNIX )
if ( APPLE )
# build relies on python3 version for both
# naming of files and project configuration
build_find_python3(
build_python3
build_python3_version
build_python3_versiontag
build_python3_include_dir
build_python3_library_dir
)
endif()
endif()
# define environment
if( UNIX )
if( APPLE )
set( build_env
unset DYLD_LIBRARY_PATH &&
export DYLD_FALLBACK_LIBRARY_PATH=${build_lib_dir} &&
export CXXFLAGS=-stdlib=libc++
)
execute_process(
COMMAND xcodebuild -version
OUTPUT_VARIABLE XCODE_VERSION_OUTPUT
ERROR_VARIABLE XCODE_VERSION_ERROR
RESULT_VARIABLE XCODE_VERSION_RESULT
)
if(XCODE_VERSION_RESULT EQUAL 0)
string(REGEX MATCH "[0-9]+\\.[0-9]+" XCODE_VERSION ${XCODE_VERSION_OUTPUT})
if(XCODE_VERSION VERSION_GREATER_EQUAL "15.0")
set( build_env
${build_env} &&
export LDFLAGS=-Wl,-ld_classic
)
endif()
endif()
else()
set( build_env
export C_INCLUDE_PATH=${build_inc_dir} &&
export CPLUS_INCLUDE_PATH=${build_inc_dir} &&
export LIBRARY_PATH=${build_lib_dir} &&
export LD_LIBRARY_PATH=${build_lib_dir}
)
endif()
endif()
# build configuration
message( STATUS "Build configuration" )
if( build_base )
message( STATUS "Adding base" )
build_add_project(
bzip2
DIR ${CMAKE_SOURCE_DIR}/src/bzip2
DESCRIPTION "Bzip2"
BUILD ON
)
build_add_project(
boost
DIR ${CMAKE_SOURCE_DIR}/src/boost
DESCRIPTION "Boost C++ Libraries"
BUILD ON
)
build_add_project(
jasper
DIR ${CMAKE_SOURCE_DIR}/src/jasper
DESCRIPTION "Jasper"
BUILD ON
)
build_add_project(
giflib
DIR ${CMAKE_SOURCE_DIR}/src/giflib
DESCRIPTION "Giflib"
BUILD ON
)
build_add_project(
jpeg
DIR ${CMAKE_SOURCE_DIR}/src/jpeg
DESCRIPTION "Jpeg"
BUILD ON
)
build_add_project(
freetype
DIR ${CMAKE_SOURCE_DIR}/src/freetype
DESCRIPTION "Freetype"
BUILD ON
)
build_add_project(
harfbuzz
DIR ${CMAKE_SOURCE_DIR}/src/harfbuzz
DESCRIPTION "Harfbuzz"
BUILD ON
)
build_add_project(
libpng
DIR ${CMAKE_SOURCE_DIR}/src/libpng
DESCRIPTION "LibPNG"
BUILD ON
)
build_add_project(
libwebp
DIR ${CMAKE_SOURCE_DIR}/src/libwebp
DESCRIPTION "LibWebp"
BUILD ON
)
build_add_project(
ninja
DIR ${CMAKE_SOURCE_DIR}/src/ninja
DESCRIPTION "Ninja"
BUILD ON
)
build_add_project(
openjpeg
DIR ${CMAKE_SOURCE_DIR}/src/openjpeg
DESCRIPTION "OpenJpeg"
BUILD ON
)
build_add_project(
pcre2
DIR ${CMAKE_SOURCE_DIR}/src/pcre2
DESCRIPTION "Pcre2"
BUILD ON
)
build_add_project(
tiff
DIR ${CMAKE_SOURCE_DIR}/src/tiff
DESCRIPTION "LibTiff - TIFF Libraries and Utilities"
BUILD ON
)
build_add_project(
zlib
DIR ${CMAKE_SOURCE_DIR}/src/zlib
DESCRIPTION "Zlib"
BUILD ON
)
endif()
if( build_libs )
build_info( "Adding libs" )
build_add_project(
ffmpeg
DIR ${CMAKE_SOURCE_DIR}/src/ffmpeg
DESCRIPTION "FFmpeg"
BUILD ON
)
build_add_project(
glew
DIR ${CMAKE_SOURCE_DIR}/src/glew
DESCRIPTION "The OpenGL Extension Wrangler Library"
BUILD ON
)
build_add_project(
glm
DIR ${CMAKE_SOURCE_DIR}/src/glm
DESCRIPTION "OpenGL Mathematics (GLM)"
BUILD ON
)
build_add_project(
imath
DIR ${CMAKE_SOURCE_DIR}/src/imath
DESCRIPTION "Imath"
BUILD ON
)
build_add_project(
lcms2
DIR ${CMAKE_SOURCE_DIR}/src/lcms2
DESCRIPTION "Lcms2"
BUILD ON
)
build_add_project(
libraw
DIR ${CMAKE_SOURCE_DIR}/src/libraw
DESCRIPTION "LibRaw"
BUILD ON
)
build_add_project(
nasm
DIR ${CMAKE_SOURCE_DIR}/src/nasm
DESCRIPTION "Nasm"
BUILD ON
)
build_add_project(
oiio
DIR ${CMAKE_SOURCE_DIR}/src/oiio
DESCRIPTION "OpenImageIO"
BUILD ON
)
build_add_project(
ocio
DIR ${CMAKE_SOURCE_DIR}/src/ocio
DESCRIPTION "OpenColorIO"
BUILD ON
)
build_add_project(
opencv
DIR ${CMAKE_SOURCE_DIR}/src/opencv
DESCRIPTION "OpenCV"
BUILD ON
)
build_add_project(
openexr
DIR ${CMAKE_SOURCE_DIR}/src/openexr
DESCRIPTION "OpenEXR"
BUILD ON
)
build_add_project(
pkg-config
DIR ${CMAKE_SOURCE_DIR}/src/pkg-config
DESCRIPTION "pkg-config"
BUILD ON
)
build_add_project(
ptex
DIR ${CMAKE_SOURCE_DIR}/src/ptex
DESCRIPTION "ptex"
BUILD ON
)
build_add_project(
pybind
DIR ${CMAKE_SOURCE_DIR}/src/pybind
DESCRIPTION "Pybind"
BUILD ON
)
build_add_project(
x264
DIR ${CMAKE_SOURCE_DIR}/src/x264
DESCRIPTION "x264"
BUILD ON
)
build_add_project(
yasm
DIR ${CMAKE_SOURCE_DIR}/src/yasm
DESCRIPTION "yasm"
BUILD ON
)
build_add_project(
gettext
DIR ${CMAKE_SOURCE_DIR}/src/gettext
DESCRIPTION "Gettext"
BUILD ON
)
build_add_project(
autoconf
DIR ${CMAKE_SOURCE_DIR}/src/autoconf
DESCRIPTION "Autoconf"
BUILD ON
)
build_add_project(
automake
DIR ${CMAKE_SOURCE_DIR}/src/automake
DESCRIPTION "Automake"
BUILD ON
)
build_add_project(
libtool
DIR ${CMAKE_SOURCE_DIR}/src/libtool
DESCRIPTION "Libtool"
BUILD ON
)
endif()
# build extras
if( build_extras )
build_info( "Adding extras" )
build_add_project(
aces_container
DIR ${CMAKE_SOURCE_DIR}/src/aces_container
DESCRIPTION "aces_container"
BUILD ON
)
build_add_project(
alembic
DIR ${CMAKE_SOURCE_DIR}/src/alembic
DESCRIPTION "alembic"
BUILD ON
)
build_add_project(
ceres-solver
DIR ${CMAKE_SOURCE_DIR}/src/ceres-solver
DESCRIPTION "ceres-solver"
BUILD ON
)
build_add_project(
draco
DIR ${CMAKE_SOURCE_DIR}/src/draco
DESCRIPTION "draco"
BUILD ON
)
build_add_project(
eigen3
DIR ${CMAKE_SOURCE_DIR}/src/eigen
DESCRIPTION "eigen"
BUILD ON
)
build_add_project(
glog
DIR ${CMAKE_SOURCE_DIR}/src/glog
DESCRIPTION "glog"
BUILD ON
)
build_add_project(
json
DIR ${CMAKE_SOURCE_DIR}/src/json
DESCRIPTION "json"
BUILD ON
)
build_add_project(
libjpeg-turbo
DIR ${CMAKE_SOURCE_DIR}/src/libjpeg-turbo
DESCRIPTION "libJpeg-turbo"
BUILD ON
)
build_add_project(
llvm
DIR ${CMAKE_SOURCE_DIR}/src/llvm
DESCRIPTION "LLVM"
BUILD ON
)
build_add_project(
materialx
DIR ${CMAKE_SOURCE_DIR}/src/materialx
DESCRIPTION "MaterialX"
BUILD ON
)
build_add_project(
nanogui
DIR ${CMAKE_SOURCE_DIR}/src/nanogui
DESCRIPTION "nanogui"
BUILD ON
)
build_add_project(
onetbb
DIR ${CMAKE_SOURCE_DIR}/src/onetbb
DESCRIPTION "Onetbb"
BUILD ON
)
build_add_project(
opensubdiv
DIR ${CMAKE_SOURCE_DIR}/src/opensubdiv
DESCRIPTION "opensubdiv"
BUILD ON
)
build_add_project(
tclap
DIR ${CMAKE_SOURCE_DIR}/src/tclap
DESCRIPTION "tclap"
BUILD ON
)
build_add_project(
pyside
DIR ${CMAKE_SOURCE_DIR}/src/pyside
DESCRIPTION "pyside"
BUILD ON
)
build_add_project(
usd
DIR ${CMAKE_SOURCE_DIR}/src/usd
DESCRIPTION "usd"
BUILD ON
)
endif()
if( build_media )
build_info( "Adding media" )
build_add_project(
jpeg2000_images
DIR ${CMAKE_SOURCE_DIR}/src/jpeg2000_images
DESCRIPTION "Jpeg2000 images"
BUILD ON
)
build_add_project(
ocio-images
DIR ${CMAKE_SOURCE_DIR}/src/ocio-images
DESCRIPTION "OpenColorIO images"
BUILD ON
)
build_add_project(
oiio-images
DIR ${CMAKE_SOURCE_DIR}/src/oiio-images
DESCRIPTION "OpenImageIO images"
BUILD ON
)
build_add_project(
openexr-images
DIR ${CMAKE_SOURCE_DIR}/src/openexr-images
DESCRIPTION "OpenEXR images"
BUILD ON
)
endif()
# summary
if( build_summary )
build_info( "Summary" )
build_info( "Host configuration" )
build_info( " CMAKE_HOST_SYSTEM_NAME = ${CMAKE_HOST_SYSTEM_NAME}" )
build_info( " CMAKE_HOST_SYSTEM_PROCESSOR = ${CMAKE_HOST_SYSTEM_PROCESSOR}" )
build_info( " CMAKE_HOST_SYSTEM_VERSION = ${CMAKE_HOST_SYSTEM_VERSION}" )
build_info( "CMake configuration" )
build_info( " CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
build_info( " CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
build_info( " CMAKE_SHARED_LIBS = ${CMAKE_SHARED_LIBS}")
build_info( " CMAKE_VERBOSE_MAKEFILE = ${CMAKE_VERBOSE_MAKEFILE}")
build_info( "Build configuration" )
build_info( " build_dir = ${build_dir}")
build_info( " build_flags = ${build_flags}")
build_info( " build_base = ${build_base}")
build_info( " build_libs = ${build_libs}")
build_info( " build_extras = ${build_extras}")
build_info( " build_media = ${build_media}")
build_info( "Usage" )
build_info( " Change a configuration value with: cmake -D<variable>=<value>" )
endif()