-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
136 lines (118 loc) · 4.24 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
# The name of our project is "ERKALE". CMakeLists files in this project can
# refer to the root source directory of the project as ${ERKALE_SOURCE_DIR} and
# to the root binary directory of the project as ${ERKALE_BINARY_DIR}.
project (ERKALE)
set(PROJECT_TYPE CXX)
# Require CMake version 2.8 (might work with older ones, too)
cmake_minimum_required(VERSION 2.6)
# Enable Fortran for LAPACK
enable_language (Fortran)
# Set version
set(VERSION 0.1.0)
# Version of libraries
set(SOVERSION 0.1.0)
# Cmake modules/macros are in a subdirectory to keep the root directory cleaner
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# Configuration where to find libint is in current directory
set(libint_DIR ${CMAKE_CURRENT_SOURCE_DIR}/config)
set(Armadillo_DIR ${CMAKE_CURRENT_SOURCE_DIR}/config)
# System default basis set repository (need not exist)
option(ERKALE_SYSTEM_LIBRARY "System default basis set repository (need not exist)" OFF)
if(ERKALE_SYSTEM_LIBRARY)
message("Using ${ERKALE_SYSTEM_LIBRARY} as default basis set repository.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DERKALE_SYSTEM_LIBRARY=\\\"${ERKALE_SYSTEM_LIBRARY}\\\"" )
else()
message("Using default location for basis set repository.")
endif()
# Catch C++ exceptions?
option(CATCH_EXCEPTIONS "Catch C++ exceptions?" OFF)
if(CATCH_EXCEPTIONS)
add_definitions(-DCATCH_EXCEPTIONS)
endif()
# Compile SMP version?
option(USE_OPENMP "Compile OpenMP enabled version (for parallel calculations)?" ON)
# Find OpenMP support
if(USE_OPENMP)
find_package( OpenMP )
if(OPENMP_FOUND)
# Add flags to CXX flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
# Set suffix
set(SUFFIX "_omp")
# Set OMP flags for preprocessor
set(PPROC_FLAGS "${OpenMP_CXX_FLAGS}")
else()
set(SUFFIX "")
set(PPROC_FLAGS "")
endif()
else()
# No flags
set(OpenMP_C_FLAGS "" )
set(OpenMP_CXX_FLAGS "" )
set(PPROC_FLAGS "")
# No suffix
set(SUFFIX "")
endif()
# Add in svn version information?
option(SVN_VERSION "Add in svn version information? (Need to generate version.h)" OFF)
if(SVN_VERSION)
# Add flag to CXX flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSVNRELEASE")
endif()
# Find cat
find_program(CAT cat)
# Find LAPACK
find_package(LAPACK REQUIRED)
message("LAPACK headers are in ${LAPACK_INCLUDE_DIRS}")
message("LAPACK library is ${LAPACK_LIBRARIES}")
message("")
# Find Armadillo
find_package(Armadillo REQUIRED)
message("ARMADILLO headers are in ${ARMADILLO_INCLUDE_DIRS}")
message("ARMADILLO library is ${ARMADILLO_LIBRARIES}")
message("")
# Find GSL
find_package(GSL REQUIRED)
message("GSL headers are in ${GSL_INCLUDE_DIRS}")
message("GSL library is ${GSL_LIBRARIES}")
message("")
# Find libxc
find_package(libxc REQUIRED)
message("libxc headers are in ${LIBXC_INCLUDE_DIRS}")
message("libxc linker flags are ${LIBXC_LIBRARIES}")
message("")
# Find libint
find_package(libint REQUIRED)
message("libint headers are in ${LIBINT_INCLUDE_DIRS}")
message("libint linker flags are ${LIBINT_LIBRARIES}")
message("")
# Find HDF5
find_package(HDF5 REQUIRED)
message("HDF5 headers are in ${HDF5_INCLUDE_DIRS}")
message("HDF5 linker flags are ${HDF5_LIBRARIES}")
message("")
# Find out how to preprocess C++ source code files
if(CMAKE_COMPILER_IS_GNUCXX)
set( PPROC ${CMAKE_CXX_COMPILER} -x c++ -E ${DFTFLAGS} ${PPROC_FLAGS})
elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" )
set( PPROC ${CMAKE_CXX_COMPILER} -x c++ -E ${DFTFLAGS} ${PPROC_FLAGS})
elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "PGI" )
set( PPROC ${CMAKE_CXX_COMPILER} -E ${DFTFLAGS} ${PPROC_FLAGS})
elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "PathScale" )
set( PPROC ${CMAKE_CXX_COMPILER} -E ${DFTFLAGS} ${PPROC_FLAGS})
elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel" )
set( PPROC ${CMAKE_CXX_COMPILER} -x c++ -E ${DFTFLAGS} ${PPROC_FLAGS})
else()
set( PPROC "" )
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} not supported." )
endif()
# Recurse into the "src" subdirectory.
add_subdirectory (src)
# Testing
if((${CMAKE_MAJOR_VERSION} GREATER 2) OR (${CMAKE_MAJOR_VERSION} EQUAL 2 AND (${CMAKE_MINOR_VERSION} EQUAL 8 OR ${CMAKE_MINOR_VERSION} GREATER 8)))
enable_testing()
add_subdirectory (tests)
message("Can run tests.")
elseif()
message("Version of CMake too old to run tests; at least version 2.8 required.")
endif()