CMakeLists.txt 2.36 KB
Newer Older
1

2
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
3

4

5
set(USE_SSE4_INSTRUCTIONS ON CACHE BOOL "Use SSE4 instructions")
6
7
8
# Make DLIB_ASSERT statements not abort the python interpreter, but just return an error.
add_definitions(-DDLIB_NO_ABORT_ON_2ND_FATAL_ERROR)

9
include(../../dlib/cmake_utils/add_python_module)
10

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Test for numpy
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)
        MESSAGE(WARNING "Numpy not found. Functions that return numpy arrays will throw exceptions!")
    ELSE(NUMPYRC EQUAL 1)
        MESSAGE(STATUS "Found Python with installed numpy package")
        EXECUTE_PROCESS( COMMAND ${PYTHON_EXECUTABLE} -c "import sys; from numpy import get_include; sys.stdout.write(get_include())" OUTPUT_VARIABLE NUMPY_INCLUDE_PATH)
        MESSAGE(STATUS "Numpy include path '${NUMPY_INCLUDE_PATH}'")
        include_directories(${NUMPY_INCLUDE_PATH})
    ENDIF(NUMPYRC EQUAL 1)
ELSE(PYTHONINTERP_FOUND)
    MESSAGE(FATAL_ERROR "Could not find Python interpreter")
ENDIF(PYTHONINTERP_FOUND)

27
28
add_definitions(-DDLIB_VERSION=${DLIB_VERSION})

Davis King's avatar
Davis King committed
29
# Tell cmake to compile all these cpp files into a dlib python module.
30
31
32
set(python_srcs
   src/dlib.cpp
   src/matrix.cpp
33
   src/vector.cpp
34
   src/svm_c_trainer.cpp
35
   src/svm_rank_trainer.cpp
Davis King's avatar
Davis King committed
36
   src/decision_functions.cpp
Davis King's avatar
Davis King committed
37
38
   src/other.cpp
   src/basic.cpp
Davis King's avatar
Davis King committed
39
   src/cca.cpp
40
   src/sequence_segmenter.cpp
41
   src/svm_struct.cpp
42
   src/image.cpp
43
   src/rectangles.cpp
44
   src/object_detection.cpp
45
   src/shape_predictor.cpp
46
   src/correlation_tracker.cpp
47
   src/face_recognition.cpp
48
   src/cnn_face_detector.cpp
49
   src/global_optimization.cpp
50
51
)

52
53
54
55
56
57
58
59
60
61
62
# Only add the Numpy returning functions if Numpy is present
IF(NUMPYRC EQUAL 1)
    list(APPEND python_srcs src/numpy_returns_stub.cpp)
ELSE(NUMPYRC EQUAL 1)
    list(APPEND python_srcs src/numpy_returns.cpp)
ENDIF(NUMPYRC EQUAL 1)

if(NOT ${DLIB_NO_GUI_SUPPORT})
   list(APPEND python_srcs src/gui.cpp)
endif(NOT ${DLIB_NO_GUI_SUPPORT})

63
64
65
66
67
68
# Only add the GUI module if requested
if(NOT ${DLIB_NO_GUI_SUPPORT})
   list(APPEND python_srcs src/gui.cpp)
endif(NOT ${DLIB_NO_GUI_SUPPORT})

add_python_module(dlib ${python_srcs})
69

70
# When you run "make install" we will copy the compiled dlib.so (or dlib.pyd)
Davis King's avatar
Davis King committed
71
# library file to the python_examples folder.
72
install_dlib_to(../../python_examples)