-
-
Notifications
You must be signed in to change notification settings - Fork 58
/
CMakeLists.txt
1044 lines (920 loc) · 36.9 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
##################################################################
# IQ-TREE cmake build definition
# Copyright (c) 2012-2015 Bui Quang Minh, Lam-Tung Nguyen
##################################################################
# For full build instructions, see .github/workflows/ci.yaml
# CI is more likely to be up to date than the example usage section below
# IQTREE_FLAGS (set via -DIQTREE_FLAGS=...):
#---------------
# single: compile sequential version (default is OpenMP)
#
# lto: perform link time optimization
# static: link statically
# nostrip: do not strip debug information
#
# KNL: compile for Intel Xeon Phi (KNL) architecture
# avx: enable AVX instructions
# fma: enable FMA instructions
# novx: disable AVX instructions
# nosse: disable SSE instructions
#
# oldmac: compile for older Mac OS X versions (10.5)
#
# nozlib: do not use zlib
# libcxx
#
# cpp14: use C++14 standard (default is C++17)
# CMAPLE: Integrate CMAPLE library
#---------------
# Compile IQ-TREE with CMAPLE integrated:
# cmake -DUSE_CMAPLE=ON ....
# Windows example usages:
#------------------------
# cmake -G "Visual Studio 12 Win64" <source_dir> (compiled with MSVC)
# cmake -G "Visual Studio 12 Win64" -T "Intel C++ Compiler XE 15.0" <source_dir> (compiled with ICC)
# cmake -G "MinGW Makefiles" <source_dir> (TDM-GCC)
# cmake -G "Unix Makefiles" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_MAKE_PROGRAM=mingw32-make <source_dir> (TDM-GCC and clang)
# Linux example usages:
#----------------------
# cmake <source_dir> -DIQTREE_FLAGS=single (sequential version)
# cmake <source_dir> (OpenMP version)
#
# To compile with CLANG on Linux:
# export CC=/usr/bin/clang
# export CXX=/usr/bin/clang++
# Best practices for setting up CMAKE for diffrent compiler can be found here:
# http://stackoverflow.com/questions/7031126/switching-between-gcc-and-clang-llvm-using-cmake
#
# Mac OSX example usages:
#------------------------
#
# cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ <source_dir> (OpenMP version)
# cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DIQTREE_FLAGS=single <source_dir> (sequential version)
#
# Xcode project example usages:
#------------------------------
#
# To generate Xcode project without OpenMP:
# cmake -G Xcode -DIQTREE_FLAGS=single <source_dir>
#
# To generate Xcode project with OpenMP support,
# assuming you installed LLVM via Homebrew: brew install --with-toolchain llvm
# cmake -G XCode -DCMAKE_XCODE_ATTRIBUTE_CC=/usr/local/opt/llvm/bin/clang -DCMAKE_XCODE_ATTRIBUTE_CXX=/usr/local/opt/llvm/bin/clang++ <source_dir>
# Replace /usr/local with /opt/homebrew on osx-arm64
#NOTE: Static linking with clang windows: make a symlink libgcc_eh.a to libgcc.a (administrator required)
# C:\TDM-GCC-64\lib\gcc\x86_64-w64-mingw32\5.1.0>mklink libgcc_eh.a libgcc.a
#
#
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) # Lowest version tested in CI (on linux x86_64)
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
set(GCC_MIN_VERSION "9") # minimum GCC version that is tested in CI
project(iqtree)
add_definitions(-DIQ_TREE)
# Find Eigen3 library
if (NOT EIGEN3_INCLUDE_DIR)
find_package(Eigen3)
if(NOT EIGEN3_FOUND)
message(FATAL_ERROR "Eigen3 library not found. Either install it or rerun cmake with -DEIGEN3_INCLUDE_DIR=<installed_eigen3_dir>")
endif()
endif()
add_definitions(-I${EIGEN3_INCLUDE_DIR})
# Find Boost library
find_package(Boost REQUIRED)
if(Boost_FOUND)
add_definitions(-I${Boost_INCLUDE_DIRS})
add_definitions(-DUSE_BOOST)
endif()
# The version number.
set (iqtree_VERSION_MAJOR 2)
set (iqtree_VERSION_MINOR 3)
set (iqtree_VERSION_PATCH ".6")
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
if (CMAKE_C_COMPILER MATCHES "mpic")
set(IQTREE_FLAGS "${IQTREE_FLAGS} mpi")
endif()
message("IQ-TREE flags : ${IQTREE_FLAGS}")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Release")
message("Build mode : Release")
endif()
if (BUILD_LIB STREQUAL "ON")
message("Build lib : ON")
else()
message("Build lib : OFF")
endif()
if (CMAKE_GENERATOR MATCHES "Xcode")
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym")
# if (NOT CMAKE_XCODE_ATTRIBUTE_COMPILER_INDEX_STORE_ENABLE)
# set(CMAKE_XCODE_ATTRIBUTE_COMPILER_INDEX_STORE_ENABLE "No")
# endif()
endif()
include_directories("${PROJECT_SOURCE_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/yaml-cpp/include")
include_directories(after system "/usr/local/include")
##################################################################
# Include the Terraphast library
##################################################################
option(USE_TERRAPHAST "Use phylogentic terraces library (terraphast)" ON)
if (USE_TERRAPHAST)
add_definitions(-DIQTREE_TERRAPHAST)
option(TERRAPHAST_USE_GMP "" OFF)
option(TERRAPHAST_BUILD_CLIB "" OFF)
option(TERRAPHAST_BUILD_APPS "" OFF)
option(TERRAPHAST_BUILD_TESTS "" OFF)
endif()
##################################################################
# Include the LSD2 library
##################################################################
option(USE_LSD2 "Use least square dating (lsd2)" ON)
if (USE_LSD2)
add_definitions(-DUSE_LSD2)
endif()
# Check if __ARM_NEON is defined
#include(cmake_utls/check_neon_exists.cmake)
set (__ARM_NEON "FALSE")
set (NEON 0)
if (APPLE)
execute_process(
COMMAND uname -m
RESULT_VARIABLE result
OUTPUT_VARIABLE OSX_NATIVE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(OSX_NATIVE_ARCHITECTURE STREQUAL "arm64")
message("APPLE SILICON (M1/M2/M3) DETECTED!")
set (__ARM_NEON "TRUE")
set (NEON 1)
endif()
elseif (UNIX AND NOT APPLE) # Unix and Linux
execute_process(
COMMAND uname -m
RESULT_VARIABLE result
OUTPUT_VARIABLE OS_NATIVE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(OS_NATIVE_ARCHITECTURE STREQUAL "aarch64")
message("Unix/Linux ARM64 DETECTED!")
set (__ARM_NEON "TRUE")
set (NEON 1)
endif()
endif()
##################################################################
# Include the CMAPLE library
##################################################################
option(USE_CMAPLE "Integrate CMAPLE" OFF)
if (USE_CMAPLE STREQUAL "ON")
message("Integrate CMAPLE: ON")
add_definitions(-DUSE_CMAPLE)
set(TARGET_CMAPLE "maple")
else()
message("Integrate CMAPLE: OFF")
set(TARGET_CMAPLE "")
endif()
##################################################################
# Detect target platforms
##################################################################
if (WIN32)
message("Target OS : Windows")
# build as static binary to run on most machines
if (IQTREE_FLAGS MATCHES "static")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif()
SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
elseif (APPLE)
message("Target OS : Mac OS X")
if(OSX_NATIVE_ARCHITECTURE STREQUAL "arm64")
add_definitions("--target=arm64-apple-macos10.5")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --target=arm64-apple-macos12.0.1")
else()
# to be compatible back to Mac OS X 10.7
if (IQTREE_FLAGS MATCHES "oldmac")
add_definitions("-mmacosx-version-min=10.5")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mmacosx-version-min=10.5")
else()
add_definitions("--target=x86_64-apple-macos10.7")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --target=x86_64-apple-macos10.7")
endif()
endif()
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
elseif (UNIX)
message("Target OS : Unix")
# build as static binary to run on most machines
if (NOT IQTREE_FLAGS MATCHES "static")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif()
else()
# Note that IQ-TREE has NOT been tested on other platforms
message("Target OS : Unknown and untested yet")
endif()
##################################################################
# Setup compiler, currently supported GCC, CLANG, MSVC, and ICC
##################################################################
set(GCC "FALSE") # GNU compiler
set(CLANG "FALSE") # Clang compiler
set(ICC "FALSE") # Intel compiler
set(VCC "FALSE") # MS Visual C Compiler, note that it is different from MSVC variable
set(CLANG_UNDER_VS "FALSE") #Clang compiler, used from inside Visual Studio
# using C++17 standard (unless IQTREE_FLAGS specifies c++14, required for compilation using mingw in Github actions)
# disable AVX for NEON
if (__ARM_NEON)
set(IQTREE_FLAGS "${IQTREE_FLAGS} novx")
elseif (CMAKE_CXX_COMPILER MATCHES "VISUAL STUDIO")
set(CLANG_UNDER_VS "TRUE")
#it won't recognize the -std=c++17 parameter.
#Todo: don't hard-code this; figure out some way it can be passed in (though ideally, not the whole shebang).
include_directories("C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\Llvm\\lib\\clang\\10.0.0\\include")
elseif(IQTREE_FLAGS MATCHES "cpp14")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
message("Compiler : GNU Compiler (gcc)")
set(GCC "TRUE")
# set(COMBINED_FLAGS "-Wall -Wno-unused-function -Wno-sign-compare -pedantic -D_GNU_SOURCE -fms-extensions -Wno-deprecated")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -g -ffunction-sections -fdata-sections")
set(CMAKE_C_FLAGS_RELEASE "-O2 -g -ffunction-sections -fdata-sections")
if (APPLE)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Wl,-dead_strip")
else()
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Wl,--gc-sections")
endif()
# require at least gcc ${GCC_MIN_VERSION}
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_MIN_VERSION)
message(FATAL_ERROR "GCC version must be at least ${GCC_MIN_VERSION}!")
endif()
if (WIN32)
# disable AVX on Windows due to memory alignment
set(IQTREE_FLAGS "${IQTREE_FLAGS} novx")
message("WARNING: AVX is disabled on Windows as GCC does not properly suport memory alignment")
endif()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message("Compiler : Clang")
set(CLANG "TRUE")
# set(COMBINED_FLAGS "-Wall -Wno-unused-function -Wno-sign-compare -pedantic -D_GNU_SOURCE -Wno-nested-anon-types")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffunction-sections -fdata-sections")
set(CMAKE_C_FLAGS_RELEASE "-O3 -ffunction-sections -fdata-sections")
if (APPLE)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Wl,-dead_strip")
else()
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Wl,--gc-sections")
endif()
# use libc++ per default in MacOS
if (APPLE)
SET(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
endif()
#remove -rdynamic for Clang under Linux
if (UNIX AND IQTREE_FLAGS MATCHES "static")
SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
endif()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(VCC "TRUE")
message("Compiler : MS Visual C++ Compiler")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
message("Compiler : Intel C++ Compiler (icc)")
set(ICC "TRUE")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Qstd=c99")
else()
message("Compiler : Unknown and untested yet")
endif()
message("Compiler version: ${CMAKE_CXX_COMPILER_VERSION}")
set(EXE_SUFFIX "")
if (MSVC)
# MS Visual Studio environment
message("Exporting MS Visual Studio projects...")
if (CLANG_UNDER_VS)
#see https://clang.llvm.org/docs/UsersManual.html#clang-cl
#note .GX is how you say -fexceptions
add_definitions(/D_UWIN)
set(CMAKE_C_FLAGS_RELEASE "/O2 /GX")
set(CMAKE_C_FLAGS_DEBUG "/D_UWIN /GX")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /I${EIGEN3_INCLUDE_DIR}")
else()
add_definitions(/MP) # enable multi-processor compilation
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Release")
add_definitions(/Ot /Oi)
if (VCC)
add_definitions(/O2)
elseif (ICC)
add_definitions(/O3)
endif()
endif()
endif()
# enable link time optimization
if (IQTREE_FLAGS MATCHES "lto")
#if (CLANG)
# set(COMBINED_FLAGS "${COMBINED_FLAGS} -flto=thin")
#else()
set(COMBINED_FLAGS "${COMBINED_FLAGS} -flto")
#endif()
endif()
# for mac arm boost compilation issue
if (__ARM_NEON AND APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dthread_local=")
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4 OR IQTREE_FLAGS MATCHES "m32")
error("32-bit compilation is not supported")
else()
message("Target binary : 64-bit")
if (CLANG_UNDER_VS)
set(COMBINED_FLAGS "${COMBINED_FLAGS} -m64")
endif()
if (WIN32)
add_definitions(-DWIN64)
endif()
endif()
##################################################################
# configure MPI compilation
##################################################################
if (IQTREE_FLAGS MATCHES "mpi")
add_definitions(-D_IQTREE_MPI)
if (NOT CMAKE_CXX_COMPILER MATCHES "mpi")
# if not using the MPI compiler wrapper, set own options manually
find_package(MPI)
if (MPI_Found)
set(CMAKE_CXX_COMPILE_FLAGS "${CMAKE_CXX_COMPILE_FLAGS} ${MPI_CXX_COMPILE_FLAGS}")
set(CMAKE_C_COMPILE_FLAGS "${CMAKE_C_COMPILE_FLAGS} ${MPI_C_COMPILE_FLAGS}")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} ${MPI_CXX_LINK_FLAGS}")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} ${MPI_C_LINK_FLAGS}")
include_directories(${MPI_C_INCLUDE_PATH})
include_directories(${MPI_CXX_INCLUDE_PATH})
else()
if(CLANG_UNDER_VS)
#Under Visual Studio, the MPI package isn't found, if you haven't installed FORTRAN
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /I${MPI_DIR}/Include")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /I${MPI_DIR}/Include")
#Zork. Linker
#message("MPI DIR was ${MPI_DIR}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LIBPATH:${MPI_DIR}\\lib\\x64 msmpi.lib /PROFILE")
endif()
endif()
endif()
endif()
##################################################################
# Configure PLL build
##################################################################
if (IQTREE_FLAGS MATCHES "pll")
add_definitions(-DUSING_PLL)
set(EXE_SUFFIX "${EXE_SUFFIX}-pll")
endif()
if(IQTREE_FLAGS MATCHES "novx")
add_definitions(-D__NOAVX__)
endif()
##################################################################
# configure OpenMP/PThreads compilation
# change the executable name if compiled for OpenMP parallel version
##################################################################
if (NOT IQTREE_FLAGS MATCHES "single")
message("OpenMP : Yes")
#SET(EXE_SUFFIX "${EXE_SUFFIX}-omp")
if (NOT CLANG_UNDER_VS)
add_definitions(-D_USE_PTHREADS)
endif()
if (MSVC)
if (NOT CLANG_UNDER_VS)
add_definitions(/MT)
endif()
endif()
if(CLANG AND APPLE)
if(OSX_NATIVE_ARCHITECTURE STREQUAL "arm64")
link_directories(${PROJECT_SOURCE_DIR}/libmac_m1)
else()
link_directories(${PROJECT_SOURCE_DIR}/libmac)
endif()
elseif (UNIX AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
if (__ARM_NEON)
link_directories(${PROJECT_SOURCE_DIR}/liblinux_arm)
else()
link_directories(${PROJECT_SOURCE_DIR}/lib)
endif()
elseif (WIN32)
link_directories(${PROJECT_SOURCE_DIR}/lib)
endif()
if (VCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
include_directories("${PROJECT_SOURCE_DIR}/pll") # for PThreads headers
elseif (ICC)
if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qopenmp")
include_directories("${PROJECT_SOURCE_DIR}/pll") # for PThreads headers
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qopenmp")
endif()
elseif (GCC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -pthread")
elseif (CLANG)
if (CLANG_UNDER_VS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DCLANG_UNDER_VS=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DCLANG_UNDER_VS=1")
include_directories("${PROJECT_SOURCE_DIR}/pll") # for PThreads headers
#Next two lines don't work for me, as I only have VS 2019 Community
#set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /implib:vcomp.lib")
#set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /implib:vcompd.lib")
#The problem here is that LLVM installs either 64 bit or 32 bit libraries, but not both.
#Though perhaps in debug builds this should be libiomp5md.lib
set (LLVM_DIR "C:\\Projects\\LLVM_10")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LIBPATH:${LLVM_DIR}\\lib libomp.lib")
#Also need to ensure libomp.dll is in the path (or copied into the output directory).
#(You want the one in ${LLVM_DIR}\\bin
#But I don't as yet know how to tell CMake to do that. -James B. 23-Jul-2020
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
if (APPLE OR WIN32 )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xpreprocessor -fopenmp -pthread")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lomp")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -pthread")
endif()
endif()
endif()
else()
message("OpenMP : NONE")
endif()
if (IQTREE_FLAGS MATCHES "mpi")
message("MPI : Yes")
SET(EXE_SUFFIX "${EXE_SUFFIX}-mpi")
else()
message("MPI : NONE")
endif()
##################################################################
# configure SSE/AVX/FMA instructions
##################################################################
SET(AVX_FLAGS "-D__SSE3 -D__AVX")
if (VCC)
set(AVX_FLAGS "${AVX_FLAGS} /arch:AVX")
elseif (CLANG)
if (__ARM_NEON)
set(AVX_FLAGS "${AVX_FLAGS} -march=armv8-a+fp+simd+crypto+crc")
else()
set(AVX_FLAGS "${AVX_FLAGS} -mavx")
endif()
elseif (GCC)
if (__ARM_NEON)
set(AVX_FLAGS "${AVX_FLAGS} -march=armv8-a+fp+simd+crypto+crc")
else()
set(AVX_FLAGS "${AVX_FLAGS} -mavx -fabi-version=0")
endif()
elseif (ICC)
if (WIN32)
set(AVX_FLAGS "${AVX_FLAGS} /arch:avx")
else()
set(AVX_FLAGS "${AVX_FLAGS} -mavx")
endif()
endif()
SET(SSE_FLAGS "-D__SSE3")
if (VCC)
set(SSE_FLAGS "${SSE_FLAGS} /arch:SSE2 -D__SSE3__")
elseif (GCC OR CLANG)
if (__ARM_NEON)
set(SSE_FLAGS "${SSE_FLAGS} -march=armv8-a+fp+simd+crypto+crc")
else()
set(SSE_FLAGS "${SSE_FLAGS} -msse3")
endif()
elseif (ICC)
if (WIN32)
set(SSE_FLAGS "${SSE_FLAGS} /arch:sse3")
else()
set(SSE_FLAGS "${SSE_FLAGS} -msse3")
endif()
endif()
SET(FMA_FLAGS "-D__SSE3 -D__AVX")
if (VCC)
set(FMA_FLAGS "${FMA_FLAGS} /arch:AVX2")
elseif (CLANG)
if (__ARM_NEON)
set(FMA_FLAGS "${FMA_FLAGS} -march=armv8-a+fp+simd+crypto+crc")
else()
set(FMA_FLAGS "${FMA_FLAGS} -mavx -mfma")
endif()
elseif (GCC)
if (__ARM_NEON)
set(FMA_FLAGS "${FMA_FLAGS} -march=armv8-a+fp+simd+crypto+crc")
else()
set(FMA_FLAGS "${FMA_FLAGS} -mavx -fabi-version=0 -mfma")
endif()
elseif (ICC)
if (WIN32)
set(FMA_FLAGS "${FMA_FLAGS} /arch:core-avx2")
else()
set(FMA_FLAGS "${FMA_FLAGS} -march=core-avx2")
endif()
endif()
SET(AVX512_FLAGS "-D__SSE3 -D__AVX")
if (VCC)
message("AVX512 not available in Visual C++")
#set(AVX512_FLAGS "${AVX512_FLAGS} /arch:AVX512")
elseif (CLANG)
set(AVX512_FLAGS "${AVX512_FLAGS} -mavx512f -mfma")
elseif (GCC)
set(AVX512_FLAGS "${AVX512_FLAGS} -mavx512f -mfma")
elseif (ICC)
if (WIN32)
set(AVX512_FLAGS "${AVX512_FLAGS} /QxMIC-AVX512")
else()
set(AVX512_FLAGS "${AVX512_FLAGS} -xMIC-AVX512")
endif()
endif()
# further flag to improve performance
if (IQTREE_FLAGS MATCHES "fma") # AVX+FMA instruction set
message("Vectorization : AVX+FMA")
add_definitions(-D__SSE3 -D__AVX) # define both SSE3 and AVX directive
set(COMBINED_FLAGS "${COMBINED_FLAGS} ${FMA_FLAGS}")
#SET(EXE_SUFFIX "${EXE_SUFFIX}-fma")
elseif (IQTREE_FLAGS MATCHES "avx") # AVX instruction set
message("Vectorization : AVX")
add_definitions(-D__SSE3 -D__AVX) # define both SSE3 and AVX directive
set(COMBINED_FLAGS "${COMBINED_FLAGS} ${AVX_FLAGS}")
#SET(EXE_SUFFIX "${EXE_SUFFIX}-avx")
elseif (NOT IQTREE_FLAGS MATCHES "nosse") #SSE intruction set
if (IQTREE_FLAGS MATCHES "KNL")
message("Vectorization : SSE3/AVX/AVX2/AVX-512")
add_definitions(-D__AVX512KNL)
elseif (NOT __ARM_NEON)
message("Vectorization : SSE3/AVX/AVX2")
endif()
#add_definitions(-D__SSE3)
#set(COMBINED_FLAGS "${COMBINED_FLAGS} ${SSE_FLAGS}")
endif()
##################################################################
# Setup compiler flags
##################################################################
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMBINED_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMBINED_FLAGS}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS} -fno-inline-functions -fno-inline-functions-called-once -fno-optimize-sibling-calls -fno-default-inline -fno-inline -O2 -fno-omit-frame-pointer -g")
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS} -fno-inline-functions -fno-inline-functions-called-once -fno-optimize-sibling-calls -O2 -fno-omit-frame-pointer -g")
if(CLANG AND IQTREE_FLAGS MATCHES "static")
#set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread -Wl,--allow-multiple-definition")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
endif()
if (IQTREE_FLAGS MATCHES "libcxx")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Release")
message("C flags : ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}")
message("CXX flags : ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("C flags : ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}")
message("CXX flags : ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Profile")
message("C flags : ${CMAKE_C_FLAGS_PROFILE} ")
message("CXX flags : ${CMAKE_CXX_FLAGS_PROFILE} ")
endif()
message("LINKER flags : ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
if (GCC)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fno-inline-functions -fno-inline-functions-called-once -fno-default-inline -fno-inline")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -fno-inline-functions -fno-inline-functions-called-once -fno-default-inline -fno-inline")
set(CMAKE_CXX_FLAGS_MEM "-g -O1")
set(CMAKE_C_FLAGS_MEM "-g -O1")
elseif (CLANG AND NOT CLANG_UNDER_VS)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fno-inline-functions -fno-inline")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -fno-inline-functions -fno-inline")
set(CMAKE_CXX_FLAGS_MEM "-g -O1")
set(CMAKE_C_FLAGS_MEM "-g -O1")
endif()
##################################################################
# check existence of a few basic functions
##################################################################
include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
check_function_exists (gettimeofday HAVE_GETTIMEOFDAY)
check_function_exists (getrusage HAVE_GETRUSAGE)
check_function_exists (GlobalMemoryStatusEx HAVE_GLOBALMEMORYSTATUSEX)
check_function_exists (strndup HAVE_STRNDUP)
check_function_exists (strtok_r HAVE_STRTOK_R)
include (CheckIncludeFile)
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTDH)
find_package(Backtrace)
# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/iqtree_config.h.in"
"${PROJECT_BINARY_DIR}/iqtree_config.h"
)
# add the binary tree to the search path for include files
# so that we will find iqtree_config.h
include_directories("${PROJECT_BINARY_DIR}")
# add the binary tree to the search path for include files
# so that we will find cmaple/cmaple_config.h
if (USE_CMAPLE STREQUAL "ON")
include_directories("${PROJECT_BINARY_DIR}/cmaple")
endif()
#zlib will be detected for appearance
#include_directories("${PROJECT_BINARY_DIR}/zlib-1.2.7")
if (NOT IQTREE_FLAGS MATCHES "nozlib")
find_package(ZLIB)
endif()
if(ZLIB_FOUND)
message ("Using system zlib")
include_directories(${ZLIB_INCLUDE_DIRS})
else(ZLIB_FOUND)
message ("Using own zlib-1.2.7")
include_directories("${PROJECT_BINARY_DIR}/zlib-1.2.7" "${PROJECT_SOURCE_DIR}/zlib-1.2.7")
add_subdirectory(zlib-1.2.7)
endif(ZLIB_FOUND)
##################################################################
# subdirectories containing necessary libraries for the build
##################################################################
option(USE_BOOSTER "Use Booster for transfer bootstrap expectation" ON)
if (USE_BOOSTER)
add_subdirectory(booster)
add_definitions(-DUSE_BOOSTER)
endif()
add_subdirectory(pll)
add_subdirectory(ncl)
add_subdirectory(nclextra)
add_subdirectory(utils)
add_subdirectory(pda)
add_subdirectory(lbfgsb)
add_subdirectory(whtest)
add_subdirectory(sprng)
#add_subdirectory(zlib-1.2.7)
add_subdirectory(vectorclass)
LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}")
add_subdirectory(model)
add_subdirectory(gsl)
add_subdirectory(alignment)
add_subdirectory(tree)
add_subdirectory(terrace)
add_subdirectory(simulator)
if (USE_CMAPLE STREQUAL "ON")
SET(INSTALL_CMAPLE OFF CACHE BOOL "Disable installation of googletest" FORCE)
add_subdirectory(cmaple)
endif()
add_subdirectory(main)
# YAML library
option(YAML_CPP_BUILD_TESTS "Enable testing" OFF)
option(YAML_CPP_BUILD_TOOLS "Enable parse tools" OFF)
option(YAML_CPP_BUILD_CONTRIB "Enable contrib stuff in library" OFF)
option(YAML_CPP_INSTALL "Enable generation of install target" OFF)
add_subdirectory(yaml-cpp)
add_subdirectory(phylo-yaml)
if (USE_TERRAPHAST)
add_subdirectory(terraphast)
add_subdirectory(terracetphast)
endif()
if (USE_LSD2)
add_subdirectory(lsd2)
endif()
add_library(kernelsse tree/phylokernelsse.cpp)
if (NOT IQTREE_FLAGS MATCHES "novx")
add_library(kernelavx tree/phylotreeavx.cpp)
add_library(kernelfma tree/phylokernelfma.cpp)
if (IQTREE_FLAGS MATCHES "KNL")
add_library(kernelavx512 tree/phylokernelavx512.cpp)
endif()
endif()
##################################################################
# build lib file or main executable
##################################################################
option(BUILD_LIB "Build IQ-TREE2 library" OFF)
if (BUILD_LIB STREQUAL "ON")
add_library(iqtree2
obsolete/parsmultistate.cpp
obsolete/parsmultistate.h
)
else()
add_executable(iqtree2
obsolete/parsmultistate.cpp
obsolete/parsmultistate.h
)
endif()
if (USE_CMAPLE STREQUAL "ON")
add_executable(iqtree2-aa
obsolete/parsmultistate.cpp
obsolete/parsmultistate.h
)
endif()
if(Backtrace_FOUND)
include_directories(${Backtrace_INCLUDE_DIR})
target_link_libraries(iqtree2 ${Backtrace_LIBRARY})
if (USE_CMAPLE STREQUAL "ON")
target_link_libraries(iqtree2-aa ${Backtrace_LIBRARY})
endif()
endif(Backtrace_FOUND)
if (USE_BOOSTER)
target_link_libraries(iqtree2 booster)
if (USE_CMAPLE STREQUAL "ON")
target_link_libraries(iqtree2-aa booster)
endif()
endif()
if (NOT IQTREE_FLAGS MATCHES "avx" AND NOT IQTREE_FLAGS MATCHES "fma")
if (NOT IQTREE_FLAGS MATCHES "nosse")
set_target_properties(iqtree2 ncl nclextra utils pda lbfgsb whtest sprng vectorclass model gsl alignment tree simulator yaml-cpp phyloYAML main ${TARGET_CMAPLE} PROPERTIES COMPILE_FLAGS "${SSE_FLAGS}")
if (USE_CMAPLE STREQUAL "ON")
set_target_properties(iqtree2-aa ncl nclextra utils pda lbfgsb whtest sprng vectorclass model gsl alignment tree simulator yaml-cpp phyloYAML main-aa maple-aa PROPERTIES COMPILE_FLAGS "${SSE_FLAGS}")
endif()
if (USE_TERRAPHAST)
set_target_properties(terracetphast terraphast PROPERTIES COMPILE_FLAGS "${SSE_FLAGS}")
endif()
if (USE_LSD2)
set_target_properties(lsd2 PROPERTIES COMPILE_FLAGS "${SSE_FLAGS}")
endif()
if (USE_BOOSTER)
set_target_properties(booster PROPERTIES COMPILE_FLAGS "${SSE_FLAGS}")
endif()
endif()
set_target_properties(kernelsse pll PROPERTIES COMPILE_FLAGS "${SSE_FLAGS}")
if (NOT IQTREE_FLAGS MATCHES "novx")
set_target_properties(kernelavx pllavx PROPERTIES COMPILE_FLAGS "${AVX_FLAGS}")
set_target_properties(kernelfma PROPERTIES COMPILE_FLAGS "${FMA_FLAGS}")
if (IQTREE_FLAGS MATCHES "KNL")
set_target_properties(kernelavx512 PROPERTIES COMPILE_FLAGS "${AVX512_FLAGS}")
endif()
endif()
endif()
##################################################################
# setup linking flags
##################################################################
# link special lib for WIN32
if (WIN32)
set(PLATFORM_LIB "ws2_32")
else()
set(PLATFORM_LIB "m")
endif()
if (IQTREE_FLAGS MATCHES "libcxx")
set(STD_LIB "c++abi")
endif()
set(THREAD_LIB "")
if (NOT IQTREE_FLAGS MATCHES "single")
if (MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LIBPATH:${PROJECT_SOURCE_DIR}/lib")
set(THREAD_LIB "pthreadVC2")
elseif(CLANG AND WIN32)
target_link_libraries(iqtree2 ${PROJECT_SOURCE_DIR}/lib/libiomp5md.dll)
if (USE_CMAPLE STREQUAL "ON")
target_link_libraries(iqtree2-aa ${PROJECT_SOURCE_DIR}/lib/libiomp5md.dll)
endif()
endif()
endif()
# basic linking librararies
target_link_libraries(iqtree2 pll ncl nclextra utils pda lbfgsb whtest sprng vectorclass model
gsl alignment tree simulator terrace yaml-cpp phyloYAML main ${TARGET_CMAPLE} ${PLATFORM_LIB} ${STD_LIB} ${THREAD_LIB} ${ATOMIC_LIB})
if (USE_CMAPLE STREQUAL "ON")
target_link_libraries(iqtree2-aa pll ncl nclextra utils pda lbfgsb whtest sprng vectorclass model
gsl alignment tree simulator terrace yaml-cpp phyloYAML main-aa maple-aa ${PLATFORM_LIB} ${STD_LIB} ${THREAD_LIB} ${ATOMIC_LIB})
endif()
if (USE_TERRAPHAST)
target_link_libraries(iqtree2 terracetphast)
if (USE_CMAPLE STREQUAL "ON")
target_link_libraries(iqtree2-aa terracetphast)
endif()
endif()
if (USE_LSD2)
target_link_libraries(iqtree2 lsd2)
if (USE_CMAPLE STREQUAL "ON")
target_link_libraries(iqtree2-aa lsd2)
endif()
endif()
if (NOT IQTREE_FLAGS MATCHES "nosse")
target_link_libraries(iqtree2 kernelsse)
if (USE_CMAPLE STREQUAL "ON")
target_link_libraries(iqtree2-aa kernelsse)
endif()
endif()
# MPI libraries
if (IQTREE_FLAGS MATCHES "mpi")
if (NOT CMAKE_CXX_COMPILER MATCHES "mpi")
target_link_libraries(iqtree2 ${MPI_CXX_LIBRARIES})
if (USE_CMAPLE STREQUAL "ON")
target_link_libraries(iqtree2-aa ${MPI_CXX_LIBRARIES})
endif()
endif()
endif()
# SSE, AVX etc. libraries
if (NOT BINARY32 AND NOT IQTREE_FLAGS MATCHES "novx")
target_link_libraries(iqtree2 pllavx kernelavx kernelfma)
if (USE_CMAPLE STREQUAL "ON")
target_link_libraries(iqtree2-aa pllavx kernelavx kernelfma)
endif()
if (IQTREE_FLAGS MATCHES "KNL")
target_link_libraries(iqtree2 kernelavx512)
if (USE_CMAPLE STREQUAL "ON")
target_link_libraries(iqtree2-aa kernelavx512)
endif()
endif()
endif()
# setup the executable name
##################################################################
set_target_properties(iqtree2 PROPERTIES OUTPUT_NAME "iqtree2${EXE_SUFFIX}")
if (USE_CMAPLE STREQUAL "ON")
set_target_properties(iqtree2-aa PROPERTIES OUTPUT_NAME "iqtree2-aa${EXE_SUFFIX}")
endif()
# strip the release build
if (NOT IQTREE_FLAGS MATCHES "nostrip" AND CMAKE_BUILD_TYPE STREQUAL "Release" AND (GCC OR CLANG) AND NOT APPLE) # strip is not necessary for MSVC
if (WIN32)
ADD_CUSTOM_COMMAND(TARGET iqtree2 POST_BUILD COMMAND strip $<TARGET_FILE:iqtree2>)
if (USE_CMAPLE STREQUAL "ON")
ADD_CUSTOM_COMMAND(TARGET iqtree2-aa POST_BUILD COMMAND strip $<TARGET_FILE:iqtree2-aa>)
endif()
elseif (NOT APPLE)
ADD_CUSTOM_COMMAND(TARGET iqtree2 POST_BUILD COMMAND strip $<TARGET_FILE:iqtree2>)
if (USE_CMAPLE STREQUAL "ON")
ADD_CUSTOM_COMMAND(TARGET iqtree2-aa POST_BUILD COMMAND strip $<TARGET_FILE:iqtree2-aa>)
endif()
endif()
endif()
if (MSVC)
set (BINARY_DIR "${PROJECT_BINARY_DIR}/Release")
else()
set (BINARY_DIR "${PROJECT_BINARY_DIR}")
endif()
if (WIN32)
if (MSVC)
if (CLANG_UNDER_VS)
ADD_CUSTOM_COMMAND(TARGET iqtree2 POST_BUILD COMMAND copy "iqtree2${EXE_SUFFIX}.exe" "iqtree2${EXE_SUFFIX}-click.exe")
if (USE_CMAPLE STREQUAL "ON")
ADD_CUSTOM_COMMAND(TARGET iqtree2-aa POST_BUILD COMMAND copy "iqtree2-aa${EXE_SUFFIX}.exe" "iqtree2-aa${EXE_SUFFIX}-click.exe")
endif()
else()
ADD_CUSTOM_COMMAND(TARGET iqtree2 POST_BUILD COMMAND copy "Release\\iqtree2${EXE_SUFFIX}.exe" "Release\\iqtree2${EXE_SUFFIX}-click.exe")
if (USE_CMAPLE STREQUAL "ON")
ADD_CUSTOM_COMMAND(TARGET iqtree2-aa POST_BUILD COMMAND copy "Release\\iqtree2-aa${EXE_SUFFIX}.exe" "Release\\iqtree2-aa${EXE_SUFFIX}-click.exe")
endif()
endif()
else()
ADD_CUSTOM_COMMAND(TARGET iqtree2 POST_BUILD COMMAND copy "iqtree2${EXE_SUFFIX}.exe" "iqtree2${EXE_SUFFIX}-click.exe")
if (USE_CMAPLE STREQUAL "ON")
ADD_CUSTOM_COMMAND(TARGET iqtree2-aa POST_BUILD COMMAND copy "iqtree2-aa${EXE_SUFFIX}.exe" "iqtree2-aa${EXE_SUFFIX}-click.exe")
endif()
endif()
endif()
##############################################################
# add the install targets
##############################################################
install (TARGETS iqtree2 DESTINATION bin)
if (USE_CMAPLE STREQUAL "ON")
install (TARGETS iqtree2-aa DESTINATION bin)
endif()
install (FILES "${PROJECT_SOURCE_DIR}/example/models.nex" DESTINATION .)
install (FILES "${PROJECT_SOURCE_DIR}/example/example.phy" DESTINATION .)
install (FILES "${PROJECT_SOURCE_DIR}/example/example.nex" DESTINATION .)
install (FILES "${PROJECT_SOURCE_DIR}/example/example.cf" DESTINATION .)
if (WIN32)
install (FILES "${BINARY_DIR}/iqtree2${EXE_SUFFIX}-click.exe" DESTINATION bin)
if (USE_CMAPLE STREQUAL "ON")
install (FILES "${BINARY_DIR}/iqtree2-aa${EXE_SUFFIX}-click.exe" DESTINATION bin)
endif()
if (NOT IQTREE_FLAGS MATCHES "single" AND MSVC)
install(FILES "${PROJECT_SOURCE_DIR}/lib/pthreadVC2.dll" DESTINATION bin)
install(FILES "${PROJECT_SOURCE_DIR}/lib/libiomp5md.dll" DESTINATION bin)
endif()
if (NOT IQTREE_FLAGS MATCHES "single" AND CLANG)
install(FILES "${PROJECT_SOURCE_DIR}/lib/libiomp5md.dll" DESTINATION bin)
endif()
endif()
##############################################################
# build a CPack driven installer package
##############################################################
include (InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set (CPACK_PACKAGE_VERSION_MAJOR "${iqtree_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${iqtree_VERSION_MINOR}")
set (CPACK_PACKAGE_VERSION_PATCH "${iqtree_VERSION_PATCH}")
if(WIN32 OR APPLE)
set(CPACK_GENERATOR "ZIP")