forked from microsoft/vcpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[python3] Add vcpkg-cmake-wrapper. (microsoft#15221)
* [python3] Add vcpkg-cmake-wrapper.cmake. This is still a WIP... For now, we only remove registry detection on Windows. * [python3] Fix Windows static embedding linkage. * [python3] Fix Linux static library embedding. * [python3] Fix linkage on macOS. * [python3] Only link extra libs when static. * [python3] Bump port version for vcpkg-cmake-wrapper. * [itk] Remove obsolete Python artifact specification. * [pybind11] Remove obsolete Python artifact specification. * [python3] Mark `find_package()` calls as REQUIRED. Co-authored-by: Jack·Boos·Yu <[email protected]> * [python3] Bump port version after microsoft#15378. * [python3] Be more selective about when to unleash the nukes. * [python3] Add usage message. * [python3] Don't swallow `vcpkg_find_acquire_program`'s Python3. * [python3] Don't forcibly change the registry find state. * [python3] fix copypasta error * [python3] Fix config error with the opensubdiv port. Co-authored-by: Jack·Boos·Yu <[email protected]> Co-authored-by: Billy Robert O'Neal III <[email protected]>
- Loading branch information
1 parent
ebedac7
commit 378ffbb
Showing
8 changed files
with
153 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Source: pybind11 | ||
Version: 2.6.0 | ||
Port-Version: 1 | ||
Port-Version: 2 | ||
Homepage: https://github.com/pybind/pybind11 | ||
Description: pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code. | ||
Build-Depends: python3 (windows) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
The package python3 is compatible with built-in CMake targets: | ||
|
||
find_package(Python3 COMPONENTS Development REQUIRED) | ||
target_link_libraries(main PRIVATE Python3::Python) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# For very old ports whose upstream do not properly set the minimum CMake version. | ||
cmake_policy(SET CMP0012 NEW) | ||
cmake_policy(SET CMP0057 NEW) | ||
|
||
# This prevents the port's python.exe from overriding the Python fetched by | ||
# vcpkg_find_acquire_program(PYTHON3) and prevents the vcpkg toolchain from | ||
# stomping on FindPython's default functionality. | ||
list(REMOVE_ITEM CMAKE_PROGRAM_PATH "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools/python3") | ||
if(@PythonFinder_NO_OVERRIDE@) | ||
_find_package(${ARGS}) | ||
return() | ||
endif() | ||
|
||
# CMake's FindPython's separation of concerns is very muddy. We only want to force vcpkg's Python | ||
# if the consumer is using the development component. What we don't want to do is break detection | ||
# of the system Python, which may have certain packages the user expects. But - if the user is | ||
# embedding Python or using both the development and interpreter components, then we need the | ||
# interpreter matching vcpkg's Python libraries. Note that the "Development" component implies | ||
# both "Development.Module" and "Development.Embed" | ||
if("Development" IN_LIST ARGS OR "Development.Embed" IN_LIST ARGS) | ||
set(_PythonFinder_WantInterp TRUE) | ||
set(_PythonFinder_WantLibs TRUE) | ||
elseif("Development.Module" IN_LIST ARGS) | ||
if("Interpreter" IN_LIST ARGS) | ||
set(_PythonFinder_WantInterp TRUE) | ||
endif() | ||
set(_PythonFinder_WantLibs TRUE) | ||
endif() | ||
|
||
if(_PythonFinder_WantLibs) | ||
find_path( | ||
@PythonFinder_PREFIX@_INCLUDE_DIR | ||
NAMES "Python.h" | ||
PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include" | ||
PATH_SUFFIXES "python@PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@" | ||
NO_DEFAULT_PATH | ||
) | ||
|
||
# Don't set the public facing hint or the finder will be unable to detect the debug library. | ||
# Internally, it uses the same value with an underscore prepended. | ||
find_library( | ||
_@PythonFinder_PREFIX@_LIBRARY_RELEASE | ||
NAMES | ||
"python@PYTHON_VERSION_MAJOR@@PYTHON_VERSION_MINOR@" | ||
"python@PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@" | ||
PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" | ||
NO_DEFAULT_PATH | ||
) | ||
find_library( | ||
_@PythonFinder_PREFIX@_LIBRARY_DEBUG | ||
NAMES | ||
"python@PYTHON_VERSION_MAJOR@@PYTHON_VERSION_MINOR@_d" | ||
"python@PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@d" | ||
PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" | ||
NO_DEFAULT_PATH | ||
) | ||
|
||
if(_PythonFinder_WantInterp) | ||
find_program( | ||
@PythonFinder_PREFIX@_EXECUTABLE | ||
NAMES "python" "python@PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@" | ||
PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools/python3" | ||
NO_DEFAULT_PATH | ||
) | ||
endif() | ||
|
||
_find_package(${ARGS}) | ||
|
||
if(@VCPKG_LIBRARY_LINKAGE@ STREQUAL static) | ||
include(CMakeFindDependencyMacro) | ||
|
||
# Python for Windows embeds the zlib module into the core, so we have to link against it. | ||
# This is a separate extension module on Unix-like platforms. | ||
if(WIN32) | ||
find_dependency(ZLIB) | ||
if(TARGET @PythonFinder_PREFIX@::Python) | ||
set_property(TARGET @PythonFinder_PREFIX@::Python APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB) | ||
endif() | ||
if(TARGET @PythonFinder_PREFIX@::Module) | ||
set_property(TARGET @PythonFinder_PREFIX@::Module APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB) | ||
endif() | ||
if(DEFINED @PythonFinder_PREFIX@_LIBRARIES) | ||
list(APPEND @PythonFinder_PREFIX@_LIBRARIES ${ZLIB_LIBRARIES}) | ||
endif() | ||
endif() | ||
|
||
if(APPLE) | ||
find_dependency(Iconv) | ||
find_dependency(Intl) | ||
if(TARGET @PythonFinder_PREFIX@::Python) | ||
get_target_property(_PYTHON_INTERFACE_LIBS @PythonFinder_PREFIX@::Python INTERFACE_LINK_LIBRARIES) | ||
list(REMOVE_ITEM _PYTHON_INTERFACE_LIBS "-liconv" "-lintl") | ||
list(APPEND _PYTHON_INTERFACE_LIBS | ||
Iconv::Iconv | ||
"$<IF:$<CONFIG:Debug>,${Intl_LIBRARY_DEBUG},${Intl_LIBRARY_RELEASE}>" | ||
) | ||
set_property(TARGET @PythonFinder_PREFIX@::Python PROPERTY INTERFACE_LINK_LIBRARIES ${_PYTHON_INTERFACE_LIBS}) | ||
unset(_PYTHON_INTERFACE_LIBS) | ||
endif() | ||
if(TARGET @PythonFinder_PREFIX@::Module) | ||
get_target_property(_PYTHON_INTERFACE_LIBS @PythonFinder_PREFIX@::Module INTERFACE_LINK_LIBRARIES) | ||
list(REMOVE_ITEM _PYTHON_INTERFACE_LIBS "-liconv" "-lintl") | ||
list(APPEND _PYTHON_INTERFACE_LIBS | ||
Iconv::Iconv | ||
"$<IF:$<CONFIG:Debug>,${Intl_LIBRARY_DEBUG},${Intl_LIBRARY_RELEASE}>" | ||
) | ||
set_property(TARGET @PythonFinder_PREFIX@::Module PROPERTY INTERFACE_LINK_LIBRARIES ${_PYTHON_INTERFACE_LIBS}) | ||
unset(_PYTHON_INTERFACE_LIBS) | ||
endif() | ||
if(DEFINED @PythonFinder_PREFIX@_LIBRARIES) | ||
list(APPEND @PythonFinder_PREFIX@_LIBRARIES "-framework CoreFoundation" ${Iconv_LIBRARIES} ${Intl_LIBRARIES}) | ||
endif() | ||
endif() | ||
endif() | ||
else() | ||
_find_package(${ARGS}) | ||
endif() | ||
|
||
unset(_PythonFinder_WantInterp) | ||
unset(_PythonFinder_WantLibs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters