[kdelibs/KDE/4.14] cmake/modules: Don't rely on OLD policy behavior.
Stephen Kelly
steveire at gmail.com
Sun Jul 19 18:06:30 UTC 2015
Git commit 3fd71668f3f941742bba537946a37e2b3d345b93 by Stephen Kelly.
Committed on 19/07/2015 at 18:01.
Pushed by skelly into branch 'KDE/4.14'.
Don't rely on OLD policy behavior.
Port KDE4Macros away from use of the LOCATION target property.
It is never correct to set policies to OLD.
The other policies KDE4 sets to OLD will cause problems for KDE4 distros later.
They should have been fixed incrementally years ago instead:
http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/13376/focus=13511
Judging by the amount of policy warnings emitted when building kdelibs even
today, there is a lot of maintenance to do.
If the maintenance is not done, KDE4 will not build with newer cmake, and
distros may choose to package an old cmake version in order to build KDE4
with it.
CCMAIL: kde-buildsystem at kde.org
M +2 -2 cmake/modules/FindKDE4Internal.cmake
M +28 -12 cmake/modules/KDE4Macros.cmake
http://commits.kde.org/kdelibs/3fd71668f3f941742bba537946a37e2b3d345b93
diff --git a/cmake/modules/FindKDE4Internal.cmake b/cmake/modules/FindKDE4Internal.cmake
index a9aecfd..6f03eae 100644
--- a/cmake/modules/FindKDE4Internal.cmake
+++ b/cmake/modules/FindKDE4Internal.cmake
@@ -373,9 +373,9 @@ cmake_policy(SET CMP0011 OLD)
# in this directory over those from CMAKE_MODULE_PATH
cmake_policy(SET CMP0017 NEW)
-# since cmake 3.0: use of the LOCATION target property is disallowed while it is used in KDE4Macros.cmake
if (POLICY CMP0026)
- cmake_policy(SET CMP0026 OLD)
+ # Don't use the LOCATION target property of buildsystem targets.
+ cmake_policy(SET CMP0026 NEW)
endif (POLICY CMP0026)
# Only do something if it hasn't been found yet
diff --git a/cmake/modules/KDE4Macros.cmake b/cmake/modules/KDE4Macros.cmake
index 5b21344..9c82c12 100644
--- a/cmake/modules/KDE4Macros.cmake
+++ b/cmake/modules/KDE4Macros.cmake
@@ -589,7 +589,11 @@ macro (KDE4_HANDLE_RPATH_FOR_EXECUTABLE _target_NAME)
else (APPLE)
set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/:${LIB_INSTALL_DIR}:${KDE4_LIB_DIR}:${QT_LIBRARY_DIR}")
endif (APPLE)
- get_target_property(_executable ${_target_NAME} LOCATION )
+ if (NOT POLICY CMP0026)
+ get_target_property(_executable ${_target_NAME} LOCATION )
+ else()
+ set(_executable $<TARGET_FILE:${_target_NAME}>)
+ endif()
# use add_custom_target() to have the sh-wrapper generated during build time instead of cmake time
if (CMAKE_VERSION VERSION_GREATER 2.8.4)
@@ -617,11 +621,14 @@ macro (KDE4_HANDLE_RPATH_FOR_EXECUTABLE _target_NAME)
else (UNIX)
# under windows, set the property WRAPPER_SCRIPT just to the name of the executable
# maybe later this will change to a generated batch file (for setting the PATH so that the Qt libs are found)
- get_target_property(_executable ${_target_NAME} LOCATION )
+ if (NOT POLICY CMP0026)
+ get_target_property(_executable ${_target_NAME} LOCATION )
+ else()
+ set(_executable $<TARGET_FILE:${_target_NAME}>)
+ endif()
set_target_properties(${_target_NAME} PROPERTIES WRAPPER_SCRIPT ${_executable})
set(_ld_library_path "${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}\;${LIB_INSTALL_DIR}\;${KDE4_LIB_DIR}\;${QT_LIBRARY_DIR}")
- get_target_property(_executable ${_target_NAME} LOCATION )
# use add_custom_target() to have the batch-file-wrapper generated during build time instead of cmake time
add_custom_command(TARGET ${_target_NAME} POST_BUILD
@@ -876,28 +883,37 @@ macro (KDE4_ADD_UNIT_TEST _test_NAME)
endif(NOT using_qtest)
endforeach(_filename)
- get_target_property( loc ${_test_NAME} LOCATION )
if(WIN32)
- if(MSVC_IDE)
- STRING(REGEX REPLACE "\\$\\(.*\\)" "\${CTEST_CONFIGURATION_TYPE}" loc "${loc}")
+ if (NOT POLICY CMP0026)
+ get_target_property( loc ${_test_NAME} LOCATION )
+ if(MSVC_IDE)
+ STRING(REGEX REPLACE "\\$\\(.*\\)" "\${CTEST_CONFIGURATION_TYPE}" loc "${loc}")
+ endif()
+ # .bat because of rpath handling
+ set(_executable "${loc}.bat")
+ else()
+ set(_executable "$<TARGET_FILE:${_test_NAME}>.bat")
endif()
- # .bat because of rpath handling
- set(_executable "${loc}.bat")
else(WIN32)
if (Q_WS_MAC AND NOT _nogui)
set(_executable ${EXECUTABLE_OUTPUT_PATH}/${_test_NAME}.app/Contents/MacOS/${_test_NAME})
else (Q_WS_MAC AND NOT _nogui)
- # .shell because of rpath handling
- set(_executable "${loc}.shell")
+ if (NOT POLICY CMP0026)
+ get_target_property( loc ${_test_NAME} LOCATION )
+ # .shell because of rpath handling
+ set(_executable "${loc}.shell")
+ else()
+ set(_executable "$<TARGET_FILE:${_test_NAME}>.shell")
+ endif()
endif (Q_WS_MAC AND NOT _nogui)
endif(WIN32)
if (using_qtest AND KDE4_TEST_OUTPUT STREQUAL "xml")
#MESSAGE(STATUS "${_targetName} : Using QTestLib, can produce XML report.")
- add_test( ${_targetName} ${_executable} -xml -o ${_targetName}.tml)
+ add_test(NAME ${_targetName} COMMAND ${_executable} -xml -o ${_targetName}.tml)
else (using_qtest AND KDE4_TEST_OUTPUT STREQUAL "xml")
#MESSAGE(STATUS "${_targetName} : NOT using QTestLib, can't produce XML report, please use QTestLib to write your unit tests.")
- add_test( ${_targetName} ${_executable} )
+ add_test(NAME ${_targetName} COMMAND ${_executable} )
endif (using_qtest AND KDE4_TEST_OUTPUT STREQUAL "xml")
# add_test( ${_targetName} ${EXECUTABLE_OUTPUT_PATH}/${_test_NAME} -xml -o ${_test_NAME}.tml )
More information about the Kde-buildsystem
mailing list