This repository has been archived by the owner on Apr 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
50 lines (37 loc) · 1.63 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
cmake_minimum_required(VERSION 3.0)
SET(PROJ_NAME _pyimc)
project(${PROJ_NAME})
# Set CXX standard to 17
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ version selection")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_subdirectory(pybind11)
#######################################################
## DUNE ##
#######################################################
# Embed DUNE into build, but only build dune-core
add_subdirectory(dune EXCLUDE_FROM_ALL)
include_directories(dune/src/)
include_directories(${CMAKE_BINARY_DIR}/DUNEGeneratedFiles/src) # Contains generated Config.hpp/Version.cpp files
if(MSVC)
include_directories(dune/vendor/libraries/pthreads-win32)
endif()
set_property(TARGET dune-core PROPERTY POSITION_INDEPENDENT_CODE ON) # Enable -fPIC on dune-core build
#######################################################
## IMC ##
#######################################################
# Generate IMC definitions from spec
add_dependencies(dune-core imc)
#######################################################
## Source/Libs ##
#######################################################
# Find all source files starting with pb
FILE(GLOB_RECURSE CPP_SRC src pb*.cpp)
# Use THIN_LTO if available (Clang/LLVM)
pybind11_add_module(${PROJ_NAME} MODULE THIN_LTO src/pyimc.cpp ${CPP_SRC})
# Link with dune-core
if(MSVC)
target_link_libraries(${PROJ_NAME} PRIVATE pybind11::module dune-core ws2_32)
else()
target_link_libraries(${PROJ_NAME} PRIVATE pybind11::module dune-core)
endif()