-
Notifications
You must be signed in to change notification settings - Fork 25
/
CMakeLists.txt
executable file
·95 lines (84 loc) · 3.14 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
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
enable_testing()
project(HPhi NONE)
option(USE_SCALAPACK "Use Scalapack" OFF)
set(CMAKE_C_FLAGS "-Wall")
if(CONFIG)
message(STATUS "Loading configration: " ${PROJECT_SOURCE_DIR}/config/${CONFIG}.cmake)
include(${PROJECT_SOURCE_DIR}/config/${CONFIG}.cmake)
endif(CONFIG)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Type of build" FORCE)
endif(NOT CMAKE_BUILD_TYPE)
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(ENABLE_MPI "Enable MPI Parallelization" ON)
option(ENABLE_SCALAPACK "Use Scalapack" ON)
option(GIT_SUBMODULE_UPDATE "Execute `git submodule update --init` automatically" ON)
enable_language(C Fortran)
#set(CMAKE_C_FLAGS "-lscalapack -lgfortran -lm")
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)
if(NOT STDFACE_DIR)
set(STDFACE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/StdFace")
# git submodule update
# ref: https://cliutils.gitlab.io/modern-cmake/chapters/projects/submodule.html
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
# Update submodules as needed
if(GIT_SUBMODULE_UPDATE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
if(NOT EXISTS "${STDFACE_DIR}/CMakeLists.txt")
message(FATAL_ERROR "StdFace is not found. Please `git clone` the repository (https://github.com/issp-center-dev/HPhi) or download an archive file (HPhi-X.Y.Z.tar.gz) from the release page (https://github.com/issp-center-dev/HPhi/releases)")
endif()
else()
if(NOT EXISTS "${STDFACE_DIR}/CMakeLists.txt")
message(FATAL_ERROR "STDFACE_DIR is manually set to ${STDFACE_DIR}, but ${STDFACE_DIR}/CMakeLists.txt does not exists")
endif()
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "Intel")
if("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "15.0.0.20140528")
set(OMP_FLAG_Intel "-openmp")
else()
set(OMP_FLAG_Intel "-qopenmp")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OMP_FLAG_Intel}")
else()
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
endif(OPENMP_FOUND)
endif()
if(ENABLE_MPI)
find_package(MPI)
if(MPI_FOUND)
include_directories(${MPI_C_INCLUDE_PATH})
add_definitions(-DMPI)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_C_LINK_FLAGS}")
endif(MPI_FOUND)
endif(ENABLE_MPI)
find_package(LAPACK)
if(USE_SCALAPACK MATCHES OFF)
if(LAPACK_FOUND)
add_definitions(-D_lapack)
endif(LAPACK_FOUND)
else()
add_definitions(-D_SCALAPACK)
endif()
add_subdirectory(src)
add_subdirectory(tool)
add_subdirectory(test)
if (Document)
add_subdirectory(doc)
endif(Document)