From 6fe8a3d5a1c1f2b963fe25e9032b562f6c6467e6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 22 Oct 2012 09:32:24 +0200 Subject: CMake: Make qt5_use_modules a macro, not a function. Because qt5_use_modules is a function that does a find package which finds imported targets, things like this: qt5_use_modules(foo Sql) if (TARGET Qt5::Sql) message("Qt5Sql_FOUND: ${Qt5Sql_FOUND}") endif() will show Qt5Sql as being not found, even though the target is in scope. Fix that by making it a macro instead. Change-Id: If314bd5b4d3f769c6c7df5ff2c924eabd16dcc0e Reviewed-by: Alexander Neundorf Reviewed-by: Stephen Kelly --- src/corelib/Qt5CoreMacros.cmake | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/corelib/Qt5CoreMacros.cmake') diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 089445a184..614b79ab88 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -217,29 +217,29 @@ endfunction() if (NOT CMAKE_VERSION VERSION_LESS 2.8.9) - function(qt5_use_modules _target _link_type) + macro(qt5_use_modules _target _link_type) if (NOT TARGET ${_target}) message(FATAL_ERROR "The first argument to qt5_use_modules must be an existing target.") endif() if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE" ) - set(modules ${ARGN}) - set(link_type ${_link_type}) + set(_qt5_modules ${ARGN}) + set(_qt5_link_type ${_link_type}) else() - set(modules ${_link_type} ${ARGN}) + set(_qt5_modules ${_link_type} ${ARGN}) endif() - if ("${modules}" STREQUAL "") + if ("${_qt5_modules}" STREQUAL "") message(FATAL_ERROR "qt5_use_modules requires at least one Qt module to use.") endif() - foreach(_module ${modules}) + foreach(_module ${_qt5_modules}) if (NOT Qt5${_module}_FOUND) find_package(Qt5${_module} PATHS ${_qt5_corelib_install_prefix} NO_DEFAULT_PATH) if (NOT Qt5${_module}_FOUND) message(FATAL_ERROR "Can not use \"${_module}\" module which has not yet been found.") endif() endif() - target_link_libraries(${_target} ${link_type} ${Qt5${_module}_LIBRARIES}) + target_link_libraries(${_target} ${_qt5_link_type} ${Qt5${_module}_LIBRARIES}) set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_module}_INCLUDE_DIRS}) set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_module}_COMPILE_DEFINITIONS}) set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG) @@ -248,5 +248,5 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.9) set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE}) endif() endforeach() - endfunction() + endmacro() endif() -- cgit v1.2.3