Skip to content

Commit d6a4a4f

Browse files
author
Valentin Noel
committed
Windows: get python libs version with CMAKE
1 parent cef5fb8 commit d6a4a4f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,19 @@ if(SWIG_FOUND)
6565
if(PYTHONLIBS_FOUND)
6666
include_directories(${PYTHON_INCLUDE_PATH})
6767

68-
# Get Python version from include path
69-
string(LENGTH ${PYTHON_INCLUDE_DIR} PYTHON_INCLUDE_DIRS_LENGTH)
70-
math(EXPR PYTHON_INCLUDE_DIRS_LENGTH "${PYTHON_INCLUDE_DIRS_LENGTH} - 3" )
71-
string(SUBSTRING ${PYTHON_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS_LENGTH} 3 PYTHONLIBS_VERSION_STRING)
68+
if(${CMAKE_VERSION} STRLESS 2.8.8)
69+
# Get Python version from include path
70+
string(LENGTH ${PYTHON_INCLUDE_DIR} PYTHON_INCLUDE_DIRS_LENGTH)
71+
if(WIN32)
72+
set(PYTHON_INCLUDE_DIRS_LENGTH_EXPRESSION "${PYTHON_INCLUDE_DIRS_LENGTH} - 10")
73+
set(PYTHON_VERSION_LENGTH_EXPRESSION "2")
74+
else()
75+
set(PYTHON_INCLUDE_DIRS_LENGTH_EXPRESSION "${PYTHON_INCLUDE_DIRS_LENGTH} - 3")
76+
set(PYTHON_VERSION_LENGTH_EXPRESSION "3")
77+
endif()
78+
math(EXPR PYTHON_INCLUDE_DIRS_LENGTH ${PYTHON_INCLUDE_DIRS_LENGTH_EXPRESSION} )
79+
string(SUBSTRING ${PYTHON_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS_LENGTH} ${PYTHON_VERSION_LENGTH_EXPRESSION} PYTHONLIBS_VERSION_STRING)
80+
endif()
7281

7382
# Swig flags
7483
set(CMAKE_SWIG_FLAGS -c++ -fcompact)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy