-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
64 lines (48 loc) · 1.96 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
cmake_minimum_required(VERSION 3.15)
# set the project name
project(
cfish_sim VERSION 0.0
DESCRIPTION "simulate the collective behaviour of fish as active matter"
)
find_package(Python COMPONENTS Interpreter Development)
find_package(OpenMP)
add_subdirectory(extern/pybind11)
add_subdirectory(extern/eigen3 EXCLUDE_FROM_ALL)
# setup usual compile flag
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
add_compile_options(-Wall -O3 -fPIC)
set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard to use")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# build the cpp targets
add_library(core STATIC src/core.cpp src/core.hpp)
target_link_libraries(core eigen)
add_library(neighbour_list STATIC src/neighbour_list.cpp src/neighbour_list.hpp)
target_link_libraries(neighbour_list core eigen)
add_library(boundary STATIC src/boundary.cpp src/boundary.hpp)
target_link_libraries(boundary core eigen)
add_library(network STATIC src/network.cpp src/network.hpp)
target_link_libraries(network core eigen)
add_library(vicsek STATIC src/vicsek.cpp src/vicsek.hpp)
target_link_libraries(vicsek core neighbour_list eigen)
add_library(couzin STATIC src/couzin.cpp src/couzin.hpp)
target_link_libraries(couzin core eigen)
add_library(montecarlo STATIC src/montecarlo.cpp src/montecarlo.hpp)
target_link_libraries(montecarlo core boundary eigen)
if(OpenMP_CXX_FOUND)
target_link_libraries(neighbour_list OpenMP::OpenMP_CXX)
target_link_libraries(core OpenMP::OpenMP_CXX)
endif()
# build the python module
add_library(cmodel MODULE src/cmodel.cpp)
target_link_libraries(
cmodel PRIVATE pybind11::module pybind11::lto
core neighbour_list boundary network vicsek couzin eigen montecarlo
)
pybind11_extension(cmodel)
set_target_properties(cmodel PROPERTIES CXX_VISIBILITY_PRESET "hidden")
# move the libraries to lib folder
SET(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/lib/fish_sim)
install(TARGETS cmodel DESTINATION ${CMAKE_INSTALL_PREFIX})