diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,10 +46,17 @@ PURPOSE "Needed for building KI18n unless glibc is the system libc implementation" ) +# KF5I18NMacros.cmake only needs to know the python executable path. +# Due to CMake caching the variables, and KF5I18NMacros being included by KF5I18nConfig, +# we have to hardcode the PYTHON_EXECUTABLE path or anything depending on KF5I18n +# would be unable to find another Python version. +find_package(PythonInterp REQUIRED) +configure_file(cmake/KF5I18NMacros.cmake.in ${KI18n_BINARY_DIR}/cmake/KF5I18NMacros.cmake @ONLY) + # usually is called using find_package(KF5I18n), # KF5I18NMacros.cmake needs to know the scripts directory set(KF5I18n_DIR ${CMAKE_CURRENT_LIST_DIR}/cmake) -include(cmake/KF5I18NMacros.cmake) +include(${KI18n_BINARY_DIR}/cmake/KF5I18NMacros.cmake) remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY) if(MSVC) @@ -96,7 +103,7 @@ DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel) install( FILES - cmake/KF5I18NMacros.cmake + ${KI18n_BINARY_DIR}/cmake/KF5I18NMacros.cmake cmake/kf5i18nuic.cmake cmake/build-pofiles.cmake cmake/build-tsfiles.cmake diff --git a/cmake/KF5I18NMacros.cmake b/cmake/KF5I18NMacros.cmake.in rename from cmake/KF5I18NMacros.cmake rename to cmake/KF5I18NMacros.cmake.in --- a/cmake/KF5I18NMacros.cmake +++ b/cmake/KF5I18NMacros.cmake.in @@ -26,7 +26,8 @@ # SUCH DAMAGE. find_package(Gettext REQUIRED) -find_package(PythonInterp REQUIRED) + +set(KI18N_PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@") set(_ki18n_pmap_compile_script ${CMAKE_CURRENT_LIST_DIR}/ts-pmap-compile.py) set(_ki18n_uic_script ${CMAKE_CURRENT_LIST_DIR}/kf5i18nuic.cmake) @@ -115,7 +116,7 @@ add_custom_target(tsfiles-${pathmd5} ALL COMMENT "Generating ts..." COMMAND ${CMAKE_COMMAND} - -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} + -DPYTHON_EXECUTABLE=${KI18N_PYTHON_EXECUTABLE} -D_ki18n_pmap_compile_script=${_ki18n_pmap_compile_script} -DCOPY_TO=${CMAKE_CURRENT_BINARY_DIR}/${dirname} -DPO_DIR=${absolute_podir} @@ -157,7 +158,7 @@ set(pmapc_basename "${pmap_basename}c") set(pmapc_file "${lang}-${subpath}-${pmapc_basename}") add_custom_command(OUTPUT ${pmapc_file} - COMMAND ${PYTHON_EXECUTABLE} + COMMAND ${KI18N_PYTHON_EXECUTABLE} ARGS -B ${_ki18n_pmap_compile_script}