2013-04-27 20:35:04 +08:00
|
|
|
|
2022-08-01 05:45:18 +08:00
|
|
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.8.0)
|
2020-06-28 08:08:39 +08:00
|
|
|
|
|
|
|
if (WIN32 AND NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
|
|
|
|
message(FATAL_ERROR "\n"
|
|
|
|
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
|
|
|
|
"You must use Visual Studio to build a python extension on windows. If you "
|
|
|
|
"are getting this error it means you have not installed Visual C++. Note that "
|
|
|
|
"there are many flavors of Visual Studio, like Visual Studio for C\# development. "
|
|
|
|
"You need to install Visual Studio for C++. \n"
|
|
|
|
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
|
|
|
|
endif()
|
|
|
|
|
2019-07-19 19:12:27 +08:00
|
|
|
project(dlib_python_bindings)
|
2014-12-06 21:38:04 +08:00
|
|
|
|
2018-07-07 20:59:16 +08:00
|
|
|
# Pybind11's cmake scripts enable link time optimization by default. However,
|
|
|
|
# it makes linking take a really long time and doesn't seem to substantively
|
|
|
|
# improve runtime performance. So we disable LTO here to make building dlib
|
|
|
|
# faster.
|
|
|
|
set(PYBIND11_LTO_CXX_FLAGS "")
|
2018-03-18 05:10:31 +08:00
|
|
|
|
2018-01-16 03:41:40 +08:00
|
|
|
|
|
|
|
# Avoid cmake warnings about changes in behavior of some Mac OS X path
|
|
|
|
# variable we don't care about.
|
|
|
|
if (POLICY CMP0042)
|
|
|
|
cmake_policy(SET CMP0042 NEW)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
# To avoid dll hell, always link everything statically when compiling in
|
|
|
|
# visual studio. This way, the resulting library won't depend on a bunch
|
2018-06-01 10:15:57 +08:00
|
|
|
# of other dll files and can be safely copied to someone else's computer
|
2018-01-16 03:41:40 +08:00
|
|
|
# and expected to run.
|
|
|
|
if (MSVC)
|
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/../../dlib/cmake_utils/tell_visual_studio_to_use_static_runtime.cmake)
|
|
|
|
endif()
|
|
|
|
|
2018-05-22 19:15:27 +08:00
|
|
|
add_subdirectory(../../dlib/external/pybind11 pybind11_build)
|
|
|
|
add_subdirectory(../../dlib dlib_build)
|
2018-01-16 03:41:40 +08:00
|
|
|
|
2016-02-03 21:24:11 +08:00
|
|
|
add_definitions(-DDLIB_VERSION=${DLIB_VERSION})
|
|
|
|
|
2013-05-30 10:41:01 +08:00
|
|
|
# Tell cmake to compile all these cpp files into a dlib python module.
|
2014-12-11 20:05:10 +08:00
|
|
|
set(python_srcs
|
|
|
|
src/dlib.cpp
|
|
|
|
src/matrix.cpp
|
2013-04-27 20:35:04 +08:00
|
|
|
src/vector.cpp
|
2013-04-27 21:57:24 +08:00
|
|
|
src/svm_c_trainer.cpp
|
2013-04-28 02:05:38 +08:00
|
|
|
src/svm_rank_trainer.cpp
|
2013-04-28 00:29:52 +08:00
|
|
|
src/decision_functions.cpp
|
2013-04-28 00:28:46 +08:00
|
|
|
src/other.cpp
|
|
|
|
src/basic.cpp
|
2013-04-29 03:46:55 +08:00
|
|
|
src/cca.cpp
|
2013-05-21 11:18:14 +08:00
|
|
|
src/sequence_segmenter.cpp
|
2013-06-27 10:34:00 +08:00
|
|
|
src/svm_struct.cpp
|
2014-12-10 20:14:53 +08:00
|
|
|
src/image.cpp
|
2018-05-21 10:34:49 +08:00
|
|
|
src/image2.cpp
|
2018-07-08 02:01:08 +08:00
|
|
|
src/image3.cpp
|
2018-07-08 02:10:30 +08:00
|
|
|
src/image4.cpp
|
2015-05-20 17:46:01 +08:00
|
|
|
src/rectangles.cpp
|
2014-02-10 01:56:35 +08:00
|
|
|
src/object_detection.cpp
|
2014-12-11 01:25:20 +08:00
|
|
|
src/shape_predictor.cpp
|
2015-05-20 18:29:14 +08:00
|
|
|
src/correlation_tracker.cpp
|
2017-02-13 09:37:18 +08:00
|
|
|
src/face_recognition.cpp
|
2017-08-19 04:30:33 +08:00
|
|
|
src/cnn_face_detector.cpp
|
2017-11-25 23:07:00 +08:00
|
|
|
src/global_optimization.cpp
|
2018-02-11 01:44:39 +08:00
|
|
|
src/image_dataset_metadata.cpp
|
2018-04-18 10:49:25 +08:00
|
|
|
src/numpy_returns.cpp
|
Added hough_transform, remove_incoherent_edge_pixels(),
normalize_image_gradients(), line, signed_distance_to_line(),
distance_to_line(), reverse(), intersect(), count_points_on_side_of_line(),
count_points_between_lines(), dot(), and normalize() to Python API.
2018-05-22 09:20:18 +08:00
|
|
|
src/line.cpp
|
2014-12-11 20:05:10 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# Only add the GUI module if requested
|
|
|
|
if(NOT ${DLIB_NO_GUI_SUPPORT})
|
|
|
|
list(APPEND python_srcs src/gui.cpp)
|
2017-12-08 23:09:30 +08:00
|
|
|
endif()
|
2014-12-11 20:05:10 +08:00
|
|
|
|
2020-06-08 04:42:44 +08:00
|
|
|
pybind11_add_module(_dlib_pybind11 ${python_srcs})
|
|
|
|
target_link_libraries(_dlib_pybind11 PRIVATE dlib::dlib)
|
2013-05-27 02:21:02 +08:00
|
|
|
|
2021-11-15 03:05:47 +08:00
|
|
|
# When invoked from setup.py CMAKE_LIBRARY_OUTPUT_DIRECTORY will be set. But when you are just building via say
|
|
|
|
# `cd dlib/tools/python; mkdir build; cd build; cmake ..` it won't be set. It only matters for building the actual
|
|
|
|
# distribution. So skip this for people building directly with cmake (which they might do when testing stuff).
|
|
|
|
if (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
|
|
|
configure_file(${PROJECT_SOURCE_DIR}/dlib/__init__.py.in ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/dlib/__init__.py)
|
|
|
|
endif()
|