diff options
Diffstat (limited to 'Tests')
74 files changed, 901 insertions, 154 deletions
diff --git a/Tests/CMakeCommands/CMakeLists.txt b/Tests/CMakeCommands/CMakeLists.txt new file mode 100644 index 0000000..aa400d0 --- /dev/null +++ b/Tests/CMakeCommands/CMakeLists.txt @@ -0,0 +1,11 @@ +macro(add_CMakeCommands_test test) + add_test(CMakeCommands.${test} ${CMAKE_CMAKE_COMMAND} + -DCMake_SOURCE_DIR=${CMake_SOURCE_DIR} # TODO: Remove + -Ddir=${CMAKE_CURRENT_BINARY_DIR}/${test} + -Dgen=${CMAKE_TEST_GENERATOR} + -P "${CMAKE_CURRENT_SOURCE_DIR}/${test}/test.cmake" + ) +endmacro() + +add_CMakeCommands_test(build_command) +add_CMakeCommands_test(find_package) diff --git a/Tests/CMakeCommands/build_command/RunCMake.cmake b/Tests/CMakeCommands/build_command/test.cmake index 55d9359..55d9359 100644 --- a/Tests/CMakeCommands/build_command/RunCMake.cmake +++ b/Tests/CMakeCommands/build_command/test.cmake diff --git a/Tests/CMakeCommands/find_package/CMakeLists.txt b/Tests/CMakeCommands/find_package/CMakeLists.txt new file mode 100644 index 0000000..c2deed0 --- /dev/null +++ b/Tests/CMakeCommands/find_package/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${TEST} NONE) +include(${TEST}.cmake) diff --git a/Tests/CMakeCommands/find_package/MissingConfig-stderr.txt b/Tests/CMakeCommands/find_package/MissingConfig-stderr.txt new file mode 100644 index 0000000..0d14dcb --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingConfig-stderr.txt @@ -0,0 +1,13 @@ +CMake Warning at MissingConfig.cmake:1 \(find_package\): + Could not find a package configuration file provided by "NotHere" with any + of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/CMakeCommands/find_package/MissingConfig.cmake b/Tests/CMakeCommands/find_package/MissingConfig.cmake new file mode 100644 index 0000000..3cebef1 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingConfig.cmake @@ -0,0 +1 @@ +find_package(NotHere CONFIG) diff --git a/Tests/CMakeCommands/find_package/MissingConfigOneName-stderr.txt b/Tests/CMakeCommands/find_package/MissingConfigOneName-stderr.txt new file mode 100644 index 0000000..10e71fa --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingConfigOneName-stderr.txt @@ -0,0 +1,10 @@ +CMake Warning at MissingConfigOneName.cmake:1 \(find_package\): + Could not find a package configuration file named "NotHereConfig.cmake" + provided by package "NotHere". + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/CMakeCommands/find_package/MissingConfigOneName.cmake b/Tests/CMakeCommands/find_package/MissingConfigOneName.cmake new file mode 100644 index 0000000..11676a9 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingConfigOneName.cmake @@ -0,0 +1 @@ +find_package(NotHere CONFIGS NotHereConfig.cmake) diff --git a/Tests/CMakeCommands/find_package/MissingConfigRequired-result.txt b/Tests/CMakeCommands/find_package/MissingConfigRequired-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingConfigRequired-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/CMakeCommands/find_package/MissingConfigRequired-stderr.txt b/Tests/CMakeCommands/find_package/MissingConfigRequired-stderr.txt new file mode 100644 index 0000000..56325d8 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingConfigRequired-stderr.txt @@ -0,0 +1,13 @@ +CMake Error at MissingConfigRequired.cmake:1 \(find_package\): + Could not find a package configuration file provided by "NotHere" with any + of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/CMakeCommands/find_package/MissingConfigRequired.cmake b/Tests/CMakeCommands/find_package/MissingConfigRequired.cmake new file mode 100644 index 0000000..3c28552 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingConfigRequired.cmake @@ -0,0 +1 @@ +find_package(NotHere CONFIG REQUIRED) diff --git a/Tests/CMakeCommands/find_package/MissingConfigVersion-stderr.txt b/Tests/CMakeCommands/find_package/MissingConfigVersion-stderr.txt new file mode 100644 index 0000000..2f5086e --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingConfigVersion-stderr.txt @@ -0,0 +1,13 @@ +CMake Warning at MissingConfigVersion.cmake:1 \(find_package\): + Could not find a package configuration file provided by "NotHere" + \(requested version 1\.2\) with any of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/CMakeCommands/find_package/MissingConfigVersion.cmake b/Tests/CMakeCommands/find_package/MissingConfigVersion.cmake new file mode 100644 index 0000000..ac35a79 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingConfigVersion.cmake @@ -0,0 +1 @@ +find_package(NotHere 1.2 CONFIG) diff --git a/Tests/CMakeCommands/find_package/MissingModule-stderr.txt b/Tests/CMakeCommands/find_package/MissingModule-stderr.txt new file mode 100644 index 0000000..71b5eae --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingModule-stderr.txt @@ -0,0 +1,21 @@ +CMake Warning at MissingModule.cmake:1 \(find_package\): + No "FindNotHere.cmake" found in CMAKE_MODULE_PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Warning \(dev\) at MissingModule.cmake:1 \(find_package\): + FindNotHere.cmake must either be part of this project itself, in this case + adjust CMAKE_MODULE_PATH so that it points to the correct location inside + its source tree. + + Or it must be installed by a package which has already been found via + find_package\(\). In this case make sure that package has indeed been found + and adjust CMAKE_MODULE_PATH to contain the location where that package has + installed FindNotHere.cmake. This must be a location provided by that + package. This error in general means that the buildsystem of this project + is relying on a Find-module without ensuring that it is actually available. + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/CMakeCommands/find_package/MissingModule.cmake b/Tests/CMakeCommands/find_package/MissingModule.cmake new file mode 100644 index 0000000..420539f --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingModule.cmake @@ -0,0 +1 @@ +find_package(NotHere MODULE) diff --git a/Tests/CMakeCommands/find_package/MissingModuleRequired-result.txt b/Tests/CMakeCommands/find_package/MissingModuleRequired-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingModuleRequired-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/CMakeCommands/find_package/MissingModuleRequired-stderr.txt b/Tests/CMakeCommands/find_package/MissingModuleRequired-stderr.txt new file mode 100644 index 0000000..c3cd350 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingModuleRequired-stderr.txt @@ -0,0 +1,21 @@ +CMake Error at MissingModuleRequired.cmake:1 \(find_package\): + No "FindNotHere.cmake" found in CMAKE_MODULE_PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Warning \(dev\) at MissingModuleRequired.cmake:1 \(find_package\): + FindNotHere.cmake must either be part of this project itself, in this case + adjust CMAKE_MODULE_PATH so that it points to the correct location inside + its source tree. + + Or it must be installed by a package which has already been found via + find_package\(\). In this case make sure that package has indeed been found + and adjust CMAKE_MODULE_PATH to contain the location where that package has + installed FindNotHere.cmake. This must be a location provided by that + package. This error in general means that the buildsystem of this project + is relying on a Find-module without ensuring that it is actually available. + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/CMakeCommands/find_package/MissingModuleRequired.cmake b/Tests/CMakeCommands/find_package/MissingModuleRequired.cmake new file mode 100644 index 0000000..07f36c5 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingModuleRequired.cmake @@ -0,0 +1 @@ +find_package(NotHere MODULE REQUIRED) diff --git a/Tests/CMakeCommands/find_package/MissingNormal-stderr.txt b/Tests/CMakeCommands/find_package/MissingNormal-stderr.txt new file mode 100644 index 0000000..e5cbd97 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingNormal-stderr.txt @@ -0,0 +1,17 @@ +CMake Warning at MissingNormal.cmake:1 \(find_package\): + By not providing "FindNotHere.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "NotHere", but + CMake did not find one. + + Could not find a package configuration file provided by "NotHere" with any + of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/CMakeCommands/find_package/MissingNormal.cmake b/Tests/CMakeCommands/find_package/MissingNormal.cmake new file mode 100644 index 0000000..778cd38 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingNormal.cmake @@ -0,0 +1 @@ +find_package(NotHere) diff --git a/Tests/CMakeCommands/find_package/MissingNormalRequired-result.txt b/Tests/CMakeCommands/find_package/MissingNormalRequired-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingNormalRequired-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/CMakeCommands/find_package/MissingNormalRequired-stderr.txt b/Tests/CMakeCommands/find_package/MissingNormalRequired-stderr.txt new file mode 100644 index 0000000..ac52aec --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingNormalRequired-stderr.txt @@ -0,0 +1,17 @@ +CMake Error at MissingNormalRequired.cmake:1 \(find_package\): + By not providing "FindNotHere.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "NotHere", but + CMake did not find one. + + Could not find a package configuration file provided by "NotHere" with any + of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/CMakeCommands/find_package/MissingNormalRequired.cmake b/Tests/CMakeCommands/find_package/MissingNormalRequired.cmake new file mode 100644 index 0000000..5c33fca --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingNormalRequired.cmake @@ -0,0 +1 @@ +find_package(NotHere REQUIRED) diff --git a/Tests/CMakeCommands/find_package/MissingNormalVersion-stderr.txt b/Tests/CMakeCommands/find_package/MissingNormalVersion-stderr.txt new file mode 100644 index 0000000..36de800 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingNormalVersion-stderr.txt @@ -0,0 +1,17 @@ +CMake Warning at MissingNormalVersion.cmake:1 \(find_package\): + By not providing "FindNotHere.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "NotHere", but + CMake did not find one. + + Could not find a package configuration file provided by "NotHere" + \(requested version 1\.2\) with any of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/CMakeCommands/find_package/MissingNormalVersion.cmake b/Tests/CMakeCommands/find_package/MissingNormalVersion.cmake new file mode 100644 index 0000000..2d9ce4e --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingNormalVersion.cmake @@ -0,0 +1 @@ +find_package(NotHere 1.2) diff --git a/Tests/CMakeCommands/find_package/MissingNormalWarnNoModuleNew-stderr.txt b/Tests/CMakeCommands/find_package/MissingNormalWarnNoModuleNew-stderr.txt new file mode 100644 index 0000000..d34f23c --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingNormalWarnNoModuleNew-stderr.txt @@ -0,0 +1,30 @@ +CMake Warning \(dev\) at MissingNormalWarnNoModuleNew.cmake:3 \(find_package\): + find_package called without either MODULE or CONFIG option and no + FindNotHere.cmake module is in CMAKE_MODULE_PATH. Add MODULE to + exclusively request Module mode and fail if FindNotHere.cmake is missing. + Add CONFIG to exclusively request Config mode and search for a package + configuration file provided by NotHere \(NotHereConfig.cmake or + nothere-config.cmake\). + + \(Variable CMAKE_FIND_PACKAGE_WARN_NO_MODULE enabled this warning.\) +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Warning at MissingNormalWarnNoModuleNew.cmake:3 \(find_package\): + By not providing "FindNotHere.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "NotHere", but + CMake did not find one. + + Could not find a package configuration file provided by "NotHere" with any + of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/CMakeCommands/find_package/MissingNormalWarnNoModuleNew.cmake b/Tests/CMakeCommands/find_package/MissingNormalWarnNoModuleNew.cmake new file mode 100644 index 0000000..0211249 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingNormalWarnNoModuleNew.cmake @@ -0,0 +1,3 @@ +set(CMAKE_FIND_PACKAGE_WARN_NO_MODULE 1) +set(CMAKE_MINIMUM_REQUIRED_VERSION 2.8.8) +find_package(NotHere) diff --git a/Tests/CMakeCommands/find_package/MissingNormalWarnNoModuleOld-stderr.txt b/Tests/CMakeCommands/find_package/MissingNormalWarnNoModuleOld-stderr.txt new file mode 100644 index 0000000..b336b56 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingNormalWarnNoModuleOld-stderr.txt @@ -0,0 +1,29 @@ +CMake Warning \(dev\) at MissingNormalWarnNoModuleOld.cmake:2 \(find_package\): + find_package called without NO_MODULE option and no FindNotHere.cmake + module is in CMAKE_MODULE_PATH. Add NO_MODULE to exclusively request + Config mode and search for a package configuration file provided by NotHere + \(NotHereConfig.cmake or nothere-config.cmake\). Otherwise make + FindNotHere.cmake available in CMAKE_MODULE_PATH. + + \(Variable CMAKE_FIND_PACKAGE_WARN_NO_MODULE enabled this warning.\) +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Warning at MissingNormalWarnNoModuleOld.cmake:2 \(find_package\): + By not providing "FindNotHere.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "NotHere", but + CMake did not find one. + + Could not find a package configuration file provided by "NotHere" with any + of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/CMakeCommands/find_package/MissingNormalWarnNoModuleOld.cmake b/Tests/CMakeCommands/find_package/MissingNormalWarnNoModuleOld.cmake new file mode 100644 index 0000000..1c4a775 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MissingNormalWarnNoModuleOld.cmake @@ -0,0 +1,2 @@ +set(CMAKE_FIND_PACKAGE_WARN_NO_MODULE 1) +find_package(NotHere) diff --git a/Tests/CMakeCommands/find_package/MixedModeOptions-result.txt b/Tests/CMakeCommands/find_package/MixedModeOptions-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/CMakeCommands/find_package/MixedModeOptions-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/CMakeCommands/find_package/MixedModeOptions-stderr.txt b/Tests/CMakeCommands/find_package/MixedModeOptions-stderr.txt new file mode 100644 index 0000000..b867022 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MixedModeOptions-stderr.txt @@ -0,0 +1,14 @@ +CMake Error at MixedModeOptions.cmake:1 \(find_package\): + find_package given options exclusive to Module mode: + + MODULE + + and options exclusive to Config mode: + + CONFIG + CONFIGS + NO_DEFAULT_PATH + + The options are incompatible. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/CMakeCommands/find_package/MixedModeOptions.cmake b/Tests/CMakeCommands/find_package/MixedModeOptions.cmake new file mode 100644 index 0000000..7f78ee0 --- /dev/null +++ b/Tests/CMakeCommands/find_package/MixedModeOptions.cmake @@ -0,0 +1 @@ +find_package(NotHere MODULE CONFIG CONFIGS NotHereConfig.cmake NO_DEFAULT_PATH) diff --git a/Tests/CMakeCommands/find_package/test.cmake b/Tests/CMakeCommands/find_package/test.cmake new file mode 100644 index 0000000..dd1072e --- /dev/null +++ b/Tests/CMakeCommands/find_package/test.cmake @@ -0,0 +1,80 @@ +if(NOT DEFINED dir) + message(FATAL_ERROR "dir not defined") +endif() + +if(NOT DEFINED gen) + message(FATAL_ERROR "gen not defined") +endif() + +# TODO: Generalize this for other tests. +function(run_test test) + set(top_src "${CMAKE_CURRENT_LIST_DIR}") + set(top_bin "${dir}") + if(EXISTS ${top_src}/${test}-result.txt) + file(READ ${top_src}/${test}-result.txt expect_result) + string(REGEX REPLACE "\n+$" "" expect_result "${expect_result}") + else() + set(expect_result 0) + endif() + foreach(o out err) + if(EXISTS ${top_src}/${test}-std${o}.txt) + file(READ ${top_src}/${test}-std${o}.txt expect_std${o}) + string(REGEX REPLACE "\n+$" "" expect_std${o} "${expect_std${o}}") + else() + unset(expect_std${o}) + endif() + endforeach() + set(source_dir "${top_src}") + set(binary_dir "${top_bin}/${test}-build") + file(REMOVE_RECURSE "${binary_dir}") + file(MAKE_DIRECTORY "${binary_dir}") + execute_process( + COMMAND ${CMAKE_COMMAND} "${source_dir}" -G "${gen}" -DTEST=${test} + WORKING_DIRECTORY "${binary_dir}" + OUTPUT_VARIABLE actual_stdout + ERROR_VARIABLE actual_stderr + RESULT_VARIABLE actual_result + ) + set(msg "") + if(NOT "${actual_result}" STREQUAL "${expect_result}") + set(msg "${msg}Result is [${actual_result}], not [${expect_result}].\n") + endif() + foreach(o out err) + string(REGEX REPLACE "\n+$" "" actual_std${o} "${actual_std${o}}") + set(expect_${o} "") + if(DEFINED expect_std${o}) + if(NOT "${actual_std${o}}" MATCHES "${expect_std${o}}") + string(REGEX REPLACE "\n" "\n expect-${o}> " expect_${o} + " expect-${o}> ${expect_std${o}}") + set(expect_${o} "Expected std${o} to match:\n${expect_${o}}\n") + set(msg "${msg}std${o} does not match that expected.\n") + endif() + endif() + endforeach() + if(msg) + string(REGEX REPLACE "\n" "\n actual-out> " actual_out " actual-out> ${actual_stdout}") + string(REGEX REPLACE "\n" "\n actual-err> " actual_err " actual-err> ${actual_stderr}") + message(SEND_ERROR "${test} - FAILED:\n" + "${msg}" + "${expect_out}" + "Actual stdout:\n${actual_out}\n" + "${expect_err}" + "Actual stderr:\n${actual_err}\n" + ) + else() + message(STATUS "${test} - PASSED") + endif() +endfunction() + +run_test(MissingNormal) +run_test(MissingNormalRequired) +run_test(MissingNormalVersion) +run_test(MissingNormalWarnNoModuleOld) +run_test(MissingNormalWarnNoModuleNew) +run_test(MissingModule) +run_test(MissingModuleRequired) +run_test(MissingConfig) +run_test(MissingConfigOneName) +run_test(MissingConfigRequired) +run_test(MissingConfigVersion) +run_test(MixedModeOptions) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9c97828..07a6c36 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -16,6 +16,11 @@ MACRO(ADD_TEST_MACRO NAME COMMAND) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}") ENDMACRO(ADD_TEST_MACRO) +MACRO(REGEX_ESCAPE_STRING _OUT _IN) + # Escape special regex metacharacters with a backslash + string(REGEX REPLACE "([$^.[|*+?()]|])" "\\\\\\1" ${_OUT} "${_IN}") +ENDMACRO(REGEX_ESCAPE_STRING _OUT _IN) + INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake) # Fake a user home directory to avoid polluting the real one. @@ -48,6 +53,7 @@ IF(BUILD_TESTING) ADD_SUBDIRECTORY(CMakeLib) ADD_SUBDIRECTORY(CMakeOnly) + ADD_SUBDIRECTORY(CMakeCommands) ADD_SUBDIRECTORY(FindPackageModeMakefileTest) @@ -227,12 +233,35 @@ IF(BUILD_TESTING) LIST(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX}) + IF(NOT QT4_FOUND) + FIND_PACKAGE(Qt4) + ENDIF(NOT QT4_FOUND) + + IF(QT4_FOUND) + # test whether the Qt4 which has been found works, on some machines + # which run nightly builds there were errors like "wrong file format" + # for libQtCore.so. So first check it works, and only if it does add + # the automoc test. + INCLUDE(CheckCXXSourceCompiles) + SET(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") + SET(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + SET(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES}) + SET(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES}) + + CHECK_CXX_SOURCE_COMPILES("#include <QCoreApplication>\n int main() {return (qApp == 0 ? 0 : 1); }\n" + QT4_WORKS) + + SET(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}") + SET(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}") + ENDIF() # run test for BundleUtilities on supported platforms/compilers if(MSVC OR CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") if(NOT "${CMAKE_TEST_GENERATOR}" STREQUAL "Watcom WMake") + ADD_TEST(BundleUtilities ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/BundleUtilities" @@ -242,6 +271,24 @@ IF(BUILD_TESTING) --build-project BundleUtilities ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleUtilities") + + # run test for DeployQt4 on supported platforms/compilers (which depends on BundleUtilities) + # this test also depends on the existence of the standard qtiff plugin + if(QT4_WORKS AND QT_QTSQL_FOUND) + ADD_TEST(Qt4Deploy ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Qt4Deploy" + "${CMake_BINARY_DIR}/Tests/Qt4Deploy" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project Qt4Deploy + --build-options + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Deploy") + endif() + endif() endif() @@ -585,6 +632,14 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ set(CTEST_package_X11_TEST ${CTEST_TEST_CPACK}) set(CTEST_RUN_CPackComponentsForAll ${CTEST_TEST_CPACK}) + if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") + find_program(RPMBUILD NAMES rpmbuild) + endif(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") + # Do not try to build RPM + if (NOT RPMBUILD) + set(CPACK_BINARY_RPM OFF) + endif(NOT RPMBUILD) + find_program(NSIS_MAKENSIS_EXECUTABLE NAMES makensis PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS] DOC "makensis program location" @@ -847,43 +902,20 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment") - IF(NOT QT4_FOUND) - FIND_PACKAGE(Qt4) - ENDIF(NOT QT4_FOUND) - - IF(QT4_FOUND) - # test whether the Qt4 which has been found works, on some machines - # which run nightly builds there were errors like "wrong file format" - # for libQtCore.so. So first check it works, and only if it does add - # the automoc test. - INCLUDE(CheckCXXSourceCompiles) - SET(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") - SET(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - SET(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES}) - SET(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES}) - - CHECK_CXX_SOURCE_COMPILES("#include <QCoreApplication>\n int main() {return (qApp == 0 ? 0 : 1); }\n" - QT4_WORKS_FOR_AUTOMOC_TEST) - - SET(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}") - SET(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}") - - IF(QT4_WORKS_FOR_AUTOMOC_TEST) - ADD_TEST(QtAutomoc ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/QtAutomoc" - "${CMake_BINARY_DIR}/Tests/QtAutomoc" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project QtAutomoc - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc" - --force-new-ctest-process - --build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} - --test-command ${CMAKE_CTEST_COMMAND} -V - ) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc") - ENDIF() + IF(QT4_WORKS AND QT_QTGUI_FOUND) + ADD_TEST(QtAutomoc ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutomoc" + "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project QtAutomoc + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --force-new-ctest-process + --build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + --test-command ${CMAKE_CTEST_COMMAND} -V + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc") ENDIF() ADD_TEST(ExternalProject ${CMAKE_CTEST_COMMAND} @@ -1306,6 +1338,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endif() IF(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio") + IF(NOT MSVC60) + ADD_TEST_MACRO(SBCS SBCS) + ENDIF(NOT MSVC60) + ADD_TEST(VSExternalInclude ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/VSExternalInclude" @@ -1638,9 +1674,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake" -V --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/testOut1.log" ) + REGEX_ESCAPE_STRING(CTEST_TEST_ESCAPED_SOURCE_DIR "${CMake_SOURCE_DIR}") SET_TESTS_PROPERTIES(CTestTestConfigFileInBuildDir1 PROPERTIES DEPENDS CTestTestNoBuild PASS_REGULAR_EXPRESSION - "Reading ctest configuration file: ${CMake_SOURCE_DIR}.Tests.CTestTestConfigFileInBuildDir.CTestConfig.cmake") + "Reading ctest configuration file: ${CTEST_TEST_ESCAPED_SOURCE_DIR}.Tests.CTestTestConfigFileInBuildDir.CTestConfig.cmake") CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in" @@ -1654,10 +1691,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/test2.cmake" -V --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/testOut2.log" ) + REGEX_ESCAPE_STRING(CTEST_TEST_ESCAPED_BINARY_DIR "${CMake_BINARY_DIR}") SET_TESTS_PROPERTIES(CTestTestConfigFileInBuildDir2 PROPERTIES DEPENDS CTestTestNoBuild REQUIRED_FILES ${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/CTestConfig.cmake PASS_REGULAR_EXPRESSION - "Reading ctest configuration file: ${CMake_BINARY_DIR}.Tests.CTestTestConfigFileInBuildDir2.CTestConfig.cmake") + "Reading ctest configuration file: ${CTEST_TEST_ESCAPED_BINARY_DIR}.Tests.CTestTestConfigFileInBuildDir2.CTestConfig.cmake") # Use macro, not function so that build can still be driven by CMake 2.4. # After 2.6 is required, this could be a function without the extra 'set' @@ -1695,13 +1733,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ add_config_tests(Release) add_config_tests(RelWithDebInfo) - add_test(CMakeCommands.build_command ${CMAKE_CMAKE_COMMAND} - -DCMake_SOURCE_DIR=${CMake_SOURCE_DIR} - -Ddir=${CMake_BINARY_DIR}/Tests/CMakeCommands/build_command - -Dgen=${CMAKE_TEST_GENERATOR} - -P "${CMake_SOURCE_DIR}/Tests/CMakeCommands/build_command/RunCMake.cmake" - ) - ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries) CONFIGURE_FILE( diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt index f76f0d9..22b1b7b 100644 --- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -16,16 +16,16 @@ macro(do_find MODULE_NAME) endmacro(do_find) # It is only possible to use either Qt3 or Qt4 in one project. -# Since FindQt will complain if both are found we explicitely -# filter out this and FindQt3. FindKDE3 also depends on Qt3 and +# Since FindQt will complain if both are found we explicitly request Qt4 here +# and filter out FindQt3. FindKDE3 also depends on Qt3 and # is therefore also blocked +set(DESIRED_QT_VERSION 4) set(NO_QT4_MODULES "Qt3" "KDE3") # These modules are named Find*.cmake, but are nothing that works in # find_package(). set(NO_FIND_MODULES "PackageHandleStandardArgs" "PackageMessage") -set(DESIRED_QT_VERSION 4) foreach(FIND_MODULE ${FIND_MODULES}) string(REGEX REPLACE ".*/Find(.*)\\.cmake$" "\\1" MODULE_NAME "${FIND_MODULE}") @@ -45,24 +45,31 @@ if (NOT QT4_FOUND) endforeach(FIND_MODULE) endif (NOT QT4_FOUND) -# If any of these modules reported that it was found a version number should have been -# reported. -set(VERSIONS_REQUIRED - ALSA BISON BZIP2 CUPS CURL DOXYGEN EXPAT FLEX GETTEXT GIF GIT - ImageMagick JASPER LibArchive LIBXML2 PERL PostgreSQL SWIG TIFF ZLIB) - -foreach(VTEST ${VERSIONS_REQUIRED}) - if (${VTEST}_FOUND) - if (DEFINED ${VTEST}_VERSION_STRING) - if (NOT ${VTEST}_VERSION_STRING MATCHES "^[0-9][0-9\\.]*[A-Za-z_]*[0-9\\.]*$") - message(SEND_ERROR "${VTEST}_VERSION_STRING has unexpected content ${${VTEST}_VERSION_STRING}") - endif() - elseif (DEFINED ${VTEST}_VERSION) - if (NOT ${VTEST}_VERSION MATCHES "^[0-9][0-9\\.]*[A-Za-z_]*[0-9\\.]*$") - message(SEND_ERROR "${VTEST}_VERSION has unexpected content ${${VTEST}_VERSION}") +macro(check_version_string MODULE_NAME VERSION_VAR) + if (${MODULE_NAME}_FOUND) + if (DEFINED ${VERSION_VAR}) + if (NOT ${VERSION_VAR} MATCHES "^[0-9][0-9\\.]*[-A-Za-z_\\+]*[0-9\\.]*$") + message(SEND_ERROR "${VERSION_VAR} has unexpected content ${${VERSION_VAR}}") endif() else() - message(SEND_ERROR "${VTEST}_FOUND is set but no version number is defined") + message(SEND_ERROR "${MODULE_NAME}_FOUND is set but no version number is defined") endif() - endif(${VTEST}_FOUND) + endif () +endmacro(check_version_string) + +# If any of these modules reported that it was found a version number should have been +# reported. + +foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HSPELL + JASPER LIBXML2 LIBXSLT PERL PostgreSQL TIFF ZLIB) + check_version_string(${VTEST} ${VTEST}_VERSION_STRING) endforeach(VTEST) + +foreach(VTEST BISON Boost CUDA DOXYGEN FLEX GIF GTK2 LibArchive OPENSCENEGRAPH + RUBY SWIG) + check_version_string(${VTEST} ${VTEST}_VERSION) +endforeach(VTEST) + +check_version_string(PYTHONINTERP PYTHON_VERSION_STRING) +check_version_string(SUBVERSION Subversion_VERSION_SVN) +check_version_string(PKGCONFIG PKG_CONFIG_VERSION_STRING) diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index 4407efb..a1551ca 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -22,3 +22,9 @@ add_CMakeOnly_test(CheckLanguage) add_CMakeOnly_test(AllFindModules) add_CMakeOnly_test(TargetScope) + +add_test(CMakeOnly.ProjectInclude ${CMAKE_CMAKE_COMMAND} + -DTEST=ProjectInclude + -DCMAKE_ARGS=-DCMAKE_PROJECT_ProjectInclude_INCLUDE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectInclude/include.cmake + -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake + ) diff --git a/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt b/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt new file mode 100644 index 0000000..a9abb4a --- /dev/null +++ b/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt @@ -0,0 +1,4 @@ +project(ProjectInclude) +if(NOT AUTO_INCLUDE) + message(FATAL_ERROR "include file not found") +endif() diff --git a/Tests/CMakeOnly/ProjectInclude/include.cmake b/Tests/CMakeOnly/ProjectInclude/include.cmake new file mode 100644 index 0000000..527ebe7 --- /dev/null +++ b/Tests/CMakeOnly/ProjectInclude/include.cmake @@ -0,0 +1 @@ +set(AUTO_INCLUDE TRUE) diff --git a/Tests/CMakeOnly/Test.cmake.in b/Tests/CMakeOnly/Test.cmake.in index aa2d093..42af068 100644 --- a/Tests/CMakeOnly/Test.cmake.in +++ b/Tests/CMakeOnly/Test.cmake.in @@ -3,7 +3,8 @@ set(binary_dir "@CMAKE_CURRENT_BINARY_DIR@/${TEST}-build") file(REMOVE_RECURSE "${binary_dir}") file(MAKE_DIRECTORY "${binary_dir}") execute_process( - COMMAND ${CMAKE_COMMAND} "${source_dir}" -G "@CMAKE_TEST_GENERATOR@" + COMMAND ${CMAKE_COMMAND} ${CMAKE_ARGS} + "${source_dir}" -G "@CMAKE_TEST_GENERATOR@" WORKING_DIRECTORY "${binary_dir}" RESULT_VARIABLE result ) diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index fc1426e..c42c490 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -22,6 +22,7 @@ AddCMakeTest(ConfigureFile "") AddCMakeTest(SeparateArguments "") AddCMakeTest(ImplicitLinkInfo "") AddCMakeTest(ModuleNotices "") +AddCMakeTest(GetProperty "") AddCMakeTest(If "") AddCMakeTest(String "") AddCMakeTest(Math "") @@ -29,6 +30,7 @@ AddCMakeTest(CMakeMinimumRequired "") AddCMakeTest(CompilerIdVendor "") AddCMakeTest(ProcessorCount "") AddCMakeTest(PushCheckState "") +AddCMakeTest(While "") AddCMakeTest(FileDownload "") set_property(TEST CMake.FileDownload PROPERTY @@ -55,14 +57,13 @@ AddCMakeTest(GetPrerequisites "${GetPrerequisites_PreArgs}") # suite. It detects if any changes have been made to the CMake source tree # by any previous configure, build or test steps. # -if(do_cvs_tests OR GIT_EXECUTABLE) +if(GIT_EXECUTABLE) string(REPLACE "\\" "/" ENV_HOME "$ENV{HOME}") set(CheckSourceTree_PreArgs "-DCMake_BINARY_DIR:PATH=${CMake_BINARY_DIR}" "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}" - "-DCVS_EXECUTABLE:STRING=${CVS_EXECUTABLE}" "-DGIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}" "-DHOME:STRING=${ENV_HOME}" ) AddCMakeTest(CheckSourceTree "${CheckSourceTree_PreArgs}") -endif(do_cvs_tests OR GIT_EXECUTABLE) +endif() diff --git a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in index 73f8b01..59b2890 100644 --- a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in +++ b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in @@ -5,7 +5,6 @@ message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") message("") message("CMake_BINARY_DIR='${CMake_BINARY_DIR}'") message("CMake_SOURCE_DIR='${CMake_SOURCE_DIR}'") -message("CVS_EXECUTABLE='${CVS_EXECUTABLE}'") message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'") message("HOME='${HOME}'") message("ENV{DASHBOARD_TEST_FROM_CTEST}='$ENV{DASHBOARD_TEST_FROM_CTEST}'") @@ -43,7 +42,7 @@ message("in_source_build='${in_source_build}'") message("") -# If this does not appear to be a git or CVS checkout, just pass the test here +# If this does not appear to be a git checkout, just pass the test here # and now. (Do not let the test fail if it is run in a tree *exported* from a # repository or unpacked from a .zip file source installer...) # @@ -52,29 +51,13 @@ if(EXISTS "${CMake_SOURCE_DIR}/.git") set(is_git_checkout 1) endif() -set(is_cvs_checkout 0) -if(EXISTS "${CMake_SOURCE_DIR}/CVS/Root") - set(is_cvs_checkout 1) -endif() - message("is_git_checkout='${is_git_checkout}'") -message("is_cvs_checkout='${is_cvs_checkout}'") message("") -if(NOT is_cvs_checkout) if(NOT is_git_checkout) - message("source tree is neither git nor CVS checkout... test passes by early return...") + message("source tree is not a git checkout... test passes by early return...") return() endif() -endif() - -if(is_cvs_checkout) -if(is_git_checkout) - message("warning: source tree has both git *and* CVS file system bits???") - # should this condition be a FATAL_ERROR test failure...? -endif() -endif() - # This test looks for the following types of changes in the source tree: # @@ -83,51 +66,13 @@ set(conflicts 0) set(modifications 0) set(nonadditions 0) -# ov == output variable... conditionally filled in by either cvs or git below: +# ov == output variable... conditionally filled in by either git below: # set(cmd "") set(ov "") set(ev "") set(rv "") - -if(is_cvs_checkout AND CVS_EXECUTABLE) - # Check with "cvs -q -n up -dP" if there are any local modifications to the - # CMake source tree: - # - message("=============================================================================") - message("This is a cvs checkout, using cvs to verify source tree....") - message("") - - execute_process(COMMAND ${CVS_EXECUTABLE} --version - WORKING_DIRECTORY ${CMake_SOURCE_DIR} - OUTPUT_VARIABLE version_output - OUTPUT_STRIP_TRAILING_WHITESPACE) - message("=== output of 'cvs --version' ===") - message("${version_output}") - message("=== end output ===") - message("") - - file(READ "${CMake_SOURCE_DIR}/CVS/Root" contents) - message("=== content of CVS/Root ===") - message("${contents}") - message("=== end content ===") - message("") - - file(READ "${CMake_SOURCE_DIR}/CVS/Repository" contents) - message("=== content of CVS/Repository ===") - message("${contents}") - message("=== end content ===") - message("") - - message("Copy/paste this command to reproduce:") - message("cd \"${CMake_SOURCE_DIR}\" && \"${CVS_EXECUTABLE}\" -q -n up -dP") - message("") - - set(cmd ${CVS_EXECUTABLE} -q -n up -dP) -endif() - - # If no GIT_EXECUTABLE, see if we can figure out which git was used # for the ctest_update step on this dashboard... # @@ -268,8 +213,8 @@ endif() if(cmd) - # Use the HOME value passed in to the script for calling cvs/git so it can - # find its .cvspass or user/global config settings... + # Use the HOME value passed in to the script for calling git so it can + # find its user/global config settings... # set(original_ENV_HOME "$ENV{HOME}") set(ENV{HOME} "${HOME}") @@ -322,28 +267,6 @@ if(NOT ov STREQUAL "") endif() if(consider) - if(is_cvs_checkout) - if(line MATCHES "^A ") - message(" locally added file/directory detected...") - set(additions 1) - endif() - - if(line MATCHES "^C ") - message(" conflict detected...") - set(conflicts 1) - endif() - - if(line MATCHES "^M ") - message(" locally modified file detected...") - set(modifications 1) - endif() - - if(line MATCHES "^\\? ") - message(" locally non-added file/directory detected...") - set(nonadditions 1) - endif() - endif() - if(is_git_checkout) if(line MATCHES "^#[ \t]*modified:") message(" locally modified file detected...") diff --git a/Tests/CMakeTests/GetProperty-Bad-Argument.cmake b/Tests/CMakeTests/GetProperty-Bad-Argument.cmake new file mode 100644 index 0000000..382dabb --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Bad-Argument.cmake @@ -0,0 +1 @@ +get_property(FOO GLOBAL PROPERTY FOO FOO) diff --git a/Tests/CMakeTests/GetProperty-Bad-Directory.cmake b/Tests/CMakeTests/GetProperty-Bad-Directory.cmake new file mode 100644 index 0000000..cdbfa80 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Bad-Directory.cmake @@ -0,0 +1 @@ +get_property(FOO DIRECTORY NonExistentSubDir PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-Bad-Scope.cmake b/Tests/CMakeTests/GetProperty-Bad-Scope.cmake new file mode 100644 index 0000000..ea8566b --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Bad-Scope.cmake @@ -0,0 +1 @@ +get_property(FOO FOO FOO) diff --git a/Tests/CMakeTests/GetProperty-Bad-Target.cmake b/Tests/CMakeTests/GetProperty-Bad-Target.cmake new file mode 100644 index 0000000..9992dab --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Bad-Target.cmake @@ -0,0 +1 @@ +get_property(FOO TARGET FOO PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-Bad-Test.cmake b/Tests/CMakeTests/GetProperty-Bad-Test.cmake new file mode 100644 index 0000000..44bf3eb --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Bad-Test.cmake @@ -0,0 +1 @@ +get_property(FOO TEST FOO PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-Doc-Properties.cmake b/Tests/CMakeTests/GetProperty-Doc-Properties.cmake new file mode 100644 index 0000000..6c2c362 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Doc-Properties.cmake @@ -0,0 +1,10 @@ +get_property(FOO_BRIEF GLOBAL PROPERTY FOO BRIEF_DOCS) +get_property(FOO_FULL GLOBAL PROPERTY FOO FULL_DOCS) + +if (NOT FOO_BRIEF STREQUAL "NOTFOUND") + message(SEND_ERROR "property FOO has BRIEF_DOCS set to '${FOO_BRIEF}'") +endif () + +if (NOT FOO_FULL STREQUAL "NOTFOUND") + message(SEND_ERROR "property FOO has FULL_DOCS set to '${FOO_FULL}'") +endif () diff --git a/Tests/CMakeTests/GetProperty-Global-Name.cmake b/Tests/CMakeTests/GetProperty-Global-Name.cmake new file mode 100644 index 0000000..497700c --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Global-Name.cmake @@ -0,0 +1 @@ +get_property(FOO GLOBAL FOO PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-Missing-Argument.cmake b/Tests/CMakeTests/GetProperty-Missing-Argument.cmake new file mode 100644 index 0000000..f0d004d --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Missing-Argument.cmake @@ -0,0 +1 @@ +get_property() diff --git a/Tests/CMakeTests/GetProperty-No-Cache.cmake b/Tests/CMakeTests/GetProperty-No-Cache.cmake new file mode 100644 index 0000000..9719fe7 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-No-Cache.cmake @@ -0,0 +1 @@ +get_property(FOO CACHE PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-No-Property.cmake b/Tests/CMakeTests/GetProperty-No-Property.cmake new file mode 100644 index 0000000..bee230d --- /dev/null +++ b/Tests/CMakeTests/GetProperty-No-Property.cmake @@ -0,0 +1 @@ +get_property(FOO GLOBAL PROPERTY) diff --git a/Tests/CMakeTests/GetProperty-No-Source.cmake b/Tests/CMakeTests/GetProperty-No-Source.cmake new file mode 100644 index 0000000..89773c8 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-No-Source.cmake @@ -0,0 +1 @@ +get_property(FOO SOURCE PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-No-Target.cmake b/Tests/CMakeTests/GetProperty-No-Target.cmake new file mode 100644 index 0000000..8f1fa23 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-No-Target.cmake @@ -0,0 +1 @@ +get_property(FOO TARGET PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-No-Test.cmake b/Tests/CMakeTests/GetProperty-No-Test.cmake new file mode 100644 index 0000000..045bd56 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-No-Test.cmake @@ -0,0 +1 @@ +get_property(FOO TEST PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-Variable-Name.cmake b/Tests/CMakeTests/GetProperty-Variable-Name.cmake new file mode 100644 index 0000000..9190f80 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Variable-Name.cmake @@ -0,0 +1 @@ +get_property(FOO VARIABLE FOO PROPERTY FOO) diff --git a/Tests/CMakeTests/GetPropertyTest.cmake.in b/Tests/CMakeTests/GetPropertyTest.cmake.in new file mode 100644 index 0000000..ab96e5b --- /dev/null +++ b/Tests/CMakeTests/GetPropertyTest.cmake.in @@ -0,0 +1,98 @@ +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") + +set(Missing-Argument-RESULT 1) +set(Missing-Argument-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Missing-Argument.cmake:1 \\(get_property\\):.*get_property called with incorrect number of arguments.*") + +check_cmake_test(GetProperty + Missing-Argument +) + +set(Bad-Scope-RESULT 1) +set(Bad-Scope-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Bad-Scope.cmake:1 \\(get_property\\):.*get_property given invalid scope FOO\\..*") + +check_cmake_test(GetProperty + Bad-Scope +) + +set(Bad-Argument-RESULT 1) +set(Bad-Argument-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Bad-Argument.cmake:1 \\(get_property\\):.*get_property given invalid argument \"FOO\"\\..*") + +check_cmake_test(GetProperty + Bad-Argument +) + +set(No-Property-RESULT 1) +set(No-Property-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-No-Property.cmake:1 \\(get_property\\):.*get_property not given a PROPERTY <name> argument\\..*") + +check_cmake_test(GetProperty + No-Property +) + +set(Doc-Properties-RESULT 0) + +check_cmake_test(GetProperty + Doc-Properties +) + +set(Global-Name-RESULT 1) +set(Global-Name-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Global-Name.cmake:1 \\(get_property\\):.*get_property given name for GLOBAL scope\\..*") + +check_cmake_test(GetProperty + Global-Name +) + +set(Bad-Directory-RESULT 1) +set(Bad-Directory-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Bad-Directory.cmake:1 \\(get_property\\):.*get_property DIRECTORY scope provided but requested directory was not.*found\\..*") + +check_cmake_test(GetProperty + Bad-Directory +) + +set(No-Target-RESULT 1) +set(No-Target-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-No-Target.cmake:1 \\(get_property\\):.*get_property not given name for TARGET scope\\..*") + +check_cmake_test(GetProperty + No-Target +) + +set(Bad-Target-RESULT 1) +set(Bad-Target-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Bad-Target.cmake:1 \\(get_property\\):.*get_property could not find TARGET FOO\\..*") + +check_cmake_test(GetProperty + Bad-Target +) + +set(No-Source-RESULT 1) +set(No-Source-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-No-Source.cmake:1 \\(get_property\\):.*get_property not given name for SOURCE scope\\..*") + +check_cmake_test(GetProperty + No-Source +) + +set(No-Test-RESULT 1) +set(No-Test-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-No-Test.cmake:1 \\(get_property\\):.*get_property not given name for TEST scope\\..*") + +check_cmake_test(GetProperty + No-Test +) + +set(Bad-Test-RESULT 1) +set(Bad-Test-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Bad-Test.cmake:1 \\(get_property\\):.*get_property given TEST name that does not exist: FOO.*") + +check_cmake_test(GetProperty + Bad-Test +) + +set(Variable-Name-RESULT 1) +set(Variable-Name-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Variable-Name.cmake:1 \\(get_property\\):.*get_property given name for VARIABLE scope\\..*") + +check_cmake_test(GetProperty + Variable-Name +) + +set(No-Cache-RESULT 1) +set(No-Cache-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-No-Cache.cmake:1 \\(get_property\\):.*get_property not given name for CACHE scope\\..*") + +check_cmake_test(GetProperty + No-Cache +) diff --git a/Tests/CMakeTests/While-Endwhile-Alone-Args.cmake b/Tests/CMakeTests/While-Endwhile-Alone-Args.cmake new file mode 100644 index 0000000..886d98c --- /dev/null +++ b/Tests/CMakeTests/While-Endwhile-Alone-Args.cmake @@ -0,0 +1 @@ +endwhile(a) diff --git a/Tests/CMakeTests/While-Endwhile-Alone.cmake b/Tests/CMakeTests/While-Endwhile-Alone.cmake new file mode 100644 index 0000000..82c09a0 --- /dev/null +++ b/Tests/CMakeTests/While-Endwhile-Alone.cmake @@ -0,0 +1 @@ +endwhile() diff --git a/Tests/CMakeTests/While-Endwhile-Mismatch.cmake b/Tests/CMakeTests/While-Endwhile-Mismatch.cmake new file mode 100644 index 0000000..5c338d6 --- /dev/null +++ b/Tests/CMakeTests/While-Endwhile-Mismatch.cmake @@ -0,0 +1,2 @@ +while(a) +endwhile(b) diff --git a/Tests/CMakeTests/While-Missing-Argument.cmake b/Tests/CMakeTests/While-Missing-Argument.cmake new file mode 100644 index 0000000..32eaa26 --- /dev/null +++ b/Tests/CMakeTests/While-Missing-Argument.cmake @@ -0,0 +1 @@ +while() diff --git a/Tests/CMakeTests/While-Missing-Endwhile.cmake b/Tests/CMakeTests/While-Missing-Endwhile.cmake new file mode 100644 index 0000000..1abaaaf --- /dev/null +++ b/Tests/CMakeTests/While-Missing-Endwhile.cmake @@ -0,0 +1 @@ +while(a) diff --git a/Tests/CMakeTests/WhileTest.cmake.in b/Tests/CMakeTests/WhileTest.cmake.in new file mode 100644 index 0000000..4693f2d --- /dev/null +++ b/Tests/CMakeTests/WhileTest.cmake.in @@ -0,0 +1,53 @@ +set(NUMBERS "") +set(COUNT 0) + +while(COUNT LESS 200) + set(NUMBERS "${NUMBERS} ${COUNT}") + set(COUNT "2${COUNT}") + + set(NCOUNT 3) + while(NCOUNT LESS 31) + set(NUMBERS "${NUMBERS} ${NCOUNT}") + set(NCOUNT "${NCOUNT}0") + endwhile() +endwhile(COUNT LESS 200) + +if(NOT NUMBERS STREQUAL " 0 3 30 20 3 30") + message(SEND_ERROR "while loop nesting error, result: '${NUMBERS}'") +endif() + +set(Missing-Argument-RESULT 1) +set(Missing-Argument-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?While-Missing-Argument.cmake:1 \\(while\\):.*while called with incorrect number of arguments.*") + +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") +check_cmake_test(While + Missing-Argument +) + +set(Missing-Endwhile-RESULT 1) +set(Missing-Endwhile-STDERR ".*CMake Error in (@CMAKE_CURRENT_SOURCE_DIR@/)?While-Missing-Endwhile.cmake:.*A logical block opening on the line.*(@CMAKE_CURRENT_SOURCE_DIR@/)?While-Missing-Endwhile.cmake:1 \\(while\\).*is not closed\\..*") + +check_cmake_test(While + Missing-Endwhile +) + +set(Endwhile-Mismatch-RESULT 0) +set(Endwhile-Mismatch-STDERR ".*CMake Warning \\(dev\\) in (@CMAKE_CURRENT_SOURCE_DIR@/)?While-Endwhile-Mismatch.cmake:.*A logical block opening on the line.*(@CMAKE_CURRENT_SOURCE_DIR@/)?While-Endwhile-Mismatch.cmake:1 \\(while\\).*with mis-matching arguments\\..*") + +check_cmake_test(While + Endwhile-Mismatch +) + +set(Endwhile-Alone-RESULT 1) +set(Endwhile-Alone-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?While-Endwhile-Alone.cmake:1 \\(endwhile\\):.*An ENDWHILE command was found outside of a proper WHILE ENDWHILE.*structure\\.\n.*$") + +check_cmake_test(While + Endwhile-Alone +) + +set(Endwhile-Alone-Args-RESULT 1) +set(Endwhile-Alone-Args-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?While-Endwhile-Alone-Args.cmake:1 \\(endwhile\\):.*An ENDWHILE command was found outside of a proper WHILE ENDWHILE.*structure\\. Or its arguments did not.*$") + +check_cmake_test(While + Endwhile-Alone-Args +) diff --git a/Tests/CTestUpdateCVS.cmake.in b/Tests/CTestUpdateCVS.cmake.in index a04673e..f7f5db6 100644 --- a/Tests/CTestUpdateCVS.cmake.in +++ b/Tests/CTestUpdateCVS.cmake.in @@ -18,6 +18,19 @@ set(CVS "@CVS_EXECUTABLE@") message(" cvs = ${CVS}") set(REPO ${TOP}/repo) + +# The MSYS cvs tool interprets "c:/" as a "machine:" name for SSH. +# Detect the MSYS cvs and convert the repo path to an MSYS path. +if(WIN32) + if(EXISTS "${CVS}") + file(STRINGS "${CVS}" cvs_is_msys LIMIT_COUNT 1 REGEX "[Mm][Ss][Yy][Ss]") + if(cvs_is_msys) + message(" '${CVS}' is from MSYS (contains '${cvs_is_msys}')") + string(REGEX REPLACE "^([A-Za-z]):" "/\\1" REPO "${REPO}") + endif() + endif() +endif() + set(CVSCMD ${CVS} -d${REPO}) # CVSNT requires an extra option to 'cvs init'. diff --git a/Tests/CTestUpdateHG.cmake.in b/Tests/CTestUpdateHG.cmake.in index 543ddd9..5a9daae 100644 --- a/Tests/CTestUpdateHG.cmake.in +++ b/Tests/CTestUpdateHG.cmake.in @@ -28,7 +28,7 @@ run_child( WORKING_DIRECTORY ${TOP}/repo.hg COMMAND ${HG} init ) -set(REPO file://${TOP}/repo.hg) +set(REPO file:///${TOP}/repo.hg) #----------------------------------------------------------------------------- # Import initial content into the repository. diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index b505019..ec3ad39 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -199,7 +199,9 @@ CONFIGURE_FILE( ${Complex_SOURCE_DIR}/Library/dummy ${Complex_BINARY_DIR}/Library/dummylib.lib COPYONLY IMMEDIATE) -FOREACH (ext ${CMAKE_SHLIB_SUFFIX};.so;.a;.sl) +FOREACH (ext ${CMAKE_SHLIB_SUFFIX};.so;.a;.sl + ${CMAKE_SHARED_LIBRARY_SUFFIX}.2 + ${CMAKE_STATIC_LIBRARY_SUFFIX}.2) CONFIGURE_FILE( ${Complex_SOURCE_DIR}/Library/dummy ${Complex_BINARY_DIR}/Library/libdummylib${ext} @@ -216,6 +218,34 @@ FIND_LIBRARY(FIND_DUMMY_LIB PATHS ${Complex_BINARY_DIR}/Library DOC "find dummy lib") +# This doesn't work for platforms that have a shared library and an import +# library, like Windows with .dll and .lib. Limit is to ".so" now because it's +# known to work there. +IF(CMAKE_SHARED_LIBRARY_SUFFIX STREQUAL ".so") + FIND_LIBRARY(FIND_DUMMY_SHLIB_VERSIONED + NAMES libdummylib${CMAKE_SHARED_LIBRARY_SUFFIX}.2 + PATHS ${Complex_BINARY_DIR}/Library + DOC "find versioned dummy shared lib" + NO_DEFAULT_PATH) + + IF(NOT FIND_DUMMY_SHLIB_VERSIONED MATCHES "/libdummylib${CMAKE_SHARED_LIBRARY_SUFFIX}.2") + MESSAGE(SEND_ERROR "FIND_DUMMY_SHLIB_VERSIONED is not set correctly: " + "${FIND_DUMMY_SHLIB_VERSIONED}") + ENDIF() +ENDIF() + +# Static library, should work everywhere +FIND_LIBRARY(FIND_DUMMY_STLIB_VERSIONED + NAMES libdummylib${CMAKE_STATIC_LIBRARY_SUFFIX}.2 + PATHS ${Complex_BINARY_DIR}/Library + DOC "find versioned dummy static lib" + NO_DEFAULT_PATH) + +IF(NOT FIND_DUMMY_STLIB_VERSIONED MATCHES "/libdummylib${CMAKE_STATIC_LIBRARY_SUFFIX}.2") + MESSAGE(SEND_ERROR "FIND_DUMMY_STLIB_VERSIONED is not set correctly: " + "${FIND_DUMMY_STLIB_VERSIONED}") +ENDIF() + # # Test SET_SOURCE_FILES_PROPERTIES # diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index e65e362..a21e1b0 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -137,3 +137,14 @@ add_library(imp_lib1 STATIC imp_lib1.c) target_link_libraries(imp_lib1 exp_testLib2) add_library(imp_lib1b STATIC imp_lib1.c) target_link_libraries(imp_lib1b bld_testLib2) + +#----------------------------------------------------------------------------- +# Test that handling imported targets, including transitive dependencies, +# works in CheckFunctionExists (...and hopefully all other try_compile() checks +include(CheckFunctionExists) +unset(HAVE_TESTLIB1_FUNCTION CACHE) +set(CMAKE_REQUIRED_LIBRARIES exp_testLib2) +check_function_exists(testLib1 HAVE_TESTLIB1_FUNCTION) +if (NOT HAVE_TESTLIB1_FUNCTION) + message(SEND_ERROR "Using imported target testLib2 in check_function_exists() failed !") +endif() diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index ac70129..7a76261 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -280,6 +280,18 @@ if(do_cvs_tests) set_property(TARGET ${proj} PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing") + # The MSYS cvs tool interprets "c:/" as a "machine:" name for SSH. + # Detect the MSYS cvs and convert the repo path to an MSYS path. + if(WIN32) + if(EXISTS "${CVS_EXECUTABLE}") + file(STRINGS "${CVS_EXECUTABLE}" cvs_is_msys LIMIT_COUNT 1 REGEX "[Mm][Ss][Yy][Ss]") + if(cvs_is_msys) + message(STATUS "'${CVS_EXECUTABLE}' is from MSYS (contains '${cvs_is_msys}')") + string(REGEX REPLACE "^([A-Za-z]):" "/\\1" local_cvs_repo "${local_cvs_repo}") + endif() + endif() + endif() + # CVS by date stamp: # set(proj TutorialStep1-CVS-20090626) diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index 60b8c22..60f5e5e 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -45,3 +45,5 @@ else() set_target_properties(IncludeDirectories PROPERTIES COMPILE_FLAGS "-ITarProp") endif() + +add_subdirectory(TargetIncludeDirectories) diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt new file mode 100644 index 0000000..2cf36f5 --- /dev/null +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt @@ -0,0 +1,26 @@ + +cmake_minimum_required(VERSION 2.8) + +project(TargetIncludeDirectories) + +macro(create_header _name) + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_name}") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_name}/${_name}.h" + "//${_name}.h + ") +endmacro() + +create_header(bar) +create_header(bat) +create_header(foo) +create_header(baz) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include_directories("${CMAKE_CURRENT_BINARY_DIR}/bar") + +add_executable(TargetIncludeDirectories main.cpp) +set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/bat") +set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/foo") + +include_directories("${CMAKE_CURRENT_BINARY_DIR}/baz") diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp new file mode 100644 index 0000000..8aa3532 --- /dev/null +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp @@ -0,0 +1,10 @@ + +#include "bar.h" +#include "bat.h" +#include "foo.h" +#include "baz.h" + +int main(int, char**) +{ + return 0; +} diff --git a/Tests/Qt4Deploy/CMakeLists.txt b/Tests/Qt4Deploy/CMakeLists.txt new file mode 100644 index 0000000..646ea9f --- /dev/null +++ b/Tests/Qt4Deploy/CMakeLists.txt @@ -0,0 +1,70 @@ +cmake_minimum_required(VERSION 2.8) + +project(Qt4Deploy) +set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install) + +find_package(Qt4 REQUIRED QtMain QtCore QtSql) +include(${QT_USE_FILE}) + +add_executable(testdeploy MACOSX_BUNDLE testdeploy.cpp) +target_link_libraries(testdeploy ${QT_LIBRARIES}) +set_target_properties(testdeploy PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") + +if(CMAKE_CONFIGURATION_TYPES AND QT_QTCORE_LIBRARY_RELEASE AND QT_QTCORE_LIBRARY_DEBUG) + # note: installing debug Qt libraries from a Qt installation configured with + # -debug-and-release not yet supported (very low priority). + install(CODE " + if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^([Dd][Ee][Bb][Uu][Gg])$\") + return() + endif() + ") +endif() + +# install the Qt4 app with qsqlite plugin +install(CODE "file(REMOVE_RECURSE \"${CMAKE_INSTALL_PREFIX}\")") +install(TARGETS testdeploy DESTINATION .) +include(../../Modules/DeployQt4.cmake) +if(APPLE) + install_qt4_executable(testdeploy.app "qsqlite") +elseif(WIN32) + install_qt4_executable(testdeploy.exe "qsqlite") +else() + install_qt4_executable(testdeploy "qsqlite") +endif() + + +# test depends on standard qsqlite plugin +if(QT_QSQLITE_PLUGIN_DEBUG OR QT_QSQLITE_PLUGIN_RELEASE) + + # test the deployed Qt application + if(APPLE) + install(CODE " + message(STATUS \"executing: ${CMAKE_INSTALL_PREFIX}/testdeploy.app/Contents/MacOS/testdeploy\") + execute_process(COMMAND \"${CMAKE_INSTALL_PREFIX}/testdeploy.app/Contents/MacOS/testdeploy\" + RESULT_VARIABLE result) + if(NOT result STREQUAL \"0\") + message(FATAL_ERROR \"error running testdeploy app\") + endif() + ") + else() + install(CODE " + message(STATUS \"executing: ${CMAKE_INSTALL_PREFIX}/testdeploy\") + execute_process(COMMAND \"${CMAKE_INSTALL_PREFIX}/testdeploy\" + RESULT_VARIABLE result) + if(NOT result STREQUAL \"0\") + message(FATAL_ERROR \"error running testdeploy app\") + endif() + ") + endif() + + # custom target to install and test the installation at build time + if(CMAKE_CONFIGURATION_TYPES) + set(install_config "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}") + endif() + + add_custom_target(testdeploy_test ALL + COMMAND ${CMAKE_COMMAND} ${install_config} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake + COMMENT "${CMAKE_COMMAND} ${install_config} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake" + DEPENDS testdeploy) + +endif() diff --git a/Tests/Qt4Deploy/testdeploy.cpp b/Tests/Qt4Deploy/testdeploy.cpp new file mode 100644 index 0000000..8b9c8d6 --- /dev/null +++ b/Tests/Qt4Deploy/testdeploy.cpp @@ -0,0 +1,29 @@ +#include <QCoreApplication> +#include <QSqlDatabase> +#include <QLibraryInfo> +#include <QDebug> +#include <QStringList> + +int main(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + + qDebug() << "App path:" << app.applicationDirPath(); + qDebug() << "Plugin path:" << QLibraryInfo::location(QLibraryInfo::PluginsPath); + + bool foundSqlite = false; + + qDebug() << "Supported Database Drivers:"; + foreach(const QString &sqlDriver, QSqlDatabase::drivers()) + { + qDebug() << " " << sqlDriver; + if(sqlDriver == "QSQLITE") + foundSqlite = true; + } + + if(foundSqlite) + qDebug() << "Found sqlite support from plugin."; + else + qDebug() << "Could not find sqlite support from plugin."; + return foundSqlite ? 0 : 1; +} diff --git a/Tests/README b/Tests/README new file mode 100644 index 0000000..9b0f5c1 --- /dev/null +++ b/Tests/README @@ -0,0 +1,34 @@ +If you think about adding a new testcase then here is a small checklist you +can run through to find a proper place for it. Go through the list from the +beginning and stop once you find something that matches your tests needs, +i.e. if you will test a module and only need the configure mode use the +instructions from section 2, not 3. + +1. Your testcase can run in CMake script mode, i.e. "cmake -P something" + +Put your test in Tests/CMakeTests/ directory as a .cmake.in file. It will be +put into the test binary directory by configure_file(... @ONLY) and run from +there. Use the AddCMakeTest() macro in Tests/CMakeTests/CMakeLists.txt to add +your test to the test runs. + +2. Your test needs CMake to run in configure mode, but will not build anything + +This includes tests that will build something using try_compile() and friends, +but nothing that expects add_executable(), add_library(), or add_test() to run. + +If this matches your test you should put it into the Tests/CMakeOnly/ directory. +Create a subdirectory named like your test and write the CMakeLists.txt you +need into that subdirectory. Use the add_CMakeOnly_test() macro from +Tests/CMakeOnly/CMakeLists.txt to add your test to the test runs. + +3. If you are testing something from the Modules directory + +Put your test in the Tests/Modules/ directory. Create a subdirectory there +named after your test. Use the ADD_TEST_MACRO macro from Tests/CMakeLists.txt +to add your test to the test run. If you have put your stuff in +Tests/Modules/Foo then you call it using ADD_TEST_MACRO(Module.Foo Foo). + +4. You are doing other stuff. + +Find a good place ;) In doubt mail to cmake-developers@cmake.org and ask for +advise. diff --git a/Tests/SBCS/CMakeLists.txt b/Tests/SBCS/CMakeLists.txt new file mode 100644 index 0000000..b3c3c2c --- /dev/null +++ b/Tests/SBCS/CMakeLists.txt @@ -0,0 +1,6 @@ +# a SBCS test case +project (SBCS) + +add_definitions(-D_SBCS) + +add_executable (SBCS SBCS.cxx) diff --git a/Tests/SBCS/SBCS.cxx b/Tests/SBCS/SBCS.cxx new file mode 100644 index 0000000..6ce2c9f --- /dev/null +++ b/Tests/SBCS/SBCS.cxx @@ -0,0 +1,22 @@ +// Test to verify that _SBCS being defined causes CharacterSet to be set to 0 (Single Byte Character Set) + +int main () +{ +#ifdef _UNICODE + bool UnicodeSet=true; +#else + bool UnicodeSet=false; +#endif + +#ifdef _MBCS + bool MBCSSet=true; +#else + bool MBCSSet=false; +#endif + + // if neither _UNICODE nor _MBCS is set, CharacterSet must be set to SBCS. + bool SBCSSet=(!UnicodeSet && !MBCSSet); + + // Reverse boolean to indicate error case correctly + return !SBCSSet; +} |