From 5b485a628b0dccde0bbf37ee78a2b283669e9219 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Thu, 11 Dec 2014 12:05:10 +0000 Subject: [PATCH] Properly handle turning the GUI off --- tools/python/CMakeLists.txt | 16 +++++++++++----- tools/python/src/dlib.cpp | 5 +++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/python/CMakeLists.txt b/tools/python/CMakeLists.txt index e1861a98f..15bc5ef88 100644 --- a/tools/python/CMakeLists.txt +++ b/tools/python/CMakeLists.txt @@ -9,9 +9,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.4) include(../../dlib/add_python_module) # Tell cmake to compile all these cpp files into a dlib python module. -add_python_module(dlib - src/dlib.cpp - src/matrix.cpp +set(python_srcs + src/dlib.cpp + src/matrix.cpp src/vector.cpp src/svm_c_trainer.cpp src/svm_rank_trainer.cpp @@ -24,8 +24,14 @@ add_python_module(dlib src/image.cpp src/object_detection.cpp src/shape_predictor.cpp - src/gui.cpp - ) +) + +# 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}) # When you run "make install" we will copy the compiled dlib.so (or dlib.pyd) # library file to the python_examples folder. diff --git a/tools/python/src/dlib.cpp b/tools/python/src/dlib.cpp index f6d7c5532..8c939b110 100644 --- a/tools/python/src/dlib.cpp +++ b/tools/python/src/dlib.cpp @@ -16,7 +16,10 @@ void bind_svm_struct(); void bind_image_classes(); void bind_object_detection(); void bind_shape_predictors(); + +#ifndef DLIB_NO_GUI_SUPPORT void bind_gui(); +#endif BOOST_PYTHON_MODULE(dlib) { @@ -37,6 +40,8 @@ BOOST_PYTHON_MODULE(dlib) bind_image_classes(); bind_object_detection(); bind_shape_predictors(); +#ifndef DLIB_NO_GUI_SUPPORT bind_gui(); +#endif }