Skip to content

Commit 2b35f86

Browse files
author
Clement Champetier
committed
CMake: fix python version
* Never get python version from DEFINED PYTHONLIBS_VERSION_STRING, even if CMake 2.8.8. * Get python version from include path. * This will fix the python stuff when create packages. * Use PYTHON_INCLUDE_DIR instead of PYTHON_INCLUDE_DIRS (not defined in all CMake versions...).
1 parent 4315699 commit 2b35f86

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,10 @@ if(SWIG_FOUND)
6161
if(PYTHONLIBS_FOUND)
6262
include_directories(${PYTHON_INCLUDE_PATH})
6363

64-
if(NOT DEFINED PYTHONLIBS_VERSION_STRING) # Since CMake 2.8.8
65-
# Get Python version from include path
66-
string(LENGTH ${PYTHON_INCLUDE_DIRS} PYTHON_INCLUDE_DIRS_LENGTH)
67-
math(EXPR PYTHON_INCLUDE_DIRS_LENGTH "${PYTHON_INCLUDE_DIRS_LENGTH} - 3" )
68-
string(SUBSTRING ${PYTHON_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS_LENGTH} 3 PYTHONLIBS_VERSION_STRING)
69-
endif()
64+
# Get Python version from include path
65+
string(LENGTH ${PYTHON_INCLUDE_DIR} PYTHON_INCLUDE_DIRS_LENGTH)
66+
math(EXPR PYTHON_INCLUDE_DIRS_LENGTH "${PYTHON_INCLUDE_DIRS_LENGTH} - 3" )
67+
string(SUBSTRING ${PYTHON_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS_LENGTH} 3 PYTHONLIBS_VERSION_STRING)
7068

7169
# Swig flags
7270
set(CMAKE_SWIG_FLAGS -c++ -fcompact)

0 commit comments

Comments
 (0)