Skip to content

Commit

Permalink
remove linking to libpython on linux/OSX (#703)
Browse files Browse the repository at this point in the history
* remove linking to libpython on linux

* add OSX libpython free building

* add automatic discovery of include python dir back in

* make the libs non required for building on manylinux
  • Loading branch information
Joost van Amersfoort authored and davisking committed Jul 15, 2017
1 parent be8b5cd commit 4a4fd91
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions dlib/cmake_utils/add_python_module
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ if (PYTHON3)
FIND_PACKAGE(Boost 1.41.0 COMPONENTS python)
endif()
set(Python_ADDITIONAL_VERSIONS 3.5 3.6)
FIND_PACKAGE(PythonLibs 3.4 REQUIRED)
FIND_PACKAGE(PythonLibs 3.4)
else()
FIND_PACKAGE(Boost 1.41.0 COMPONENTS python)
FIND_PACKAGE(PythonLibs 2.6 REQUIRED)
FIND_PACKAGE(PythonLibs 2.6)
endif()

if (NOT Boost_FOUND)
Expand Down Expand Up @@ -126,7 +126,6 @@ else()
endif()

message(STATUS "USING BOOST_LIBS: ${Boost_LIBRARIES}")
message(STATUS "USING PYTHON_LIBS: ${PYTHON_LIBRARIES}")

if (CMAKE_COMPILER_IS_GNUCXX)
# Just setting CMAKE_POSITION_INDEPENDENT_CODE should be enough to set
Expand All @@ -148,7 +147,8 @@ include(${CMAKE_CURRENT_LIST_DIR}/../cmake)
# output name is set to what the user asked for (i.e. no _).
macro(add_python_module module_name module_sources )
ADD_LIBRARY(${module_name}_ SHARED ${module_sources} ${ARGN} )
TARGET_LINK_LIBRARIES(${module_name}_ ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} dlib::dlib)
TARGET_LINK_LIBRARIES(${module_name}_ ${Boost_LIBRARIES} dlib::dlib)

if(WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES( ${module_name}_
PROPERTIES
Expand All @@ -163,9 +163,18 @@ macro(add_python_module module_name module_sources )
SUFFIX ".dll"
OUTPUT_NAME ${module_name}
)
elseif(APPLE)
SET_TARGET_PROPERTIES( ${module_name}_
PROPERTIES
LINK_FLAGS "-undefined dynamic_lookup"
PREFIX ""
SUFFIX ".so"
OUTPUT_NAME ${module_name}
)
else()
SET_TARGET_PROPERTIES( ${module_name}_
PROPERTIES
LINK_FLAGS "-shared"
PREFIX ""
SUFFIX ".so"
OUTPUT_NAME ${module_name}
Expand Down

0 comments on commit 4a4fd91

Please sign in to comment.