-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
89 lines (70 loc) · 3.46 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
cmake_minimum_required(VERSION 3.0)
enable_language(Fortran)
project(sis Fortran)
option(BUILD_MPI "Build with MPI" OFF)
#ifort
if (CMAKE_Fortran_COMPILER_ID MATCHES Intel)
#set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -traceback -check all -warn all -fp-model strict -standf18")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -traceback -check all -warn all -fp-model strict")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -march=native")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-O3 -g -march=native")
endif()
#gfortran
if (CMAKE_Fortran_COMPILER_ID MATCHES GNU)
#set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -Wall -g -fbacktrace -ffpe-trap=zero,overflow,denormal,underflow -ffree-line-length-none -fbounds-check -fmax-errors=5")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -Wall -g -fbacktrace -ffpe-trap=zero,overflow,denormal -ffree-line-length-none -fbounds-check -fmax-errors=5")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -march=native -ffree-line-length-none")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-O3 -g -march=native -ffree-line-length-none")
endif()
#gfortran MPI
if (BUILD_MPI)
find_package(MPI REQUIRED)
if(NOT MPI_Fortran_FOUND)
message(FATAL_ERROR "Could not find Fortran MPI. Please set MPI_Fortran_COMPILER to point to the mpifort wrapper.")
endif()
add_definitions(${MPI_Fortran_COMPILE_FLAGS})
include_directories(${MPI_Fortran_INCLUDE_PATH})
link_directories(${MPI_Fortran_LIBRARIES})
#target_link_libraries(${exe_name} ${MPI_Fortran_LIBRARIES})
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -DPAR_MPI")
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -DPAR_MPI")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} -DPAR_MPI")
endif (BUILD_MPI)
# Option to dumping force data
option(DUMPFORCE "Use DUMPFORCE option to output force data" OFF)
if (DUMPFORCE)
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -DDUMPFORCE")
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -DDUMPFORCE")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} -DDUMPFORCE")
endif (DUMPFORCE)
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
endif()
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# To output Git commit hash. Either CheckGitSetup or NoGitSetup will be called.
include(./CheckGit.cmake)
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
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 --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
# Output Git hash
CheckGitSetup()
else()
# Set githash = "?" and output version number (in main.F90)
NoGitSetup()
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/subprojects/toml-f/CMakeLists.txt")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()
add_subdirectory(subprojects)
add_subdirectory(src)