-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
3280 lines (2924 loc) · 132 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
#***********************************************************************
# This file is part of OpenMolcas. *
# *
# OpenMolcas is free software; you can redistribute it and/or modify *
# it under the terms of the GNU Lesser General Public License, v. 2.1. *
# OpenMolcas is distributed in the hope that it will be useful, but it *
# is provided "as is" and without any express or implied warranties. *
# For more details see the full text of the license in the file *
# LICENSE or in <http://www.gnu.org/licenses/>. *
# *
# Copyright (C) 2014-2016, Steven Vancoillie *
# 2014-2018, Ignacio Fdez. Galván *
# 2015, Stefan Knecht *
#***********************************************************************
# Global CMakeLists.txt file for building Molcas with CMake.
#
# Steven Vancoillie - Spring 2014, on a Saturday afternoon, with coffee
# Ignacio Fdez. Galván made several improvements / additions
# Lasse Sørensen - Mac CMP0042 fix
cmake_minimum_required (VERSION 2.8.11)
#set (CMAKE_VERBOSE_MAKEFILE true)
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif ()
if (POLICY CMP0045)
cmake_policy(SET CMP0045 NEW)
endif ()
# Prevent in-source builds
# If an in-source build is attempted, you will still need to clean up a few files manually.
set (CMAKE_DISABLE_SOURCE_CHANGES ON)
set (CMAKE_DISABLE_IN_SOURCE_BUILD ON)
get_filename_component (sourcedir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component (binarydir "${CMAKE_BINARY_DIR}" REALPATH)
if ("${sourcedir}" STREQUAL "${binarydir}")
message(FATAL_ERROR "In-source builds in ${CMAKE_BINARY_DIR} are not "
"allowed, please remove ./CMakeCache.txt and ./CMakeFiles/, create a "
"separate build directory and run cmake from there.")
endif ()
# workaround for CMake bug 14874
# (i.e., fix for files with same name in different directories)
if (${CMAKE_VERSION} VERSION_LESS 3.1)
if (NOT DEFINED CMAKE_Fortran_ARCHIVE_CREATE)
set(CMAKE_Fortran_ARCHIVE_CREATE "<CMAKE_AR> cq <TARGET> <LINK_FLAGS> <OBJECTS>")
endif ()
if (NOT DEFINED CMAKE_Fortran_ARCHIVE_APPEND)
set(CMAKE_Fortran_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
endif ()
if (NOT DEFINED CMAKE_C_ARCHIVE_CREATE)
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cq <TARGET> <LINK_FLAGS> <OBJECTS>")
endif ()
if (NOT DEFINED CMAKE_C_ARCHIVE_APPEND)
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
endif ()
if (NOT DEFINED CMAKE_CXX_ARCHIVE_CREATE)
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cq <TARGET> <LINK_FLAGS> <OBJECTS>")
endif ()
if (NOT DEFINED CMAKE_CXX_ARCHIVE_APPEND)
set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
endif ()
endif ()
################################################################################
# #
# Options #
# #
################################################################################
# The build type, specifies the different optimization types.
if (NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")
set (CMAKE_BUILD_TYPE "Release" CACHE STRING
"Type of build, options are: None (CFLAGS/FFLAGS can be used), Debug, Garble, RelWithDebInfo, Release, Fast."
FORCE
)
endif ()
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS None Debug Garble RelWithDebInfo Release Fast)
# The place where Molcas is installed with make install.
if (NOT DEFINED CMAKE_INSTALL_PREFIX)
set (CMAKE_INSTALL_PREFIX "/opt/molcas" CACHE STRING
"Location where Molcas will be installed.")
endif ()
option (DEBUGPRINT "Enable excessive print statements for debugging." OFF)
option (DEBUGTRACE "Enable tracing print statements for debugging." OFF)
set (DEBUG_DEFS_DESC "Additional debugging definitions.")
if (DEFINED DEBUG_DEFS)
separate_arguments(DEBUG_DEFS)
set (DEBUG_DEFS "${DEBUG_DEFS}" CACHE STRING "${DEBUG_DEFS_DESC}" FORCE)
else ()
set (DEBUG_DEFS "" CACHE STRING "${DEBUG_DEFS_DESC}")
endif ()
option (BUILD_SHARED_LIBS "Build dynamically-linked molcas library." OFF)
option (BUILD_STATIC_LIB "Build statically-linked molcas library too." OFF)
if (BUILD_SHARED_LIBS)
mark_as_advanced (CLEAR BUILD_STATIC_LIB)
else ()
mark_as_advanced (FORCE BUILD_STATIC_LIB)
endif ()
option (MPI "Enable MPI parallellization." OFF)
option (GA "Use Global Arrays library." OFF)
option (OPENMP "Enable multi-threading." OFF)
option (BOUNDS "Enable bounds checking (only gfortran >= 4.8)." OFF)
option (EXPERT "Show advanced CMake cache entries in GUI)." OFF)
option (BIGOT "Do not allow any compiler warning (treat them as errors)." OFF)
set (LINALG_OPTIONS "Choose linear algebra library, options: Internal (default), Runtime, MKL, ACML, OpenBLAS, Accelerate.")
if (DEFINED LINALG)
set (LINALG "${LINALG}" CACHE STRING "${LINALG_OPTIONS}")
if (NOT ";Internal;Runtime;MKL;ACML;OpenBLAS;Accelerate;" MATCHES ";${LINALG};")
message (FATAL_ERROR "Unsuported LINALG: ${LINALG}")
endif ()
else ()
set (LINALG "Internal" CACHE STRING "${LINALG_OPTIONS}")
endif ()
set_property (CACHE LINALG PROPERTY STRINGS Internal Runtime MKL ACML OpenBLAS Accelerate)
option (CUBLAS "Enable CUDA BLAS library." OFF)
option (NVBLAS "Enable NVidia BLAS library." OFF)
option (FDE "Enable Frozen-density-embedding (FDE) interface." OFF)
option (GROMACS "Compile Gromacs interface." OFF)
option (BLOCK "Activate BLOCK-DMRG support." OFF)
option (NEWBLOCK "Activate New BLOCK-DMRG support." OFF)
option (CHEMPS2 "Activate CheMPS2-DMRG support." OFF)
option (DICE "Activate DICE-SHCI support." OFF)
option (GPERFTOOLS "Activate gperftools CPU profiling." OFF)
option (GCOV "Activate code coverage profiling (use with Debug/-O0)." OFF)
option (HDF5 "Activate HDF5 support for wavefunction format." ON)
option (TOOLS "Compile supported tools." OFF)
option (CTEST "Enable CTest." OFF)
mark_as_advanced (CTEST)
# External projects
option (MSYM "Activate MSYM support (requires External/libmsym submodule)." OFF)
option (DMRG "Activate QCMaquis DMRG driver and library." OFF)
option (DMRG_DEBUG "Enable DEBUG print in QCMaquis driver." OFF)
if (DMRG)
mark_as_advanced (CLEAR DMRG_DEBUG)
else ()
mark_as_advanced (FORCE DMRG_DEBUG)
endif ()
option (GEN1INT "Enable Gen1Int library for 1-electron integrals." OFF)
option (NECI "Activate NECI support (requires External/NECI submodule)." OFF)
option (WFA "Activate extended wavefunction analysis (requires External/libwfa submodule)." OFF)
option (NEVPT2 "Activate (DMRG)-NEVPT2 support." OFF)
option (EFPLIB "Enable EFPLib library for effective fragment potentials (requires External/efp submodule)." OFF)
option (GRID_IT "Enable public GRID_IT code (requires External/grid_it submodule)." OFF)
################################################################################
# #
# Global settings #
# #
################################################################################
# mark that we are running CMake (for subprocesses)
set (ENV{CMAKE_SESSION} "OpenMolcas")
# project name and supported languages
#=====================================
message ("Configuring compilers:")
if (DMRG)
project (Molcas Fortran C CXX)
cmake_minimum_required (VERSION 3.2.0)
if (NOT DEFINED QCMaquis_ROOT)
if (DEFINED ENV{QCMaquis_ROOT})
set (QCMaquis_ROOT $ENV{QCMaquis_ROOT})
else ()
set (QCMaquis_ROOT "None")
endif ()
set (QCMaquis_ROOT ${QCMaquis_ROOT} CACHE STRING "Specify path to existing QCMaquis installation. This will allow to skip the installation of ALPS/BOOST and QCMaquis.")
endif ()
elseif (WFA)
project (Molcas Fortran C CXX)
else ()
project (Molcas Fortran C )
endif ()
if (EFPLIB)
cmake_minimum_required (VERSION 3.0.2)
endif ()
add_definitions (-D_MOLCAS_)
#set cmake module search paths
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
# discover some necessary tools
find_program (GIT "git")
find_program (PERL "perl")
mark_as_advanced(FORCE GIT PERL)
# location of molcas-extra
if (NOT DEFINED EXTRA)
if (DEFINED ENV{EXTRA})
set (EXTRA $ENV{EXTRA})
else ()
set (EXTRA "")
endif ()
endif ()
if (NOT "${EXTRA}" STREQUAL "")
if (NOT IS_ABSOLUTE "${EXTRA}")
set (EXTRA "${PROJECT_BINARY_DIR}/${EXTRA}")
endif ()
get_filename_component (EXTRA "${EXTRA}" ABSOLUTE)
if (NOT EXISTS "${EXTRA}")
message (WARNING "The Molcas-extra directory ${EXTRA} does not exist.")
else ()
FILE (STRINGS "${EXTRA}/.molcashome" DIR_TYPE)
if ("${DIR_TYPE}" STREQUAL "molcas-extra")
set (EXTRA_DIR ${EXTRA})
add_definitions (-D_HAVE_EXTRA_)
else ()
message (FATAL_ERROR "The directory ${EXTRA} does not contain Molcas-extra.")
endif ()
endif ()
endif ()
set (EXTRA "${EXTRA}" CACHE PATH "Location of the Molcas-extra directory." FORCE)
# possible locations for source code
set (OPENMOLCAS_DIR ${CMAKE_CURRENT_LIST_DIR})
if (NOT ${PROJECT_SOURCE_DIR} STREQUAL ${OPENMOLCAS_DIR})
set (basedirs ${PROJECT_SOURCE_DIR})
set (EXTRA_DIR ${PROJECT_SOURCE_DIR})
add_definitions (-D_HAVE_EXTRA_)
endif ()
list (APPEND basedirs ${OPENMOLCAS_DIR})
if (NOT "${EXTRA}" STREQUAL "")
if (NOT ";${basedirs};" MATCHES ";${EXTRA};")
list (APPEND basedirs ${EXTRA})
endif ()
endif ()
foreach (BASE_DIR ${basedirs})
file (GLOB source_roots_tmp RELATIVE ${PROJECT_SOURCE_DIR} "${BASE_DIR}/src*")
list (SORT source_roots_tmp)
list (APPEND source_roots ${source_roots_tmp})
endforeach ()
list (REVERSE basedirs)
# set function to find source directories
#========================================
function (find_source name)
foreach (src ${source_roots})
if (EXISTS ${PROJECT_SOURCE_DIR}/${src}/${name})
file (GLOB tmplist RELATIVE ${PROJECT_SOURCE_DIR}/${src}/${name} ${PROJECT_SOURCE_DIR}/${src}/${name}/*)
# ignore possible leftover files from previous configure+make
list (REMOVE_ITEM tmplist Makefile 00dependencies 00sources)
if (tmplist)
set (found "${src}/${name}")
break ()
endif ()
endif ()
endforeach ()
# do not overwrite existing definitions
if (DEFINED ${name}_src)
set (${name}_src "${${name}_src}" PARENT_SCOPE)
else ()
if (DEFINED found)
set (${name}_src "${found}" PARENT_SCOPE)
#else ()
# message (WARNING "${name} not found, expect trouble")
endif ()
endif ()
endfunction ()
# set function to insert list
#============================
function (insert_before _list _item _new)
list (GET ${_item} 0 _first)
list (FIND ${_list} ${_first} _index)
if (_index GREATER -1)
list (INSERT ${_list} ${_index} ${_new})
else ()
list (APPEND ${_list} ${_new})
endif ()
set (${_list} ${${_list}} PARENT_SCOPE)
endfunction ()
# get version from git if available, otherwise look in .molcasversion
#====================================================================
message ("Detecting Molcas version info:")
set (ENV{MOLCAS} ${PROJECT_BINARY_DIR})
set (ENV{OPENMOLCAS} ${OPENMOLCAS_DIR})
if (DEFINED EXTRA_DIR)
set (ENV{MOLCAS_SOURCE} ${EXTRA_DIR})
else ()
set (ENV{MOLCAS_SOURCE} ${OPENMOLCAS_DIR})
endif ()
execute_process (
COMMAND ${GIT} "rev-parse" "--git-dir"
WORKING_DIRECTORY ${OPENMOLCAS_DIR}
OUTPUT_VARIABLE GIT_REVPARSE_OUTPUT
ERROR_VARIABLE GIT_REVPARSE_ERROR
RESULT_VARIABLE GIT_REVPARSE_RC
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (GIT_REVPARSE_RC)
set (OPENMOLCAS_GIT_REPO "${OPENMOLCAS_DIR}/.git")
else ()
set (OPENMOLCAS_GIT_REPO "${GIT_REVPARSE_OUTPUT}")
if (NOT IS_ABSOLUTE "${OPENMOLCAS_GIT_REPO}")
set (OPENMOLCAS_GIT_REPO "${OPENMOLCAS_DIR}/${OPENMOLCAS_GIT_REPO}")
endif ()
endif ()
set (MOLCAS_VERSION_FILE "${PROJECT_SOURCE_DIR}/.molcasversion")
if (DEFINED EXTRA_DIR)
execute_process (
COMMAND ${GIT} "rev-parse" "--git-dir"
WORKING_DIRECTORY ${EXTRA_DIR}
OUTPUT_VARIABLE GIT_REVPARSE_OUTPUT
ERROR_VARIABLE GIT_REVPARSE_ERROR
RESULT_VARIABLE GIT_REVPARSE_RC
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (GIT_REVPARSE_RC)
set (EXTRA_GIT_REPO "${EXTRA_DIR}/.git")
else ()
set (EXTRA_GIT_REPO "${GIT_REVPARSE_OUTPUT}")
if (NOT IS_ABSOLUTE "${EXTRA_GIT_REPO}")
set (EXTRA_GIT_REPO "${EXTRA_DIR}/${EXTRA_GIT_REPO}")
endif ()
endif ()
endif ()
if (EXISTS ${GIT})
foreach (BASE_DIR ${basedirs})
# workaround because "continue()" is not supported in CMake 2.8.11
set (do ON)
if ("${BASE_DIR}" STREQUAL "${OPENMOLCAS_DIR}")
if (EXISTS ${OPENMOLCAS_GIT_REPO})
set (MOLCAS_GIT_REPO ${OPENMOLCAS_GIT_REPO})
else ()
set (do OFF)
endif ()
set (label "")
elseif ("${BASE_DIR}" STREQUAL "${EXTRA_DIR}")
if (EXISTS ${EXTRA_GIT_REPO})
set (MOLCAS_GIT_REPO ${EXTRA_GIT_REPO})
else ()
set (do OFF)
endif ()
set (label "-extra")
endif ()
if (do)
# always set the HEAD as a source for configuring
configure_file ("${MOLCAS_GIT_REPO}/HEAD" git-head${label} COPYONLY)
# if it is a ref to a named branch, include the branch ref too
file (READ "${MOLCAS_GIT_REPO}/HEAD" HEAD_STRING)
string (STRIP "${HEAD_STRING}" HEAD_STRING)
string (REPLACE "ref: " "" HEAD_REF "${HEAD_STRING}")
if (EXISTS "${MOLCAS_GIT_REPO}/${HEAD_REF}")
configure_file ("${MOLCAS_GIT_REPO}/${HEAD_REF}" git-head-ref${label} COPYONLY)
endif ()
# now, get the actual versions from the git describe tool
execute_process (
COMMAND ${GIT} "describe" "--always" "--dirty" "--match" "v*"
WORKING_DIRECTORY ${BASE_DIR}
OUTPUT_VARIABLE MOLCAS_VERSION
ERROR_VARIABLE GIT_DESCRIBE_ERROR
RESULT_VARIABLE GIT_DESCRIBE_RC
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (GIT_DESCRIBE_RC)
message (FATAL_ERROR "Failed to run git: ${GIT_DESCRIBE_ERROR}")
endif ()
if ("${BASE_DIR}" STREQUAL "${OPENMOLCAS_DIR}")
set (OPENMOLCAS_VERSION ${MOLCAS_VERSION})
elseif ("${BASE_DIR}" STREQUAL "${EXTRA_DIR}")
set (EXTRA_VERSION ${MOLCAS_VERSION})
endif ()
endif ()
endforeach (BASE_DIR)
# used for external projects (git submodules)
set (DEVELOPMENT_CODE)
execute_process (
COMMAND ${GIT} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
ERROR_QUIET
)
if (NOT ${GIT_BRANCH} STREQUAL "")
string(STRIP ${GIT_BRANCH} GIT_BRANCH)
endif ()
endif ()
if (DEFINED OPENMOLCAS_VERSION)
# Read the version from the .tags file, which should be populated when the code
# has been obtained from "git archive". Since there's no way to know if the
# code has been modified, add a question mark
elseif (EXISTS ${OPENMOLCAS_DIR}/.tags)
file (STRINGS ${OPENMOLCAS_DIR}/.tags LINES)
foreach (line ${LINES})
string (FIND "${line}" "(" has_paren)
string (FIND "${line}" "%" has_percent)
string (REGEX MATCH "tag: (v[^,]*)," match ${line})
# Parse the tag if present
if (has_paren GREATER -1)
if (NOT ${match} STREQUAL "")
set (OPENMOLCAS_VERSION "${CMAKE_MATCH_1} ?")
endif ()
# Or just use the commit sha, making sure this is not the raw file
elseif (has_percent EQUAL -1)
string (SUBSTRING ${line} 0 14 OPENMOLCAS_VERSION)
set (OPENMOLCAS_VERSION "o${OPENMOLCAS_VERSION} ?")
endif ()
endforeach ()
elseif (EXISTS ${MOLCAS_VERSION_FILE})
file (STRINGS ${MOLCAS_VERSION_FILE} LINES)
foreach (line ${LINES})
string (FIND "${line}" ".o" is_open)
string (FIND "${line}" ".x" is_extra)
if (is_open GREATER -1)
string (STRIP ${line} OPENMOLCAS_VERSION)
elseif (is_extra GREATER -1)
string (STRIP ${line} EXTRA_VERSION)
endif ()
endforeach ()
else ()
set (OPENMOLCAS_VERSION "unknown")
set (GIT_BRANCH "")
endif ()
message ("-- OPENMOLCAS_VERSION: ${OPENMOLCAS_VERSION}")
set (MOLCAS_VERSION ${OPENMOLCAS_VERSION})
if (DEFINED EXTRA_VERSION)
message ("-- EXTRA_VERSION: ${EXTRA_VERSION}")
set (MOLCAS_VERSION "${OPENMOLCAS_VERSION} & ${EXTRA_VERSION}")
endif ()
configure_file (${OPENMOLCAS_DIR}/src/Include/molcasversion.h.in include/molcasversion.h)
# set location of libraries and executables
#==========================================
set (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# global include directory
#=========================
foreach (BASE_DIR ${basedirs})
if (EXISTS "${BASE_DIR}/src/Include")
include_directories (${BASE_DIR}/src/Include)
endif ()
endforeach ()
include_directories (${PROJECT_BINARY_DIR}/include)
include_directories (${PROJECT_BINARY_DIR}/mod)
# system information
#===================
message ("Detecting system info:")
# operating system
set (OS ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
message ("-- OS: ${OS}")
# address mode
if (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set (ADDRMODE 64)
add_definitions (-D_I8_)
else ()
set (ADDRMODE 32)
endif ()
message ("-- ADDRMODE: ${ADDRMODE}")
# platform settings
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_definitions (-D_LINUX_)
if ((${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86") OR
(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686"))
set (PLATFORM "LINUX")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set (PLATFORM "LINUX64")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ia64")
set (PLATFORM "LINUX64_IA")
elseif ((${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ppc_64") OR
(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ppc64le"))
set (PLATFORM "PPC64")
endif ()
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
add_definitions (-D_LINUX_ -D_DARWIN_)
set (CMAKE_MACOSX_RPATH 0)
set (PLATFORM "MacOS")
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN")
add_definitions (-D_LINUX_ -D_CYGWIN_)
if (ADDRMODE EQUAL 32)
set (PLATFORM "WIN")
elseif (ADDRMODE EQUAL 64)
set (PLATFORM "WIN64")
endif ()
endif ()
if (NOT PLATFORM)
message (FATAL_ERROR "unsupported platform")
else ()
message ("-- PLATFORM: ${PLATFORM}")
endif ()
################################################################################
# #
# Compiler-specific settings #
# #
################################################################################
# Set the default compiler flags to pick from
#================================================
# For new compilers, check for the proper compiler ID on the following web page:
# http://www.cmake.org/cmake/help/v2.8.12/cmake.html#variable:CMAKE_LANG_COMPILER_ID
# The regular compiler options have to be compatible with other flags (so they
# might be added or removed depending on certain options), while the flags for
# build targets are mutually exclusive (only one of them will be active).
# Ideally, build targets should accomplish the features in the table below.
# legend: opt = optimizations; bt = backtrace (call stack); trap = catch
# floating point exceptions; warn = produce warnings during compilation
# opt bt trap warn
# === === ==== ====
# - Debug NO YES NO YES
# - Garble YES YES YES YES
# - RelWithDebInfo YES YES NO YES
# - Release YES NO NO NO
# - Fast YES NO NO NO
#
# Note: trapping floating point exceptions is not compatible with LAPACK
# (which produces and handles the exceptions), so a better alternative
# has to be found
#======================================#
# GNU Compiler Collection (GCC)
#======================================#
# defines __GNUC__
# C++ compiler
list (APPEND SUPPORTED_CXX_COMPILERS "GNU")
set (CXXFLAGS_GNU_BASIC "")
set (CXXFLAGS_GNU_OPENMP "-fopenmp")
# build targets
set (CXXFLAGS_GNU_DEBUG "-O0 -g -Wall")
set (CXXFLAGS_GNU_GARBLE "-O2 -g -Wall")
set (CXXFLAGS_GNU_RELWITHDEBINFO "-O2 -g -Wall")
set (CXXFLAGS_GNU_RELEASE "-O2")
set (CXXFLAGS_GNU_FAST "-O2")
# C compiler
list (APPEND SUPPORTED_C_COMPILERS "GNU")
set (CFLAGS_GNU_BASIC "-std=gnu99")
set (CFLAGS_GNU_OPENMP "-fopenmp")
# build targets
set (CFLAGS_GNU_DEBUG "-O0 -g -Wall")
set (CFLAGS_GNU_GARBLE "-O2 -g -Wall")
set (CFLAGS_GNU_RELWITHDEBINFO "-O2 -g -Wall")
set (CFLAGS_GNU_RELEASE "-O2")
set (CFLAGS_GNU_FAST "-O2")
# Fortran compiler
list (APPEND SUPPORTED_Fortran_COMPILERS "GNU")
set (FFLAGS_GNU_BASIC "-cpp")
set (FFLAGS_GNU_OPENMP "-fopenmp")
set (FFLAGS_GNU_ILP64 "-fdefault-integer-8")
# build targets
set (FFLAGS_GNU_DEBUG "-O0 -g -Wall")
set (FFLAGS_GNU_GARBLE "-O2 -g -Wall -finit-real=snan -finit-integer=730432726 -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans")
set (FFLAGS_GNU_RELWITHDEBINFO "-O2 -g -Wall")
set (FFLAGS_GNU_RELEASE "-O2")
set (FFLAGS_GNU_FAST "-O3")
# Fix for GNU Fortran compiler version >= 4.8 to prevent wrong optimization
# version check for Fortran doesn't work yet, assume it is the same as the C compiler GCC version
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND
(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS "4.8"))
set (CFLAGS_GNU_BOUNDS "-fsanitize=address -fno-omit-frame-pointer")
set (FFLAGS_GNU_BASIC "${FFLAGS_GNU_BASIC} -fno-aggressive-loop-optimizations")
set (FFLAGS_GNU_BOUNDS "-fsanitize=address -fno-omit-frame-pointer")
endif ()
set (CXXFLAGS_GNU_BIGOT "-Wall -Werror")
set (CFLAGS_GNU_BIGOT "-Wall -Werror")
set (FFLAGS_GNU_BIGOT "-Wall -Werror")
set (GNU_TRAP "-ffpe-trap=invalid,zero,overflow")
#======================================#
# LLVM C frontend (Clang)
#======================================#
# defines __clang__
# C++ compiler
list (APPEND SUPPORTED_CXX_COMPILERS "Clang")
set (CXXFLAGS_Clang_BASIC "-std=gnu99")
set (CXXFLAGS_Clang_OPENMP "-fopenmp")
# build targets
set (CXXFLAGS_Clang_DEBUG "-O0 -g -Wall")
set (CXXFLAGS_Clang_GARBLE "-O2 -g -Wall")
set (CXXFLAGS_Clang_RELWITHDEBINFO "-O2 -g -Wall")
set (CXXFLAGS_Clang_RELEASE "-O2")
set (CXXFLAGS_Clang_FAST "-O2")
# C compiler
list (APPEND SUPPORTED_C_COMPILERS "Clang")
set (CFLAGS_Clang_BASIC "-std=gnu99")
set (CFLAGS_Clang_OPENMP "-fopenmp")
# build targets
set (CFLAGS_Clang_DEBUG "-O0 -g -Wall")
set (CFLAGS_Clang_GARBLE "-O2 -g -Wall")
set (CFLAGS_Clang_RELWITHDEBINFO "-O2 -g -Wall")
set (CFLAGS_Clang_RELEASE "-O2")
set (CFLAGS_Clang_FAST "-O2")
set (CXXFLAGS_Clang_BIGOT "-Wall -Werror")
set (CFLAGS_Clang_BIGOT "-Wall -Werror")
#set (Clang_TRAP "???")
#======================================#
# Intel C++/C/Fortran Compilers
#======================================#
# defines __INTEL_COMPILER
# C++ compiler
list (APPEND SUPPORTED_CXX_COMPILERS "Intel")
set (CXXFLAGS_Intel_BASIC "")
set (CXXFLAGS_Intel_OPENMP "-qopenmp")
# build targets
set (CXXFLAGS_Intel_DEBUG "-debug -Wall")
set (CXXFLAGS_Intel_GARBLE "-O2 -debug -Wall")
set (CXXFLAGS_Intel_RELWITHDEBINFO "-O2 -debug -Wall")
set (CXXFLAGS_Intel_RELEASE "-O2")
set (CXXFLAGS_Intel_FAST "-O2")
# C compiler
list (APPEND SUPPORTED_C_COMPILERS "Intel")
set (CFLAGS_Intel_BASIC "-std=gnu99")
set (CFLAGS_Intel_OPENMP "-qopenmp")
# build targets
set (CFLAGS_Intel_DEBUG "-debug -Wall")
set (CFLAGS_Intel_GARBLE "-O2 -debug -Wall")
set (CFLAGS_Intel_RELWITHDEBINFO "-O2 -debug -Wall")
set (CFLAGS_Intel_RELEASE "-O2")
set (CFLAGS_Intel_FAST "-O2")
# Fortran compiler
list (APPEND SUPPORTED_Fortran_COMPILERS "Intel")
set (FFLAGS_Intel_BASIC "-fpp")
set (FFLAGS_Intel_OPENMP "-qopenmp")
set (FFLAGS_Intel_ILP64 "-i8 -r8 -heap-arrays")
# build targets
set (FFLAGS_Intel_DEBUG "-debug -traceback -warn all,nointerfaces,nodeclarations")
set (FFLAGS_Intel_GARBLE "-O2 -debug -traceback -warn all,nointerfaces,nodeclarations")
set (FFLAGS_Intel_RELWITHDEBINFO "-O2 -debug -traceback -warn all,nointerfaces,nodeclarations")
set (FFLAGS_Intel_RELEASE "-O2 -traceback")
set (FFLAGS_Intel_FAST "-fast")
# Intel versions prior to 15 used -openmp
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS "15.0.0.20140528")
set (CXXFLAGS_Intel_OPENMP "-openmp")
endif ()
if (CMAKE_C_COMPILER_ID STREQUAL "Intel" AND
CMAKE_C_COMPILER_VERSION VERSION_LESS "15.0.0.20140528")
set (CFLAGS_Intel_OPENMP "-openmp")
endif ()
if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" AND
CMAKE_Fortran_COMPILER_VERSION VERSION_LESS "15.0.0.20140528")
set (FFLAGS_Intel_OPENMP "-openmp")
endif ()
#fix for MAC OS X
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set (CXXFLAGS_Intel_BASIC "-headerpad_max_install_names ${CXXFLAGS_Intel_BASIC}")
set (CFLAGS_Intel_BASIC "-headerpad_max_install_names ${CFLAGS_Intel_BASIC}")
set (FFLAGS_Intel_BASIC "-headerpad_max_install_names ${FFLAGS_Intel_BASIC}")
endif ()
set (CXXFLAGS_Intel_BIGOT "-Wall -Werror")
set (CFLAGS_Intel_BIGOT "-Wall -Werror")
set (FFLAGS_Intel_BIGOT "-warn all -warn errors")
set (Intel_TRAP "-fpe0")
#======================================#
# Oracle Developer Studio (Sun Studio)
#======================================#
# defines __SUNPRO_F90
# C compiler
list (APPEND SUPPORTED_C_COMPILERS "SunPro")
set (CFLAGS_SunPro_BASIC "-std=gnu99")
set (CFLAGS_SunPro_OPENMP "-xopenmp")
# build targets
set (CFLAGS_SunPro_DEBUG "-g -traceback -ftrap=%none")
set (CFLAGS_SunPro_GARBLE "-O -g -traceback -ftrap=%none -xcheck=init_local")
set (CFLAGS_SunPro_RELWITHDEBINFO "-O -g -traceback -ftrap=%none")
set (CFLAGS_SunPro_RELEASE "-O -ftrap=%none")
set (CFLAGS_SunPro_FAST "-O -ftrap=%none")
# Fortran compiler
list (APPEND SUPPORTED_Fortran_COMPILERS "SunPro")
set (FFLAGS_SunPro_BASIC "-fpp") # 32bit: -ftrap=common,no%division,%none
set (FFLAGS_SunPro_OPENMP "-xopenmp")
set (FFLAGS_SunPro_ILP64 "-dalign -xtypemap=real:64,double:64,integer:64")
# build targets
set (FFLAGS_SunPro_DEBUG "-g -traceback -ftrap=%none")
set (FFLAGS_SunPro_GARBLE "-O -g -traceback ftrap=%none -xcheck=init_local")
set (FFLAGS_SunPro_RELWITHDEBINFO "-O -g -traceback -ftrap=%none")
set (FFLAGS_SunPro_RELEASE "-O -ftrap=%none")
set (FFLAGS_SunPro_FAST "-fast -dbl_align_all=yes -ftrap=%none")
# older versions do not suport gnu99
if (CMAKE_C_COMPILER_ID STREQUAL "SunPro" AND
CMAKE_C_COMPILER_VERSION VERSION_LESS "5.15.0")
set (CFLAGS_SunPro_BASIC "-std=c99")
endif ()
set (CFLAGS_SunPro_BIGOT "-errwarn=%all")
set (FFLAGS_SunPro_BIGOT "-errwarn=%all")
set (SunPro_TRAP "-ftrap=common")
#======================================#
# Portland Group (PGI) Compilers
#======================================#
# defines __PGI
# C++ compiler
list (APPEND SUPPORTED_CXX_COMPILERS "PGI")
set (CXXFLAGS_PGI_BASIC "-c99 -pgf90libs")
set (CXXFLAGS_PGI_OPENMP "-mp")
# build targets
set (CXXFLAGS_PGI_DEBUG "-O0 -g -Minform=warn")
set (CXXFLAGS_PGI_GARBLE "-O2 -gopt -Minform=warn")
set (CXXFLAGS_PGI_RELWITHDEBINFO "-O2 -gopt -Minform=warn")
set (CXXFLAGS_PGI_RELEASE "-O2")
set (CXXFLAGS_PGI_FAST "-O2")
# C compiler
list (APPEND SUPPORTED_C_COMPILERS "PGI")
set (CFLAGS_PGI_BASIC "-c99 -pgf90libs")
set (CFLAGS_PGI_OPENMP "-mp")
# build targets
set (CFLAGS_PGI_DEBUG "-O0 -g -Minform=warn")
set (CFLAGS_PGI_GARBLE "-O2 -gopt -Minform=warn")
set (CFLAGS_PGI_RELWITHDEBINFO "-O2 -gopt -Minform=warn")
set (CFLAGS_PGI_RELEASE "-O2")
set (CFLAGS_PGI_FAST "-O2")
# Fortran compiler
list (APPEND SUPPORTED_Fortran_COMPILERS "PGI")
set (FFLAGS_PGI_BASIC "-Mpreprocess -Mbackslash")
set (FFLAGS_PGI_OPENMP "-mp")
set (FFLAGS_PGI_ILP64 "-i8")
# build targets
set (FFLAGS_PGI_DEBUG "-O0 -g -Minform=warn")
set (FFLAGS_PGI_GARBLE "-O2 -gopt -Minform=warn")
set (FFLAGS_PGI_RELWITHDEBINFO "-O2 -gopt -Minform=warn")
set (FFLAGS_PGI_RELEASE "-O2")
set (FFLAGS_PGI_FAST "-fast")
# The option does not exist, or I cannot find it
#set (CXXFLAGS_PGI_BIGOT "???")
#set (CFLAGS_PGI_BIGOT "???")
#set (FFLAGS_PGI_BIGOT "???")
#set (PGI_TRAP "???")
#======================================#
# Numerical Algorithms Group (NAG)
#======================================#
# defines NAGFOR
# Fortran compiler
list (APPEND SUPPORTED_Fortran_COMPILERS "NAG")
set (FFLAGS_NAG_BASIC "-fpp -dusty -dcfuns -mismatch_all -w -kind=byte")
set (FFLAGS_NAG_OPENMP "-openmp")
set (FFLAGS_NAG_ILP64 "-i8")
# build targets
set (FFLAGS_NAG_DEBUG "-O0 -g -ieee=full")
set (FFLAGS_NAG_GARBLE "-O2 -g -ieee=full -nan")
set (FFLAGS_NAG_RELWITHDEBINFO "-O2 -g -ieee=full")
set (FFLAGS_NAG_RELEASE "-O2 -ieee=full")
set (FFLAGS_NAG_FAST "-O3 -ieee=full")
# The option does not exist, or I cannot find it
#set (FFLAGS_NAG_BIGOT "???")
set(NAG_TRAP "-ieee=stop")
# Generate the actual flags used in the build
#============================================
# Preprocessor
if (CMAKE_BUILD_TYPE STREQUAL "Garble")
add_definitions (-D_GARBLE_ -D_NO_IEEECK_ -D_FPE_TRAP_)
# Disable FPE traps for compiler that do not support IEEE Fortran modules
# version check for Fortran doesn't work yet, assume it is the same as the C compiler GCC version
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND
CMAKE_C_COMPILER_VERSION VERSION_LESS "5.0")
remove_definitions (-D_FPE_TRAP_)
elseif (NOT LINALG STREQUAL "Internal")
message (WARNING
"Garble is active, but an external LINALG library is used! "
"The use of an external BLAS/LAPACK can result in floating point "
"exceptions handled by the library being trapped instead. "
"Please use -DLINALG=Internal for better chances for Garble to work correctly!")
else ()
message (WARNING
"Garble and floating point exception trapping are active! "
"It is possible that intended exceptions within BLAS/LAPACK crash the program. "
"Be warned!")
endif ()
endif ()
if (DMRG OR WFA)
# C++ compiler required for DMRG and WFA projects
foreach (CXX_COMPILER ${SUPPORTED_CXX_COMPILERS})
if (CXX_COMPILER STREQUAL "${CMAKE_CXX_COMPILER_ID}")
set (CXXCID ${CMAKE_CXX_COMPILER_ID})
endif ()
endforeach ()
if (NOT CXXCID)
message (FATAL_ERROR "unsupported CXX compiler: ${CMAKE_CXX_COMPILER_ID}")
endif ()
endif ()
# C compiler
foreach (C_COMPILER ${SUPPORTED_C_COMPILERS})
if (C_COMPILER STREQUAL "${CMAKE_C_COMPILER_ID}")
set (CCID ${CMAKE_C_COMPILER_ID})
endif ()
endforeach ()
if (NOT CCID)
message (FATAL_ERROR "unsupported C compiler: ${CMAKE_C_COMPILER_ID}")
endif ()
# overwrite any CMake defaults (some are strange, so we set our own)
if (NOT CMAKE_CXX_FLAGS_USER)
set (CMAKE_CXX_FLAGS_DEFAULT "$ENV{CXXFLAGS} ${CXXFLAGS_${CXXCID}_BASIC}"
CACHE STRING "C++ compiler flags." FORCE)
set (CMAKE_CXX_FLAGS_DEBUG ${CXXFLAGS_${CXXCID}_DEBUG}
CACHE STRING "C++ compiler flags used for debug builds." FORCE)
set (CMAKE_CXX_FLAGS_GARBLE ${CXXFLAGS_${CXXCID}_GARBLE}
CACHE STRING "C++ compiler flags used for garble builds." FORCE)
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CXXFLAGS_${CXXCID}_RELWITHDEBINFO}
CACHE STRING "C++ compiler flags used for release builds with debug info." FORCE)
set (CMAKE_CXX_FLAGS_RELEASE ${CXXFLAGS_${CXXCID}_RELEASE}
CACHE STRING "C++ compiler flags used for release builds." FORCE)
set (CMAKE_CXX_FLAGS_FAST ${CXXFLAGS_${CXXCID}_FAST}
CACHE STRING "C++ compiler flags used for fast release builds." FORCE)
set (CMAKE_CXX_FLAGS_USER "TRUE"
CACHE INTERNAL "set to FALSE to reset to default C++ flags" FORCE)
endif ()
if (EXPERT)
mark_as_advanced(CLEAR
CMAKE_CXX_FLAGS_DEFAULT
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_GARBLE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_FAST
)
else ()
mark_as_advanced(FORCE
CMAKE_CXX_FLAGS_DEFAULT
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_GARBLE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_FAST
)
endif ()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEFAULT}")
# overwrite any CMake defaults (some are strange, so we set our own)
if (NOT CMAKE_C_FLAGS_USER)
set (CMAKE_C_FLAGS_DEFAULT "$ENV{CFLAGS} ${CFLAGS_${CCID}_BASIC}"
CACHE STRING "C compiler flags." FORCE)
set (CMAKE_C_FLAGS_DEBUG ${CFLAGS_${CCID}_DEBUG}
CACHE STRING "C compiler flags used for debug builds." FORCE)
set (CMAKE_C_FLAGS_GARBLE ${CFLAGS_${CCID}_GARBLE}
CACHE STRING "C compiler flags used for garble builds." FORCE)
set (CMAKE_C_FLAGS_RELWITHDEBINFO ${CFLAGS_${CCID}_RELWITHDEBINFO}
CACHE STRING "C compiler flags used for release builds with debug info." FORCE)
set (CMAKE_C_FLAGS_RELEASE ${CFLAGS_${CCID}_RELEASE}
CACHE STRING "C compiler flags used for release builds." FORCE)
set (CMAKE_C_FLAGS_FAST ${CFLAGS_${CCID}_FAST}
CACHE STRING "C compiler flags used for fast release builds." FORCE)
set (CMAKE_C_FLAGS_USER "TRUE"
CACHE INTERNAL "set to FALSE to reset to default C flags" FORCE)
endif ()
if (EXPERT)
mark_as_advanced(CLEAR
CMAKE_C_FLAGS_DEFAULT
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_GARBLE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_FAST
)
else ()
mark_as_advanced(FORCE
CMAKE_C_FLAGS_DEFAULT
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_GARBLE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_FAST
)
endif ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_DEFAULT}")
# Fortran compiler
foreach (Fortran_COMPILER ${SUPPORTED_Fortran_COMPILERS})
if (Fortran_COMPILER STREQUAL "${CMAKE_Fortran_COMPILER_ID}")
set (FCID ${CMAKE_Fortran_COMPILER_ID})
endif ()
endforeach ()
if (NOT FCID)
message (FATAL_ERROR "unsupported Fortran compiler: ${CMAKE_Fortran_COMPILER_ID}")
endif ()
# overwrite any CMake defaults (some are strange, so we set our own)
if (NOT CMAKE_Fortran_FLAGS_USER)
set (CMAKE_Fortran_FLAGS_DEFAULT "$ENV{FFLAGS} ${FFLAGS_${FCID}_BASIC}"
CACHE STRING "Fortran compiler flags." FORCE)
set (CMAKE_Fortran_FLAGS_DEBUG ${FFLAGS_${FCID}_DEBUG}
CACHE STRING "Fortran compiler flags used for debug builds." FORCE)
set (CMAKE_Fortran_FLAGS_GARBLE ${FFLAGS_${FCID}_GARBLE}
CACHE STRING "Fortran compiler flags used for garble builds." FORCE)
set (CMAKE_Fortran_FLAGS_RELWITHDEBINFO ${FFLAGS_${FCID}_RELWITHDEBINFO}
CACHE STRING "Fortran compiler flags used for release builds with debug info." FORCE)
set (CMAKE_Fortran_FLAGS_RELEASE ${FFLAGS_${FCID}_RELEASE}
CACHE STRING "Fortran compiler flags used for release builds." FORCE)
set (CMAKE_Fortran_FLAGS_FAST ${FFLAGS_${FCID}_FAST}
CACHE STRING "Fortran compiler flags used for fast release builds." FORCE)
set (CMAKE_Fortran_FLAGS_USER "TRUE"
CACHE INTERNAL "set to FALSE to reset to default Fortran flags" FORCE)
endif ()
if (EXPERT)
mark_as_advanced(CLEAR
CMAKE_Fortran_FLAGS_DEFAULT
CMAKE_Fortran_FLAGS_DEBUG
CMAKE_Fortran_FLAGS_GARBLE
CMAKE_Fortran_FLAGS_RELWITHDEBINFO
CMAKE_Fortran_FLAGS_RELEASE
CMAKE_Fortran_FLAGS_FAST
)
else ()
mark_as_advanced(FORCE
CMAKE_Fortran_FLAGS_DEFAULT
CMAKE_Fortran_FLAGS_DEBUG
CMAKE_Fortran_FLAGS_GARBLE
CMAKE_Fortran_FLAGS_RELWITHDEBINFO
CMAKE_Fortran_FLAGS_RELEASE
CMAKE_Fortran_FLAGS_FAST
)
endif ()
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS_DEFAULT}")
if (ADDRMODE EQUAL 64)
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FFLAGS_${FCID}_ILP64}")
endif ()
if (OPENMP)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXXFLAGS_${CXXCID}_OPENMP}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CFLAGS_${CCID}_OPENMP}")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FFLAGS_${FCID}_OPENMP}")
endif ()
if (BOUNDS)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXXFLAGS_${CXXCID}_BOUNDS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CFLAGS_${CCID}_BOUNDS}")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FFLAGS_${FCID}_BOUNDS}")
add_definitions (-D_MALLOC_INTERCEPT_)
endif ()
################################################################################
# #
# Process options #
# #
################################################################################
# Install directory
#==================
if (NOT IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}")
set (CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}")
endif ()
get_filename_component (CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" ABSOLUTE)
# Special print statements
#=========================
if (DEBUGPRINT)
add_definitions (-D_DEBUG_)
endif ()
if (DEBUGTRACE)