简体   繁体   中英

How to set python version 2.7.2 in the cmake?

I have a CMakeLists.txt in which i have to pass a Python script consisting of test cases by making use of add_test as follows:

add_test( NAME My_test COMMAND python ${CMAKE_CURRENT_LIST_DIR}/win_testing/test.py )

How can i set and open "test.py" with Python version 2.7.2?

Use FindPythonInterp module to get path of Python executable to be used in add_test

find_package(PythonInterp 2.7 REQUIRED)
...
add_test(NAME My_test COMMAND ${PYTHON_EXECUTABLE} ... )

Make sure that find_program called inside FindPythonInterp.cmake can found Python 2.7.2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM