From e47fbace5be156683b905f82975ede8d12fa1848 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 16 Apr 2014 13:40:21 +0200 Subject: [PATCH] CMake: Check that executables in the linguist package exist before use. Change-Id: Ifaaff157a836e3ebfb94b563631b65a226ed0d8c Reviewed-by: Stephen Kelly --- src/linguist/Qt5LinguistToolsConfig.cmake.in | 32 ++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/linguist/Qt5LinguistToolsConfig.cmake.in b/src/linguist/Qt5LinguistToolsConfig.cmake.in index ce71646..ac598c2 100644 --- a/src/linguist/Qt5LinguistToolsConfig.cmake.in +++ b/src/linguist/Qt5LinguistToolsConfig.cmake.in @@ -27,27 +27,47 @@ get_filename_component(_qt5_linguisttools_install_prefix \"${CMAKE_CURRENT_LIST_ set(_qt5_linguisttools_install_prefix \"$$[QT_INSTALL_PREFIX]\") !!ENDIF +macro(_qt5_LinguistTools_check_file_exists file) + if(NOT EXISTS \"${file}\" ) + message(FATAL_ERROR \"The package \\\"Qt5LinguistTools\\\" references the file + \\\"${file}\\\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \\\"${CMAKE_CURRENT_LIST_FILE}\\\" +but not all the files it references. +\") + endif() +endmacro() + if (NOT TARGET Qt5::lrelease) add_executable(Qt5::lrelease IMPORTED) - set_target_properties(Qt5::lrelease PROPERTIES !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) - IMPORTED_LOCATION \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\" + set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\") !!ELSE - IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\" + set(imported_location \"$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\") !!ENDIF + _qt5_LinguistTools_check_file_exists(${imported_location}) + + set_target_properties(Qt5::lrelease PROPERTIES + IMPORTED_LOCATION ${imported_location} ) endif() if (NOT TARGET Qt5::lupdate) add_executable(Qt5::lupdate IMPORTED) - set_target_properties(Qt5::lupdate PROPERTIES !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) - IMPORTED_LOCATION \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\" + set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\") !!ELSE - IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\" + set(imported_location \"$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\") !!ENDIF + _qt5_LinguistTools_check_file_exists(${imported_location}) + + set_target_properties(Qt5::lupdate PROPERTIES + IMPORTED_LOCATION ${imported_location} ) endif() -- 2.7.4