-
Notifications
You must be signed in to change notification settings - Fork 65
/
CMakeLists.txt
118 lines (99 loc) · 4.03 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
cmake_minimum_required(VERSION 3.3) # need 3.3 for POLICY CMP0057
project(cpptraj NONE)
#version number
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h CPPTRAJ_VERSION_FILE)
foreach(LINE ${CPPTRAJ_VERSION_FILE})
separate_arguments(LINE)
#message( "Line= ${LINE}" )
list(GET LINE 0 col0)
if(col0 STREQUAL "#define")
list(GET LINE 1 col1)
if(col1 STREQUAL "CPPTRAJ_INTERNAL_VERSION")
#message( "Col0= ${LINE}" )
list(GET LINE 2 cpptraj_VERSION)
break()
endif()
endif()
endforeach()
if(NOT INSIDE_AMBER)
# initialization and include paths
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------
include(cmake-cpptraj/BuildSystemInit.cmake)
#now enable the languages
enable_language(C CXX)
# See if Fortran is available
check_language(Fortran)
if(CMAKE_Fortran_COMPILER)
enable_language(Fortran)
else()
message(STATUS "No Fortran support")
endif()
include(BuildSystemSetup)
# ARPACK support
option(USE_ARPACK "Whether to use the Arnoldi package for diagonalization of sparse matrices." TRUE)
if(NOT CMAKE_Fortran_COMPILER)
set(USE_ARPACK FALSE)
endif()
# TNG support
option(USE_TNG "Whether to support the Gromacs TNG trajectory format." TRUE)
include(OpenMPConfig)
include(MPIConfig)
include(CudaConfig)
set(LINALG_LIBS_REQUIRED TRUE)
set(NEEDED_3RDPARTY_TOOLS zlib fftw libbz2 readline pnetcdf blas lapack mkl arpack netcdf tng_io)
set(BUNDLED_3RDPARTY_TOOLS readline arpack tng_io)
set(REQUIRED_3RDPARTY_TOOLS netcdf)
include(SetupThirdParty)
if((fftw_DISABLED AND mkl_DISABLED) OR arpack_ENABLED)
# If no FFTW and no MKL we need PubFFT, so need fortran.
# If we are building arpack we need fortran.
if(NOT CMAKE_Fortran_COMPILER)
message(FATAL_ERROR "Cpptraj requires an FFT library, but no FFTW/MKL/Fortran compiler available.")
endif()
endif()
include(CompilerFlags)
include(NetlibConfig)
#CPack setup
# --------------------------------------------------------------------
set(PACKAGE_NAME "cpptraj")
set(PACKAGE_FILENAME "cpptraj")
#set(ICO_ICON ${CMAKE_SOURCE_DIR}/amber.ico)
#set(ICO_UNINSTALL_ICON ${CMAKE_SOURCE_DIR}/amber-uninstall.ico)
#set(ICNS_ICON ${CMAKE_SOURCE_DIR}/cmake-packaging/amber_logo.icns)
#set(OSX_STARTUP_SCRIPT ${CMAKE_SOURCE_DIR}/cmake-packaging/osx-startup-script.sh)
set(BUNDLE_IDENTIFIER org.ambermd.cpptraj)
set(BUNDLE_SIGNATURE CPTJ)
include(Packaging)
# build options
option(INSTALL_HEADERS "Copy headers to the include/cpptraj folder of the install directory. Useful for building with pytraj." FALSE)
option(BUILD_PARALLEL_COMBINATIONS "If true, then combinations of all enabled parallelizations will be built, e.g. cpptraj.OMP.MPI and cpptraj.OMP.MPI.cuda" FALSE)
option(INSTALL_TESTS "Copy tests to the test/ folder of the install directory" FALSE)
else()
set(INSTALL_HEADERS FALSE)
set(BUILD_PARALLEL_COMBINATIONS FALSE)
endif()
# Ensure the flag for PIC is added for NVCC
if (CUDA AND CUDA_FOUND)
if (SHARED)
if(${COMPILER} STREQUAL GNU OR ${COMPILER} STREQUAL CLANG)
set(CPPTRAJ_NVCC_PIC_FLAG "--compiler-options -fPIC")
else()
set(CPPTRAJ_NVCC_PIC_FLAG "--compiler-options -fpic")
endif()
message(STATUS "Set CUDA PIC flag ${CPPTRAJ_NVCC_PIC_FLAG}")
list(APPEND CUDA_NVCC_FLAGS ${CPPTRAJ_NVCC_PIC_FLAG})
else()
message(STATUS "Not setting CUDA PIC flag")
endif()
endif()
# on Windows, make MSVC auto-create import libraries just like MinGW does
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(dat)
#--------------------------------------------------------------
if(NOT INSIDE_AMBER)
print_build_report()
#dump_cmake_variables()
endif()