Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,28 @@ include(CTest)

# Options
option(DOWNLOAD_SOURCES "Automatically download the Python sources" ON)
option(BUILD_SHARED "Build a shared libpython library" OFF)
option(BUILD_STATIC "Build a static libpython library" ON)
set(_build_libpython_shared_default 0)
set(_build_libpython_shared_desc "Build libpython as a shared library")

if(DEFINED BUILD_SHARED OR DEFINED BUILD_STATIC)
message(AUTHOR_WARNING "Deprecated options `BUILD_SHARED` or `BUILD_STATIC` are set, "
"please change configure options to use `BUILD_LIBPYTHON_SHARED` instead.")
if(BUILD_SHARED AND BUILD_STATIC)
message(AUTHOR_WARNING "Both BUILD_SHARED and BUILD_STATIC options are set to ON. Forcing BUILD_SHARED to OFF")
endif()
if(BUILD_STATIC)
set(_build_libpython_shared_default 0)
set(_build_libpython_shared_desc "Intialized from `BUILD_STATIC` (deprecated)")
elseif(BUILD_SHARED)
set(_build_libpython_shared_default 1)
set(_build_libpython_shared_desc "Intialized from `BUILD_SHARED` (deprecated)")
endif()
message(AUTHOR_WARNING "Unsetting cache variables BUILD_SHARED and BUILD_STATIC")
unset(BUILD_SHARED CACHE)
unset(BUILD_STATIC CACHE)
endif()

option(BUILD_LIBPYTHON_SHARED ${_build_libpython_shared_desc} ${_build_libpython_shared_default})
option(BUILD_EXTENSIONS_AS_BUILTIN "Default all modules as builtin to libpython" OFF)
option(USE_LIB64 "Search for dependencies and install to prefix/lib64 instead of prefix/lib" OFF)
if(WIN32)
Expand Down Expand Up @@ -121,11 +141,8 @@ if(UNIX)
set(BUILD_EXTENSIONS_AS_BUILTIN ON CACHE BOOL "Forced to ON${_reason}" FORCE)
message(STATUS "Setting BUILD_EXTENSIONS_AS_BUILTIN to ON${_reason}")

set(BUILD_SHARED OFF CACHE BOOL "Forced to OFF${_reason}" FORCE)
message(STATUS "Setting BUILD_SHARED to OFF${_reason}")

set(BUILD_STATIC ON CACHE BOOL "Forced to ON${_reason}" FORCE)
message(STATUS "Setting BUILD_STATIC to ON${_reason}")
set(BUILD_LIBPYTHON_SHARED OFF CACHE BOOL "Forced to OFF${_reason}" FORCE)
message(STATUS "Setting BUILD_LIBPYTHON_SHARED to OFF${_reason}")
endif()
endif()
else()
Expand Down Expand Up @@ -234,6 +251,14 @@ if(PY_VERSION_MAJOR VERSION_GREATER 2)
set(IS_PY2 0)
endif()

# Convenience boolean variables to easily test the type of python library being build
set(BUILD_STATIC 1)
set(BUILD_SHARED 0)
if(BUILD_LIBPYTHON_SHARED)
set(BUILD_STATIC 0)
set(BUILD_SHARED 1)
endif()

# Options depending of the python version
if(IS_PY2)
option(Py_USING_UNICODE "Enable unicode support" ON)
Expand Down
7 changes: 2 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@ options on the commandline with `-DOPTION=VALUE`, or use the "ccmake" gui.
Download, check MD5 sum and extract python sources in the parent directory.
Source archive is downloaded from http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz

BUILD_SHARED=ON|OFF (defaults to OFF)
BUILD_STATIC=ON|OFF (defaults to ON)
BUILD_LIBPYTHON_SHARED=ON|OFF (defaults to OFF)
Build libpython as a shared library (.so or .dll) or a static library
(.a). At least one of these options must be set to ON - if they are both
set to ON then the Python executable will be linked against the shared
version of libpython.
(.a).

Note that Python extensions are always built as shared libraries. On
Windows it is not possible to build shared .dll extensions against a
Expand Down