forked from tpaviot/oce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
1550 lines (1374 loc) · 65.7 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
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# REQUIREMENTS: this script needs CMake 2.8 or higher. Downloads are available at http://www.cmake.org
# How to build OCE using CMake under Unix (Linux, Darwin etc.)?
# 1. Copy this file, as-is, to the top-level OCE folder
# 2. Make a build directory somewhere outside the OCE source tree
# 3. cmake "relative/path/to/OCE"
# 4. make
# 5. make install (or sudo make install)
# How to build OCE using CMake under Windows (Linux, Darwin etc.)?
# 1. Copy this file, as-is, to the top-level folder
# 2. Launch the cmake-gui, and select the top-level folder
# 3. You can choose whatever you want as an install directory
# 4. Click 'Configure'
# 5. Choose your generator
# 6. When configure is achived, you can change the variable with a red background
# 7. Click 'Generate'
# 8. From your IDE, open the generated makefile and run the compilation.
project(OCE)
set(OCE_VERSION_MAJOR 0)
set(OCE_VERSION_MINOR 15)
# OCE_VERSION_PATCH is used for bugfixes releases only
# (uncomment following line)
#set(OCE_VERSION_PATCH 0)
# Empty for official releases, set to -dev, -rc1, etc for development releases
set(OCE_VERSION_DEVEL -dev)
# bugfix release: add ${OCE_VERSION_PATCH} to OCE_VERSION
set(OCE_VERSION ${OCE_VERSION_MAJOR}.${OCE_VERSION_MINOR}${OCE_VERSION_DEVEL})
set(OCE_ABI_SOVERSION 7)
set(OCE_ABI_VERSION ${OCE_ABI_SOVERSION}.0.0)
# Set the minimum version of cmake required to 2.6
cmake_minimum_required( VERSION 2.6 )
# Define helper macro option_with_default
macro( option_with_default OPTION_NAME OPTION_STRING OPTION_DEFAULT )
if( NOT DEFINED ${OPTION_NAME} )
set( ${OPTION_NAME} ${OPTION_DEFAULT} )
endif( NOT DEFINED ${OPTION_NAME} )
option( ${OPTION_NAME} "${OPTION_STRING}" ${${OPTION_NAME}} )
endmacro( option_with_default OPTION_NAME OPTION_STRING OPTION_DEFAULT )
############################
# Check 32/64 bit platform #
############################
if (${CMAKE_SIZEOF_VOID_P} MATCHES "8") # It is 64bit, otherwise 32 bit systems match 4
add_definitions(-D_OCC64)
set(BIT 64)
else (${CMAKE_SIZEOF_VOID_P} MATCHES "8")
set(BIT 32)
endif(${CMAKE_SIZEOF_VOID_P} MATCHES "8")
message(STATUS "Build ${BIT}bit")
if(NOT CMAKE_CONFIGURATION_TYPES)
if( NOT DEFINED OCE_BUILD_TYPE )
# If CMAKE_BUILD_TYPE is set, initialize OCE_BUILD_TYPE to that.
# Otherwise, default to a Release build.
if( CMAKE_BUILD_TYPE )
set( OCE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Set from CMAKE_BUILD_TYPE" )
else()
set( OCE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Release Debug RelWithDebInfo MinSizeRel None" )
set( CMAKE_BUILD_TYPE ${OCE_BUILD_TYPE} CACHE INTERNAL "Build type, immutable" FORCE )
endif(CMAKE_BUILD_TYPE)
endif( NOT DEFINED OCE_BUILD_TYPE )
# The "set_property(CACHE" capability first appeared in CMake version 2.8.0
# We test against > 2.8 though, otherwise test is much less readable
if (${CMAKE_VERSION} VERSION_GREATER 2.8)
set_property(CACHE OCE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "RelWithDebInfo" "MinSizeRel" "None")
endif (${CMAKE_VERSION} VERSION_GREATER 2.8)
endif(NOT CMAKE_CONFIGURATION_TYPES)
if(CMAKE_BUILD_TOOL STREQUAL "nmake")
set(NMAKE TRUE)
endif(CMAKE_BUILD_TOOL STREQUAL "nmake")
if(MSVC)
option_with_default( OCE_INSTALL_PDB_FILES "Install PDB files (debug informations)" ON )
option_with_default( OCE_MULTITHREADED_BUILD "Multithreaded build (/CL Option)" ON )
endif(MSVC)
############################
# Library name definitions #
############################
if(MSVC)
set( OCE_LIBRARY_PREFIX "" )
set( CMAKE_DEBUG_POSTFIX "d" )
else(MSVC)
set( OCE_LIBRARY_PREFIX "lib" )
endif(MSVC)
if(APPLE)
if(OCE_NO_LIBRARY_VERSION)
set( OCE_LIBRARY_EXTENSION ${CMAKE_SHARED_LIBRARY_SUFFIX} )
else(OCE_NO_LIBRARY_VERSION)
set( OCE_LIBRARY_EXTENSION ".${OCE_ABI_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}" )
endif(OCE_NO_LIBRARY_VERSION)
elseif(WIN32)
# Don't encode library versions on Windows systems
set( OCE_LIBRARY_EXTENSION ${CMAKE_SHARED_LIBRARY_SUFFIX} )
else()
if(OCE_NO_LIBRARY_VERSION)
set( OCE_LIBRARY_EXTENSION ${CMAKE_SHARED_LIBRARY_SUFFIX} )
else(OCE_NO_LIBRARY_VERSION)
set( OCE_LIBRARY_EXTENSION "${CMAKE_SHARED_LIBRARY_SUFFIX}.${OCE_ABI_SOVERSION}" )
endif(OCE_NO_LIBRARY_VERSION)
endif()
if(MSVC OR MINGW)
option_with_default( OCE_USE_BUNDLE "Use OCE Windows Bundle that has been built and installed" OFF )
option_with_default( OCE_USE_BUNDLE_SOURCE "Use OCE Windows Bundle source and incorporate into current project" OFF )
endif(MSVC OR MINGW)
if(BORLAND)
option_with_default( OCE_INSTALL_TDS_FILES "Instal TDS files (debug informations)" ON )
endif(BORLAND)
if(OCE_USE_BUNDLE OR OCE_USE_BUNDLE_SOURCE)
option_with_default( OCE_BUNDLE_AUTOINSTALL "Autoinstall bundle DLLs" ON )
mark_as_advanced(OCE_BUNDLE_AUTOINSTALL)
endif(OCE_USE_BUNDLE OR OCE_USE_BUNDLE_SOURCE)
if ((MSVC AND NOT NMAKE) OR CMAKE_COMPILER_IS_GNUCXX)
set(OCE_COMPILER_SUPPORTS_PCH TRUE)
if(MSVC)
option_with_default( OCE_USE_PCH "Use Precompiled Headers" ON )
else()
option_with_default( OCE_USE_PCH "Use Precompiled Headers" OFF )
endif()
mark_as_advanced(OCE_USE_PCH)
endif((MSVC AND NOT NMAKE) OR CMAKE_COMPILER_IS_GNUCXX)
option_with_default( OCE_BUILD_SHARED_LIB "Build shared OCE libs" ON )
if(NOT MSVC AND NOT OCE_OSX_USE_COCOA)
option_with_default( OCE_DISABLE_X11 "Disable components requiring X11 support" OFF )
if(NOT APPLE AND NOT WIN32)
mark_as_advanced(OCE_DISABLE_X11)
endif(NOT APPLE AND NOT WIN32)
endif(NOT MSVC AND NOT OCE_OSX_USE_COCOA)
option_with_default( OCE_MODEL "Build model components" ON )
option_with_default( OCE_OCAF "Build application framework" ON )
option_with_default( OCE_DATAEXCHANGE "Build data exchange" ON )
option_with_default( OCE_DRAW "Build test harness \(DRAW\)" OFF )
option_with_default( OCE_VISUALISATION "Build visualisation component" ON )
option_with_default( OCE_WITH_GL2PS "Build with GL2PS" OFF )
option_with_default( OCE_WITH_FREEIMAGE "Build with FreeImage" OFF )
option_with_default( OCE_EXTRA_WARNINGS "Enable Maximum Warnings Level" OFF )
mark_as_advanced(OCE_EXTRA_WARNINGS)
if( NOT "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8 )
option_with_default( OCE_TESTING "Enable unittesting framework" OFF )
mark_as_advanced(OCE_TESTING)
endif( NOT "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8 )
option_with_default( OCE_ADD_HEADERS "Add headers to project files" OFF )
mark_as_advanced(OCE_ADD_HEADERS)
option_with_default( OCE_DISABLE_BSPLINE_MESHER "Disable BSpline Mesher" OFF )
mark_as_advanced(OCE_DISABLE_BSPLINE_MESHER)
if(APPLE)
option_with_default( OCE_OSX_USE_COCOA "Use native OSX Cocoa backend" ON )
endif(APPLE)
if (NOT WIN32)
option_with_default( OCE_RPATH_FILTER_SYSTEM_PATHS "Filter out system paths from RPATH" ON )
mark_as_advanced(OCE_RPATH_FILTER_SYSTEM_PATHS)
endif (NOT WIN32)
# When building OCE as part of another application, it may be useful to copy
# header files in a temporary location so that dependent applications can be built
option_with_default( OCE_COPY_HEADERS_BUILD "Copy header files when building OCE" OFF )
option_with_default( OCE_USE_TCL_TEST_FRAMEWORK "Add occt-tests target" OFF )
#
# By default, OSX uses X11 OpenGl implementation
#
if (APPLE)
if (NOT OCE_OSX_USE_COCOA)
set(MACOSX_USE_GLX TRUE)
endif(NOT OCE_OSX_USE_COCOA)
endif(APPLE)
# The default for the DEB define is ON for all the platforms , in debug mode.
# In MSVC it is not desirable to have it ON by default, since users must
# compile/use the OCE debug libraries to build it's own programs in DEBUG mode.
# DEB should be enabled by developers only, in this case
if ((MSVC OR BORLAND) AND CMAKE_CONFIGURATION_TYPES)
set (DEB_DEFAULT "OFF")
else ()
set (DEB_DEFAULT "ON")
endif ((MSVC OR BORLAND) AND CMAKE_CONFIGURATION_TYPES)
option_with_default( OCE_ENABLE_DEB_FLAG "Enables DEB define in debug configuration" ${DEB_DEFAULT} )
mark_as_advanced(OCE_ENABLE_DEB_FLAG)
if(NOT MSVC)
option_with_default( OCE_COVERAGE "Build with coverage testing" OFF )
mark_as_advanced(OCE_COVERAGE)
endif(NOT MSVC)
if( NOT DEFINED OCE_MULTITHREAD_LIBRARY)
set( OCE_MULTITHREAD_LIBRARY "NONE" CACHE STRING "(values are: NONE TBB OPENMP)" )
endif( NOT DEFINED OCE_MULTITHREAD_LIBRARY)
if (${CMAKE_VERSION} VERSION_GREATER 2.8)
set_property(CACHE OCE_MULTITHREAD_LIBRARY PROPERTY STRINGS NONE TBB OPENMP)
endif (${CMAKE_VERSION} VERSION_GREATER 2.8)
option( OCE_MULTITHREAD_LIBRARY "Multithread library" ${OCE_MULTITHREAD_LIBRARY} )
if( OCE_MULTITHREAD_LIBRARY STREQUAL "TBB" )
option_with_default( OCE_TBB_MALLOC_SUPPORT "Use TBB for memory allocation" ON )
endif( OCE_MULTITHREAD_LIBRARY STREQUAL "TBB" )
if( OCE_USE_TCL_TEST_FRAMEWORK )
set( tcl_test_groups 3rdparty;blend;boolean;bugs;caf;chamfer;de;demo;draft;feat;geometry;heal;mesh;mkface;nproject;offset;perf;pipe;prism;sewing;thrusection;v3d;xcaf;xml )
if( NOT DEFINED OCE_TCL_TEST_GROUP)
set( OCE_TCL_TEST_GROUP "ALL" CACHE STRING "Group of OCCT test packages to run (values are: ALL;${tcl_test_groups})" )
endif( NOT DEFINED OCE_TCL_TEST_GROUP)
mark_as_advanced(OCE_TCL_TEST_GROUP)
if (${CMAKE_VERSION} VERSION_GREATER 2.8)
set_property(CACHE OCE_TCL_TEST_GROUP PROPERTY STRINGS "ALL;${tcl_test_groups}")
endif (${CMAKE_VERSION} VERSION_GREATER 2.8)
endif( OCE_USE_TCL_TEST_FRAMEWORK )
if( NOT DEFINED OCE_INSTALL_PREFIX )
if( WIN32 )
set(OCE_INSTALL_PREFIX
"c:/OCE-${OCE_VERSION}")
else( WIN32 )
set(OCE_INSTALL_PREFIX
"/usr/local")
endif( WIN32 )
endif( NOT DEFINED OCE_INSTALL_PREFIX )
set( OCE_INSTALL_PREFIX ${OCE_INSTALL_PREFIX} CACHE
PATH "Install prefix prepended to target to create install location" )
set( CMAKE_INSTALL_PREFIX "${OCE_INSTALL_PREFIX}" CACHE INTERNAL "Prefix
prepended to install directories if target destination is not absolute,
immutable" FORCE )
if( OCE_BUILD_SHARED_LIB )
set( OCE_LIBRARY_TYPE SHARED )
set( OCE_BUILD_STATIC_LIB FALSE )
else( OCE_BUILD_SHARED_LIB )
set( OCE_LIBRARY_TYPE STATIC )
set( OCE_BUILD_STATIC_LIB TRUE )
if ( WIN32 )
add_definitions("-DHAVE_NO_DLL")
endif( WIN32 )
endif( OCE_BUILD_SHARED_LIB )
# MSVC specific options
if(MSVC_IDE)
if (NOT DEFINED OCE_USE_MSVC_EXPRESS )
set (OCE_USE_MSVC_EXPRESS OFF)
endif (NOT DEFINED OCE_USE_MSVC_EXPRESS)
option( OCE_USE_MSVC_EXPRESS "Use a Visual C++ express IDE"
${OCE_USE_MSVC_EXPRESS} )
endif(MSVC_IDE)
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_RELEASE NDEBUG)
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_MINSIZEREL NDEBUG)
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO NDEBUG)
if(OCE_ENABLE_DEB_FLAG)
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_DEBUG "DEB=1;_DEBUG")
else ()
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_DEBUG "_DEBUG")
endif (OCE_ENABLE_DEB_FLAG)
if(OCE_MULTITHREAD_LIBRARY STREQUAL "NONE")
add_definitions(-DIGNORE_NO_ATOMICS)
endif (OCE_MULTITHREAD_LIBRARY STREQUAL "NONE")
#
# Check components dependencies
#
set(OCE_FOUNDATION TRUE)
if(OCE_OCAF OR OCE_DATAEXCHANGE OR OCE_VISUALISATION OR OCE_DRAW)
set(OCE_VISU_DEP TRUE)
else(OCE_OCAF OR OCE_DATAEXCHANGE OR OCE_VISUALISATION OR OCE_DRAW)
set(OCE_VISU_DEP FALSE)
endif(OCE_OCAF OR OCE_DATAEXCHANGE OR OCE_VISUALISATION OR OCE_DRAW)
if(OCE_DISABLE_X11)
set(OCE_VISU_DEP FALSE)
endif(OCE_DISABLE_X11)
if(OCE_DISABLE_X11)
set(OCE_DRAW OFF CACHE BOOL "Build DRAWEXE" FORCE)
set(OCE_VISUALISATION OFF CACHE BOOL "Build visualisation component" FORCE)
endif(OCE_DISABLE_X11)
if(NOT OCE_BUILD_SHARED_LIB AND OCE_DRAW)
set(OCE_DRAW OFF CACHE BOOL "Build DRAWEXE" FORCE)
message("Warning : DRAW disabled when statically linking")
endif(NOT OCE_BUILD_SHARED_LIB AND OCE_DRAW)
if(OCE_DRAW AND NOT OCE_DATAEXCHANGE)
set(OCE_DATAEXCHANGE ON CACHE BOOL "Build data exchange" FORCE)
endif(OCE_DRAW AND NOT OCE_DATAEXCHANGE)
if(OCE_DATAEXCHANGE AND NOT OCE_OCAF)
set(OCE_OCAF ON CACHE BOOL "Build application framework" FORCE)
endif(OCE_DATAEXCHANGE AND NOT OCE_OCAF)
if(OCE_OCAF AND NOT OCE_MODEL)
set(OCE_MODEL ON CACHE BOOL "Build model components" FORCE)
endif(OCE_OCAF AND NOT OCE_MODEL)
if(OCE_VISUALISATION AND NOT OCE_MODEL)
set(OCE_MODEL ON CACHE BOOL "Build model components" FORCE)
endif(OCE_VISUALISATION AND NOT OCE_MODEL)
if(OCE_DRAW AND NOT OCE_VISUALISATION)
set(OCE_VISUALISATION ON CACHE BOOL "Build visualisation component" FORCE)
endif(OCE_DRAW AND NOT OCE_VISUALISATION)
set(INSTALL_STDRESOURCE_FILES)
set(INSTALL_RESOURCE_FILES)
file(GLOB OS_TCL_SCRIPTS RELATIVE ${OCE_SOURCE_DIR} src/OS/*.tcl)
set(INSTALL_RESOURCE_FILES ${INSTALL_RESOURCE_FILES}
${OS_TCL_SCRIPTS}
src/UnitsAPI/Lexi_Expr.dat
src/UnitsAPI/Units.dat )
set(INSTALL_STDRESOURCE_FILES ${INSTALL_STDRESOURCE_FILES}
src/UnitsAPI/CurrentUnits
src/UnitsAPI/MDTVBaseUnits
src/UnitsAPI/MDTVCurrentUnits )
find_package(Threads)
if(OCE_MULTITHREAD_LIBRARY STREQUAL "TBB")
find_path(TBB_INCLUDE_DIR tbb/tbb.h DOC "Location of header files for TBB (containing tbb/tbb.h)" ${CMAKE_SYSTEM_INCLUDE_PATH})
if(TBB_INCLUDE_DIR)
if(MSVC)
if(CMAKE_CL_64)
set(TBB_ARCH intel64)
else(CMAKE_CL_64)
set(TBB_ARCH ia32)
endif(CMAKE_CL_64)
get_filename_component(TBB_ROOT "${TBB_INCLUDE_DIR}/.." ABSOLUTE)
if(OCE_BUILD_SHARED_LIB)
if(MSVC80)
set(TBB_BIN_DIR "${TBB_ROOT}/bin/${TBB_ARCH}/vc8")
set(TBB_LIB_DIR "${TBB_ROOT}/lib/${TBB_ARCH}/vc8")
elseif(MSVC90)
set(TBB_BIN_DIR "${TBB_ROOT}/bin/${TBB_ARCH}/vc9")
set(TBB_LIB_DIR "${TBB_ROOT}/lib/${TBB_ARCH}/vc9")
elseif(MSVC10)
set(TBB_BIN_DIR "${TBB_ROOT}/bin/${TBB_ARCH}/vc10")
set(TBB_LIB_DIR "${TBB_ROOT}/lib/${TBB_ARCH}/vc10")
endif()
else(OCE_BUILD_SHARED_LIB)
set(TBB_LIB_DIR "${TBB_ROOT}/lib/${TBB_ARCH}/vc_mt")
endif(OCE_BUILD_SHARED_LIB)
endif(MSVC)
find_library( TBB_LIBRARY tbb PATHS "${TBB_LIB_DIR}" "Path to the TBB library" )
if (OCE_TBB_MALLOC_SUPPORT)
find_library( TBB_MALLOC_LIBRARY tbbmalloc PATHS "${TBB_LIB_DIR}" "Path to the TBB MALLOC library")
endif (OCE_TBB_MALLOC_SUPPORT)
if(CMAKE_CONFIGURATION_TYPES OR NMAKE)
find_library( TBB_LIBRARY_DEBUG tbb_debug PATHS "${TBB_LIB_DIR}" "Path to the TBB debug library" )
if (OCE_TBB_MALLOC_SUPPORT)
find_library( TBB_MALLOC_LIBRARY_DEBUG tbbmalloc_debug PATHS "${TBB_LIB_DIR}" "Path to the TBB MALLOC debug library")
endif (OCE_TBB_MALLOC_SUPPORT)
endif(CMAKE_CONFIGURATION_TYPES OR NMAKE)
endif(TBB_INCLUDE_DIR)
mark_as_advanced(TBB_INCLUDE_DIR TBB_LIBRARY)
endif(OCE_MULTITHREAD_LIBRARY STREQUAL "TBB")
if(OCE_MULTITHREAD_LIBRARY STREQUAL "OPENMP")
find_package(OpenMP)
endif(OCE_MULTITHREAD_LIBRARY STREQUAL "OPENMP")
if (OCE_USE_BUNDLE OR OCE_USE_BUNDLE_SOURCE)
find_path(OCE_BUNDLE_ROOT_PATH oce-bundle-root.empty "Path for the OCE-win-bundle")
endif(OCE_USE_BUNDLE OR OCE_USE_BUNDLE_SOURCE)
if(OCE_VISU_DEP)
## TKService requires OpenGL on Unix, see src/Xw/Xw_Window.cxx
if (NOT (WIN32 OR (APPLE AND OCE_OSX_USE_COCOA)))
find_package(OpenGL REQUIRED)
endif (NOT (WIN32 OR (APPLE AND OCE_OSX_USE_COCOA)))
endif(OCE_VISU_DEP)
if(OCE_VISU_DEP)
## TKService requires FreeType
if(NOT OCE_USE_BUNDLE AND NOT OCE_USE_BUNDLE_SOURCE)
find_package(Freetype REQUIRED)
else (NOT OCE_USE_BUNDLE AND NOT OCE_USE_BUNDLE_SOURCE)
find_library(FREETYPE_LIBRARY freetype)
endif(NOT OCE_USE_BUNDLE AND NOT OCE_USE_BUNDLE_SOURCE)
if(CMAKE_CONFIGURATION_TYPES OR NMAKE)
find_library(FREETYPE_LIBRARY_DEBUG freetyped "Location of freetype debug library")
endif(CMAKE_CONFIGURATION_TYPES OR NMAKE)
endif(OCE_VISU_DEP)
if(OCE_VISUALISATION)
if(OCE_WITH_FREEIMAGE)
find_path(FREEIMAGE_INCLUDE_DIR FreeImagePlus.h DOC "Location of header files for FreeImage" ${CMAKE_SYSTEM_INCLUDE_PATH})
if(FREEIMAGE_INCLUDE_DIR)
find_library( FREEIMAGE_LIBRARY freeimage "Path to the freeimage library" )
if(CMAKE_CONFIGURATION_TYPES OR NMAKE)
find_library( FREEIMAGE_LIBRARY_DEBUG freeimaged "Path to the freeimage debug library" )
endif(CMAKE_CONFIGURATION_TYPES OR NMAKE)
endif(FREEIMAGE_INCLUDE_DIR)
mark_as_advanced(FREEIMAGE_INCLUDE_DIR FREEIMAGE_LIBRARY)
if(WIN32)
if(FREEIMAGE_INCLUDE_DIR)
find_library( FREEIMAGEPLUS_LIBRARY freeimageplus "Path to the freeimageplus library" )
if(CMAKE_CONFIGURATION_TYPES OR NMAKE)
find_library( FREEIMAGEPLUS_LIBRARY_DEBUG freeimageplusd "Path to the freeimageplus debug library" )
endif(CMAKE_CONFIGURATION_TYPES OR NMAKE)
endif(FREEIMAGE_INCLUDE_DIR)
mark_as_advanced(FREEIMAGEPLUS_LIBRARY)
endif(WIN32)
endif(OCE_WITH_FREEIMAGE)
if (NOT WIN32 AND NOT OCE_OSX_USE_COCOA)
find_package(X11 REQUIRED)
endif(NOT WIN32 AND NOT OCE_OSX_USE_COCOA)
if (NOT APPLE OR OCE_OSX_USE_COCOA)
find_package(OpenGL REQUIRED)
if(NOT ${OPENGL_GLU_FOUND} STREQUAL "YES")
message( FATAL_ERROR "GLU not found" )
endif(NOT ${OPENGL_GLU_FOUND} STREQUAL "YES")
else (NOT APPLE OR OCE_OSX_USE_COCOA)
set(OPENGL_INCLUDE_DIR /usr/X11R6/include/)
set(OPENGL_LIBRARIES /usr/X11R6/lib/libGL.dylib /usr/X11R6/lib/libGLU.dylib)
endif (NOT APPLE OR OCE_OSX_USE_COCOA)
## GL2PS
if(OCE_WITH_GL2PS)
find_path(GL2PS_INCLUDE_DIR gl2ps.h DOC "Location of header files for GL2PS (containing gl2ps.h)" ${CMAKE_SYSTEM_INCLUDE_PATH})
if(GL2PS_INCLUDE_DIR)
find_library( GL2PS_LIBRARY gl2ps "Path to the gl2ps library" )
if(CMAKE_CONFIGURATION_TYPES OR NMAKE)
find_library( GL2PS_LIBRARY_DEBUG gl2psd "Path to the gl2ps debug library" )
endif(CMAKE_CONFIGURATION_TYPES OR NMAKE)
endif(GL2PS_INCLUDE_DIR)
mark_as_advanced(GL2PS_INCLUDE_DIR GL2PS_LIBRARY)
endif(OCE_WITH_GL2PS)
if (NOT WIN32 AND NOT OCE_OSX_USE_COCOA)
message(STATUS "X11 LIBS: ${X11_LIBRARIES}")
endif(NOT WIN32 AND NOT OCE_OSX_USE_COCOA)
message(STATUS "OPENGL LIBS: ${OPENGL_LIBRARIES}")
message(STATUS "FREETYPE LIBS: ${FREETYPE_LIBRARIES}")
message(STATUS "FREETYPE INCLUDES: ${FREETYPE_INCLUDE_DIRS}")
message(STATUS "THREAD LIB: ${CMAKE_THREAD_LIBS_INIT}")
file(GLOB TEXTURES_RGB_FILES RELATIVE ${OCE_SOURCE_DIR} src/Textures/*.rgb)
file(GLOB SHADERS_FILES RELATIVE ${OCE_SOURCE_DIR} src/Shaders/*.*)
set(INSTALL_RESOURCE_FILES ${INSTALL_RESOURCE_FILES} ${TEXTURES_RGB_FILES} ${SHADERS_FILES})
endif(OCE_VISUALISATION)
if(OCE_OCAF)
file(GLOB XMLOCAFRESOURCE_XSD_FILES RELATIVE ${OCE_SOURCE_DIR} src/XmlOcafResource/*.xsd)
set(INSTALL_RESOURCE_FILES ${INSTALL_RESOURCE_FILES}
${XMLOCAFRESOURCE_XSD_FILES}
src/StdResource/MigrationSheet.txt
src/StdResource/MDTV-Standard.xwd
src/StdResource/Plugin
src/StdResource/Standard
src/StdResource/Standard.us
src/StdResource/StandardLite
src/StdResource/TObj
src/StdResource/XCAF )
endif(OCE_OCAF)
if(OCE_DATAEXCHANGE)
set(INSTALL_RESOURCE_FILES ${INSTALL_RESOURCE_FILES}
src/SHMessage/SHAPE.fr
src/SHMessage/SHAPE.us
src/XSMessage/IGES.fr
src/XSMessage/IGES.us
src/XSMessage/XSTEP.fr
src/XSMessage/XSTEP.us
src/XSTEPResource/IGES
src/XSTEPResource/STEP )
endif(OCE_DATAEXCHANGE)
if(OCE_DRAW)
if (APPLE AND NOT OCE_OSX_USE_COCOA)
# under OSX-X11, should use a X11 based TCL/TK, for instance fink's implementation
set(FINK_INSTALL_PATH /sw)
mark_as_advanced(FINK_INSTALL_PATH)
set(TCL_LIBRARY ${FINK_INSTALL_PATH}/lib/libtcl.dylib)
set(TCL_INCLUDE_PATH ${FINK_INSTALL_PATH}/include)
set(TCL_TCLSH ${FINK_INSTALL_PATH}/bin/tclsh)
set(TK_LIBRARY ${FINK_INSTALL_PATH}/lib/libtk.dylib)
set(TK_INCLUDE_PATH ${FINK_INSTALL_PATH}/include)
set(TK_WISH ${FINK_INSTALL_PATH}/bin/wish)
mark_as_advanced(TCL_INCLUDE_PATH TK_INCLUDE_PATH TCL_LIBRARY TK_LIBRARY)
else(APPLE AND NOT OCE_OSX_USE_COCOA)
find_package(TCL REQUIRED)
endif(APPLE AND NOT OCE_OSX_USE_COCOA)
message(STATUS "TCL LIB: ${TCL_LIBRARY}")
message(STATUS "TK LIB: ${TK_LIBRARY}")
file(GLOB DRAWRESOURCES_TCL_FILES RELATIVE ${OCE_SOURCE_DIR} src/DrawResources/*.tcl)
set(INSTALL_RESOURCE_FILES ${INSTALL_RESOURCE_FILES}
${DRAWRESOURCES_TCL_FILES}
src/DrawResources/DRAW.doc
src/DrawResources/DRAW.info
src/DrawResources/DrawDefault
src/DrawResources/DrawPlugin
src/DrawResources/idoc
src/DrawResources/lamp.ico
src/DrawResources/mkdoc
src/DrawResources/tdoc )
endif(OCE_DRAW)
if (OCE_USE_BUNDLE AND OCE_BUNDLE_ROOT_PATH)
message("Using previously built and installed OCE Bundle")
if (OCE_VISU_DEP)
set(FREETYPE_INCLUDE_DIR_freetype2 ${OCE_BUNDLE_ROOT_PATH}/include/freetype CACHE PATH "" FORCE)
set(FREETYPE_INCLUDE_DIR_ft2build ${OCE_BUNDLE_ROOT_PATH}/include/freetype CACHE PATH "" FORCE)
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR_freetype2} ${FREETYPE_INCLUDE_DIR_ft2build})
set(FREETYPE_LIBRARY ${OCE_BUNDLE_ROOT_PATH}/Win${BIT}/lib/freetype.lib CACHE FILEPATH "" FORCE)
set(FREETYPE_LIBRARIES ${OCE_BUNDLE_ROOT_PATH}/Win${BIT}/lib/freetype.lib CACHE FILEPATH "" FORCE)
set(FREETYPE_LIBRARY_DEBUG ${OCE_BUNDLE_ROOT_PATH}/Win${BIT}/lib/freetyped.lib CACHE FILEPATH "" FORCE)
if(OCE_WITH_GL2PS)
set(GL2PS_LIBRARY ${OCE_BUNDLE_ROOT_PATH}/Win${BIT}/lib/gl2ps.lib CACHE FILEPATH "" FORCE)
set(GL2PS_LIBRARY_DEBUG ${OCE_BUNDLE_ROOT_PATH}/Win${BIT}/lib/gl2psd.lib CACHE FILEPATH "" FORCE)
set(GL2PS_INCLUDE_DIR ${OCE_BUNDLE_ROOT_PATH}/include/gl2ps CACHE PATH "" FORCE)
endif(OCE_WITH_GL2PS)
if(OCE_WITH_FREEIMAGE)
set(FREEIMAGE_LIBRARY ${OCE_BUNDLE_ROOT_PATH}/Win${BIT}/lib/FreeImage.lib CACHE FILEPATH "" FORCE)
set(FREEIMAGE_LIBRARY_DEBUG ${OCE_BUNDLE_ROOT_PATH}/Win${BIT}/lib/FreeImaged.lib CACHE FILEPATH "" FORCE)
set(FREEIMAGEPLUS_LIBRARY ${OCE_BUNDLE_ROOT_PATH}/Win${BIT}/lib/FreeImagePlus.lib CACHE FILEPATH "" FORCE)
set(FREEIMAGEPLUS_LIBRARY_DEBUG ${OCE_BUNDLE_ROOT_PATH}/Win${BIT}/lib/FreeImagePlusd.lib CACHE FILEPATH "" FORCE)
set(FREEIMAGE_INCLUDE_DIR ${OCE_BUNDLE_ROOT_PATH}/include/FreeImage CACHE PATH "" FORCE)
endif(OCE_WITH_FREEIMAGE)
endif (OCE_VISU_DEP)
endif(OCE_USE_BUNDLE AND OCE_BUNDLE_ROOT_PATH)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/build_inc
${CMAKE_CURRENT_SOURCE_DIR}/inc)
###################################
# Architecture-specific libraries #
###################################
if(WIN32)
set(LM)
set(CSF_gdi32_LIB gdi32)
set(CSF_advapi32_LIB advapi32)
set(CSF_user32_LIB user32)
set(CSF_kernel32_LIB kernel32)
set(CSF_SOCKETLibs_LIB ws2_32)
set(CSF_wsock32_LIB ws2_32)
set(CSF_psapi_LIB psapi)
else(WIN32)
set(LM "-lm")
set(WIN32_LIBS "")
set(CSF_gdi32_LIB "")
set(CSF_advapi32_LIB "")
set(CSF_user32_LIB "")
set(CSF_kernel32_LIB "")
set(CSF_SOCKETLibs_LIB "")
set(CSF_wsock32_LIB "")
set(CSF_psapi_LIB "")
endif(WIN32)
###################################################
# Check required headers, functions and libraries #
###################################################
include(CheckFunctionExists)
check_function_exists(finite HAVE_FINITE)
if (NOT WIN32)
# Check headers
# I think these should all be check cxx headers, as I think there is no c
# compilation anywhere in OCE
include(CheckIncludeFile)
#include(CheckIncludeFiles)
check_include_file(string.h HAVE_STRING_H)
check_include_file(dlfcn.h HAVE_DLFCN_H)
check_include_file(dl.h HAVE_DL_H)
check_include_file(ieeefp.h HAVE_IEEEFP_H)
check_include_file(time.h HAVE_TIME_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(pwd.h HAVE_PWD_H)
check_include_file(sys/statvfs.h HAVE_SYS_STATVFS_H)
check_include_file(sys/vfs.h HAVE_SYS_VFS_H)
check_include_file(sys/param.h HAVE_SYS_PARAM_H)
check_include_file(osfcn.h HAVE_OSFCN_H)
check_include_file(netdb.h HAVE_NETDB_H)
check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H)
check_include_file(net/if.h HAVE_NET_IF_H)
check_include_file(sys/systeminfo.h HAVE_SYS_SYSTEMINFO_H)
check_include_file(sys/utsname.h HAVE_SYS_UTSNAME_H)
check_include_file(sysent.h HAVE_SYSENT_H)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(sys/unistd.h HAVE_SYS_UNISTD_H)
check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
check_include_file(ndir.h HAVE_NDIR_H)
check_include_file(sys/ndir.h HAVE_SYS_NDIR_H)
check_include_file(sys/dir.h HAVE_SYS_DIR_H)
check_include_file(signal.h HAVE_SIGNAL_H)
check_include_file(sys/signal.h HAVE_SYS_SIGNAL_H)
check_include_file(sigfpe.h HAVE_SIGFPE_H)
check_include_file(floatingpoint.h HAVE_FLOATINGPOINT_H)
check_include_file(sys/machsig.h HAVE_SYS_MACHSIG_H)
check_include_file(sys/siginfo.h HAVE_SYS_SIGINFO_H)
check_include_file(malloc.h HAVE_MALLOC_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(sys/sem.h HAVE_SYS_SEM_H)
check_include_file(sys/ipc.h HAVE_SYS_IPC_H)
check_include_file(sys/times.h HAVE_SYS_TIMES_H)
check_include_file(dirent.h HAVE_DIRENT_H)
include(CheckIncludeFileCXX)
check_include_file_cxx(iomanip.h OCE_HAVE_IOMANIP_H)
check_include_file_cxx(limits OCE_HAVE_LIMITS)
check_include_file_cxx(climits OCE_HAVE_CLIMITS)
check_include_file_cxx(limits.h OCE_HAVE_LIMITS_H)
check_include_file_cxx(values.h HAVE_VALUES_H)
check_include_file_cxx(fstream OCE_HAVE_FSTREAM)
check_include_file_cxx(ios HAVE_IOS)
check_include_file_cxx(iomanip OCE_HAVE_IOMANIP)
check_include_file_cxx(iostream OCE_HAVE_IOSTREAM)
check_include_file_cxx(fstream.h OCE_HAVE_FSTREAM_H)
check_include_file_cxx(ios.h HAVE_IOS_H)
check_include_file_cxx(iostream.h OCE_HAVE_IOSTREAM_H)
check_include_file_cxx(stdlib.h HAVE_STDLIB_H)
check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H)
check_include_file_cxx(sys/select.h HAVE_SYS_SELECT_H)
check_include_file_cxx(X11/extensions/readdisplay.h HAVE_X11_EXTENSIONS_READDISPLAY_H)
check_include_file_cxx(X11/extensions/multibuf.h HAVE_X11_EXTENSIONS_MULTIBUF_H)
check_include_file_cxx(sys/filio.h HAVE_SYS_FILIO_H)
check_include_file_cxx(sys/mman.h HAVE_SYS_MMAN_H)
check_include_file_cxx(libc.h HAVE_LIBC_H)
check_include_file_cxx(mm_malloc.h HAVE_MM_MALLOC_H)
check_include_file_cxx(atomic.h HAVE_ATOMIC_H)
# Check library functions
check_function_exists(alloca HAVE_ALLOCA)
check_function_exists(memcmp HAVE_MEMCMP)
check_function_exists(signal HAVE_SIGNAL)
check_function_exists(statfs HAVE_STATFS)
check_function_exists(statvfs HAVE_STATVFS)
check_function_exists(localtime_r HAVE_LOCALTIME_R)
check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
set(CMAKE_REQUIRED_LIBRARIES sunmath)
check_function_exists(ieee_handler HAVE_SUNMATH)
set(CMAKE_REQUIRED_LIBRARIES)
include(CheckTypeSize)
set(CMAKE_EXTRA_INCLUDE_FILES sys/time.h)
check_type_size(tm TM_IN_SYS_TIME)
set(CMAKE_EXTRA_INCLUDE_FILES)
include (CheckCSourceCompiles)
check_c_source_compiles("
#include <sys/time.h>
#include <sys/sem.h>
int main(){union semun c;return 0;}
"
SEMUN_DEFINED)
if (SEMUN_DEFINED)
check_c_source_compiles("
#include <sys/time.h>
#include <sys/sem.h>
int main(){union semun c;c.__buf = 0;return 0;}
"
SEMUN_BUF_DEFINED)
endif (SEMUN_DEFINED)
check_c_source_compiles("
#include <sys/sem.h>
static struct sembuf event_flag;
int main(){int status; int *semid;status = semop(*semid,event_flag,1);return 0;}
"
SEMOP_NO_REFERENCE)
check_c_source_compiles("
#include <sys/sem.h>
int get_semaphore(int *semid,int *event,int *value)
{
int status;
status = semctl((*semid),*event,GETVAL,value);
return 0;
}
int main(){ int *a,*b,*c;
if(get_semaphore(a,b,c))
return 0;
return 0;}
"
SEMCTL_NO_REFERENCE)
include (CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <ios>
int main(){static const int input = (std::ios::in)|(std::ios::nocreate);
static const int output = (std::ios::out);return 0;}
"
DEF_IOS_OK)
check_cxx_source_compiles("
#include <iostream>
int main(){std::cout << std::cout.form(\"%9.3e\", 3.14159627e-4) << std::endl;return 0;}
"
OSTREAM_FORM_OK)
include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)
set(STDC_HEADERS TRUE) # Only for really old systems, being lazy
set(STACK_DIRECTION 0) # Don't have a test for this, TODO?
# TODO: check all headers/functions/libraries that are checked in configure.ac original OCC script
endif(NOT WIN32)
#######################################################
# Check compiler version - Determine Borland compiler #
#######################################################
if(BORLAND AND NOT BORLAND_VERSION)
if(EXISTS ${CMAKE_CXX_COMPILER})
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} /?
OUTPUT_VARIABLE _output
ERROR_QUIET
)
string(REGEX MATCH "Embarcadero C[+][+] [0-9]+.[0-9]+"
_borland_version "${_output}")
if(_borland_version)
string(REGEX MATCHALL "[0-9]+" _borland_version_list "${_borland_version}")
list(GET _borland_version_list 0 _borland_major)
list(GET _borland_version_list 1 _borland_minor)
else()
string(REGEX MATCH "Borland C[+][+] [0-9]+].[0-9]+"
_borland_version "${_output}")
if(_borland_version)
string(REGEX MATCHALL "[0-9]+" _borland_version_list "${_borland_version}")
list(GET _borland_version_list 0 _borland_major)
list(GET _borland_version_list 1 _borland_minor)
endif()
endif()
# XE2 compiler?
if("v${_borland_major}.${_borland_minor}" STREQUAL "v6.41")
set(BORLAND_VERSION "bcc32 v6.41 (RS XE2)")
set(BORLAND_VERSION_RS_XE2 1)
# XE compiler?
elseif("v${_borland_major}.${_borland_minor}" STREQUAL "v6.30")
set(BORLAND_VERSION "bcc32 v6.30 (RS XE)")
set(BORLAND_VERSION_RS_XE 1)
# 2010 compiler?
elseif("v${_borland_major}.${_borland_minor}" STREQUAL "v6.20")
set(BORLAND_VERSION "bcc32 v6.20 (RS 2010)")
set(BORLAND_VERSION_RS_2010 1)
# TODO: 2009 compiler?
# TODO: 2007 compiler?
# 2006 compiler?
elseif("v${_borland_major}.${_borland_minor}" STREQUAL "v5.82")
set(BORLAND_VERSION "bcc32 v5.82 (BDS 2006)")
set(BORLAND_VERSION_BDS_2006 1)
#TODO: Older compilers?
else()
set(BORLAND_VERSION "Unknown")
endif()
unset(_output)
unset(_borland_version)
unset(_borland_major)
unset(_borland_minor)
endif()
endif()
#######################################################
# Check platforms - Define specific compilation flags #
#######################################################
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CLANG TRUE)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(INTEL TRUE)
endif()
if(UNIX)
if(APPLE)
######### MacOSX ###########
message(STATUS "MacOSX platform detected")
set(PLATFORM Darwin)
else(APPLE)
######### Unix/Linux ###########
message(STATUS "Unix/Linux platform detected")
set(PLATFORM Unix)
if(INTEL)
# Disable meaningless remarks
# remark #383 given when initializing from a literal, e.g. abc("123")
# remark #522 given when a function is defined inline but prototype is not
# remark #858 given when a type qualifier is applied to a function return type
# remark #981 "operands are evaluated in unspecified order", e.g. a = b() + c()
add_definitions("-diag-disable 383,522,858,981")
endif(INTEL)
endif(APPLE)
add_definitions(-DHAVE_CONFIG_H -DCSFDB -DOCC_CONVERT_SIGNALS)
else(UNIX)
if(WIN32)
######### Windows ###########
message(STATUS "Windows system detected")
add_definitions(-DWNT -DWIN32 -D_WINDOWS -DCSFDB -DHAVE_CONFIG_H )
######### Borland ###########
if(BORLAND)
message(STATUS "Borland compiler detected: ${BORLAND_VERSION}")
add_definitions(-DHAVE_IOS )
endif(BORLAND)
set(PLATFORM win)
else(WIN32)
message(STATUS "Unknown platform")
endif(WIN32)
endif(UNIX)
# TODO: better detection of different Unices (Linux, Solaris etc.)
# TODO: add CXX compiler flags for each platform
# Enable Extra warnings for each compiler
if( OCE_EXTRA_WARNINGS)
if(MSVC)
add_definitions("/W4 /wd4100 /wd4206 /wd4127")
endif(MSVC)
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions("-Wall -Wextra")
endif(CMAKE_COMPILER_IS_GNUCXX)
if(CLANG)
add_definitions("-Weverything")
endif(CLANG)
if(BORLAND)
#TODO
endif(BORLAND)
if(INTEL)
add_definitions("-Wall -Wremarks")
endif(INTEL)
endif(OCE_EXTRA_WARNINGS)
if(OCE_MULTITHREADED_BUILD)
if(MSVC)
add_definitions("/MP")
endif()
endif()
# Detect build problems with duplicate types
try_compile(CHECK_BODY_TEMPLATE ${CMAKE_BINARY_DIR}/CMakeTmpDup
${OCE_SOURCE_DIR}/adm/cmake/config/TestDuplicateBodyTemplate.cxx
)
if (NOT CHECK_BODY_TEMPLATE)
message(STATUS "Duplicate types found, do not define HashCode(Standard_Utf32Char)")
set (OCE_IS_DUPLICATE_UINT32_T TRUE)
endif ()
################################################
# Define output path for generated libraries: #
# platform/compiler-build_type-bits #
# for instance: #
# ./win32/bin/vc7.1-release-64 #
# ./win32/bin/vc9-debug-32 #
# ./Unix/i386-debug-64 #
################################################
if(WIN32)
if(MSVC) # The compiler used is MSVC
message(STATUS "Found MSVC compiler: ${MSVC} ${MSVC_VERSION}")
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin/)
elseif (BORLAND) # The compiler used is BORLAND
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/win${BIT}/bin/${CMAKE_BUILD_TYPE})
else()
IF (MINGW)
message(STATUS "Found MINGW compiler: ${MINGW}")
endif(MINGW)
set(LIBRARY_OUTPUT_PATH win${BIT}/bin/${CMAKE_BUILD_TYPE})
endif()
set(EXECUTABLE_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
else(WIN32)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/${PLATFORM}/${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_BUILD_TYPE}-${BIT})
endif(WIN32)
message(STATUS "output_path: ${LIBRARY_OUTPUT_PATH}")
# TODO: under win32/64, dlls and libs should not be in the same path (non MSVC)
if(MINGW)
#MinGW Specific Flags
message(STATUS "MinGW:")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthreads")
if(BIT MATCHES "64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
endif(BIT MATCHES "64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mthreads")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mthreads -Wl,--export-all-symbols")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mthreads -Wl,--export-all-symbols")
if(OCE_MULTITHREAD_LIBRARY STREQUAL "OPENMP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fopenmp")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fopenmp")
endif(OCE_MULTITHREAD_LIBRARY STREQUAL "OPENMP")
# For the file Message_MsgFile.cxx of TKernel we must additionally set the __TCollection_DLL define to resolve the needed HashCode() method
set_source_files_properties("src/Message/Message_MsgFile.cxx" PROPERTIES COMPILE_FLAGS "-D__Message_DLL -D__TCollection_DLL")
message(STATUS "CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")
endif(MINGW)
# DISABLE SECURE CRT WARNINGS AND OTHER MS CRT SPECIFC THINGS
if (MSVC)
add_definitions("/D_CRT_SECURE_NO_WARNINGS")
add_definitions("/D_CRT_NONSTDC_NO_WARNINGS")
endif(MSVC)
if(MSVC_IDE)
if(NOT OCE_USE_MSVC_EXPRESS)
#Use solution folders.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(USE_SOLUTION_FOLDERS TRUE)
else( NOT OCE_USE_MSVC_EXPRESS)
set_property(GLOBAL PROPERTY USE_FOLDERS OFF)
endif( NOT OCE_USE_MSVC_EXPRESS)
endif(MSVC_IDE)
# Libraries are installed by default in /usr/local/lib on UNIX
# based platforms and c:/OCE-VERSION/Win[32|64]/lib on windows based
# platforms
if(WIN32)
set(_PSUFFIX "Win${BIT}/")
else(WIN32)
set(_PSUFFIX "")
endif(WIN32)
# If OCE_USE_BUNDLE_SOURCE, then we need to add oce-win-bundle and set it
# to build into the same destination directories as OCE. This cannot run
# until LIBRARY_OUTPUT_PATH is set above
if (OCE_USE_BUNDLE_SOURCE AND OCE_BUNDLE_ROOT_PATH)
# Embed oce-win-bundle project into this CMake project
message("Using OCE Bundle in same CMake project")
add_subdirectory( ${OCE_BUNDLE_ROOT_PATH} ${CMAKE_BINARY_DIR}/oce-win-bundle )
# The installation directory of the bundle must match the one of OCE
set(OCE_WIN_BUNDLE_INSTALL_DIR ${OCE_INSTALL_PREFIX} CACHE PATH "" FORCE)
# Look for includes in bundle source directory.
# Put oce-win-bundle libraries and dlls in same place OCE libraries and dlls are going,
# and set variables to point OCE to them.
if (OCE_VISUALISATION OR OCE_VISU_DEP)
set(FREETYPE_INCLUDE_DIR_freetype2 ${OCE_BUNDLE_ROOT_PATH}/libs/freetype CACHE PATH "" FORCE)
set(FREETYPE_INCLUDE_DIR_ft2build ${OCE_BUNDLE_ROOT_PATH}/libs/freetype/include CACHE PATH "" FORCE)
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR_freetype2} ${FREETYPE_INCLUDE_DIR_ft2build})
IF(MINGW OR MSVC)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OCE_INSTALL_PREFIX}/Win${BIT}/lib CACHE PATH "" FORCE)
endif(MINGW OR MSVC)
get_target_property( FREETYPE_ARCHIVE_OUTPUT_DIRECTORY freetype ARCHIVE_OUTPUT_DIRECTORY )
if(MINGW)
set(FREETYPE_LIBRARY ${FREETYPE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/libfreetype.dll.a CACHE FILEPATH "" FORCE)
set(FREETYPE_LIBRARIES ${FREETYPE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/libfreetype.dll.a CACHE FILEPATH "" FORCE)
set(FREETYPE_LIBRARY_DEBUG ${FREETYPE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/libfreetyped.dll.a CACHE FILEPATH "" FORCE)
else(MINGW)
set(FREETYPE_LIBRARY ${FREETYPE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/freetype.lib CACHE FILEPATH "" FORCE)
set(FREETYPE_LIBRARIES ${FREETYPE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/freetype.lib CACHE FILEPATH "" FORCE)
set(FREETYPE_LIBRARY_DEBUG ${FREETYPE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/freetyped.lib CACHE FILEPATH "" FORCE)
endif(MINGW)
if(OCE_WITH_GL2PS)
get_target_property( GL2PS_ARCHIVE_OUTPUT_DIRECTORY gl2ps ARCHIVE_OUTPUT_DIRECTORY )
if(MINGW)
set(GL2PS_LIBRARY ${GL2PS_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/libgl2ps.dll.a CACHE FILEPATH "" FORCE)
set(GL2PS_LIBRARY_DEBUG ${GL2PS_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/libgl2psd.dll.a CACHE FILEPATH "" FORCE)
else(MINGW)
set(GL2PS_LIBRARY ${GL2PS_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/gl2ps.lib CACHE FILEPATH "" FORCE)
set(GL2PS_LIBRARY_DEBUG ${GL2PS_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/gl2psd.lib CACHE FILEPATH "" FORCE)
endif(MINGW)
set(GL2PS_INCLUDE_DIR ${OCE_BUNDLE_ROOT_PATH}/libs/gl2ps CACHE PATH "" FORCE)
endif(OCE_WITH_GL2PS)
if(OCE_WITH_FREEIMAGE)
get_target_property( FREEIMAGE_ARCHIVE_OUTPUT_DIRECTORY FreeImage ARCHIVE_OUTPUT_DIRECTORY )
if(MINGW)
set(FREEIMAGE_LIBRARY ${FREEIMAGE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/libFreeImage.dll.a CACHE FILEPATH "" FORCE)
set(FREEIMAGE_LIBRARY_DEBUG ${FREEIMAGE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/libFreeImaged.dll.a CACHE FILEPATH "" FORCE)
else(MINGW)
set(FREEIMAGE_LIBRARY ${FREEIMAGE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/FreeImage.lib CACHE FILEPATH "" FORCE)
set(FREEIMAGE_LIBRARY_DEBUG ${FREEIMAGE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/FreeImaged.lib CACHE FILEPATH "" FORCE)
endif(MINGW)
get_target_property( FREEIMAGEPLUS_ARCHIVE_OUTPUT_DIRECTORY FreeImage ARCHIVE_OUTPUT_DIRECTORY )
if(MINGW)
set(FREEIMAGEPLUS_LIBRARY ${FREEIMAGEPLUS_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/libFreeImagePlus.dll.a CACHE FILEPATH "" FORCE)
set(FREEIMAGEPLUS_LIBRARY_DEBUG ${FREEIMAGEPLUS_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/libFreeImagePlusd.dll.a CACHE FILEPATH "" FORCE)
else(MINGW)
set(FREEIMAGEPLUS_LIBRARY ${FREEIMAGEPLUS_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/FreeImagePlus.lib CACHE FILEPATH "" FORCE)
set(FREEIMAGEPLUS_LIBRARY_DEBUG ${FREEIMAGEPLUS_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/FreeImagePlusd.lib CACHE FILEPATH "" FORCE)
endif(MINGW)
set(FREEIMAGE_INCLUDE_DIR ${OCE_BUNDLE_ROOT_PATH}/libs/FreeImage/Source ${OCE_BUNDLE_ROOT_PATH}/libs/FreeImage/Wrapper/FreeImagePlus CACHE PATH "" FORCE)
endif(OCE_WITH_FREEIMAGE)
endif (OCE_VISUALISATION OR OCE_VISU_DEP)
endif(OCE_USE_BUNDLE_SOURCE AND OCE_BUNDLE_ROOT_PATH)
# Binaries
if(NOT DEFINED OCE_INSTALL_BIN_DIR)
set(OCE_INSTALL_BIN_DIR ${_PSUFFIX}bin)
endif(NOT DEFINED OCE_INSTALL_BIN_DIR)