-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
121 lines (101 loc) · 3.9 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
cmake_minimum_required(VERSION 2.8.12...3.20.2 FATAL_ERROR)
project(DSQSS NONE)
set(DSQSS_VERSION 2.0.6)
message(STATUS "CMake version: " ${CMAKE_VERSION})
set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address -fomit-frame-pointer")
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(Testing "Enable testing" ON)
option(Document "Build HTML document" OFF)
option(USE_SYSTEM_BOOST "use Boost installed in system" OFF)
option(BUILD_NEW_GENERATORS "build new file-generators" ON)
option(BUILD_OLD_GENERATORS "build old file-generators" OFF)
enable_language(C CXX)
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)
option(DEBUG "Debug" OFF)
if(DEBUG)
add_definitions(-DDEB)
endif(DEBUG)
if(ENABLE_MPI)
find_package(MPI)
if(MPI_FOUND)
if(NOT MPI_CXX_INCLUDE_DIRS)
if(MPI_CXX_INCLUDE_PATH)
set(MPI_CXX_INCLUDE_DIRS ${MPI_CXX_INCLUDE_PATH})
else(MPI_CXX_INCLUDE_PATH)
set(MPI_CXX_INCLUDE_DIRS ${MPI_INCLUDE_PATH})
endif(MPI_CXX_INCLUDE_PATH)
endif(NOT MPI_CXX_INCLUDE_DIRS)
if(NOT MPI_CXX_LIBRARIES)
set(MPI_CXX_LIBRARIES ${MPI_LIBRARIES})
endif(NOT MPI_CXX_LIBRARIES)
endif(MPI_FOUND)
endif(ENABLE_MPI)
if(USE_SYSTEM_BOOST)
find_package(Boost REQUIRED)
else(USE_SYSTEM_BOOST)
set(Boost_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/boost)
message(STATUS "Use bundled Boost headers (1.67)")
endif(USE_SYSTEM_BOOST)
message(STATUS "Boost headers: ${Boost_INCLUDE_DIRS}")
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/plog)
set(python_version_required 3.6)
if(NOT PYTHON_EXECUTABLE)
if(BUILD_NEW_GENERATORS OR Testing OR Document)
if(${CMAKE_VERSION} VERSION_LESS 3.12)
find_package(PythonInterp ${python_version_required} REQUIRED)
set(python_version_mm "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
else(${CMAKE_VERSION} VERSION_LESS 3.12)
find_package(Python3 ${python_version_required} COMPONENTS Interpreter REQUIRED)
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
set(python_version_mm "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
endif(${CMAKE_VERSION} VERSION_LESS 3.12)
endif()
else()
# check python version
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-V" OUTPUT_VARIABLE result ERROR_VARIABLE result)
string(REGEX MATCH "^Python[ ]+[0-9]+\\.[0-9]+\\.[0-9]+" result "${result}")
if(NOT result)
message(FATAL_ERROR "${PYTHON_EXECUTABLE} seems not python executable")
endif()
message(STATUS "Given Python interpreter: ${PYTHON_EXECUTABLE}")
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" result "${result}")
message(STATUS "Python version: ${result}")
if("${result}" VERSION_LESS ${python_version_required})
message(FATAL_ERROR "Python ${result} is not supported (${python_version_required} or later is required)")
endif()
string(REPLACE "." ";" result "${result}")
set(result "${result}")
list(GET result 0 Python3_VERSION_MAJOR)
list(GET result 1 Python3_VERSION_MINOR)
list(GET result 2 Python3_VERSION_MICRO)
set(python_version_mm "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
endif()
add_subdirectory(src/dla)
if(MPI_FOUND)
add_subdirectory(src/pmwa)
endif(MPI_FOUND)
if(BUILD_NEW_GENERATORS)
add_subdirectory(tool)
endif()
if (Testing)
enable_testing()
add_subdirectory(test)
endif()
if (Document)
add_subdirectory(doc)
endif(Document)
add_subdirectory(sample)