-
Notifications
You must be signed in to change notification settings - Fork 25
/
CMakeLists.txt
125 lines (111 loc) · 3.8 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
cmake_minimum_required(VERSION 3.15)
project(scattnlay VERSION 2.4)
cmake_host_system_information(RESULT HOSTNAME QUERY HOSTNAME)
message("Build type is: ${CMAKE_BUILD_TYPE}")
message("Host OS System: ${CMAKE_HOST_SYSTEM}")
message("Hostname: ${HOSTNAME}")
message("CMake version: ${CMAKE_VERSION}")
# Select flags.
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g ")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options(-W -Wall -pedantic -Werror)
add_compile_options(-funroll-loops -fstrict-aliasing)
# compiler details
message(" C++ Compiler: ${CMAKE_CXX_COMPILER_ID} "
"${CMAKE_CXX_COMPILER_VERSION} "
"${CMAKE_CXX_COMPILER_WRAPPER}")
# installation details
message(" Installation prefix: ${CMAKE_INSTALL_PREFIX}")
# Find Boost
set(BOOSTROOT $ENV{BOOST_DIR})
if (USE_STATIC_LIBRARIES)
set(Boost_USE_STATIC_LIBS ON)
endif ()
set(Boost_USE_MULTITHREADED OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost)
# Set options
option(ENABLE_MP "Use multiple precision" OFF)
if (Boost_FOUND)
if (${ENABLE_MP})
add_compile_options(-DMULTI_PRECISION=100)
endif ()
if (Boost_INCLUDE_DIRS)
if (${Boost_VERSION} VERSION_LESS 1.60.0)
message(FATAL_ERROR
"Found Boost library is too old; required is version 1.60.0 or newer!")
endif ()
message("Found Boost include dir: ${Boost_INCLUDE_DIR}")
message("Found Boost library dir: ${Boost_LIBRARY_DIR}")
message("Found Boost libraries: ${Boost_LIBRARIES}")
include_directories(${Boost_INCLUDE_DIRS})
endif ()
endif()
##Find Python, NumPy and PyBind11
#find_package(Python COMPONENTS Interpreter Development)
#
#include_directories(${Python_INCLUDE_DIRS})
#
#message("Python_EXECUTABLE: ${Python_EXECUTABLE}")
#message("Python_FOUND: ${Python_FOUND}")
#message("Python_VERSION: ${Python_VERSION}")
#message("Python_Development_FOUND: ${Python_Development_FOUND}")
#message("Python_LIBRARIES: ${Python_LIBRARIES}")
#message("Python_INCLUDE_DIRS: ${Python_INCLUDE_DIRS}")
#
## Ensure that numpy is installed and read its include dir
#exec_program(${Python_EXECUTABLE}
# ARGS "-c \"import numpy; print(numpy.get_include())\""
# OUTPUT_VARIABLE NUMPY_INCLUDE_DIR
# RETURN_VALUE NUMPY_NOT_FOUND
# )
#if (NUMPY_NOT_FOUND)
# message(FATAL_ERROR "NumPy headers not found")
#endif ()
#
## Ensure that pybind11 is installed and read its include dir
#exec_program(${Python_EXECUTABLE}
# ARGS "-c \"import pybind11; print(pybind11.get_include())\""
# OUTPUT_VARIABLE PYBIND11_INCLUDE_DIR
# RETURN_VALUE PYBIND11_NOT_FOUND
# )
#if (PYBIND11_NOT_FOUND)
# message(FATAL_ERROR "PyBind11 headers not found")
#endif ()
#
## Determine correct extension suffix
#exec_program(${Python_EXECUTABLE}
# ARGS "-c \"import distutils.sysconfig; print(distutils.sysconfig.get_config_var('EXT_SUFFIX'))\""
# OUTPUT_VARIABLE EXT_SUFFIX
# RETURN_VALUE SUFFIX_NOT_FOUND
# )
#if (SUFFIX_NOT_FOUND)
# message(FATAL_ERROR "Extension suffix not found")
#endif ()
#include_directories(src)
add_subdirectory(src)
add_subdirectory(examples)
#
# Copy all python scripts to the build directory.
#
set(Python_SCRIPTS scattnlay/__init__.py scattnlay/main.py)
foreach (_script ${Python_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach ()
enable_testing()
add_subdirectory(tests)
# add_test(NAME BuildExtWithPythonSetupPy
# COMMAND ${Python_EXECUTABLE} setup.py build_ext
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if (NOT DEFINED ENV{GITHUB_ENV})
add_test(NAME tox
COMMAND tox)
endif()