-
Notifications
You must be signed in to change notification settings - Fork 49
/
CMakeLists.txt
93 lines (78 loc) · 3.21 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
# CMake 3.12.0 is the oldest version supported by the way freud links TBB to
# object libraries like _cluster. This is also the oldest version tested in CI.
cmake_minimum_required(VERSION 3.12.0)
project(freud)
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)
# This setting is required when building shared libraries from object libraries.
# CMake intentionally chooses not to infer such information, so we should expect
# to specify this.
# https://stackoverflow.com/questions/50600708/combining-cmake-object-libraries-with-shared-libraries
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(CMake)
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()
# Fail fast if users have not cloned submodules.
if(NOT WIN32)
string(ASCII 27 Esc)
set(Red "${Esc}[31m")
set(DefaultColor "${Esc}[m")
endif()
set(submodules Eigen fsph voro++)
foreach(submodule ${submodules})
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/${submodule}/.git")
message(
FATAL_ERROR
"${Red}Not all git submodules are available. Please run git submodule update --init --recursive.${DefaultColor}"
)
endif()
endforeach()
# 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()
# 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}/cpp/util ${PROJECT_SOURCE_DIR}/cpp/locality
${PROJECT_SOURCE_DIR}/cpp/box)
# We treat the extern folder as a SYSTEM library to avoid getting any diagnostic
# information from it. In particular, this avoids clang-tidy throwing errors due
# to any issues in external code. include_directories(SYSTEM ${TBB_INCLUDE_DIR})
# Ignore unused variable warning from scikit-build
set(ignoreMe "${SKBUILD}")
add_subdirectory(cpp)
add_subdirectory(freud)
if(_using_conda OR DEFINED ENV{CIBUILDWHEEL})
set_target_properties(libfreud PROPERTIES INSTALL_RPATH_USE_LINK_PATH True)
endif()