2013-04-27 20:35:04 +08:00
2017-02-28 01:23:28 +08:00
CMAKE_MINIMUM_REQUIRED ( VERSION 2.8.12 )
2014-12-06 21:38:04 +08:00
2015-09-29 09:47:44 +08:00
set ( USE_SSE4_INSTRUCTIONS ON CACHE BOOL "Use SSE4 instructions" )
2017-08-19 20:48:48 +08:00
2018-03-18 05:10:31 +08:00
# Set this to disable link time optimization. The only reason for
# doing this to make the compile faster which is nice when developing
# new modules.
2018-04-28 20:52:25 +08:00
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
# of other dll files and can be safely copied to someone elese's computer
# and expected to run.
if ( MSVC )
include ( ${ CMAKE_CURRENT_LIST_DIR } /../../dlib/cmake_utils/tell_visual_studio_to_use_static_runtime.cmake )
endif ( )
add_subdirectory ( ../../dlib/external/pybind11 ./pybind11_build )
2018-01-16 20:24:47 +08:00
add_subdirectory ( ../../dlib ./dlib_build )
2018-01-16 03:41:40 +08:00
if ( USING_OLD_VISUAL_STUDIO_COMPILER )
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 Pyhton 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***" )
endif ( )
2013-04-27 20:35:04 +08:00
2017-12-08 22:59:27 +08:00
# Test for numpy
2017-12-08 23:09:30 +08:00
find_package ( PythonInterp )
if ( PYTHONINTERP_FOUND )
execute_process ( COMMAND ${ PYTHON_EXECUTABLE } -c "import numpy" OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE NUMPYRC )
if ( NUMPYRC EQUAL 1 )
2018-04-18 10:49:25 +08:00
message ( WARNING "Numpy not found. Functions that return numpy arrays will not work without Numpy installed!" )
2017-12-08 23:09:30 +08:00
else ( )
message ( STATUS "Found Python with installed numpy package" )
endif ( )
else ( )
2018-04-18 10:49:25 +08:00
message ( WARNING "Numpy not found. Functions that return numpy arrays will not work without Numpy installed!" )
2017-12-08 23:09:30 +08:00
endif ( )
2017-12-08 22:59:27 +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
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
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