Skip to content

Commit

Permalink
Replace remaining instances of BUILD_{SHARED,STATIC} control variable
Browse files Browse the repository at this point in the history
Further clean up changes introduced with 522feb1.
  • Loading branch information
adrianbroher authored and jcfr committed Mar 6, 2017
1 parent b348a50 commit 504373b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 20 deletions.
14 changes: 1 addition & 13 deletions CMakeLists.txt
Expand Up @@ -259,14 +259,6 @@ 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 Expand Up @@ -297,10 +289,6 @@ set(LIBPYTHON python${LIBPYTHON_VERSION})
# Proceed to the configure checks
include(cmake/ConfigureChecks.cmake)

if(NOT BUILD_SHARED AND NOT BUILD_STATIC)
message(FATAL_ERROR "One or both of BUILD_SHARED or BUILD_STATIC must be set")
endif()

# Set PYTHONHOME
set(LIBDIR "Lib") # See Lib/distutils/sysconfig.py - function 'get_python_lib'
if(UNIX)
Expand Down Expand Up @@ -417,7 +405,7 @@ file(WRITE ${CONFIG_BUILD_DIR}/PythonTargets.cmake "")
# Define python executable wrapper command to ensure
# python executable resolves the expected python library.
set(PYTHON_WRAPPER_COMMAND )
if(BUILD_SHARED AND UNIX)
if(BUILD_LIBPYTHON_SHARED AND UNIX)
set(_envvar LD_LIBRARY_PATH)
if(APPLE)
set(_envvar DYLD_LIBRARY_PATH)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Extensions.cmake
Expand Up @@ -150,7 +150,7 @@ function(add_python_extension name)
set_property(GLOBAL APPEND PROPERTY extension_${name}_link_libraries ${ADD_PYTHON_EXTENSION_LIBRARIES})
set_property(GLOBAL APPEND PROPERTY extension_${name}_includedirs ${ADD_PYTHON_EXTENSION_INCLUDEDIRS})
set_property(GLOBAL APPEND PROPERTY extension_${name}_definitions ${ADD_PYTHON_EXTENSION_DEFINITIONS})
elseif(WIN32 AND NOT BUILD_SHARED)
elseif(WIN32 AND NOT BUILD_LIBPYTHON_SHARED)
# Extensions cannot be built against a static libpython on windows
else()

Expand Down
10 changes: 8 additions & 2 deletions cmake/PythonConfig.cmake.in
Expand Up @@ -3,8 +3,14 @@

@PACKAGE_INIT@

set(PYTHON_BUILD_SHARED "@BUILD_SHARED@")
set(PYTHON_BUILD_STATIC "@BUILD_STATIC@")
set(BUILD_LIBPYTHON_SHARED @BUILD_LIBPYTHON_SHARED@)
if(BUILD_LIBPYTHON_SHARED)
set(PYTHON_BUILD_SHARED 1)
set(PYTHON_BUILD_STATIC 0)
else()
set(PYTHON_BUILD_SHARED 0)
set(PYTHON_BUILD_STATIC 1)
endif()

set_and_check(PYTHON_CONFIG_DIR "@PACKAGE_CONFIG_DIR_CONFIG@")
set_and_check(PYTHON_INCLUDE_DIR "@PACKAGE_INCLUDE_DIR_CONFIG@")
Expand Down
2 changes: 1 addition & 1 deletion cmake/extensions/CMakeLists.txt
Expand Up @@ -277,7 +277,7 @@ if(WIN32)
_ctypes/libffi_msvc/prep_cif.c
_ctypes/libffi_msvc/ffi.c
_ctypes/libffi_msvc/${_ctype_arch_impl}
REQUIRES BUILD_SHARED
REQUIRES BUILD_LIBPYTHON_SHARED
INCLUDEDIRS ${SRC_DIR}/Modules/_ctypes/libffi_msvc
)
endif()
Expand Down
4 changes: 2 additions & 2 deletions cmake/libpython/CMakeLists.txt
Expand Up @@ -472,7 +472,7 @@ function(add_libpython name type install component)
endif()
endfunction()

if(BUILD_SHARED)
if(BUILD_LIBPYTHON_SHARED)
add_libpython(libpython-shared SHARED 1 Runtime)
set_target_properties(libpython-shared PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBPYTHON_ARCHIVEDIR}
Expand Down Expand Up @@ -557,7 +557,7 @@ if(BUILD_SHARED)

endif()

if(BUILD_STATIC)
if(NOT BUILD_LIBPYTHON_SHARED)
add_libpython(libpython-static STATIC ${INSTALL_DEVELOPMENT} Development)
if(HAVE_TARGET_COMPILE_DEFINITIONS)
target_compile_definitions(libpython-static PUBLIC Py_NO_ENABLE_SHARED)
Expand Down
2 changes: 1 addition & 1 deletion cmake/python/CMakeLists.txt
Expand Up @@ -13,7 +13,7 @@ set_property(

# Link against the shared libpython if it was built, otherwise use the static
# version.
if(BUILD_SHARED)
if(BUILD_LIBPYTHON_SHARED)
target_link_libraries(python libpython-shared)
else()
target_link_libraries(python libpython-static)
Expand Down

0 comments on commit 504373b

Please sign in to comment.