Skip to content

Commit 504373b

Browse files
adrianbroherjcfr
authored andcommitted
Replace remaining instances of BUILD_{SHARED,STATIC} control variable
Further clean up changes introduced with 522feb1.
1 parent b348a50 commit 504373b

6 files changed

Lines changed: 14 additions & 20 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,6 @@ if(PY_VERSION_MAJOR VERSION_GREATER 2)
259259
set(IS_PY2 0)
260260
endif()
261261

262-
# Convenience boolean variables to easily test the type of python library being build
263-
set(BUILD_STATIC 1)
264-
set(BUILD_SHARED 0)
265-
if(BUILD_LIBPYTHON_SHARED)
266-
set(BUILD_STATIC 0)
267-
set(BUILD_SHARED 1)
268-
endif()
269-
270262
# Options depending of the python version
271263
if(IS_PY2)
272264
option(Py_USING_UNICODE "Enable unicode support" ON)
@@ -297,10 +289,6 @@ set(LIBPYTHON python${LIBPYTHON_VERSION})
297289
# Proceed to the configure checks
298290
include(cmake/ConfigureChecks.cmake)
299291

300-
if(NOT BUILD_SHARED AND NOT BUILD_STATIC)
301-
message(FATAL_ERROR "One or both of BUILD_SHARED or BUILD_STATIC must be set")
302-
endif()
303-
304292
# Set PYTHONHOME
305293
set(LIBDIR "Lib") # See Lib/distutils/sysconfig.py - function 'get_python_lib'
306294
if(UNIX)
@@ -417,7 +405,7 @@ file(WRITE ${CONFIG_BUILD_DIR}/PythonTargets.cmake "")
417405
# Define python executable wrapper command to ensure
418406
# python executable resolves the expected python library.
419407
set(PYTHON_WRAPPER_COMMAND )
420-
if(BUILD_SHARED AND UNIX)
408+
if(BUILD_LIBPYTHON_SHARED AND UNIX)
421409
set(_envvar LD_LIBRARY_PATH)
422410
if(APPLE)
423411
set(_envvar DYLD_LIBRARY_PATH)

cmake/Extensions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function(add_python_extension name)
150150
set_property(GLOBAL APPEND PROPERTY extension_${name}_link_libraries ${ADD_PYTHON_EXTENSION_LIBRARIES})
151151
set_property(GLOBAL APPEND PROPERTY extension_${name}_includedirs ${ADD_PYTHON_EXTENSION_INCLUDEDIRS})
152152
set_property(GLOBAL APPEND PROPERTY extension_${name}_definitions ${ADD_PYTHON_EXTENSION_DEFINITIONS})
153-
elseif(WIN32 AND NOT BUILD_SHARED)
153+
elseif(WIN32 AND NOT BUILD_LIBPYTHON_SHARED)
154154
# Extensions cannot be built against a static libpython on windows
155155
else()
156156

cmake/PythonConfig.cmake.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33

44
@PACKAGE_INIT@
55

6-
set(PYTHON_BUILD_SHARED "@BUILD_SHARED@")
7-
set(PYTHON_BUILD_STATIC "@BUILD_STATIC@")
6+
set(BUILD_LIBPYTHON_SHARED @BUILD_LIBPYTHON_SHARED@)
7+
if(BUILD_LIBPYTHON_SHARED)
8+
set(PYTHON_BUILD_SHARED 1)
9+
set(PYTHON_BUILD_STATIC 0)
10+
else()
11+
set(PYTHON_BUILD_SHARED 0)
12+
set(PYTHON_BUILD_STATIC 1)
13+
endif()
814

915
set_and_check(PYTHON_CONFIG_DIR "@PACKAGE_CONFIG_DIR_CONFIG@")
1016
set_and_check(PYTHON_INCLUDE_DIR "@PACKAGE_INCLUDE_DIR_CONFIG@")

cmake/extensions/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ if(WIN32)
277277
_ctypes/libffi_msvc/prep_cif.c
278278
_ctypes/libffi_msvc/ffi.c
279279
_ctypes/libffi_msvc/${_ctype_arch_impl}
280-
REQUIRES BUILD_SHARED
280+
REQUIRES BUILD_LIBPYTHON_SHARED
281281
INCLUDEDIRS ${SRC_DIR}/Modules/_ctypes/libffi_msvc
282282
)
283283
endif()

cmake/libpython/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ function(add_libpython name type install component)
472472
endif()
473473
endfunction()
474474

475-
if(BUILD_SHARED)
475+
if(BUILD_LIBPYTHON_SHARED)
476476
add_libpython(libpython-shared SHARED 1 Runtime)
477477
set_target_properties(libpython-shared PROPERTIES
478478
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBPYTHON_ARCHIVEDIR}
@@ -557,7 +557,7 @@ if(BUILD_SHARED)
557557

558558
endif()
559559

560-
if(BUILD_STATIC)
560+
if(NOT BUILD_LIBPYTHON_SHARED)
561561
add_libpython(libpython-static STATIC ${INSTALL_DEVELOPMENT} Development)
562562
if(HAVE_TARGET_COMPILE_DEFINITIONS)
563563
target_compile_definitions(libpython-static PUBLIC Py_NO_ENABLE_SHARED)

cmake/python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ set_property(
1313

1414
# Link against the shared libpython if it was built, otherwise use the static
1515
# version.
16-
if(BUILD_SHARED)
16+
if(BUILD_LIBPYTHON_SHARED)
1717
target_link_libraries(python libpython-shared)
1818
else()
1919
target_link_libraries(python libpython-static)

0 commit comments

Comments
 (0)