2013-04-27 20:35:04 +08:00
2017-02-28 01:23:28 +08:00
CMAKE_MINIMUM_REQUIRED ( VERSION 2.8.12 )
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
if ( USING_OLD_VISUAL_STUDIO_COMPILER )
2018-05-04 04:35:33 +08:00
message ( FATAL_ERROR "You have to use a version of Visual Studio that supports C++11. As of December 2017, the only versions that have good enough C++11 support to compile the dlib Python API is a fully updated Visual Studio 2015 or a fully updated Visual Studio 2017. Older versions of either of these compilers have bad C++11 support and will fail to compile the Python extension. ***SO UPDATE YOUR VISUAL STUDIO TO MAKE THIS ERROR GO AWAY***" )
2018-01-16 03:41:40 +08:00
endif ( )
2013-04-27 20:35:04 +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
s r c / d l i b . c p p
s r c / m a t r i x . c p p
2013-04-27 20:35:04 +08:00
s r c / v e c t o r . c p p
2013-04-27 21:57:24 +08:00
s r c / s v m _ c _ t r a i n e r . c p p
2013-04-28 02:05:38 +08:00
s r c / s v m _ r a n k _ t r a i n e r . c p p
2013-04-28 00:29:52 +08:00
s r c / d e c i s i o n _ f u n c t i o n s . c p p
2013-04-28 00:28:46 +08:00
s r c / o t h e r . c p p
s r c / b a s i c . c p p
2013-04-29 03:46:55 +08:00
s r c / c c a . c p p
2013-05-21 11:18:14 +08:00
s r c / s e q u e n c e _ s e g m e n t e r . c p p
2013-06-27 10:34:00 +08:00
s r c / s v m _ s t r u c t . c p p
2014-12-10 20:14:53 +08:00
s r c / i m a g e . c p p
2018-05-21 10:34:49 +08:00
s r c / i m a g e 2 . c p p
2018-07-08 02:01:08 +08:00
s r c / i m a g e 3 . c p p
2018-07-08 02:10:30 +08:00
s r c / i m a g e 4 . c p p
2015-05-20 17:46:01 +08:00
s r c / r e c t a n g l e s . c p p
2014-02-10 01:56:35 +08:00
s r c / o b j e c t _ d e t e c t i o n . c p p
2014-12-11 01:25:20 +08:00
s r c / s h a p e _ p r e d i c t o r . c p p
2015-05-20 18:29:14 +08:00
s r c / c o r r e l a t i o n _ t r a c k e r . c p p
2017-02-13 09:37:18 +08:00
s r c / f a c e _ r e c o g n i t i o n . c p p
2017-08-19 04:30:33 +08:00
s r c / c n n _ f a c e _ d e t e c t o r . c p p
2017-11-25 23:07:00 +08:00
s r c / g l o b a l _ o p t i m i z a t i o n . c p p
2018-02-11 01:44:39 +08:00
s r c / i m a g e _ d a t a s e t _ m e t a d a t a . c p p
2018-04-18 10:49:25 +08:00
s r c / n u m p y _ r e t u r n s . c p p
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
s r c / l i n e . c p p
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
2018-01-16 20:24:47 +08:00
pybind11_add_module ( dlib_python ${ python_srcs } )
target_link_libraries ( dlib_python PRIVATE dlib::dlib )
# Set the output library name to dlib because that's what setup.py and distutils expects.
set_target_properties ( dlib_python PROPERTIES OUTPUT_NAME dlib )
2013-05-27 02:21:02 +08:00