-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
52 lines (42 loc) · 1.61 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
cmake_minimum_required(VERSION 3.12)
project(cppy3)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
option(CPPY3_USE_BOOST_CONVERT "use Boost.Locale instead of std::codecvt for string conversion" OFF)
option(CPPY3_BUILD_EXECUTABLES "Build cppy3 examples" OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(MSVC)
add_compile_options(/Zc:__cplusplus)
endif()
# find Boost if necessary
if(USE_BOOST_CONVERT)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost REQUIRED)
message(STATUS "Using Boost string convert: Enabled")
add_definitions(-DCPPY3_USE_BOOST_CONVERT)
endif()
find_package (Python3 3.5 REQUIRED COMPONENTS Interpreter Development NumPy)
message(STATUS "Found Python: ${Python3_FOUND} ${Python3_INTERPRETER_ID} ${Python3_EXECUTABLE}")
message(STATUS "Found Python3_LIBRARIES: ${Python3_LIBRARIES}")
message(STATUS "Found Python3_Development_FOUND: ${Python3_Development_FOUND}")
message(STATUS "Found Python3_NumPy_FOUND: ${Python3_NumPy_FOUND} ${Python3_NumPy_INCLUDE_DIRS}")
if (Python3_Development_FOUND)
include_directories(${Python3_INCLUDE_DIRS})
else()
message(FATAL_ERROR "Python dev C headers required (python-dev package)" )
endif()
if(Python3_NumPy_FOUND)
add_definitions(-DCPPY3_BUILT_WITH_NUMPY)
else()
message(WARNING "Building cppy3 without numpy.ndarray support because NumPy is not found in system")
endif()
# make lib
add_subdirectory(cppy3)
if(CPPY3_BUILD_EXECUTABLES)
# make tests
add_subdirectory(tests)
# make examples
add_executable(console examples/console.cpp)
target_link_libraries(console cppy3)
endif()