-
Notifications
You must be signed in to change notification settings - Fork 41
/
CMakeLists.txt
67 lines (54 loc) · 2.97 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
cmake_minimum_required(VERSION 3.4)
if(POLICY CMP0011)
cmake_policy(SET CMP0011 NEW)
endif()
#**************************************************************************************************
# General CMake settings
#**************************************************************************************************
project(Test_pybind11)
#**************************************************************************************************
# Find Package **************************************************************************************************
find_package(OpenCV REQUIRED)
MESSAGE( " *** OpenCV_INCLUDE_DIRS : " ${OpenCV_INCLUDE_DIRS} )
MESSAGE( " *** OpenCV_LIB_DIRS : " ${OpenCV_LIB_DIRS} )
MESSAGE( " *** OpenCV_LIBS : " ${OpenCV_LIBS} )
find_package(pybind11 CONFIG REQUIRED)
MESSAGE( " *** PYTHON_INCLUDE_DIRS : " ${PYTHON_INCLUDE_DIRS} )
MESSAGE( " *** PYTHON_LIBRARIES : " ${PYTHON_LIBRARIES} )
set(NUMPY_INCLUDE_DIR "" CACHE FILEPATH "Path to numpy header if cmake can't find them.")
if (NOT ${NUMPY_INCLUDE_DIR} STREQUAL "")
message( " *** NUMPY_INCLUDE_DIR : ${NUMPY_INCLUDE_DIR}" )
if(NOT EXISTS ${NUMPY_INCLUDE_DIR}/numpy/ndarrayobject.h)
message(SEND_ERROR "Can't find numpy/ndarrayobject.h in ${NUMPY_INCLUDE_DIR}")
endif()
include_directories(${NUMPY_INCLUDE_DIR})
endif()
#**************************************************************************************************
# Include **************************************************************************************************
include_directories(${pybind11_INCLUDE_DIR})
include_directories(${PYTHON_INCLUDE_DIRS})
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${OpenCV_INCLUDE_DIRS}/opencv4)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
#**************************************************************************************************
# Set variable **************************************************************************************************
SET(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/ndarray_converter.cpp
)
#**************************************************************************************************
# Set compiler **************************************************************************************************
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_compile_options(/std:c++17 /Oy /utf-8)
else()
add_compile_options(-std=c++17 -fPIC -O3)
endif()
#**************************************************************************************************
# Linker **************************************************************************************************
LINK_DIRECTORIES(
${OpenCV_LIB_DIR}
)
#**************************************************************************************************
# Make configuration
#**************************************************************************************************
pybind11_add_module(test_module MODULE ${SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/tests/cpp/test.cpp)
target_link_libraries(test_module PRIVATE ${OpenCV_LIBS})