-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
145 lines (125 loc) · 4.97 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
137
138
139
140
141
142
143
144
145
#################################
# Commad line arguments section
#################################
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
# By default the built is in CONSOLE mode and 32 bits. If 64 bits have to be used one should do -D ARCH32=OFF
option(MINGW_HDF_TRICK "Help building with MinGW" OFF)
option(USE_HDF "Build crysfml with HDF5 library" OFF)
option(GUI "Build crysfml and wcrysfml library" OFF)
option(ARCH32 "32 or 64 bit architecture" ON)
option(CRYSFML08 "Build CrysFML08" OFF)
option(HEAP_ARRAYS "Put arrays in heap instead of stack (only for Windows ifort)" OFF)
option(PROG_EX "Build the Program Examples" ON)
option(PYTHON_API "Build Python API" OFF)
option(QPARALLEL "qparallel option for Ifort on Windows" ON)
if(DEFINED CMAKE_Fortran_COMPILER)
set(CMAKE_Fortran_COMPILER ${CMAKE_Fortran_COMPILER} CACHE STRING "The Fortran compiler. One of 'ifort', 'g95' or 'gfortran'.")
else()
set(CMAKE_Fortran_COMPILER ifort CACHE STRING "The Fortran compiler. One of 'ifort', 'g95' or 'gfortran'.")
endif()
message(STATUS "Setting compiler to ${CMAKE_Fortran_COMPILER}")
if(DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "The build type. One of 'Release' or 'Debug'.")
else()
set(CMAKE_BUILD_TYPE Release CACHE STRING "The build type. One of 'Release' or 'Debug'.")
endif()
message(STATUS "Setting build type to ${CMAKE_BUILD_TYPE}")
get_filename_component(COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME_WE)
if (DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "The installation path.")
else()
set(CMAKE_INSTALL_PREFIX ${CMAKE_HOME_DIRECTORY}/${COMPILER_NAME} CACHE PATH "The installation path.")
endif()
message(STATUS "Setting CMAKE_INSTALL_PREFIX to ${CMAKE_INSTALL_PREFIX}")
if (DEFINED CRYSFML_PREFIX)
set(CRYSFML_PREFIX ${CRYSFML_PREFIX})
else()
if(CRYSFML08)
set(CRYSFML_PREFIX LibC08)
else()
set(CRYSFML_PREFIX LibC)
endif()
endif()
set (CRYSFML_PREFIX ${CMAKE_INSTALL_PREFIX}/${CRYSFML_PREFIX})
message(STATUS "CrysFML installation path set to ${CRYSFML_PREFIX}")
# Include and library paths for Python.
# They must be set by the user.
if(DEFINED PYTHON_LIBRARY_PATH)
set(PYTHON_LIBRARY_PATH ${PYTHON_LIBRARY_PATH} CACHE PATH "Python library path")
else()
set(PYTHON_LIBRARY_PATH "" CACHE PATH "Python library path")
endif()
if(DEFINED PYTHON_INTERPRETER_PATH)
set(PYTHON_INTERPRETER_PATH ${PYTHON_INTERPRETER_PATH} CACHE PATH "Python interpreter path")
else()
set(PYTHON_INTERPRETER_PATH "" CACHE PATH "Python interpreter path")
endif()
# Include and library paths for HDF5.
# They must be set by the user.
if(DEFINED HDF5_INCLUDE_PATH)
set(HDF5_INCLUDE_PATH ${HDF5_INCLUDE_PATH} CACHE PATH "HDF5 include path")
else()
set(HDF5_INCLUDE_PATH "" CACHE PATH "HDF5 include path")
endif()
if(DEFINED HDF5_LIBRARY_PATH)
set(HDF5_LIBRARY_PATH ${HDF5_LIBRARY_PATH} CACHE PATH "HDF5 library path")
else()
set(HDF5_LIBRARY_PATH "" CACHE PATH "HDF5 library path")
endif()
#################################
# Project section
#################################
# The project is declared. It is a Fortran project.
project(libcrysfml Fortran)
# Set the a verbose make.
set(CMAKE_VERBOSE_MAKEFILE ON)
# Set module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
if (GUI)
if (DEFINED WCRYSFML_PREFIX)
set(WCRYSFML_PREFIX ${WCRYSFML_PREFIX})
else()
set(WCRYSFML_PREFIX LibW)
endif()
set (WCRYSFML_PREFIX ${CMAKE_INSTALL_PREFIX}/${WCRYSFML_PREFIX})
message(STATUS "WCrysFML installation path set to ${WCRYSFML_PREFIX}")
endif()
if (NOT WCRYSFML_PREFIX)
# Set the default name for wcrysfml library within the install prefix.
set(WCRYSFML_PREFIX LibW CACHE STRING "The name of wcrysfml library within library directory")
endif()
# Includes some modules and build the project.
include(add_prefix)
include(add_suffix)
if (NOT CRYSFML08)
include(set_compiler_flags)
set_compiler_flags()
# The subdirectories of the project.
add_subdirectory(Src)
else()
include(set_compiler_flags_08)
set_compiler_flags_08()
# The subdirectories of the project.
add_subdirectory(Src08)
endif()
# Build the program example executables and use them as functional tests
if (PROG_EX)
enable_testing()
macro(add_runtest _name _bindir)
add_test(
NAME ${_name}
COMMAND python3 ${CMAKE_SOURCE_DIR}/Tests/${_name}/test --binary-dir=${_bindir} --work-dir=${CMAKE_BINARY_DIR}/Tests/${_name} --verbose --log=${CMAKE_BINARY_DIR}/Tests/${_name}/runtest.stderr.log)
#if(NOT "${_labels}" STREQUAL "")
set_tests_properties(${_name} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Tests/${_name})
#endif()
endmacro()
add_subdirectory(Program_Examples/PowderPattern)
if(USE_HDF)
add_subdirectory(Program_Examples/ReadNeXuS)
endif()
endif()
if (PYTHON_API)
set(PYTHON_API_PREFIX ${CMAKE_INSTALL_PREFIX}/Python_API)
add_subdirectory(Python_API/Src)
endif()