Require CMake 2.8.4 or greater to build CMake

This allows the use of the $<TARGET_FILE:...> generator expression as a
replacement for the use of the LOCATION target property.  The use of the
LOCATION target property is now deprecated for in-build targets.

Also drop other checks for older CMake versions:

* Simplify cmake_set_target_folder macro.
* Use find_package(LibArchive) unconditionally.
* Simplify condition for running testVisualStudioSlnParser test.
* Convert two macros to functions.
* Unconditionally run the CTestTestRerunFailed test.
This commit is contained in:
Stephen Kelly 2013-10-11 00:02:24 +02:00 committed by Brad King
parent 872db622d6
commit 920ffbf50f
3 changed files with 15 additions and 44 deletions

View File

@ -9,8 +9,7 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information. # See the License for more information.
#============================================================================= #=============================================================================
cmake_minimum_required(VERSION 2.8.2 FATAL_ERROR) cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR)
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
if(POLICY CMP0025) if(POLICY CMP0025)
cmake_policy(SET CMP0025 NEW) cmake_policy(SET CMP0025 NEW)
endif() endif()
@ -196,16 +195,9 @@ mark_as_advanced(CMAKE_USE_FOLDERS)
macro(CMAKE_SET_TARGET_FOLDER tgt folder) macro(CMAKE_SET_TARGET_FOLDER tgt folder)
if(CMAKE_USE_FOLDERS) if(CMAKE_USE_FOLDERS)
set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(MSVC AND TARGET ${tgt})
# Really, I just want this to be an "if(TARGET ${tgt})" ...
# but I'm not sure that our min req'd., CMake 2.4.5 can handle
# that... so I'm just activating this for now, with a version
# compare, and only for MSVC builds.
if(MSVC)
if(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8)
set_property(TARGET "${tgt}" PROPERTY FOLDER "${folder}") set_property(TARGET "${tgt}" PROPERTY FOLDER "${folder}")
endif() endif()
endif()
else() else()
set_property(GLOBAL PROPERTY USE_FOLDERS OFF) set_property(GLOBAL PROPERTY USE_FOLDERS OFF)
endif() endif()
@ -326,11 +318,7 @@ macro (CMAKE_BUILD_UTILITIES)
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# Build or use system libarchive for CMake and CTest. # Build or use system libarchive for CMake and CTest.
if(CMAKE_USE_SYSTEM_LIBARCHIVE) if(CMAKE_USE_SYSTEM_LIBARCHIVE)
if(EXISTS ${CMAKE_ROOT}/Modules/FindLibArchive.cmake) # added in 2.8.3
find_package(LibArchive) find_package(LibArchive)
else()
include(${CMake_SOURCE_DIR}/Modules/FindLibArchive.cmake)
endif()
if(NOT LibArchive_FOUND) if(NOT LibArchive_FOUND)
message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!") message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!")
endif() endif()

View File

@ -12,7 +12,7 @@ set(CMakeLib_TESTS
testXMLSafe testXMLSafe
) )
if(WIN32 AND NOT UNIX) # Just if(WIN32) when CMake >= 2.8.4 is required if(WIN32)
list(APPEND CMakeLib_TESTS list(APPEND CMakeLib_TESTS
testVisualStudioSlnParser testVisualStudioSlnParser
) )

View File

@ -1985,12 +1985,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
"Process file.*foo.py.*Total LOC:.*13.*Percentage Coverage: 84.62.*" "Process file.*foo.py.*Total LOC:.*13.*Percentage Coverage: 84.62.*"
ENVIRONMENT COVFILE=) ENVIRONMENT COVFILE=)
# Use macro, not function so that build can still be driven by CMake 2.4. function(add_config_tests cfg)
# After 2.6 is required, this could be a function without the extra 'set'
# calls.
#
macro(add_config_tests cfg)
set(cfg "${cfg}")
set(base "${CMake_BINARY_DIR}/Tests/CTestConfig") set(base "${CMake_BINARY_DIR}/Tests/CTestConfig")
# Test -S script with a -C config arg to ctest: # Test -S script with a -C config arg to ctest:
@ -2014,7 +2009,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
add_test(CTestConfig.Dashboard.${cfg} ${CMAKE_CMAKE_COMMAND} add_test(CTestConfig.Dashboard.${cfg} ${CMAKE_CMAKE_COMMAND}
-P "${base}/${cfg}-dashboard.cmake" -VV -P "${base}/${cfg}-dashboard.cmake" -VV
) )
endmacro() endfunction()
add_config_tests(Debug) add_config_tests(Debug)
add_config_tests(MinSizeRel) add_config_tests(MinSizeRel)
@ -2165,15 +2160,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
set_tests_properties(CTestTestTimeout PROPERTIES set_tests_properties(CTestTestTimeout PROPERTIES
PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*CheckChild *\\.+ *Passed") PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*CheckChild *\\.+ *Passed")
# this test only runs correctly if WORKING_DIRECTORY is honored.
if (NOT CMAKE_VERSION VERSION_LESS "2.8.4")
add_test( add_test(
NAME CTestTestRerunFailed NAME CTestTestRerunFailed
COMMAND ${CMAKE_CTEST_COMMAND} --rerun-failed) COMMAND ${CMAKE_CTEST_COMMAND} --rerun-failed)
set_tests_properties(CTestTestRerunFailed PROPERTIES set_tests_properties(CTestTestRerunFailed PROPERTIES
PASS_REGULAR_EXPRESSION "1/1 Test #1: TestTimeout" DEPENDS CTestTestTimeout PASS_REGULAR_EXPRESSION "1/1 Test #1: TestTimeout" DEPENDS CTestTestTimeout
WORKING_DIRECTORY ${CMake_BINARY_DIR}/Tests/CTestTestTimeout) WORKING_DIRECTORY ${CMake_BINARY_DIR}/Tests/CTestTestTimeout)
endif ()
configure_file( configure_file(
"${CMake_SOURCE_DIR}/Tests/CTestTestZeroTimeout/test.cmake.in" "${CMake_SOURCE_DIR}/Tests/CTestTestZeroTimeout/test.cmake.in"
@ -2234,20 +2226,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
--output-log "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/testOutput.log" --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/testOutput.log"
) )
# Use macro, not function so that build can still be driven by CMake 2.4. function(add_failed_submit_test name source build in out log regex)
# After 2.6 is required, this could be a function without the extra 'set'
# calls.
#
macro(add_failed_submit_test name source build in out log regex)
# Have variables named source, build and drop_method because the
# configure_file call expects those variables to be defined.
#
set(source "${source}")
set(build "${build}")
configure_file("${in}" "${out}" @ONLY) configure_file("${in}" "${out}" @ONLY)
add_test(${name} ${CMAKE_CTEST_COMMAND} -S "${out}" -V --output-log "${log}") add_test(${name} ${CMAKE_CTEST_COMMAND} -S "${out}" -V --output-log "${log}")
set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${regex}") set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${regex}")
endmacro() endfunction()
set(regex "(Problems when submitting via S*CP") set(regex "(Problems when submitting via S*CP")
set(regex "${regex}|Error message was: ") set(regex "${regex}|Error message was: ")