forked from NREL/OpenStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1370 lines (1123 loc) · 53.2 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
cmake_minimum_required(VERSION 3.14.0)
cmake_policy(SET CMP0048 NEW)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Do not enable compiler specific extensions, for eg on GCC use -std=c++1z (=c++17) and not -std=gnu++17
set(CMAKE_CXX_EXTENSIONS OFF)
# Use ccache if available, has to be before "project()"
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
# Support Unix Makefiles and Ninja
message(STATUS "Using CCACHE")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()
# Project macro can only take digits in the version, it splits these out to specific variables
project(OpenStudio VERSION 3.1.0)
# The RT Manifest file and C# SDK only support the digit portion of patch
string(APPEND PROJECT_VERSION_PATCH_DIGIT ${PROJECT_VERSION_PATCH})
# CPack package version does not support extended patch version
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
if ( APPLE )
find_library(SECURITY_FRAMEWORK Security)
endif()
include(CPackComponent)
include(CheckCXXCompilerFlag)
if(POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
endif()
if(POLICY CMP0022)
cmake_policy(SET CMP0022 NEW)
endif()
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
###############################################################################
# N I N J A #
###############################################################################
# Ninja support: has to be atop for it to take effect before anything else is done
# Add Color Output if Using Ninja
macro(AddCXXFlagIfSupported flag test)
CHECK_CXX_COMPILER_FLAG(${flag} ${test})
if(${${test}})
message("adding ${flag}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
endif()
endmacro()
if("Ninja" STREQUAL ${CMAKE_GENERATOR})
# Will be passed to OpenStudio.in to deal with the Win32 case
set(NINJA TRUE)
# Clang
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
AddCXXFlagIfSupported(-fcolor-diagnostics COMPILER_SUPPORTS_fcolor-diagnostics)
endif()
# g++
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# For some reason it doesn't say its supported, but it works...
# AddCXXFlagIfSupported(-fdiagnostics-color COMPILER_SUPPORTS_fdiagnostics-color)
message(STATUS "Ninja: Forcing -fdiagnostics-color=always")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
endif()
endif()
# Xcode/Ninja generators undefined MAKE
if(CMAKE_GENERATOR MATCHES "Make")
set(MAKE "$(MAKE)")
else()
set(MAKE make)
endif()
###############################################################################
# Project version information
set(PROJECT_VERSION_BUILD "Unknown" CACHE STRING "Build number") # git sha
find_package(Git)
if(NOT GIT_FOUND)
find_program(GIT_EXECUTABLE git HINTS "$ENV{LOCALAPPDATA}/Programs/git/bin" "C:/Program Files/Git/bin")
if(NOT GIT_EXECUTABLE_NOTFOUND)
set(GIT_FOUND TRUE)
endif()
endif()
if(GIT_FOUND)
# Git SHA (length 10)
execute_process(COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--short=10" "HEAD"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
TIMEOUT 10
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE GIT_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(${RESULT} EQUAL 0 AND NOT "${GIT_VERSION}" EQUAL "${PROJECT_VERSION_BUILD}")
set(PROJECT_VERSION_BUILD ${GIT_VERSION} CACHE STRING "Build number" FORCE) # git sha
endif()
# Git branch name
execute_process(COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--abbrev-ref" "HEAD"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
TIMEOUT 10
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE GIT_BRANCH
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(${RESULT} EQUAL 0 AND NOT "${GIT_BRANCH}" EQUAL "${PROJECT_GIT_BRANCH}")
set(PROJECT_GIT_BRANCH ${GIT_BRANCH} CACHE STRING "Git Branch Name" FORCE)
endif()
get_filename_component(GIT_DIR "${GIT_EXECUTABLE}" DIRECTORY)
else()
set(GIT_DIR "")
endif()
find_program(PATCH_EXE patch HINTS "${GIT_DIR}" "${GIT_DIR}/../bin/" "${GIT_DIR}/../usr/bin/")
string(COMPARE EQUAL "${PATCH_EXE}" "PATCH_EXE-NOTFOUND" PATCH_EXE_NOTFOUND)
if(PATCH_EXE_NOTFOUND)
message(SEND_ERROR "Required program patch not found")
endif()
# Check if scope has a parent
get_directory_property(hasParent PARENT_DIRECTORY)
# README: what's the difference between all these versions?
# The "OpenStudio_VERSION" ones should be used in CMakeLists.txt
# * OpenStudio_VERSION: includes the prerelease tag if any: '3.0.0-rc1'
# * OpenStudio_VERSION_PATCH: Patch + prelrease tag if any
# The "OPENSTUDIO_VERSION" ones should only be used in OpenStudio.in (aside from using the the long version for naming the installer)
# * OPENSTUDIO_VERSION: just major.minor.patch: '3.0.0'
# * OPENSTUDIO_LONG_VERSION: includes prelrease and build sha: "3.0.0-rc1+ejfbxhza'
# TODO: Modify the more specific variables as needed to indicate prerelease, etc
# Keep in beta in-between release cycles. Set to empty string (or comment out) for official)
set(PROJECT_VERSION_PRERELEASE "alpha")
# OpenStudio version: Only include Major.Minor.Patch, eg "3.0.0", even if you have a prerelease tag
set(OPENSTUDIO_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
if (NOT "${PROJECT_VERSION_PRERELEASE}" STREQUAL "")
message(STATUS "We have a prerelease tag set to '${PROJECT_VERSION_PRERELEASE}'")
if("${PROJECT_GIT_BRANCH}" STREQUAL "master")
message(AUTHOR_WARNING "You are building branch 'master', perhaps you shouldn't have included a pre-release tag")
endif()
string(APPEND OpenStudio_VERSION "-${PROJECT_VERSION_PRERELEASE}")
string(APPEND OpenStudio_VERSION_PATCH "-${PROJECT_VERSION_PRERELEASE}")
# Long version, include prerelease and build metadata. eg '3.0.0-rc1+6383a191dc'
set(OPENSTUDIO_LONG_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-${PROJECT_VERSION_PRERELEASE}+${PROJECT_VERSION_BUILD}")
else()
message(STATUS "We do not have a prerelease tag")
if(NOT "${PROJECT_GIT_BRANCH}" STREQUAL "master")
message(AUTHOR_WARNING "You are building another branch than master but you do not have a prerelease tag, consider adding one such as 'beta'")
endif()
# Long version, include build metadata. eg '3.0.0+6383a191dc' for an official release
set(OPENSTUDIO_LONG_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}+${PROJECT_VERSION_BUILD}")
endif()
# Export to parent scope
if(hasParent)
set(OPENSTUDIO_VERSION "${OPENSTUDIO_VERSION}" PARENT_SCOPE)
set(OPENSTUDIO_LONG_VERSION "${OPENSTUDIO_LONG_VERSION}" PARENT_SCOPE)
endif()
# EnergyPlus Idd version
set(ENERGYPLUS_VERSION_MAJOR 9)
set(ENERGYPLUS_VERSION_MINOR 3)
set(ENERGYPLUS_VERSION_PATCH 0)
set(ENERGYPLUS_VERSION "${ENERGYPLUS_VERSION_MAJOR}.${ENERGYPLUS_VERSION_MINOR}.${ENERGYPLUS_VERSION_PATCH}")
# Build SHA is not required to have a value, but if it does OpenStudio will require this build.
set(ENERGYPLUS_BUILD_SHA "baff08990c")
# ENERGYPLUS_RELEASE_NAME is used to locate the E+ download
# from the github releases
set(ENERGYPLUS_RELEASE_NAME "v9.3.0")
# Radiance
set(RADIANCE_VERSION "5.0.a.12")
# configure file with version information
configure_file(${PROJECT_SOURCE_DIR}/OpenStudio.in ${PROJECT_BINARY_DIR}/src/OpenStudio.hxx)
# Deployment target
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
endif()
# compiler id for about boxes
if(MSVC)
set(ABOUT_COMPILER "${CMAKE_GENERATOR}")
elseif(APPLE)
set(ABOUT_COMPILER "${CMAKE_CXX_COMPILER_ID} ${CMAKE_OSX_ARCHITECTURES} - OSX ${CMAKE_OSX_DEPLOYMENT_TARGET}")
else()
set(ABOUT_COMPILER "${CMAKE_CXX_COMPILER_ID}")
endif()
###############################################################################
###############################################################################
# Build options
if(UNIX AND NOT APPLE)
# the RPATH to be used when installing
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
endif()
# TODO: should this be only in OpenStudioApplication?
option(BUILD_PAT "Build PAT" OFF)
# Build C++ documentation using Doxygen
# Requires: doxygen
option(BUILD_DOCUMENTATION "Build Documentation" OFF)
# Build CSharp bindings
option(BUILD_CSHARP_BINDINGS "Build CSharp bindings" OFF)
option(BUILD_NUGET_PACKAGE "Build NuGet Package" OFF)
# Build Java bindings
# Requires: SWIG
option(BUILD_JAVA_BINDINGS "Build Java bindings" OFF)
# Build V8 Node bindings
# Requires: SWIG, Node
option(BUILD_V8_BINDINGS "Build Node V8 bindings" OFF)
# Build Python bindings
# Requires: SWIG Python
option(BUILD_PYTHON_BINDINGS "Build Python bindings" OFF)
# Build ctest testing
# Requires: EnergyPlus
option(BUILD_TESTING "Build testing targets" OFF)
option(BUILD_RUBY_BINDINGS "Build Ruby bindings" ON)
mark_as_advanced(BUILD_RUBY_BINDINGS)
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # 32 bit
set(BUILD_RUBY_BINDINGS OFF CACHE BOOL "Override option" FORCE)
message("Ruby bindings are not support on 32 bit platforms, forcing BUILD_RUBY_BINDINGS OFF")
endif()
option(BUILD_CLI "Build OpenStudio command line interface" ON)
mark_as_advanced(BUILD_CLI)
if(NOT BUILD_RUBY_BINDINGS)
set(BUILD_CLI OFF CACHE BOOL "Override option" FORCE)
message("OpenStudio CLI depends on Ruby bindings which are disabled, therefore BUILD_CLI is also disabled")
endif()
# Build with OpenSSL support
set(BUILD_WITH_OPENSSL ON CACHE INTERNAL "Build With OpenSSL Support For SSH Connections")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_definitions(-Qunused-arguments)
endif()
# Enable runtime checking features
if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
option(ENABLE_THREAD_SANITIZER "Enable thread sanitizer testing in gcc/clang" OFF)
if(ENABLE_THREAD_SANITIZER)
add_definitions(-fsanitize=thread -g)
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=thread")
endif()
option(ENABLE_ADDRESS_SANITIZER "Enable address sanitizer testing in gcc/clang" OFF)
if(ENABLE_ADDRESS_SANITIZER)
add_definitions(-fsanitize=address -g)
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=address")
endif()
option(ENABLE_UNDEFINED_SANITIZER "Enable undefined behavior sanitizer testing in gcc/clang" OFF)
if(ENABLE_UNDEFINED_SANITIZER)
add_definitions(-fsanitize=undefined -g)
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=undefined")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}")
mark_as_advanced(ENABLE_THREAD_SANITIZER ENABLE_ADDRESS_SANITIZER ENABLE_UNDEFINED_SANITIZER)
endif()
if(APPLE)
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
#add_definitions(-DBOOST_SYSTEM_NO_DEPRECATED)
endif()
if(UNIX AND NOT APPLE)
# Enable libgtest linking
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
endif()
if(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64 bit
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF /OPT:NOICF")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi")
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF /OPT:NOICF")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi")
endif()
endif()
if(BUILD_V8_BINDINGS)
option(BUILD_NODE_MODULES "Build V8 Bindings as Node Modules" ON)
endif()
option(USE_LTO "Use Link-Time-Optimization" OFF)
if (USE_LTO)
include(CheckIPOSupported)
check_ipo_supported()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
endif()
if(WIN32)
add_definitions(-DNOMINMAX)
endif()
if(MSVC AND NOT NINJA)
# Build with Multiple Processes
set(BUILD_WITH_MULTIPLE_PROCESSES ON CACHE BOOL "/MP compiler flag for full processor utilization")
mark_as_advanced(BUILD_WITH_MULTIPLE_PROCESSES)
endif()
###############################################################################
###############################################################################
# Conan
# Note JM 2019-04-24: Another option is to globally set "print_run_commands = True" in ~/.conan/conan.conf
option(CONAN_PRINT_RUN_COMMANDS "Log every conan self.run command" OFF)
mark_as_advanced(CONAN_PRINT_RUN_COMMANDS)
if(CONAN_PRINT_RUN_COMMANDS)
set(ENV{CONAN_PRINT_RUN_COMMANDS} "1")
message(STATUS "Setting CONAN_PRINT_RUN_COMMANDS: $ENV{CONAN_PRINT_RUN_COMMANDS}")
else()
unset(ENV{CONAN_PRINT_RUN_COMMANDS})
message(STATUS "CONAN_PRINT_RUN_COMMANDS: $ENV{CONAN_PRINT_RUN_COMMANDS}")
endif()
# Attempt to run, it'll do the right thing if the calling cmake script already ran it
set(CONAN_INSTALL_FILE "${PROJECT_SOURCE_DIR}/ConanInstall.cmake")
include("${CONAN_INSTALL_FILE}")
# A macro to find a conan related value especially when using multi-config builds (MSVC)
# But it also works with single-config builds
macro(FindValue ValueName)
set(LocalVar "")
set(LocalVar $<$<CONFIG:Debug>:${${ValueName}_DEBUG}>$<$<CONFIG:Release>:${${ValueName}_RELEASE}>$<$<CONFIG:RelWithDebInfo>:${$ValueName}_RELWITHDEBINFO}>$<$<CONFIG:MinSizeRel>:${${ValueName}_MINSIZEREL}>
)
# list(JOIN LocalVar "" LocalVar)
string(STRIP ${LocalVar} LocalVar)
set(CURRENT_${ValueName} $<IF:$<BOOL:${LocalVar}>,${LocalVar},${${ValueName}}>)
# For debug purposes
# message(STATUS "Found '${ValueName}' as '${CURRENT_${ValueName}}'")
endmacro()
###############################################################################
if(BUILD_RUBY_BINDINGS)
get_target_property(RUBY_INCLUDE_DIRS CONAN_PKG::openstudio_ruby INTERFACE_INCLUDE_DIRECTORIES)
endif()
# Export to Parent
if(hasParent)
set(RUBY_INCLUDE_DIRS "${RUBY_INCLUDE_DIRS}" PARENT_SCOPE)
endif()
###############################################################################
# CMake control
# High level project configuration
# TODO: Do we actually want everything to go to CMAKE_BINARY_DIR/Products,
# so that when you build OpenStudioApplication you get both OpenStudio (core) and Application in the same place?
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Products")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Products")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Products")
set(LIBRARY_SEARCH_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/Release" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/Debug")
# TODO: move App macros to a local ProjectMacros.cmake
# Include project specific macros
include("${PROJECT_SOURCE_DIR}/ProjectMacros.cmake")
# Search first in the binary dir, where conan will install finders, then
# search for modules in the root dir to override cmake ones
# Start with ROOT, then PROJECT_BINARY_DIR
list(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR} ${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/CMake")
# Use CTest
set(ALL_TESTING_TARGETS "") # global list
if(BUILD_TESTING)
enable_testing()
include(CTest)
endif()
###############################################################################
###############################################################################
# Compiler and system specific options
if(UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC -fno-strict-aliasing")
# all warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -fno-strict-aliasing -Winvalid-pch -Wnon-virtual-dtor")
# Treat all warnings as errors
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual -ftemplate-depth=1024")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual")
# DLM: had to add this due to issues with boost optional and gcc, may be resolved if we move to std::optional
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
endif()
# Note: CMAKE_CXX_STANDARD (with no extensions) already sets -std=c++17 (or std=c++1z).
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
endif()
if(MINGW)
# all warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
# effective c++
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weffc++")
# treat warnings as errors
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
# wchar not supported for MinGW
#add_definitions(-DBOOST_LOG_USE_CHAR)
#add_definitions(-DBOOST_LOG_NO_COMPILER_TLS)
endif()
if(MSVC)
# warning level 3
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
# warning level 4 - DLM: we should shoot for this
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
# all warnings - DLM: probably too high to ever use
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall")
# create compiler processes on all effective processors
# /MP is useless for ninja and will cause problems. BUILD_WITH_MULTIPLE_PROCESSES shouldn't have been set if ninja but let's be safe
if(BUILD_WITH_MULTIPLE_PROCESSES AND NOT NINJA)
add_definitions(/MP)
endif()
# Enable warning on thread un-safe static member initialization - DLM: we have been bit by this many times
# TODO: JM 2019-09-19: Disabling for now
# Using the righg flag (/w14460 and not the previously mispelled /w44640) will make compilation fail with many warnings treated as error,
# eg: IddRegex.cpp all scoped `const static std::string result` inside functions will issue that and make it fatal
# add_definitions(/w14640)
# ignore decorated name length exceeded
add_definitions(/wd4503)
# ignore needs to have dll-interface to be used by clients of class
# we will not rely on exporting templates instead all libraries must
# be linked against the same runtime
add_definitions(/wd4251)
# ignore base class not dll-exported error
add_definitions(/wd4275)
add_definitions(/bigobj)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64 bit
# ignore conversion from size_t to int for now
add_definitions(/wd4267)
else()
# ignore conversion from 'type1' to 'type2', possible loss of data
add_definitions(/wd4244)
endif()
# treat warnings as errors
# DLM: only do this for our code, added in later
# add_definitions(/WX)
# ignore warnings about the stl being insecure
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
# ignore c++17 deprecation warnings generated by boost
add_definitions(-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
add_definitions(-D_SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING)
endif()
##############################################################################
###############################################################################
# Check version of gcc
if(CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
endif()
###############################################################################
# Dependencies
# If Linux, check LSB_RELEASE globally so we can use it after
if(UNIX AND NOT APPLE)
find_program(LSB_RELEASE lsb_release)
# -rs outputs only 16.04, or 18.04
execute_process(COMMAND ${LSB_RELEASE} -rs
OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "LSB_RELEASE_ID_SHORT = ${LSB_RELEASE_ID_SHORT}")
endif()
# EnergyPlus
if(UNIX)
if(APPLE)
set(ENERGYPLUS_EXPECTED_HASH 20c12af58cb9ed8b3c30c206f7123498)
set(ENERGYPLUS_PLATFORM "Darwin-x86_64")
elseif(EXISTS "/etc/redhat-release")
# TODO: There aren't any redhat releases anymore, see PR #3145 too
set(ENERGYPLUS_EXPECTED_HASH DOES_NOT_EXIST_02ed618aab65bf46c96bf1faf2e1905b)
set(ENERGYPLUS_PLATFORM "Redhat-x86_64")
else()
set(ENERGYPLUS_EXPECTED_HASH d146ddaef57b79ca9272cd64bc75babd)
set(ENERGYPLUS_PLATFORM "Linux-x86_64")
endif()
set(ENERGYPLUS_PATH "EnergyPlus-${ENERGYPLUS_VERSION}-${ENERGYPLUS_BUILD_SHA}-${ENERGYPLUS_PLATFORM}")
if(EXISTS "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}.tar.gz")
file(MD5 "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}.tar.gz" ENERGYPLUS_HASH)
endif()
if(NOT EXISTS "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}.tar.gz" OR NOT "${ENERGYPLUS_HASH}" MATCHES "${ENERGYPLUS_EXPECTED_HASH}")
message(STATUS "Downloading EnergyPlus ${ENERGYPLUS_VERSION} (${ENERGYPLUS_PLATFORM})")
if(EXISTS "/etc/redhat-release")
file(DOWNLOAD "http://openstudio-resources.s3.amazonaws.com/dependencies/${ENERGYPLUS_PATH}.tar.gz" "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}.tar.gz"
INACTIVITY_TIMEOUT 300 # 5-min timeout
SHOW_PROGRESS
EXPECTED_MD5 ${ENERGYPLUS_EXPECTED_HASH})
else()
file(DOWNLOAD "https://github.com/NREL/EnergyPlus/releases/download/${ENERGYPLUS_RELEASE_NAME}/${ENERGYPLUS_PATH}.tar.gz" "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}.tar.gz"
INACTIVITY_TIMEOUT 300 # 5-min timeout
SHOW_PROGRESS
EXPECTED_MD5 ${ENERGYPLUS_EXPECTED_HASH})
endif()
# Remove the old extracted dir if exists
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}")
endif()
elseif(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64 bit
set(ENERGYPLUS_PATH "EnergyPlus-${ENERGYPLUS_VERSION}-${ENERGYPLUS_BUILD_SHA}-Windows-x86_64")
set(ENERGYPLUS_ARCH 64)
set(ENERGYPLUS_EXPECTED_HASH 0d47ac399199de733a6efc548f474f55)
else()
set(ENERGYPLUS_PATH "EnergyPlus-${ENERGYPLUS_VERSION}-${ENERGYPLUS_BUILD_SHA}-Windows-i386")
set(ENERGYPLUS_ARCH 32)
set(ENERGYPLUS_EXPECTED_HASH a002a02922eddccff684760116cef710)
endif()
if(EXISTS "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}.zip")
file(MD5 "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}.zip" ENERGYPLUS_HASH)
endif()
if(NOT EXISTS "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}.zip" OR NOT "${ENERGYPLUS_HASH}" MATCHES "${ENERGYPLUS_EXPECTED_HASH}")
message(STATUS "Downloading EnergyPlus ${ENERGYPLUS_VERSION} (${ENERGYPLUS_ARCH}-bit)")
file(DOWNLOAD "https://github.com/NREL/EnergyPlus/releases/download/${ENERGYPLUS_RELEASE_NAME}/${ENERGYPLUS_PATH}.zip" "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}.zip"
INACTIVITY_TIMEOUT 300 # 5 minute timeout
SHOW_PROGRESS
EXPECTED_MD5 ${ENERGYPLUS_EXPECTED_HASH})
# Remove the old extracted dir if exists
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}")
endif()
endif()
# Allows placing the archive manually in the build dir too
if (NOT EXISTS "${ENERGYPLUS_PATH}")
unset(ENERGYPLUS_FOUND CACHE)
unset(ENERGYPLUS_EXE CACHE)
unset(ENERGYPLUS_IDD CACHE)
unset(ENERGYPLUS_WEATHER_DIR CACHE)
if (UNIX)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}.tar.gz" WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
else()
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}.zip" WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
endif()
endif()
# Prior to E+ 9.1.0 (OS 2.7.2), zip/tar.gz would extract to something like `./EnergyPlus-9.0.0-buildsha-Linux-x86_64/EnergyPlus-9-0-0`
if (ENERGYPLUS_VERSION VERSION_LESS "9.1.0")
set(ENV{ENERGYPLUSDIR} "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}/EnergyPlus-${ENERGYPLUS_VERSION_MAJOR}-${ENERGYPLUS_VERSION_MINOR}-${ENERGYPLUS_VERSION_PATCH}")
else()
# After 9.1.0, due to QtIFW/Mac packaging (NREL/EnergPlus#7148), it is going directly to `./EnergyPlus-9.1.0-buildsha-Linux-x86_64/`
set(ENV{ENERGYPLUSDIR} "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}")
endif()
# Find EnergyPlus, which will set the ENERGYPLUS_XXX variables and cache them
find_package(EnergyPlus "${ENERGYPLUS_VERSION}" REQUIRED)
# Radiance
if(UNIX)
if(APPLE)
set(RADIANCE_EXPECTED_HASH 115ef9052ad5011d3fc7cebc2991644f)
set(RADIANCE_PLATFORM "Darwin")
elseif(EXISTS "/etc/redhat-release")
# DLM: note that the installer expects the extracted directory to be named radiance-5.0.a.12-Linux
set(RADIANCE_EXPECTED_HASH f75898bbfd238a740c1902d385c42b92)
set(RADIANCE_PLATFORM "Redhat")
else()
set(RADIANCE_EXPECTED_HASH 7b9e4df2b6050fe51c6e138e4c0e6a5a)
set(RADIANCE_PLATFORM "Linux")
endif()
set(RADIANCE_PATH "radiance-${RADIANCE_VERSION}-${RADIANCE_PLATFORM}")
if(EXISTS "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}.tar.gz")
file(MD5 "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}.tar.gz" RADIANCE_HASH)
endif()
if(NOT EXISTS "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}.tar.gz" OR NOT "${RADIANCE_HASH}" MATCHES "${RADIANCE_EXPECTED_HASH}")
message(STATUS "Downloading Radiance ${RADIANCE_VERSION} (${RADIANCE_PLATFORM})")
if(EXISTS "/etc/redhat-release")
message("http://openstudio-resources.s3.amazonaws.com/dependencies/radiance-${RADIANCE_VERSION}-${RADIANCE_PLATFORM}.tar.gz")
file(DOWNLOAD "http://openstudio-resources.s3.amazonaws.com/dependencies/radiance-${RADIANCE_VERSION}-${RADIANCE_PLATFORM}.tar.gz" "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}.tar.gz" TIMEOUT 120 INACTIVITY_TIMEOUT 120 SHOW_PROGRESS EXPECTED_MD5 ${RADIANCE_EXPECTED_HASH})
else()
file(DOWNLOAD "http://github.com/NREL/Radiance/releases/download/${RADIANCE_VERSION}/radiance-${RADIANCE_VERSION}-${RADIANCE_PLATFORM}.tar.gz" "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}.tar.gz" TIMEOUT 120 INACTIVITY_TIMEOUT 120 SHOW_PROGRESS EXPECTED_MD5 ${RADIANCE_EXPECTED_HASH})
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}.tar.gz" WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
endif()
set(RADIANCE_LOCATION "${PROJECT_BINARY_DIR}/radiance-${RADIANCE_VERSION}-${RADIANCE_PLATFORM}/usr/local/radiance")
elseif(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64 bit
set(RADIANCE_ARCH 64)
set(RADIANCE_EXPECTED_HASH 7bd7a418d181365b4153c8bc146ede06)
else()
message(WARNING "32 bit Radiance build is not available")
message(WARNING "Using 64 bit build of Radiance with a 32 bit build of OpenStudio")
set(RADIANCE_ARCH 64)
set(RADIANCE_EXPECTED_HASH 7bd7a418d181365b4153c8bc146ede06)
#set(RADIANCE_ARCH 32)
#set(RADIANCE_EXPECTED_HASH 78eda5d4b0215cd675cc3ec8975e6122)
endif()
set(RADIANCE_PATH "radiance-${RADIANCE_VERSION}-win${RADIANCE_ARCH}")
set(RADIANCE_PLATFORM "win${RADIANCE_ARCH}")
if(EXISTS "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}.zip")
file(MD5 "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}.zip" RADIANCE_HASH)
endif()
if(NOT EXISTS "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}.zip" OR NOT "${RADIANCE_HASH}" MATCHES "${RADIANCE_EXPECTED_HASH}")
message(STATUS "Downloading Radiance ${RADIANCE_VERSION} (${RADIANCE_ARCH}-bit)")
file(DOWNLOAD "http://github.com/NREL/Radiance/releases/download/${RADIANCE_VERSION}/Radiance-${RADIANCE_VERSION}-win${RADIANCE_ARCH}.zip" "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}.zip" TIMEOUT 120 INACTIVITY_TIMEOUT 120 SHOW_PROGRESS EXPECTED_MD5 ${RADIANCE_EXPECTED_HASH})
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}.zip" WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
endif()
set(RADIANCE_LOCATION "${PROJECT_BINARY_DIR}/radiance-${RADIANCE_VERSION}-${RADIANCE_PLATFORM}/")
endif()
# Perl
if(NOT UNIX)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${PROJECT_SOURCE_DIR}/dependencies/strawberry-perl-5.16.2.1-32bit-portable-reduced.tar.bz2"
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
RESULT_VARIABLE rv)
set(PERL_EXE "${PROJECT_BINARY_DIR}/strawberry-perl-5.16.2.1-32bit-portable-reduced/perl/bin/perl.exe")
endif()
include(FetchRubyMinGW.cmake)
FetchRubyMinGW()
if(BUILD_CLI)
# CI will build and upload openstudio gems to s3 at https://github.com/NREL/OpenStudio-gems
# need to update the MD5sum for each platform and url below
if(UNIX)
if(APPLE)
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20200622-darwin.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "4212a009d37e38b087aad51b4b2800e0")
else()
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20200622-linux.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "eb52b76926b82f6c0505fb57d2f46c5b")
endif()
elseif(WIN32)
# OpenStudio gems are only supported on 64 bit windows
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20200622-windows.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "52c80458909142726b1287dabe0da7a3")
endif()
set(OPENSTUDIO_GEMS_ZIP_LOCAL_PATH "${PROJECT_BINARY_DIR}/${OPENSTUDIO_GEMS_ZIP_FILENAME}")
set(OPENSTUDIO_GEMS_DIR "${PROJECT_BINARY_DIR}/openstudio-gems")
set(OPENSTUDIO_GEMS_TARGETS_FILE "${OPENSTUDIO_GEMS_DIR}/export-extensions.cmake")
set(OPENSTUDIO_GEMS_INIT_FILE "${OPENSTUDIO_GEMS_DIR}/init-extensions.cpp")
if(EXISTS "${OPENSTUDIO_GEMS_ZIP_LOCAL_PATH}")
file(MD5 "${OPENSTUDIO_GEMS_ZIP_LOCAL_PATH}" OPENSTUDIO_GEMS_ZIP_MD5)
endif()
if(NOT OPENSTUDIO_GEMS_ZIP_MD5 STREQUAL OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5)
message(STATUS "Downloading OpenStudio Gems: ${OPENSTUDIO_GEMS_ZIP_FILENAME}")
file(DOWNLOAD "http://openstudio-resources.s3.amazonaws.com/dependencies/${OPENSTUDIO_GEMS_ZIP_FILENAME}"
${OPENSTUDIO_GEMS_ZIP_LOCAL_PATH}
INACTIVITY_TIMEOUT 300 # 5 minute timeout
SHOW_PROGRESS
EXPECTED_MD5 ${OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5})
file(REMOVE_RECURSE "${OPENSTUDIO_GEMS_DIR}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz ${OPENSTUDIO_GEMS_ZIP_LOCAL_PATH} WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
file(REMOVE_RECURSE "${PROJECT_BINARY_DIR}/src/cli/embedded_files")
endif()
endif()
# SWIG
# Note: JM 2019-10-16
# We use conan swig_installer 4.0 which enhances our PATH to include the CONAN_BIN_DIRS_SWIG_INSTALLER already
# So I could just do:
# set(SWIG_EXECUTABLE swig)
# But will have the probblem with the swiglib anyways.
# Plus, it doesn't appear to work on windows either, the PATH doesn't include it.
#find_program(SWIG_EXECUTABLE swig PATHS CURRENT_CONAN_SWIG_ROOT NO_DEFAULT_PATH)
#if(NOT SWIG_EXECUTABLE)
# message(FATAL_ERROR "Couldn't find swig, which shouldn't happen. CONAN_BIN_DIRS_SWIG_INSTALLER=${CONAN_BIN_DIRS_SWIG_INSTALLER}, CONAN_SWIG_ROOT_RELEASE=${CONAN_SWIG_ROOT_RELEASE}, CURRENT_CONAN_SWIG_ROOT=${CURRENT_CONAN_SWIG_ROOT}, ${ENV{SWIG_LIB}}, ${ENV{SWIG_INSTALLER_ROOT}}")
#endif()
# Another thing I tried is to use the `virtualenv` generator (`conan_cmake_run( ... GENERATORS virtualenv)`),
# but you end up having to call the activation script on each call, and the call is dependent on the platform which is even more annoying
# (either cmake -E cmd /C activate.bat, or cmake -E source activate.sh)
# I also tried using CMake to extract the value from the activate.sh script on all plaftorms but it seems even more of a hack
# So instead, we use a generator expression to find the right value. At least it makes sense, and should be robust.
FindValue(CONAN_SWIG_ROOT)
set(SWIG_EXECUTABLE "${CURRENT_CONAN_SWIG_ROOT}/bin/swig")
# The conan-provided binary has a built-in swiglib (`swig -swiglib`) that points to the build box on which it was built, which is problematic for us.
set(SWIG_LIB "${CURRENT_CONAN_SWIG_ROOT}/bin/swiglib")
# Export SWIG to parent scope
if(hasParent)
set(SWIG_EXECUTABLE "${SWIG_EXECUTABLE}" PARENT_SCOPE)
set(SWIG_LIB "${SWIG_LIB}" PARENT_SCOPE)
endif()
set(ALL_RUBY_BINDING_TARGETS "") # global list
# build rdoc
if(BUILD_DOCUMENTATION)
if(WIN32)
get_filename_component(RUBY_BIN_DIR "${RUBY_EXECUTABLE}" DIRECTORY)
find_file(RDOC NAMES rdoc.bat HINTS $ENV{PATH} "${RUBY_BIN_DIR}")
find_file(RI NAMES ri.bat HINTS $ENV{PATH} "${RUBY_BIN_DIR}")
else()
find_program(RDOC NAMES rdoc)
find_program(RI NAMES ri)
endif()
mark_as_advanced(
RDOC
RI
)
set(ALL_RDOC_TARGETS ${ALL_RUBY_BINDING_TARGETS})
endif()
# C#
if(BUILD_CSHARP_BINDINGS)
set(ALL_CSHARP_BINDING_DEPENDS "") # global list of library dependencies of the generated wrapper cxx files
set(ALL_CSHARP_WRAPPER_FILES "") # global list of generated wrapper cxx files
set(ALL_CSHARP_WRAPPER_TARGETS "") # global list targets that build generated wrapper cxx files
endif()
# JAVA
if(BUILD_JAVA_BINDINGS)
find_package(JNI)
find_package(Java)
set(ALL_JAVA_BINDING_TARGETS "") # global list
set(ALL_JAVA_SRC_DIRECTORIES "") # global list
endif()
if(BUILD_NODE_MODULES)
add_definitions(-DBUILD_NODE_MODULE)
endif()
if(BUILD_PYTHON_BINDINGS)
find_package(Python COMPONENTS Interpreter Development REQUIRED)
include_directories(SYSTEM ${Python_INCLUDE_DIRS})
set(ALL_PYTHON_BINDINGS "") # global list of python bindings
set(ALL_PYTHON_BINDING_DEPENDS "") # global list of library dependencies of the generated wrapper cxx files
set(ALL_PYTHON_WRAPPER_FILES "") # global list of generated wrapper cxx files
set(ALL_PYTHON_WRAPPER_TARGETS "") # global list targets that build generated wrapper cxx files
endif()
# Threading library
find_package(Threads)
if(UNIX)
set(CMAKE_THREAD_LIBS "${CMAKE_THREAD_LIBS_INIT}" CACHE STRING "Thread library used.")
mark_as_advanced(CMAKE_THREAD_LIBS)
endif()
###############################################################################
# Add to include path
# Project source directory
include_directories("${PROJECT_SOURCE_DIR}/src/")
# Project binary directory
include_directories("${PROJECT_BINARY_DIR}/src/")
###############################################################################
###############################################################################
# RPATH settings
# Conan set this to true, which is not the cmake default and not what we want
# for the openstudio targets
set(CMAKE_SKIP_RPATH FALSE)
###############################################################################
###############################################################################
# Add project sub directories
if(MSVC)
# treat warnings as errors
add_definitions(/WX)
elseif()
add_definitions(-Werror)
endif()
include("embedded/EmbedFiles.cmake")
add_subdirectory("embedded")
if(BUILD_PAT)
add_subdirectory("pat")
endif()
# Each subfolder of src is a major sub-project
set(project_directories
generateiddfactory
utilities
model
energyplus
radiance
gbxml
airflow
isomodel
osversion
measure
sdd
lib
install_utility
)
# resources must be added after find EnergyPlus
add_subdirectory(resources)
foreach(D ${project_directories})
add_subdirectory(src/${D})
endforeach()
if(BUILD_RUBY_BINDINGS)
add_subdirectory(ruby)
endif()
if(BUILD_CLI)
add_subdirectory(src/cli)
endif()
add_dependencies(openstudio_utilities
CreateEmbeddedSource
)
# csharp, after loading projects
if(BUILD_CSHARP_BINDINGS)
add_subdirectory(csharp)
endif()
# java, after loading projects
if(BUILD_JAVA_BINDINGS)
add_subdirectory(java)
endif()
# python, after loading projects
if(BUILD_PYTHON_BINDINGS)
add_subdirectory(python)
endif()
# v8-node
if(BUILD_NODE_MODULES)
add_subdirectory(v8-node)
endif()
###############################################################################
###############################################################################
# Targets that combine all bindings targets
if(BUILD_RUBY_BINDINGS)
add_custom_target(ALL_RUBY_BINDINGS)
add_dependencies(ALL_RUBY_BINDINGS ${ALL_RUBY_BINDING_TARGETS})
endif()
if(BUILD_PYTHON_BINDINGS)
add_custom_target(ALL_PYTHON_BINDINGS)
#add_dependencies(ALL_PYTHON_BINDINGS python_sdk ${ALL_PYTHON_BINDING_TARGETS})
endif()
if(BUILD_CSHARP_BINDINGS)
add_custom_target(ALL_CSHARP_BINDINGS)
add_dependencies(ALL_CSHARP_BINDINGS csharp_sdk ${ALL_CSHARP_BINDING_TARGETS})
endif()
if(BUILD_JAVA_BINDINGS)
add_custom_target(ALL_JAVA_BINDINGS)
#add_dependencies(ALL_JAVA_BINDINGS java_sdk ${ALL_JAVA_BINDING_TARGETS})
endif()
if(BUILD_V8_BINDINGS)
add_custom_target(ALL_V8_BINDINGS)
add_dependencies(ALL_V8_BINDINGS ${ALL_V8_BINDING_TARGETS})
endif()
set(MAXIMIZE_CPU_USAGE OFF CACHE BOOL "Attempt to fully load the CPU during builds")
mark_as_advanced(MAXIMIZE_CPU_USAGE)
###############################################################################
# Targets that combine all documentation targets
# Doxygen
if(BUILD_DOCUMENTATION)
# need doxygen
find_package(Doxygen REQUIRED)
# if have dot you have more options
#if(DOXYGEN_DOT_FOUND)
#endif()
configure_file(${PROJECT_SOURCE_DIR}/doc/index.html ${PROJECT_BINARY_DIR}/doc/index.html COPYONLY)
set(doxygen_directories ${project_directories})
# Add the idd files to the documentation list as a separate entry, along with shared_gui_components
list(APPEND doxygen_directories utilities/idd shared_gui_components)
# Remove directories we don't want documentation generated for
list(REMOVE_ITEM doxygen_directories generateiddfactory)
add_custom_target(openstudio_doc_resources
COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/doc/css" "css"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/doc/fonts" "fonts"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/doc/js" "js"
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/doc
)
foreach(D ${doxygen_directories})
string(REPLACE "/" "_" DOC_NAME ${D})
set(DOXY_INPUT_DIR "\"${PROJECT_SOURCE_DIR}/src/${D}\"")
set(DOXY_ADDITIONAL_DIR "")
set(DOXY_EXCLUDE_DIR "")
set(DOXY_TAGFILES "")
# Specific settings
if(${D} STREQUAL "utilities/idd")
# We want to build the idd documentation separately because of the generated files
set(DOXY_ADDITIONAL_DIR "\"${PROJECT_BINARY_DIR}/src/${D}\"")
elseif(${D} STREQUAL "utilities")
# Exclude the idd directory when building the utilities documentation