Skip to content

Commit 0c97c6a

Browse files
(PyKDL) Update CMakeLists.txt (#489)
* (PyKDL) Update CMakeLists.txt * (PyKDL) change python to python3 variable names
1 parent 93d8ccf commit 0c97c6a

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

python_orocos_kdl/CMakeLists.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.12.0)
1+
cmake_minimum_required(VERSION 3.20)
22
if(POLICY CMP0048)
33
cmake_policy(SET CMP0048 NEW)
44
endif()
@@ -9,6 +9,18 @@ endif()
99
if(POLICY CMP0057)
1010
cmake_policy(SET CMP0057 NEW) # support IN_LISTS which is required for PyBind11 2.6 and newer
1111
endif()
12+
# CMake policy CMP0094 controls how Python versions are found;
13+
# the OLD policy was to find the newest one, while the new policy
14+
# is to stop after finding the first one. We want to find the first
15+
# one, so be sure to set that policy here.
16+
if(POLICY CMP0094)
17+
cmake_policy(SET CMP0094 NEW)
18+
endif()
19+
# The default for Python3_FIND_UNVERSIONED_NAMES is LAST, which
20+
# means find_package(Python3) will prefer to find /usr/bin/python3.11
21+
# over /usr/bin/python3. We actually prefer to find the system version,
22+
# so set this to FIRST.
23+
set(Python3_FIND_UNVERSIONED_NAMES FIRST)
1224

1325
project(python_orocos_kdl VERSION 1.5.2)
1426

@@ -17,18 +29,12 @@ find_package(orocos_kdl ${PROJECT_VERSION} EXACT REQUIRED)
1729
include_directories(${orocos_kdl_INCLUDE_DIRS})
1830
link_directories(${orocos_kdl_LIBRARY_DIRS})
1931

20-
if(DEFINED ENV{ROS_PYTHON_VERSION})
21-
SET(PYTHON_VERSION $ENV{ROS_PYTHON_VERSION} CACHE STRING "Python Version")
22-
else()
23-
SET(PYTHON_VERSION 3 CACHE STRING "Python Version")
24-
endif()
25-
26-
set(PYBIND11_PYTHON_VERSION ${PYTHON_VERSION} CACHE STRING "Python version used by PyBind11")
32+
set(PYBIND11_PYTHON_VERSION 3 CACHE STRING "Python version used by PyBind11")
2733

28-
find_package(Python ${PYTHON_VERSION} EXACT COMPONENTS Interpreter Development REQUIRED)
34+
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
2935
# get_python_lib in python3 produces path which isn't in sys.path: https://bugs.launchpad.net/ubuntu/+source/python3-stdlib-extensions/+bug/1832215
3036
# execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True, prefix=''))" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
31-
set(PYTHON_SITE_PACKAGES_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/dist-packages" CACHE STRING "Install location of the python package") # This might be overridden below if built with catkin.
37+
set(PYTHON_SITE_PACKAGES_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/dist-packages" CACHE STRING "Install location of the python package") # This might be overridden below if built with catkin.
3238
set(LIBRARY_NAME "PyKDL")
3339

3440
# catkin-specific configuration (optional)
@@ -43,12 +49,6 @@ if(catkin_FOUND)
4349
endif()
4450

4551
# Build the module
46-
if(WIN32)
47-
set(PYTHON_MODULE_EXTENSION ".pyd")
48-
else()
49-
set(PYTHON_MODULE_EXTENSION ".so")
50-
endif()
51-
5252
find_package(pybind11 2.6 QUIET)
5353
if(NOT ${pybind11_FOUND})
5454
message(STATUS "pybind11 not found, building from source")

0 commit comments

Comments
 (0)