diff --git a/ament_cmake/CMakeLists.txt b/ament_cmake/CMakeLists.txt index 82d72aee..a876026f 100644 --- a/ament_cmake/CMakeLists.txt +++ b/ament_cmake/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake NONE) diff --git a/ament_cmake_auto/CMakeLists.txt b/ament_cmake_auto/CMakeLists.txt index fb35123e..822b5878 100644 --- a/ament_cmake_auto/CMakeLists.txt +++ b/ament_cmake_auto/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_auto NONE) diff --git a/ament_cmake_core/CMakeLists.txt b/ament_cmake_core/CMakeLists.txt index 959ca0aa..5eaf4773 100644 --- a/ament_cmake_core/CMakeLists.txt +++ b/ament_cmake_core/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_core NONE) diff --git a/ament_cmake_core/ament_cmake_package_templates-extras.cmake b/ament_cmake_core/ament_cmake_package_templates-extras.cmake index fbf085f4..24f34884 100644 --- a/ament_cmake_core/ament_cmake_package_templates-extras.cmake +++ b/ament_cmake_core/ament_cmake_package_templates-extras.cmake @@ -13,10 +13,9 @@ # limitations under the License. # extract information from ament_package.templates -if(NOT PYTHON_EXECUTABLE) +if(NOT TARGET Python3::Interpreter) message(FATAL_ERROR - "ament_cmake_package_templates: variable 'PYTHON_EXECUTABLE' must not be " - "empty") + "ament_cmake_package_templates: target 'Python3::Interpreter' must exist") endif() # stamp script to generate CMake code @@ -27,8 +26,9 @@ stamp("${_generator}") # invoke generator script set(_generated_file "${CMAKE_CURRENT_BINARY_DIR}/ament_cmake_package_templates/templates.cmake") +get_executable_path(_python_interpreter Python3::Interpreter CONFIGURE) set(_cmd - "${PYTHON_EXECUTABLE}" + "${_python_interpreter}" "${_generator}" "${_generated_file}" ) diff --git a/ament_cmake_core/cmake/core/ament_package_xml.cmake b/ament_cmake_core/cmake/core/ament_package_xml.cmake index ae8bd46a..b829532d 100644 --- a/ament_cmake_core/cmake/core/ament_package_xml.cmake +++ b/ament_cmake_core/cmake/core/ament_package_xml.cmake @@ -75,12 +75,13 @@ macro(_ament_package_xml dest_dir) # extract information from package.xml file(MAKE_DIRECTORY ${dest_dir}) - if(NOT PYTHON_EXECUTABLE) + if(NOT TARGET Python3::Interpreter) message(FATAL_ERROR - "ament_package_xml() variable 'PYTHON_EXECUTABLE' must not be empty") + "ament_package_xml() target 'Python3::Interpreter' must exist") endif() + get_executable_path(_python_interpreter Python3::Interpreter CONFIGURE) set(_cmd - "${PYTHON_EXECUTABLE}" + "${_python_interpreter}" "${ament_cmake_core_DIR}/core/package_xml_2_cmake.py" "${PACKAGE_XML_DIRECTORY}/package.xml" "${dest_dir}/package.cmake" diff --git a/ament_cmake_core/cmake/core/python.cmake b/ament_cmake_core/cmake/core/python.cmake index 51389270..7583a0fc 100644 --- a/ament_cmake_core/cmake/core/python.cmake +++ b/ament_cmake_core/cmake/core/python.cmake @@ -12,12 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(PYTHON_VERSION "" CACHE STRING - "Specify specific Python version to use ('major.minor' or 'major')") -# if not specified otherwise use Python 3 -if(NOT PYTHON_VERSION) - set(PYTHON_VERSION "3") +# ament_cmake needs a Python 3 interpreter +# If a specific Python version is required then find it before finding ament_cmake +# Example: +# find_package(Python3 3.8 REQUIRED) +# find_package(ament_cmake REQUIRED) +if (NOT TARGET Python3::Interpreter) + find_package(Python3 REQUIRED COMPONENTS Interpreter) endif() - -find_package(PythonInterp ${PYTHON_VERSION} REQUIRED) -message(STATUS "Using PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}") diff --git a/ament_cmake_core/cmake/environment/ament_generate_environment.cmake b/ament_cmake_core/cmake/environment/ament_generate_environment.cmake index 4cc20c54..dabfa7bd 100644 --- a/ament_cmake_core/cmake/environment/ament_generate_environment.cmake +++ b/ament_cmake_core/cmake/environment/ament_generate_environment.cmake @@ -23,6 +23,14 @@ function(ament_generate_environment) "ament_generate_environment() called with unused arguments: ${ARGN}") endif() + if(NOT TARGET Python3::Interpreter) + message(FATAL_ERROR + "ament_generate_environment() target 'Python3::Interpreter' must exist") + endif() + + # Default python used in local_setup.* scripts + get_executable_path(ament_package_PYTHON_EXECUTABLE Python3::Interpreter CONFIGURE) + # configure and install setup files foreach(file ${ament_cmake_package_templates_PREFIX_LEVEL}) # check if the file is a template diff --git a/ament_cmake_export_definitions/CMakeLists.txt b/ament_cmake_export_definitions/CMakeLists.txt index deb66334..5dbe6f7d 100644 --- a/ament_cmake_export_definitions/CMakeLists.txt +++ b/ament_cmake_export_definitions/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_export_definitions NONE) diff --git a/ament_cmake_export_dependencies/CMakeLists.txt b/ament_cmake_export_dependencies/CMakeLists.txt index f65f7201..e4b9feb2 100644 --- a/ament_cmake_export_dependencies/CMakeLists.txt +++ b/ament_cmake_export_dependencies/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_export_dependencies NONE) diff --git a/ament_cmake_export_include_directories/CMakeLists.txt b/ament_cmake_export_include_directories/CMakeLists.txt index d7912e47..f9505d22 100644 --- a/ament_cmake_export_include_directories/CMakeLists.txt +++ b/ament_cmake_export_include_directories/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_export_include_directories NONE) diff --git a/ament_cmake_export_interfaces/CMakeLists.txt b/ament_cmake_export_interfaces/CMakeLists.txt index f3f724cd..69df43e5 100644 --- a/ament_cmake_export_interfaces/CMakeLists.txt +++ b/ament_cmake_export_interfaces/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_export_interfaces NONE) diff --git a/ament_cmake_export_libraries/CMakeLists.txt b/ament_cmake_export_libraries/CMakeLists.txt index b0e756ab..f4994335 100644 --- a/ament_cmake_export_libraries/CMakeLists.txt +++ b/ament_cmake_export_libraries/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_export_libraries NONE) diff --git a/ament_cmake_export_link_flags/CMakeLists.txt b/ament_cmake_export_link_flags/CMakeLists.txt index c93783aa..1f4244cc 100644 --- a/ament_cmake_export_link_flags/CMakeLists.txt +++ b/ament_cmake_export_link_flags/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_export_link_flags NONE) diff --git a/ament_cmake_export_targets/CMakeLists.txt b/ament_cmake_export_targets/CMakeLists.txt index b13ef0c7..c31eeef2 100644 --- a/ament_cmake_export_targets/CMakeLists.txt +++ b/ament_cmake_export_targets/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_export_targets NONE) diff --git a/ament_cmake_gmock/CMakeLists.txt b/ament_cmake_gmock/CMakeLists.txt index 6003d2f1..a41e3f93 100644 --- a/ament_cmake_gmock/CMakeLists.txt +++ b/ament_cmake_gmock/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_gmock NONE) diff --git a/ament_cmake_google_benchmark/CMakeLists.txt b/ament_cmake_google_benchmark/CMakeLists.txt index 51e24dc3..60bb4663 100644 --- a/ament_cmake_google_benchmark/CMakeLists.txt +++ b/ament_cmake_google_benchmark/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_google_benchmark NONE) # find dependencies diff --git a/ament_cmake_google_benchmark/cmake/ament_add_google_benchmark_test.cmake b/ament_cmake_google_benchmark/cmake/ament_add_google_benchmark_test.cmake index 5539f0d0..1321012e 100644 --- a/ament_cmake_google_benchmark/cmake/ament_add_google_benchmark_test.cmake +++ b/ament_cmake_google_benchmark/cmake/ament_add_google_benchmark_test.cmake @@ -66,11 +66,13 @@ function(ament_add_google_benchmark_test target) set(OVERLAY_ARG "--result-file-overlay" "${AMENT_CMAKE_GOOGLE_BENCHMARK_OVERLAY}") endif() + get_executable_path(python_interpreter Python3::Interpreter BUILD) + set(executable "$") set(benchmark_out "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${target}.google_benchmark.json") set(common_out "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${target}.benchmark.json") set(cmd - "${PYTHON_EXECUTABLE}" "-u" "${ament_cmake_google_benchmark_DIR}/run_and_convert.py" + "${python_interpreter}" "-u" "${ament_cmake_google_benchmark_DIR}/run_and_convert.py" "${benchmark_out}" "${common_out}" "--package-name" "${PROJECT_NAME}" ${OVERLAY_ARG} "--command" "${executable}" diff --git a/ament_cmake_gtest/CMakeLists.txt b/ament_cmake_gtest/CMakeLists.txt index ec64bfd1..04c65c8b 100644 --- a/ament_cmake_gtest/CMakeLists.txt +++ b/ament_cmake_gtest/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_gtest NONE) diff --git a/ament_cmake_include_directories/CMakeLists.txt b/ament_cmake_include_directories/CMakeLists.txt index e423ac3f..7b4a43a7 100644 --- a/ament_cmake_include_directories/CMakeLists.txt +++ b/ament_cmake_include_directories/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_include_directories NONE) diff --git a/ament_cmake_libraries/CMakeLists.txt b/ament_cmake_libraries/CMakeLists.txt index 57ffba3b..20092c42 100644 --- a/ament_cmake_libraries/CMakeLists.txt +++ b/ament_cmake_libraries/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_libraries NONE) diff --git a/ament_cmake_nose/CMakeLists.txt b/ament_cmake_nose/CMakeLists.txt index 47939d58..1d802092 100644 --- a/ament_cmake_nose/CMakeLists.txt +++ b/ament_cmake_nose/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_nose NONE) diff --git a/ament_cmake_nose/ament_cmake_nose-extras.cmake b/ament_cmake_nose/ament_cmake_nose-extras.cmake index ca116be0..86284363 100644 --- a/ament_cmake_nose/ament_cmake_nose-extras.cmake +++ b/ament_cmake_nose/ament_cmake_nose-extras.cmake @@ -23,15 +23,16 @@ macro(_ament_cmake_nose_find_nosetests) find_package(ament_cmake_test QUIET REQUIRED) find_program(NOSETESTS NAMES - "nosetests${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" - "nosetests-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" - "nosetests${PYTHON_VERSION_MAJOR}" - "nosetests-${PYTHON_VERSION_MAJOR}" + "nosetests${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}" + "nosetests-${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}" + "nosetests${Python3_VERSION_MAJOR}" + "nosetests-${Python3_VERSION_MAJOR}" "nosetests") if(NOSETESTS) # if Python is located in a path containing spaces the shebang line of nosetests is invalid # to avoid using the shebang line of nosetests the script is being invoked through Python - set(_cmd "${PYTHON_EXECUTABLE}" "${NOSETESTS}" "--version") + get_executable_path(_python_interpreter Python3::Interpreter CONFIGURE) + set(_cmd "${_python_interpreter}" "${NOSETESTS}" "--version") execute_process( COMMAND ${_cmd} RESULT_VARIABLE _res @@ -49,14 +50,9 @@ macro(_ament_cmake_nose_find_nosetests) list(GET _output_list 1 NOSETESTS_VERSION) message(STATUS "Using Python nosetests: ${NOSETESTS} (${NOSETESTS_VERSION})") else() - if(PYTHON_VERSION_MAJOR STREQUAL "3") - set(_python_nosetests_package "python3-nose") - else() - set(_python_nosetests_package "python-nose") - endif() message(WARNING "'nosetests' not found, Python nose tests can not be run (e.g. on " - "Ubuntu/Debian install the package '${_python_nosetests_package}')") + "Ubuntu/Debian install the package 'python3-nose')") endif() endif() endmacro() diff --git a/ament_cmake_nose/cmake/ament_add_nose_test.cmake b/ament_cmake_nose/cmake/ament_add_nose_test.cmake index ca89b7f9..07f5e74b 100644 --- a/ament_cmake_nose/cmake/ament_add_nose_test.cmake +++ b/ament_cmake_nose/cmake/ament_add_nose_test.cmake @@ -22,8 +22,8 @@ # :type path: string # :param SKIP_TEST: if set mark the test as being skipped # :type SKIP_TEST: option -# :param PYTHON_EXECUTABLE: absolute path to the executable used to run the test, -# default to the CMake variable with the same name returned by FindPythonInterp +# :param PYTHON_EXECUTABLE: Python executable used to run the test. +# It defaults to the CMake executable target Python3::Interpreter. # :type PYTHON_EXECUTABLE: string # :param RUNNER: the path to the test runner script (default: see ament_add_test). # :type RUNNER: string @@ -72,7 +72,7 @@ function(_ament_add_nose_test testname path) "ament_add_nose_test() the path '${path}' does not exist") endif() if(NOT ARG_PYTHON_EXECUTABLE) - set(ARG_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}") + set(ARG_PYTHON_EXECUTABLE Python3::Interpreter) endif() get_executable_path(python_interpreter "${ARG_PYTHON_EXECUTABLE}" BUILD) diff --git a/ament_cmake_pytest/CMakeLists.txt b/ament_cmake_pytest/CMakeLists.txt index cf3d6930..65fa8e82 100644 --- a/ament_cmake_pytest/CMakeLists.txt +++ b/ament_cmake_pytest/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_pytest NONE) diff --git a/ament_cmake_pytest/cmake/ament_add_pytest_test.cmake b/ament_cmake_pytest/cmake/ament_add_pytest_test.cmake index 66c21783..fae9fe3f 100644 --- a/ament_cmake_pytest/cmake/ament_add_pytest_test.cmake +++ b/ament_cmake_pytest/cmake/ament_add_pytest_test.cmake @@ -22,8 +22,8 @@ # :type path: string # :param SKIP_TEST: if set mark the test as being skipped # :type SKIP_TEST: option -# :param PYTHON_EXECUTABLE: absolute path to the executable used to run the test, -# default to the CMake variable with the same name returned by FindPythonInterp +# :param PYTHON_EXECUTABLE: Python executable used to run the test. +# It defaults to the CMake executable target Python3::Interpreter. # :type PYTHON_EXECUTABLE: string # :param RUNNER: the path to the test runner script (default: see ament_add_test). # :type RUNNER: string @@ -68,7 +68,7 @@ function(ament_add_pytest_test testname path) "ament_add_pytest_test() the path '${path}' does not exist") endif() if(NOT ARG_PYTHON_EXECUTABLE) - set(ARG_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}") + set(ARG_PYTHON_EXECUTABLE Python3::Interpreter) endif() get_executable_path(python_interpreter "${ARG_PYTHON_EXECUTABLE}" BUILD) diff --git a/ament_cmake_pytest/cmake/ament_get_pytest_cov_version.cmake b/ament_cmake_pytest/cmake/ament_get_pytest_cov_version.cmake index 482673f6..3804450d 100644 --- a/ament_cmake_pytest/cmake/ament_get_pytest_cov_version.cmake +++ b/ament_cmake_pytest/cmake/ament_get_pytest_cov_version.cmake @@ -17,9 +17,8 @@ # # :param var: the output variable name # :type var: string -# :param PYTHON_EXECUTABLE: absolute path to the Python interpreter to be used, -# default to the CMake variable with the same name returned by -# FindPythonInterp +# :param PYTHON_EXECUTABLE: Python executable used to check the version +# It defaults to the CMake executable target Python3::Interpreter. # :type PYTHON_EXECUTABLE: string # # @public @@ -32,7 +31,7 @@ function(ament_get_pytest_cov_version var) endif() if(NOT ARG_PYTHON_EXECUTABLE) - set(ARG_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}") + set(ARG_PYTHON_EXECUTABLE Python3::Interpreter) endif() get_executable_path(python_interpreter "${ARG_PYTHON_EXECUTABLE}" CONFIGURE) diff --git a/ament_cmake_pytest/cmake/ament_has_pytest.cmake b/ament_cmake_pytest/cmake/ament_has_pytest.cmake index 4541db27..40d82c2b 100644 --- a/ament_cmake_pytest/cmake/ament_has_pytest.cmake +++ b/ament_cmake_pytest/cmake/ament_has_pytest.cmake @@ -20,9 +20,8 @@ # :param QUIET: suppress the CMake warning if pytest is not found, if not set # and pytest was not found a CMake warning is printed # :type QUIET: option -# :param PYTHON_EXECUTABLE: absolute path to the Python interpreter to be used, -# default to the CMake variable with the same name returned by -# FindPythonInterp +# :param PYTHON_EXECUTABLE: Python executable used to check for pytest +# It defaults to the CMake executable target Python3::Interpreter. # :type PYTHON_EXECUTABLE: string # # @public @@ -35,7 +34,7 @@ function(ament_has_pytest var) endif() if(NOT ARG_PYTHON_EXECUTABLE) - set(ARG_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}") + set(ARG_PYTHON_EXECUTABLE Python3::Interpreter) endif() get_executable_path(python_interpreter "${ARG_PYTHON_EXECUTABLE}" CONFIGURE) diff --git a/ament_cmake_python/CMakeLists.txt b/ament_cmake_python/CMakeLists.txt index 7e760c58..25d8b06c 100644 --- a/ament_cmake_python/CMakeLists.txt +++ b/ament_cmake_python/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_python NONE) diff --git a/ament_cmake_python/ament_cmake_python-extras.cmake b/ament_cmake_python/ament_cmake_python-extras.cmake index 75c478b0..4034ae6b 100644 --- a/ament_cmake_python/ament_cmake_python-extras.cmake +++ b/ament_cmake_python/ament_cmake_python-extras.cmake @@ -48,9 +48,10 @@ macro(_ament_cmake_python_get_python_install_dir) "import os" "print(os.path.relpath(get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}'), start='${CMAKE_INSTALL_PREFIX}').replace(os.sep, '/'))" ) + get_executable_path(_python_interpreter Python3::Interpreter CONFIGURE) execute_process( COMMAND - "${PYTHON_EXECUTABLE}" + "${_python_interpreter}" "-c" "${_python_code}" OUTPUT_VARIABLE _output @@ -59,7 +60,7 @@ macro(_ament_cmake_python_get_python_install_dir) ) if(NOT _result EQUAL 0) message(FATAL_ERROR - "execute_process(${PYTHON_EXECUTABLE} -c '${_python_code}') returned " + "execute_process(${_python_interpreter} -c '${_python_code}') returned " "error code ${_result}") endif() diff --git a/ament_cmake_python/cmake/ament_python_install_module.cmake b/ament_cmake_python/cmake/ament_python_install_module.cmake index 6ce90895..6d61edcc 100644 --- a/ament_cmake_python/cmake/ament_python_install_module.cmake +++ b/ament_cmake_python/cmake/ament_python_install_module.cmake @@ -59,11 +59,12 @@ function(_ament_cmake_python_install_module module_file) ) get_filename_component(module_file "${module_file}" NAME) if(NOT ARG_SKIP_COMPILE) + get_executable_path(python_interpreter Python3::Interpreter CONFIGURE) # compile Python files install(CODE "execute_process( COMMAND - \"${PYTHON_EXECUTABLE}\" \"-m\" \"compileall\" + \"${python_interpreter}\" \"-m\" \"compileall\" \"${CMAKE_INSTALL_PREFIX}/${destination}/${module_file}\" )" ) diff --git a/ament_cmake_python/cmake/ament_python_install_package.cmake b/ament_cmake_python/cmake/ament_python_install_package.cmake index 7a593836..f5356da0 100644 --- a/ament_cmake_python/cmake/ament_python_install_package.cmake +++ b/ament_cmake_python/cmake/ament_python_install_package.cmake @@ -120,14 +120,16 @@ setup( list(APPEND egg_dependencies ament_cmake_python_symlink_${package_name}_setup) endif() + get_executable_path(python_interpreter Python3::Interpreter BUILD) + add_custom_target( ament_cmake_python_build_${package_name}_egg ALL - COMMAND ${PYTHON_EXECUTABLE} setup.py egg_info + COMMAND ${python_interpreter} setup.py egg_info WORKING_DIRECTORY "${build_dir}" DEPENDS ${egg_dependencies} ) - set(python_version "py${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") + set(python_version "py${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}") set(egg_name "${package_name}") set(egg_install_name "${egg_name}-${ARG_VERSION}") @@ -143,7 +145,7 @@ setup( add_custom_target( ament_cmake_python_build_${package_name}_scripts ALL - COMMAND ${PYTHON_EXECUTABLE} setup.py install_scripts -d scripts + COMMAND ${python_interpreter} setup.py install_scripts -d scripts WORKING_DIRECTORY "${build_dir}" DEPENDS ${egg_dependencies} ) @@ -168,11 +170,12 @@ setup( ) if(NOT ARG_SKIP_COMPILE) + get_executable_path(python_interpreter_config Python3::Interpreter CONFIGURE) # compile Python files install(CODE "execute_process( COMMAND - \"${PYTHON_EXECUTABLE}\" \"-m\" \"compileall\" + \"${python_interpreter_config}\" \"-m\" \"compileall\" \"${CMAKE_INSTALL_PREFIX}/${ARG_DESTINATION}/${package_name}\" )" ) diff --git a/ament_cmake_target_dependencies/CMakeLists.txt b/ament_cmake_target_dependencies/CMakeLists.txt index 5c842f54..0854fc68 100644 --- a/ament_cmake_target_dependencies/CMakeLists.txt +++ b/ament_cmake_target_dependencies/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_target_dependencies NONE) diff --git a/ament_cmake_test/CMakeLists.txt b/ament_cmake_test/CMakeLists.txt index 7e332cf2..52ad290f 100644 --- a/ament_cmake_test/CMakeLists.txt +++ b/ament_cmake_test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_test NONE) diff --git a/ament_cmake_test/cmake/ament_add_test.cmake b/ament_cmake_test/cmake/ament_add_test.cmake index e4ea3f07..a7dcea35 100644 --- a/ament_cmake_test/cmake/ament_add_test.cmake +++ b/ament_cmake_test/cmake/ament_add_test.cmake @@ -83,8 +83,9 @@ function(ament_add_test testname) set(ARG_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") endif() + get_executable_path(python_interpreter Python3::Interpreter BUILD) # wrap command with run_test script to ensure test result generation - set(cmd_wrapper "${PYTHON_EXECUTABLE}" "-u" "${ARG_RUNNER}" + set(cmd_wrapper "${python_interpreter}" "-u" "${ARG_RUNNER}" "${ARG_RESULT_FILE}" "--package-name" "${PROJECT_NAME}") if(ARG_SKIP_TEST) diff --git a/ament_cmake_version/CMakeLists.txt b/ament_cmake_version/CMakeLists.txt index 8037285a..ac5c1bb2 100644 --- a/ament_cmake_version/CMakeLists.txt +++ b/ament_cmake_version/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(ament_cmake_version NONE)