Commit 24ac9bc4 authored by Davis King's avatar Davis King

A bit of cmake cleanup

parent 4a97b216
......@@ -35,6 +35,20 @@ endif()
if (DLIB_IN_PROJECT_BUILD)
# Check if we are being built as part of a pybind11 module.
if (COMMAND pybind11_add_module)
set(CMAKE_POSITION_INDEPENDENT_CODE True)
if (CMAKE_COMPILER_IS_GNUCXX)
# Just setting CMAKE_POSITION_INDEPENDENT_CODE should be enough to set
# -fPIC for GCC but sometimes it still doesn't get set, so make sure it
# does.
add_definitions("-fPIC")
endif()
# Make DLIB_ASSERT statements not abort the python interpreter, but just return an error.
list(APPEND active_preprocessor_switches "-DDLIB_NO_ABORT_ON_2ND_FATAL_ERROR")
endif()
# DLIB_IN_PROJECT_BUILD==true means you are using dlib by invoking
# add_subdirectory(dlib) in the parent project. In this case, we always want
# to build dlib as a static library so the parent project doesn't need to
......
......@@ -2,8 +2,6 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
set(USE_SSE4_INSTRUCTIONS ON CACHE BOOL "Use SSE4 instructions")
# Make DLIB_ASSERT statements not abort the python interpreter, but just return an error.
add_definitions(-DDLIB_NO_ABORT_ON_2ND_FATAL_ERROR)
# Set this to disable link time optimization. The only reason for
# doing this to make the compile faster which is nice when developing
......@@ -18,16 +16,6 @@ if (POLICY CMP0042)
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
# Just setting CMAKE_POSITION_INDEPENDENT_CODE should be enough to set
# -fPIC for GCC but sometimes it still doesn't get set, so make sure it
# does.
add_definitions("-fPIC")
set(CMAKE_POSITION_INDEPENDENT_CODE True)
else()
set(CMAKE_POSITION_INDEPENDENT_CODE True)
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
......
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