-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
31 lines (24 loc) · 1.31 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
cmake_minimum_required(VERSION 3.4)
project(pyncnn)
set( PACKAGE_VERSION "0.0.2" )
add_definitions(-DVERSION_INFO="${PACKAGE_VERSION}")
set( CMAKE_CXX_STANDARD 11 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
#find_package(Python3 REQUIRED Interpreter Development)
find_package(ncnn CONFIG REQUIRED)
find_package(pybind11 REQUIRED)
set(CMAKE_MODULE_PATH "${pybind11_DIR};${CMAKE_MODULE_PATH}")
find_package(PythonLibsNew REQUIRED)
if(MSVC OR CMAKE_GENERATOR STREQUAL "Xcode")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}/ncnn/)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}/ncnn/)
endif(MSVC OR CMAKE_GENERATOR STREQUAL "Xcode")
include_directories(${pybind11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
pybind11_add_module(pyncnn src/main.cpp)
set_target_properties(pyncnn PROPERTIES OUTPUT_NAME "ncnn")
target_link_libraries(pyncnn PUBLIC ncnn)
set_target_properties(pyncnn PROPERTIES PREFIX "" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/ncnn")
add_custom_command(TARGET pyncnn POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/ncnn/ncnn${PYTHON_MODULE_PREFIX}${PYTHON_MODULE_EXTENSION}
${PROJECT_SOURCE_DIR}/python/ncnn/ncnn${PYTHON_MODULE_PREFIX}${PYTHON_MODULE_EXTENSION})
configure_file(python/setup.py.i ${PROJECT_SOURCE_DIR}/python/setup.py)