Initial support for using the built-in dependencies version of Python.

In CMake it is only possible to use one version of Python at any given time.
metadata
Edgar Velazquez-Armendariz 2014-01-25 16:51:16 -05:00
parent 498a1f1e89
commit dd03cbd2d9
2 changed files with 35 additions and 26 deletions

View File

@ -90,10 +90,10 @@ int main (int argc, char **argv) {
# Try to figure out if this boost distro has Boost::python. If we include # Try to figure out if this boost distro has Boost::python. If we include
# python in the main boost components list above, CMake will abort if it # python in the main boost components list above, CMake will abort if it
# is not found. So we resort to checking for the boost_python library's # is not found. So we resort to checking for the boost_python library's
# existance to get a soft failure # existence to get a soft failure
if (APPLE AND MTS_DEPENDENCIES) if ((APPLE OR WIN32) AND MTS_DEPENDENCIES)
set(mts_boost_python_names boost_python boost_python26 boost_python27 set(mts_boost_python_names boost_python boost_python27
boost_python32 boost_python33) boost_python32 boost_python33 boost_python)
else() else()
set(mts_boost_python_names boost_python) set(mts_boost_python_names boost_python)
endif() endif()
@ -101,31 +101,33 @@ find_library (mts_boost_python_lib NAMES ${mts_boost_python_names}
HINTS ${Boost_LIBRARY_DIRS} NO_DEFAULT_PATH) HINTS ${Boost_LIBRARY_DIRS} NO_DEFAULT_PATH)
mark_as_advanced (mts_boost_python_lib) mark_as_advanced (mts_boost_python_lib)
if (NOT mts_boost_python_lib AND Boost_SYSTEM_LIBRARY_RELEASE) if (NOT mts_boost_python_lib AND Boost_SYSTEM_LIBRARY_RELEASE)
get_filename_component (mts_boost_PYTHON_rel get_filename_component (mts_boost_SYSTEM_rel
${Boost_SYSTEM_LIBRARY_RELEASE} NAME ${Boost_SYSTEM_LIBRARY_RELEASE} NAME)
) set(mts_boost_PYTHON_rel_names "")
string (REGEX REPLACE "^(lib)?(.+)_system(.+)$" "\\2_python\\3" foreach (name ${mts_boost_python_names})
mts_boost_PYTHON_rel ${mts_boost_PYTHON_rel} string (REGEX REPLACE "^(.*)boost_system(.+)$" "\\1${name}\\2"
) mts_boost_PYTHON_rel ${mts_boost_SYSTEM_rel})
list(APPEND mts_boost_PYTHON_rel_names ${mts_boost_PYTHON_rel})
endforeach()
find_library (mts_boost_PYTHON_LIBRARY_RELEASE find_library (mts_boost_PYTHON_LIBRARY_RELEASE
NAMES ${mts_boost_PYTHON_rel} lib${mts_boost_PYTHON_rel} NAMES ${mts_boost_PYTHON_rel_names}
HINTS ${Boost_LIBRARY_DIRS} HINTS ${Boost_LIBRARY_DIRS}
NO_DEFAULT_PATH NO_DEFAULT_PATH)
)
mark_as_advanced (mts_boost_PYTHON_LIBRARY_RELEASE) mark_as_advanced (mts_boost_PYTHON_LIBRARY_RELEASE)
endif () endif ()
if (NOT mts_boost_python_lib AND Boost_SYSTEM_LIBRARY_DEBUG) if (NOT mts_boost_python_lib AND Boost_SYSTEM_LIBRARY_DEBUG)
get_filename_component (mts_boost_PYTHON_dbg get_filename_component (mts_boost_SYSTEM_dbg
${Boost_SYSTEM_LIBRARY_DEBUG} NAME ${Boost_SYSTEM_LIBRARY_DEBUG} NAME)
) set(mts_boost_PYTHON_dbg_names "")
string (REGEX REPLACE "^(lib)?(.+)_system(.+)$" "\\2_python\\3" foreach (name ${mts_boost_python_names})
mts_boost_PYTHON_dbg ${mts_boost_PYTHON_dbg} string (REGEX REPLACE "^(.*)boost_system(.+)$" "\\1${name}\\2"
) mts_boost_PYTHON_dbg ${mts_boost_SYSTEM_dbg})
list(APPEND mts_boost_PYTHON_dbg_names ${mts_boost_PYTHON_dbg})
endforeach()
find_library (mts_boost_PYTHON_LIBRARY_DEBUG find_library (mts_boost_PYTHON_LIBRARY_DEBUG
NAMES ${mts_boost_PYTHON_dbg} lib${mts_boost_PYTHON_dbg} NAMES ${mts_boost_PYTHON_dbg_names}
HINTS ${Boost_LIBRARY_DIRS} HINTS ${Boost_LIBRARY_DIRS}
NO_DEFAULT_PATH NO_DEFAULT_PATH)
)
mark_as_advanced (mts_boost_PYTHON_LIBRARY_DEBUG) mark_as_advanced (mts_boost_PYTHON_LIBRARY_DEBUG)
endif () endif ()
if (mts_boost_python_lib OR if (mts_boost_python_lib OR
@ -244,7 +246,14 @@ if (APPLE)
endif() endif()
# The Python libraries. # The Python libraries. When using the built-in dependencies we need
# to specify the include directory, otherwise CMake finds the one
# from the local installation using the Windows registry / OSX Frameworks
if (MTS_DEPENDENCIES AND NOT PYTHON_INCLUDE_DIR AND
EXISTS "${MTS_DEPS_DIR}/include/python27")
set(PYTHON_INCLUDE_DIR "${MTS_DEPS_DIR}/include/python27"
CACHE STRING "Path to the Python include directory.")
endif()
find_package (PythonLibs "2.6") find_package (PythonLibs "2.6")
CMAKE_DEPENDENT_OPTION(BUILD_PYTHON "Build the Python bindings." ON CMAKE_DEPENDENT_OPTION(BUILD_PYTHON "Build the Python bindings." ON
"PYTHONLIBS_FOUND;mts_boost_PYTHON_FOUND" OFF) "PYTHONLIBS_FOUND;mts_boost_PYTHON_FOUND" OFF)

View File

@ -3,13 +3,13 @@ if (NOT MTS_VERSION)
message(FATAL_ERROR "Use the top level configuration file") message(FATAL_ERROR "Use the top level configuration file")
endif() endif()
# The Mitsuba provided dependencies on OS X add a version suffix to # The Mitsuba provided dependencies on OS X and Windows add a version suffix to
# boost-python to provide support for multiple version in the same # boost-python to provide support for multiple version in the same
# distribution. CMake does not know how to handle this, requiring a little hack # distribution. CMake does not know how to handle this, requiring a little hack
set(mts_python "python") set(mts_python "python")
if(APPLE AND MTS_DEPENDENCIES) if((APPLE OR WIN32) AND MTS_DEPENDENCIES)
# Try to guess the suffix from the library version # Try to guess the suffix from the library version
if (PYTHON_LIBRARY MATCHES ".+python([23])\\.?([0-9]).+dylib$") if (PYTHON_LIBRARY MATCHES ".+python([23])\\.?([0-9])\\.[^.]+$")
set(mts_python "python${CMAKE_MATCH_1}${CMAKE_MATCH_2}") set(mts_python "python${CMAKE_MATCH_1}${CMAKE_MATCH_2}")
endif() endif()
endif() endif()