-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
62 lines (50 loc) · 1.73 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
cmake_minimum_required(VERSION 3.9)
project(pybind11_generics)
# Check if we are building this project as top level
set(PYBIND11_GENERICS_MASTER_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(PYBIND11_GENERICS_MASTER_PROJECT ON)
endif()
option(PYBIND11_GENERICS_TEST "Build pybind11_generics test suite?"
${PYBIND11_GENERICS_MASTER_PROJECT})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# control compiler warnings
add_compile_options(-fexceptions)
add_compile_options(-g)
add_compile_options(-Wall)
add_compile_options(-Wno-delete-non-virtual-dtor)
# add_compile_options(-Wno-logical-op-parentheses)
# add_compile_options(-Wno-new-returns-null)
# set optimzation level for release
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
# generate compilation commands file for emacs
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# prefer pthreads
set(THREADS_PREFER_PTHREAD_FLAG ON)
# make sure linker raise errors if shared library has undefined symbols
# this makes it a lot easier to debug
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
# add rpaths to the final install executable
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Must use GNUInstallDirs to install libraries into correct
# locations on all platforms.
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# Include pybind11
# enable C++17 support for variant/optional wrapping
set(PYBIND11_CPP_STANDARD --std=c++1z)
add_subdirectory(pybind11)
# Define pybind11_generics interface library
add_library(pybind11_generics INTERFACE)
target_link_libraries(pybind11_generics
INTERFACE
pybind11::module
)
target_include_directories(pybind11_generics
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
if (PYBIND11_GENERICS_TEST)
add_subdirectory(src)
endif()