Skip to content

Commit 2b719c2

Browse files
committed
Intelligently deal with capitalised or non capitalised Python include directory
1 parent f69f555 commit 2b719c2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ FIND_PACKAGE(PythonInterp 2.7)
77
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('INCLUDEDIR')" OUTPUT_VARIABLE PYTHON_INCLUDE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
88
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LIBDIR')" OUTPUT_VARIABLE PYTHON_LIB_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
99
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
10-
set(PYTHON_LIBRARIES "${PYTHON_LIB_PATH}/libpython2.7.dylib" CACHE FILEPATH "Path to the libpython2.7.dylib library file" FORCE)
11-
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_PATH}/Python2.7" CACHE FILEPATH "Directory holding the python.h include file" FORCE)
10+
set(PYTHON_LIBRARIES "${PYTHON_LIB_PATH}/libpython2.7.dylib" CACHE FILEPATH "Path to the libpython2.7.dylib library file" FORCE)
11+
if(IS_DIRECTORY "${PYTHON_INCLUDE_PATH}/Python2.7")
12+
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_PATH}/Python2.7" CACHE FILEPATH "Directory holding the python.h include file" FORCE)
13+
else()
14+
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_PATH}/python2.7" CACHE FILEPATH "Directory holding the python.h include file" FORCE)
15+
endif()
1216
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
1317
set(PYTHON_LIBRARIES "${PYTHON_LIB_PATH}/x86_64-linux-gnu/libpython2.7.so" CACHE FILEPATH "Path to the libpython2.7.so library file" FORCE)
14-
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_PATH}/python2.7" CACHE FILEPATH "Directory holding the python.h include file" FORCE)
18+
if(IS_DIRECTORY "${PYTHON_INCLUDE_PATH}/Python2.7")
19+
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_PATH}/Python2.7" CACHE FILEPATH "Directory holding the python.h include file" FORCE)
20+
else()
21+
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_PATH}/python2.7" CACHE FILEPATH "Directory holding the python.h include file" FORCE)
22+
endif()
1523
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
1624

1725
set(PYTHONLIBS_FOUND TRUE)

0 commit comments

Comments
 (0)