summaryrefslogtreecommitdiffstats
path: root/Modules/FindCxxTest.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-28 15:25:54 (GMT)
committerBrad King <brad.king@kitware.com>2016-09-28 15:27:20 (GMT)
commit32ee69c56241e4991269a8d114339878363ead61 (patch)
tree1b8e66cc272afeec7ddc1bf409699a34bf9f925c /Modules/FindCxxTest.cmake
parent8f25f37676cb860348738eff4dfb1c3b8bae0b59 (diff)
downloadCMake-32ee69c56241e4991269a8d114339878363ead61.zip
CMake-32ee69c56241e4991269a8d114339878363ead61.tar.gz
CMake-32ee69c56241e4991269a8d114339878363ead61.tar.bz2
FindCxxTest: Do not run cxxtestgen through interpreter unless necessary
On platforms that support shebang lines the `cxxtestgen` script should be able to execute without an explicit interpreter. Do this if possible so that the proper interpreter specified by the shebang line is honored. Ideally we shouldn't even need to find `python` in this case, but that will be a larger change better made by a dedicated module maintainer. Closes: #16331
Diffstat (limited to 'Modules/FindCxxTest.cmake')
-rw-r--r--Modules/FindCxxTest.cmake11
1 files changed, 9 insertions, 2 deletions
diff --git a/Modules/FindCxxTest.cmake b/Modules/FindCxxTest.cmake
index 62489f9..9ba1ff3 100644
--- a/Modules/FindCxxTest.cmake
+++ b/Modules/FindCxxTest.cmake
@@ -58,7 +58,8 @@
# The test generator that is actually used (chosen using user preferences
# and interpreters found in the system)
# CXXTEST_TESTGEN_INTERPRETER (since CMake 2.8.3)
-# The full path to the Perl or Python executable on the system
+# The full path to the Perl or Python executable on the system, on
+# platforms where the script cannot be executed using its shebang line.
#
#
#
@@ -210,7 +211,13 @@ if(PYTHONINTERP_FOUND OR PERL_FOUND)
if(PYTHONINTERP_FOUND AND (CXXTEST_USE_PYTHON OR NOT PERL_FOUND OR NOT DEFINED CXXTEST_USE_PYTHON))
set(CXXTEST_TESTGEN_EXECUTABLE ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE})
- set(CXXTEST_TESTGEN_INTERPRETER ${PYTHON_EXECUTABLE})
+ execute_process(COMMAND ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE} --version
+ OUTPUT_VARIABLE _CXXTEST_OUT ERROR_VARIABLE _CXXTEST_OUT RESULT_VARIABLE _CXXTEST_RESULT)
+ if(_CXXTEST_RESULT EQUAL 0)
+ set(CXXTEST_TESTGEN_INTERPRETER "")
+ else()
+ set(CXXTEST_TESTGEN_INTERPRETER ${PYTHON_EXECUTABLE})
+ endif()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG
CXXTEST_INCLUDE_DIR CXXTEST_PYTHON_TESTGEN_EXECUTABLE)