Require CMake 2.8.9 for the qt5_use_modules function.
authorStephen Kelly <stephen.kelly@kdab.com>
Thu, 2 Aug 2012 08:07:19 +0000 (10:07 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 10 Aug 2012 19:57:47 +0000 (21:57 +0200)
The newer CMake version has the POSITION_INDEPENDENT_CODE property which is
what we need here. The CMake 2.8.8 implementation uses awkward and incomplete
string manipulation which I don't want to maintain for any amount of time
when Qt 5.0 is released.

Change-Id: If7ace9c6925ccdbf800f1863fa2368e55fa44d7f
Reviewed-by: Brad King <brad.king@kitware.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
src/corelib/Qt5CoreMacros.cmake
tests/auto/cmake/CMakeLists.txt

index 7cccefd..608c9be 100644 (file)
@@ -212,7 +212,7 @@ function(QT5_ADD_RESOURCES outfiles )
 endfunction()
 
 
-if (NOT CMAKE_VERSION VERSION_LESS 2.8.8)
+if (NOT CMAKE_VERSION VERSION_LESS 2.8.9)
     function(qt5_use_modules _target _link_type)
         if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE" )
             set(modules ${ARGN})
@@ -233,19 +233,6 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.8)
 
             if (Qt5_POSITION_INDEPENDENT_CODE)
                 set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE})
-                if (CMAKE_VERSION VERSION_LESS 2.8.9)
-                    # We can't just append to the COMPILE_FLAGS property. That creats a ';' separated list
-                    # which breaks the compile commmand line.
-                    # Ensure non-duplication here manually instead.
-                    get_property(_target_type TARGET ${_target} PROPERTY TYPE)
-                    if ("${_target_type}" STREQUAL "EXECUTABLE" AND Qt5${_module}_EXECUTABLE_COMPILE_FLAGS)
-                        get_target_property(_flags ${_target} COMPILE_FLAGS)
-                        string(FIND "${_flags}" "${Qt5${_module}_EXECUTABLE_COMPILE_FLAGS}" _find_result)
-                        if (NOT _find_result)
-                            set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "${_flags} ${Qt5${_module}_EXECUTABLE_COMPILE_FLAGS}")
-                        endif()
-                    endif()
-                endif()
             endif()
         endforeach()
     endfunction()
index d9eb683..99150f2 100644 (file)
@@ -47,11 +47,12 @@ find_package(Qt5Core REQUIRED)
 
 include("${_Qt5CTestMacros}")
 
-if(NOT ${CMAKE_VERSION} VERSION_LESS 2.8.8)
+if(NOT ${CMAKE_VERSION} VERSION_LESS 2.8.9)
     # Requires INCLUDE_DIRECTORIES target property in CMake 2.8.8
+    # and POSITION_INDEPENDENT_CODE target property in 2.8.9
     expect_pass(test_use_modules_function)
 else()
-    message("CMake version older than 2.8.8 (Found ${CMAKE_VERSION}). Not running test \"test_use_modules_function\"")
+    message("CMake version older than 2.8.9 (Found ${CMAKE_VERSION}). Not running test \"test_use_modules_function\"")
 endif()
 expect_pass(test_wrap_cpp_and_resources)
 expect_pass(test_dependent_modules)