diff options
| author | Marc Chevrier <marc.chevrier@gmail.com> | 2025-05-16 16:42:28 (GMT) |
|---|---|---|
| committer | Brad King <brad.king@kitware.com> | 2025-05-20 13:16:14 (GMT) |
| commit | 41a4a3213598fb6e1dbc16dbe6b94cc74566de5b (patch) | |
| tree | 70a184bc4c08add4972452a13f0d7ee9b7def65f /Modules/FindPython | |
| parent | 811f00f9adca089323a1d4e2ddc9e9e4307e323e (diff) | |
| download | CMake-41a4a3213598fb6e1dbc16dbe6b94cc74566de5b.zip CMake-41a4a3213598fb6e1dbc16dbe6b94cc74566de5b.tar.gz CMake-41a4a3213598fb6e1dbc16dbe6b94cc74566de5b.tar.bz2 | |
FindPython: Avoid implicit link library on Windows
Starting with version 3.14, on Windows, by specifying macro Py_NO_LINK_LIB,
the python library is no longer implicitly specified at the link step.
Fixes: #26756
Diffstat (limited to 'Modules/FindPython')
| -rw-r--r-- | Modules/FindPython/Support.cmake | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 9b89307..2997650 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -4069,7 +4069,11 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") set_property (TARGET ${__name} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${${_PYTHON_PREFIX}_DEFINITIONS}") endif() - + if(WIN32) + # avoid implicit library link (recognized by version 3.14 and upper) + set_property (TARGET ${__name} + APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "Py_NO_LINK_LIB") + endif() if (${_PYTHON_PREFIX}_${_PREFIX}LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_${_PREFIX}LIBRARY_RELEASE) # System manage shared libraries in two parts: import and runtime @@ -4131,6 +4135,11 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") set_property (TARGET ${__name} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${${_PYTHON_PREFIX}_DEFINITIONS}") endif() + if(WIN32) + # avoid implicit library link (recognized by version 3.14 and upper) + set_property (TARGET ${__name} + APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "Py_NO_LINK_LIB") + endif() # When available, enforce shared library generation with undefined symbols if (APPLE) |
