Commit a18e72e5 authored by Davis King's avatar Davis King

A bit of cmake cleanup

parent ec83abf6
......@@ -5,6 +5,20 @@ if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
# Check if we are being built as part of a pybind11 module.
if (COMMAND pybind11_add_module)
# For python users, assume they have SSE4 at least and then if the host machine has AVX use that too.
set(USE_SSE4_INSTRUCTIONS ON CACHE BOOL "Use SSE4 instructions")
include(${CMAKE_CURRENT_LIST_DIR}/check_if_avx_instructions_executable_on_host.cmake)
if (AVX_IS_AVAILABLE_ON_HOST)
set(USE_AVX_INSTRUCTIONS ON CACHE BOOL "Use AVX instructions")
endif()
endif()
set(USING_OLD_VISUAL_STUDIO_COMPILER 0)
if(MSVC AND MSVC_VERSION VERSION_LESS 1900)
message(FATAL_ERROR "C++11 is required to use dlib, but the version of Visual Studio you are using is too old and doesn't support C++11. You need Visual Studio 2015 or newer. ")
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
set(USE_SSE4_INSTRUCTIONS ON CACHE BOOL "Use SSE4 instructions")
include(../../dlib/cmake_utils/check_if_avx_instructions_executable_on_host.cmake)
if (AVX_IS_AVAILABLE_ON_HOST)
set(USE_AVX_INSTRUCTIONS ON CACHE BOOL "Use AVX instructions")
endif()
# 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.
......@@ -29,27 +22,14 @@ 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)
add_subdirectory(../../dlib ./dlib_build)
add_subdirectory(../../dlib/external/pybind11 pybind11_build)
add_subdirectory(../../dlib dlib_build)
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 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***")
endif()
# 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 not work without Numpy installed!")
else()
message(STATUS "Found Python with installed numpy package")
endif()
else()
message(WARNING "Numpy not found. Functions that return numpy arrays will not work without Numpy installed!")
endif()
add_definitions(-DDLIB_VERSION=${DLIB_VERSION})
# Tell cmake to compile all these cpp files into a dlib python module.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment