Blob Blame Raw
commit 8ae03bd2b1beca9210445aac33e0dcc8e0e90f0b
Author: Till Hofmann <thofmann@fedoraproject.org>
Date:   Sat Jul 14 13:00:45 2018 +0200

    cmake: search for python interpreter and use the found interpreter
    
    Instead of just calling 'python', find the correct python interpreter
    with find_package and use that interpreter when calling python.
    
    This avoids a bug on systems that do not provide an unversioned python
    (i.e., that use 'python2' instead of 'python'). This should also avoid
    using the python3 interpeter on accident.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cdb18f09..33e3f18c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,6 +17,8 @@ string(REGEX REPLACE "^.*GINAC_LT_REVISION[ \t]+([0-9]+).*" "\\1" ginac_lt_revis
 math(EXPR ginaclib_soversion "${ginac_lt_current} - ${ginac_lt_age}")
 set(ginaclib_version ${ginaclib_soversion}.${ginac_lt_age}.${ginac_lt_revision})
 
+find_package(PythonInterp 2 EXACT REQUIRED)
+
 # make check
 enable_testing()
 add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index e1416d31..7a226a26 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -45,7 +45,7 @@ macro(pdflatex_process texfile)
 	add_custom_command(
 		OUTPUT ${_ind}
 		COMMAND ${MAKEINDEX_COMPILER} ${_idx}
-		COMMAND python ${_fixupind} ${_idx}
+		COMMAND ${PYTHON_EXECUTABLE} ${_fixupind} ${_idx}
 		WORKING_DIRECTORY ${_dirname}
 		DEPENDS ${texfile} ${_idx}
 		COMMENT "MAKEINDEX ${_basename}.idx")
diff --git a/ginac/CMakeLists.txt b/ginac/CMakeLists.txt
index 27f4db8d..d3d344c1 100644
--- a/ginac/CMakeLists.txt
+++ b/ginac/CMakeLists.txt
@@ -168,11 +168,11 @@ install(FILES ${ginaclib_public_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/gin
 
 add_custom_command(
 	OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/function.h
-	COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/function.py -o ${CMAKE_CURRENT_BINARY_DIR}/function.h ${CMAKE_CURRENT_SOURCE_DIR}/function.hppy
+	COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/function.py -o ${CMAKE_CURRENT_BINARY_DIR}/function.h ${CMAKE_CURRENT_SOURCE_DIR}/function.hppy
 	DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/function.hppy ${CMAKE_CURRENT_SOURCE_DIR}/function.py)
 
 add_custom_command(
 	OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/function.cpp
-	COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/function.py -o ${CMAKE_CURRENT_BINARY_DIR}/function.cpp ${CMAKE_CURRENT_SOURCE_DIR}/function.cppy
+	COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/function.py -o ${CMAKE_CURRENT_BINARY_DIR}/function.cpp ${CMAKE_CURRENT_SOURCE_DIR}/function.cppy
 	DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/function.h ${CMAKE_CURRENT_SOURCE_DIR}/function.cppy ${CMAKE_CURRENT_SOURCE_DIR}/function.py)
 
diff --git a/ginsh/CMakeLists.txt b/ginsh/CMakeLists.txt
index c350a21a..5e408594 100644
--- a/ginsh/CMakeLists.txt
+++ b/ginsh/CMakeLists.txt
@@ -40,13 +40,13 @@ endif()
 
 add_custom_command(
 	OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ginsh_fcn_help.h
-	COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_fcn_help.py -o ginsh_fcn_help.h ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in
+	COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_fcn_help.py -o ginsh_fcn_help.h ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in
 	DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_fcn_help.py
 	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
 
 add_custom_command(
 	OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ginsh_op_help.h
-	COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_op_help.py -o ginsh_op_help.h ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in
+	COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_op_help.py -o ginsh_op_help.h ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in
 	DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_op_help.py
 	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})