-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathCMakeLists.txt
102 lines (86 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
96
97
98
99
100
101
102
cmake_minimum_required(VERSION 3.15...3.30)
project(freud)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(DEFAULT_BUILD_TYPE "Release")
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(
STATUS
"Setting build type to '${DEFAULT_BUILD_TYPE}' since none was specified.")
set(CMAKE_BUILD_TYPE
"${DEFAULT_BUILD_TYPE}"
CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(CMake)
find_package(
Python 3.9
COMPONENTS Interpreter Development.Module
REQUIRED)
find_package_config_first(TBB)
if(TBB_FOUND)
include(FindPackageMessage)
find_package_message(
tbb "Found TBB: ${TBB_DIR} ${TBB_LIBRARY} ${TBB_INCLUDE_DIR}"
"[${TBB_LIBRARY}][${TBB_INCLUDE_DIR}]")
endif()
# go find nanobind
execute_process(
COMMAND ${Python_EXECUTABLE} "-m" "nanobind" "--cmake_dir"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE nanobind_ROOT)
find_package(nanobind CONFIG REQUIRED 2.0)
if(nanobind_FOUND)
find_package_message(
nanobind "Found nanobind: ${nanobind_DIR} ${nanobind_VERSION}"
"[${nanobind_DIR},${nanobind_VERSION}]")
endif()
# Define preprocessor directives for Windows
if(WIN32)
# Export all symbols (forces creation of .def file)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Use add_compile_definitions when dropping support for CMake < 3.12 Force
# Windows to define M_PI in <cmath>
add_compile_options(/D_USE_MATH_DEFINES)
# Prevent Windows from defining min/max as macros
add_compile_options(/DNOMINMAX)
endif()
# Detect when building against a conda environment set the _using_conda variable
# for use both in this file and in the parent
get_filename_component(_python_bin_dir ${Python_EXECUTABLE} DIRECTORY)
if(EXISTS "${_python_bin_dir}/../conda-meta")
message(
STATUS "Detected conda environment, setting INSTALL_RPATH_USE_LINK_PATH")
set(_using_conda On)
else()
set(_using_conda Off)
endif()
# Enable diagnostic colors for ninja
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics")
endif()
include_directories(
${PROJECT_SOURCE_DIR}/freud/box
${PROJECT_SOURCE_DIR}/freud/cluster
${PROJECT_SOURCE_DIR}/freud/density
${PROJECT_SOURCE_DIR}/freud/diffraction
${PROJECT_SOURCE_DIR}/freud/environment
${PROJECT_SOURCE_DIR}/freud/locality
${PROJECT_SOURCE_DIR}/freud/order
${PROJECT_SOURCE_DIR}/freud/parallel
${PROJECT_SOURCE_DIR}/freud/pmft
${PROJECT_SOURCE_DIR}/freud/util)
add_subdirectory(freud)
# enable compile_commands.json
if(NOT WIN32)
file(CREATE_LINK "${CMAKE_BINARY_DIR}/compile_commands.json"
"${CMAKE_SOURCE_DIR}/compile_commands.json" SYMBOLIC)
endif()