-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
114 lines (103 loc) · 3.91 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
# -------------
# Include guard
# -------------
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
project(mVMC NONE)
option(USE_SCALAPACK "Use Scalapack" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
add_definitions(-D_mVMC)
# ----------------------------------------------
# Set specific configuration using -DCONFIG flag
# ----------------------------------------------
if(CONFIG)
message(STATUS "Loading configuration file: "
${PROJECT_SOURCE_DIR}/config/${CONFIG}.cmake)
include(${PROJECT_SOURCE_DIR}/config/${CONFIG}.cmake)
endif(CONFIG)
enable_language(C Fortran)
# ---------------------------------------------------------
# Set build type (Debug or Release) 'Release being default'
# ---------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" MATCHES "Release")
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING "Type of build" FORCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran} ${CMAKE_Fortran_FLAGS_RELEASE}")
elseif("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
set(CMAKE_BUILD_TYPE
"Debug"
CACHE STRING "Type of build" FORCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG} -ggdb -Wall")
endif()
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_MACOSX_RPATH 1)
# -------------------------------
# Compiler specific configuration
# -------------------------------
if(CMAKE_C_COMPILER STREQUAL "icc")
set(OMP_FLAG_Intel "-qopenmp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OMP_FLAG_Intel}")
elseif(CMAKE_C_COMPILER MATCHES "clang")
set(OpenMP_C_LIB_NAMES "libomp" "omp")
set(OpenMP_C_FLAGS
"-Xclang -fopenmp -I/usr/local/opt/libomp/include/ -L /usr/local/opt/libomp/lib -lomp"
)
set(OpenMP_omp_LIBRARY "/usr/local/lib/libomp.dylib")
set(OpenMP_libomp_LIBRARY "/usr/local/lib/libomp.dylib")
endif()
# ------------------------------------------
# OpenMP package search (fails if not found)
# ------------------------------------------
find_package(OpenMP REQUIRED)
if(OPENMP_FOUND)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
endif(OPENMP_FOUND)
# -------------------------------------------
# OpenMPI package search (fails if not found)
# -------------------------------------------
find_package(MPI COMPONENTS C)
if(MPI_FOUND)
message(${MPI_C_INCLUDE_PATH})
include_directories(${MPI_C_INCLUDE_PATH})
add_definitions(-D_mpi_use)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_C_LINK_FLAGS}")
else()
message(FATAL_ERROR "MPI not found, please verify MPI installation PATH.")
endif(MPI_FOUND)
# ------------------------------------------
# LAPACK package search (fails if not found)
# ------------------------------------------
find_package(LAPACK)
if(USE_SCALAPACK MATCHES OFF)
if(LAPACK_FOUND)
add_definitions(-D_lapack)
else()
message(
FATAL_ERROR "LAPACK not found, please verify LAPACK installation PATH.")
endif(LAPACK_FOUND)
endif()
# ----------------------------------------
# Adding sub-CMakeLists.txt to be compiled
# ----------------------------------------
add_subdirectory(src/ComplexUHF)
add_subdirectory(src/pfapack)
add_subdirectory(src/mVMC)
add_subdirectory(tool)
add_subdirectory(tool/dvmc)
add_subdirectory(tool/dvmc_cli)
# ---------------------------------------------------------------------------
# Build and enable tests testing setup enable_testing() must be called in the
# top-level CMakeLists.txt before any add_subdirectory() is called.
# ---------------------------------------------------------------------------
option(Testing "Enable testing" OFF)
if(Testing)
enable_testing(test)
add_subdirectory(test)
endif()