Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,811
    • Issues 3,811
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 10
    • Merge requests 10
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

An update will be applied May 24th, between 12PM and 1PM EDT (UTC -400). The site may be slow during that time.

  • CMake
  • CMakeCMake
  • Issues
  • #19763

Closed
Open
Created Sep 28, 2019 by Axel Naumann@Axel-Naumann

Xcode 11 confuses find_package(PythonLibs)

CMake version 3.15.3 on MacOS 10.14.6 (18G103) with the following CMakeLists.txt:

cmake_minimum_required(VERSION 3.14)
project(TEST)
find_package(PythonInterp)
find_package(PythonLibs)
message("PYTHONLIBS_VERSION_STRING: ${PYTHONLIBS_VERSION_STRING} PYTHON_VERSION_STRING ${PYTHON_VERSION_STRING}")

prints:

-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python (found version "2.7.10")
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found version "2.7.16")
PYTHONLIBS_VERSION_STRING: 2.7.16 PYTHON_VERSION_STRING 2.7.10
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/axel/tmp/build

Tracing shows that the inconsistent header / library combination stems from inconsistent frameworks being used:

$ ls -l /usr/lib/libpython2.7.dylib
lrwxr-xr-x  1 root  wheel  68 Jan 16  2019 /usr/lib/libpython2.7.dylib -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/Python

(which corresponds to what /usr/lib/python will use) versus /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/python2.7/patchlevel.h which has #define PY_VERSION "2.7.16". /usr/bin/python --version says Python 2.7.10.

Looks like Xcode delivers a MacSDK (which CMake picks up) with a python header that is newer than that on 10.14.6 (18G103).

A reasonable work-around might be to rely on the python binary to figure out its library and include path:

from distutils.sysconfig import get_python_inc
get_python_inc()

This should guarantee a consistent answer.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking