diff options
author | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 15:39:57 -0700 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 15:39:57 -0700 |
commit | 035c7fabc3b82cbc9a346c11abe2e9462b4c0379 (patch) | |
tree | 7e40f5a790eae329a8c5d3e59f046451767956ff /Tests/CMakeTests | |
download | cmake-035c7fabc3b82cbc9a346c11abe2e9462b4c0379.tar.gz cmake-035c7fabc3b82cbc9a346c11abe2e9462b4c0379.tar.bz2 cmake-035c7fabc3b82cbc9a346c11abe2e9462b4c0379.zip |
Imported Upstream version 2.8.9upstream/2.8.9
Diffstat (limited to 'Tests/CMakeTests')
101 files changed, 3184 insertions, 0 deletions
diff --git a/Tests/CMakeTests/.gitattributes b/Tests/CMakeTests/.gitattributes new file mode 100644 index 000000000..c34e350e5 --- /dev/null +++ b/Tests/CMakeTests/.gitattributes @@ -0,0 +1 @@ +File-HASH-Input.txt crlf=input diff --git a/Tests/CMakeTests/A/include/cmake_i_do_not_exist_in_the_system.h b/Tests/CMakeTests/A/include/cmake_i_do_not_exist_in_the_system.h new file mode 100644 index 000000000..2392aee71 --- /dev/null +++ b/Tests/CMakeTests/A/include/cmake_i_do_not_exist_in_the_system.h @@ -0,0 +1 @@ +/* empty header file */ diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt new file mode 100644 index 000000000..c42c490b0 --- /dev/null +++ b/Tests/CMakeTests/CMakeLists.txt @@ -0,0 +1,69 @@ +SET(CMAKE_EXECUTABLE "${CMake_BIN_DIR}/cmake") + + +MACRO(AddCMakeTest TestName PreArgs) + CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/${TestName}Test.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/${TestName}Test.cmake" @ONLY IMMEDIATE) + ADD_TEST(CMake.${TestName} ${CMAKE_EXECUTABLE} ${PreArgs} + -P "${CMAKE_CURRENT_BINARY_DIR}/${TestName}Test.cmake" ${ARGN}) +ENDMACRO(AddCMakeTest) + + +AddCMakeTest(List "") +AddCMakeTest(VariableWatch "") +AddCMakeTest(Include "") +AddCMakeTest(FindBase "") +AddCMakeTest(Toolchain "") +AddCMakeTest(GetFilenameComponentRealpath "") +AddCMakeTest(Version "") +AddCMakeTest(Message "") +AddCMakeTest(File "") +AddCMakeTest(ConfigureFile "") +AddCMakeTest(SeparateArguments "") +AddCMakeTest(ImplicitLinkInfo "") +AddCMakeTest(ModuleNotices "") +AddCMakeTest(GetProperty "") +AddCMakeTest(If "") +AddCMakeTest(String "") +AddCMakeTest(Math "") +AddCMakeTest(CMakeMinimumRequired "") +AddCMakeTest(CompilerIdVendor "") +AddCMakeTest(ProcessorCount "") +AddCMakeTest(PushCheckState "") +AddCMakeTest(While "") + +AddCMakeTest(FileDownload "") +set_property(TEST CMake.FileDownload PROPERTY + PASS_REGULAR_EXPRESSION "file already exists with expected MD5 sum" + ) + +AddCMakeTest(FileUpload "") + +if(HAVE_ELF_H) + AddCMakeTest(ELF "") +endif() + +SET(EndStuff_PreArgs + "-Ddir:STRING=${CMAKE_CURRENT_BINARY_DIR}/EndStuffTest" + ) +AddCMakeTest(EndStuff "${EndStuff_PreArgs}") + +SET(GetPrerequisites_PreArgs + "-DCTEST_CONFIGURATION_TYPE:STRING=\\\${CTEST_CONFIGURATION_TYPE}" + ) +AddCMakeTest(GetPrerequisites "${GetPrerequisites_PreArgs}") + +# Run CheckSourceTree as the very last test in the CMake/CTest/CPack test +# suite. It detects if any changes have been made to the CMake source tree +# by any previous configure, build or test steps. +# +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}" + "-DGIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}" + "-DHOME:STRING=${ENV_HOME}" + ) + AddCMakeTest(CheckSourceTree "${CheckSourceTree_PreArgs}") +endif() diff --git a/Tests/CMakeTests/CMakeMinimumRequiredTest.cmake.in b/Tests/CMakeTests/CMakeMinimumRequiredTest.cmake.in new file mode 100644 index 000000000..b83a779bb --- /dev/null +++ b/Tests/CMakeTests/CMakeMinimumRequiredTest.cmake.in @@ -0,0 +1,18 @@ +# Execute each test listed in: +# +set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/CMakeMinimumRequiredTestScript.cmake") +set(number_of_tests_expected 8) + +include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake") +execute_all_script_tests(${scriptname} number_of_tests_executed) + +# And verify that number_of_tests_executed is at least as many as we know +# about as of this writing... +# +message(STATUS "scriptname='${scriptname}'") +message(STATUS "number_of_tests_executed='${number_of_tests_executed}'") +message(STATUS "number_of_tests_expected='${number_of_tests_expected}'") + +if(number_of_tests_executed LESS number_of_tests_expected) + message(FATAL_ERROR "error: some test cases were skipped") +endif() diff --git a/Tests/CMakeTests/CMakeMinimumRequiredTestScript.cmake b/Tests/CMakeTests/CMakeMinimumRequiredTestScript.cmake new file mode 100644 index 000000000..d434d2901 --- /dev/null +++ b/Tests/CMakeTests/CMakeMinimumRequiredTestScript.cmake @@ -0,0 +1,31 @@ +message(STATUS "testname='${testname}'") + +if(testname STREQUAL empty) # pass + cmake_minimum_required() + +elseif(testname STREQUAL bogus) # fail + cmake_minimum_required(BOGUS) + +elseif(testname STREQUAL no_version) # fail + cmake_minimum_required(VERSION) + +elseif(testname STREQUAL no_version_before_fatal_error) # fail + cmake_minimum_required(VERSION FATAL_ERROR) + +elseif(testname STREQUAL bad_version) # fail + cmake_minimum_required(VERSION 2.blah.blah) + +elseif(testname STREQUAL worse_version) # fail + cmake_minimum_required(VERSION blah.blah.blah) + +elseif(testname STREQUAL future_version) # fail + math(EXPR major "${CMAKE_MAJOR_VERSION} + 1") + cmake_minimum_required(VERSION ${major}.2.1) + +elseif(testname STREQUAL unknown_arg) # fail + cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.0.0 SILLY) + +else() # fail + message(FATAL_ERROR "testname='${testname}' - error: no such test in '${CMAKE_CURRENT_LIST_FILE}'") + +endif() diff --git a/Tests/CMakeTests/CheckCMakeTest.cmake b/Tests/CMakeTests/CheckCMakeTest.cmake new file mode 100644 index 000000000..db9290522 --- /dev/null +++ b/Tests/CMakeTests/CheckCMakeTest.cmake @@ -0,0 +1,30 @@ +get_filename_component(CMakeTests_SRC_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +function(check_cmake_test prefix) + get_filename_component(CMakeTests_BIN_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) + foreach(test ${ARGN}) + message(STATUS "Test ${prefix}-${test}...") + execute_process( + COMMAND ${CMAKE_COMMAND} -P "${CMakeTests_SRC_DIR}/${prefix}-${test}.cmake" + WORKING_DIRECTORY "${CMakeTests_BIN_DIR}" + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + RESULT_VARIABLE result + ) + string(REGEX REPLACE "\n" "\n out> " out " out> ${stdout}") + string(REGEX REPLACE "\n" "\n err> " err " err> ${stderr}") + if(NOT "${result}" STREQUAL "${${test}-RESULT}") + message(FATAL_ERROR + "Test ${test} result is [${result}], not [${${test}-RESULT}].\n" + "Test ${test} output:\n" + "${out}\n" + "${err}") + endif() + if(${test}-STDERR AND NOT "${err}" MATCHES "${${test}-STDERR}") + message(FATAL_ERROR + "Test ${test} stderr does not match\n ${${test}-STDERR}\n" + "Test ${test} output:\n" + "${out}\n" + "${err}") + endif() + endforeach() +endfunction() diff --git a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in new file mode 100644 index 000000000..59b28904d --- /dev/null +++ b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in @@ -0,0 +1,357 @@ +# Check the CMake source tree and report anything suspicious... +# +message("=============================================================================") +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("GIT_EXECUTABLE='${GIT_EXECUTABLE}'") +message("HOME='${HOME}'") +message("ENV{DASHBOARD_TEST_FROM_CTEST}='$ENV{DASHBOARD_TEST_FROM_CTEST}'") +message("") +string(REPLACE "\\" "\\\\" HOME "${HOME}") + + +# Is the build directory the same as or underneath the source directory? +# (i.e. - is it an "in source" build?) +# +set(in_source_build 0) + +if(CMake_SOURCE_DIR STREQUAL "${CMake_BINARY_DIR}") + message("build dir *is* source dir") + set(in_source_build 1) +else() + string(LENGTH "${CMake_SOURCE_DIR}" src_len) + string(LENGTH "${CMake_BINARY_DIR}" bin_len) + + if(bin_len GREATER src_len) + math(EXPR substr_len "${src_len}+1") + string(SUBSTRING "${CMake_BINARY_DIR}" 0 ${substr_len} bin_dir) + if(bin_dir STREQUAL "${CMake_SOURCE_DIR}/") + message("build dir is under source dir") + set(in_source_build 1) + endif() + endif() +endif() + +message("src_len='${src_len}'") +message("bin_len='${bin_len}'") +message("substr_len='${substr_len}'") +message("bin_dir='${bin_dir}'") +message("in_source_build='${in_source_build}'") +message("") + + +# 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...) +# +set(is_git_checkout 0) +if(EXISTS "${CMake_SOURCE_DIR}/.git") + set(is_git_checkout 1) +endif() + +message("is_git_checkout='${is_git_checkout}'") +message("") + +if(NOT is_git_checkout) + message("source tree is not a git checkout... test passes by early return...") + return() +endif() + +# This test looks for the following types of changes in the source tree: +# +set(additions 0) +set(conflicts 0) +set(modifications 0) +set(nonadditions 0) + +# ov == output variable... conditionally filled in by either git below: +# +set(cmd "") +set(ov "") +set(ev "") +set(rv "") + +# If no GIT_EXECUTABLE, see if we can figure out which git was used +# for the ctest_update step on this dashboard... +# +if(is_git_checkout AND NOT GIT_EXECUTABLE) + set(ctest_ini_file "") + set(exe "") + + # Use the old name: + if(EXISTS "${CMake_BINARY_DIR}/DartConfiguration.tcl") + set(ctest_ini_file "${CMake_BINARY_DIR}/DartConfiguration.tcl") + endif() + + # But if it exists, prefer the new name: + if(EXISTS "${CMake_BINARY_DIR}/CTestConfiguration.ini") + set(ctest_ini_file "${CMake_BINARY_DIR}/CTestConfiguration.ini") + endif() + + # If there is a ctest ini file, read the update command or git command + # from it: + # + if(ctest_ini_file) + file(STRINGS "${ctest_ini_file}" line REGEX "^GITCommand: (.*)$") + string(REGEX REPLACE "^GITCommand: (.*)$" "\\1" line "${line}") + if("${line}" MATCHES "^\"") + string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}") + else() + string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}") + endif() + set(exe "${line}") + if("${exe}" STREQUAL "GITCOMMAND-NOTFOUND") + set(exe "") + endif() + if(exe) + message("info: GIT_EXECUTABLE set by 'GITCommand:' from '${ctest_ini_file}'") + endif() + + if(NOT exe) + file(STRINGS "${ctest_ini_file}" line REGEX "^UpdateCommand: (.*)$") + string(REGEX REPLACE "^UpdateCommand: (.*)$" "\\1" line "${line}") + if("${line}" MATCHES "^\"") + string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}") + else() + string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}") + endif() + set(exe "${line}") + if("${exe}" STREQUAL "GITCOMMAND-NOTFOUND") + set(exe "") + endif() + if(exe) + message("info: GIT_EXECUTABLE set by 'UpdateCommand:' from '${ctest_ini_file}'") + endif() + endif() + else() + message("info: no DartConfiguration.tcl or CTestConfiguration.ini file...") + endif() + + # If we have still not grokked the exe, look in the Update.xml file to see + # if we can parse it from there... + # + if(NOT exe) + file(GLOB_RECURSE update_xml_file "${CMake_BINARY_DIR}/Testing/Update.xml") + if(update_xml_file) + file(STRINGS "${update_xml_file}" line + REGEX "^.*<UpdateCommand>(.*)</UpdateCommand>$" LIMIT_COUNT 1) + string(REPLACE ""\;" "\"" line "${line}") + string(REGEX REPLACE "^.*<UpdateCommand>(.*)</UpdateCommand>$" "\\1" line "${line}") + if("${line}" MATCHES "^\"") + string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}") + else() + string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}") + endif() + if(line) + set(exe "${line}") + endif() + if(exe) + message("info: GIT_EXECUTABLE set by '<UpdateCommand>' from '${update_xml_file}'") + endif() + else() + message("info: no Update.xml file...") + endif() + endif() + + if(exe) + set(GIT_EXECUTABLE "${exe}") + message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'") + message("") + + if(NOT EXISTS "${GIT_EXECUTABLE}") + message(FATAL_ERROR "GIT_EXECUTABLE does not exist...") + endif() + else() + message(FATAL_ERROR "could not determine GIT_EXECUTABLE...") + endif() +endif() + + +if(is_git_checkout AND GIT_EXECUTABLE) + # Check with "git status" if there are any local modifications to the + # CMake source tree: + # + message("=============================================================================") + message("This is a git checkout, using git to verify source tree....") + message("") + + execute_process(COMMAND ${GIT_EXECUTABLE} --version + WORKING_DIRECTORY ${CMake_SOURCE_DIR} + OUTPUT_VARIABLE version_output + OUTPUT_STRIP_TRAILING_WHITESPACE) + message("=== output of 'git --version' ===") + message("${version_output}") + message("=== end output ===") + message("") + + execute_process(COMMAND ${GIT_EXECUTABLE} branch -a + WORKING_DIRECTORY ${CMake_SOURCE_DIR} + OUTPUT_VARIABLE git_branch_output + OUTPUT_STRIP_TRAILING_WHITESPACE) + message("=== output of 'git branch -a' ===") + message("${git_branch_output}") + message("=== end output ===") + message("") + + execute_process(COMMAND ${GIT_EXECUTABLE} log -1 + WORKING_DIRECTORY ${CMake_SOURCE_DIR} + OUTPUT_VARIABLE git_log_output + OUTPUT_STRIP_TRAILING_WHITESPACE) + message("=== output of 'git log -1' ===") + message("${git_log_output}") + message("=== end output ===") + message("") + + message("Copy/paste this command to reproduce:") + message("cd \"${CMake_SOURCE_DIR}\" && \"${GIT_EXECUTABLE}\" status") + message("") + + set(cmd ${GIT_EXECUTABLE} status) +endif() + + +if(cmd) + # 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}") + + execute_process(COMMAND ${cmd} + WORKING_DIRECTORY ${CMake_SOURCE_DIR} + OUTPUT_VARIABLE ov + ERROR_VARIABLE ev + RESULT_VARIABLE rv) + + set(ENV{HOME} "${original_ENV_HOME}") + + message("Results of running ${cmd}") + message("rv='${rv}'") + message("ov='${ov}'") + message("ev='${ev}'") + message("") + + if(NOT rv STREQUAL 0) + if(is_git_checkout AND (rv STREQUAL "1")) + # Many builds of git return "1" from a "nothing is changed" git status call... + # Do not fail with an error for rv==1 with git... + else() + message(FATAL_ERROR "error: ${cmd} attempt failed... (see output above)") + endif() + endif() +else() + message(FATAL_ERROR "error: no COMMAND to run to analyze source tree...") +endif() + + +# Analyze output: +# +if(NOT ov STREQUAL "") + string(REPLACE ";" "\\\\;" lines "${ov}") + string(REPLACE "\n" "E;" lines "${lines}") + + foreach(line ${lines}) + message("'${line}'") + + # But do not consider files that exist just because some user poked around + # the file system with Windows Explorer or with the Finder from a Mac... + # ('Thumbs.db' and '.DS_Store' files...) + # + set(consider 1) + set(ignore_files_regex "^(. |.*(/|\\\\))(\\.DS_Store|Thumbs.db)E$") + if(line MATCHES "${ignore_files_regex}") + message(" line matches '${ignore_files_regex}' -- not considered") + set(consider 0) + endif() + + if(consider) + if(is_git_checkout) + if(line MATCHES "^#[ \t]*modified:") + message(" locally modified file detected...") + set(modifications 1) + endif() + + if(line MATCHES "^# Untracked") + message(" locally non-added file/directory detected...") + set(nonadditions 1) + endif() + endif() + endif() + endforeach() +endif() + + +message("=============================================================================") +message("additions='${additions}'") +message("conflicts='${conflicts}'") +message("modifications='${modifications}'") +message("nonadditions='${nonadditions}'") +message("") + + +# Decide if the test passes or fails: +# +message("=============================================================================") + +if("$ENV{DASHBOARD_TEST_FROM_CTEST}" STREQUAL "") + + # developers are allowed to have local additions and modifications... + set(is_dashboard 0) + message("interactive test run") + message("") + +else() + + set(is_dashboard 1) + message("dashboard test run") + message("") + + # but dashboard machines are not allowed to have local additions or modifications... + if(additions) + message(FATAL_ERROR "test fails: local source tree additions") + endif() + + if(modifications) + message(FATAL_ERROR "test fails: local source tree modifications") + endif() + + # + # It's a dashboard run if ctest was run with '-D ExperimentalTest' or some + # other -D arg on its command line or if ctest is running a -S script to run + # a dashboard... Running ctest like that sets the DASHBOARD_TEST_FROM_CTEST + # env var. + # + +endif() + + +# ...and nobody is allowed to have local non-additions or conflicts... +# Not even developers. +# +if(nonadditions) + if(in_source_build AND is_dashboard) + message(" +warning: test results confounded because this is an 'in-source' build - cannot +distinguish between non-added files that are in-source build products and +non-added source files that somebody forgot to 'git add'... - this is only ok +if this is intentionally an in-source dashboard build... Developers should +use out-of-source builds to verify a clean source tree with this test... + +Allowing test to pass despite the warning message... +") + else() + message(FATAL_ERROR "test fails: local source tree non-additions: use git add before committing, or remove the files from the source tree") + endif() +endif() + +if(conflicts) + message(FATAL_ERROR "test fails: local source tree conflicts: resolve before committing") +endif() + + +# Still here? Good then... +# +message("test passes") +message("") diff --git a/Tests/CMakeTests/CompilerIdVendorTest.cmake.in b/Tests/CMakeTests/CompilerIdVendorTest.cmake.in new file mode 100644 index 000000000..68f646212 --- /dev/null +++ b/Tests/CMakeTests/CompilerIdVendorTest.cmake.in @@ -0,0 +1,31 @@ +# This is not supposed to be included by user code, but we need to +# test it. +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) + +set(MY_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/CompilerIdVendor") +file(REMOVE_RECURSE ${MY_BINARY_DIR}) +file(MAKE_DIRECTORY ${MY_BINARY_DIR}) + +set(CMAKE_MyLang_COMPILER ${CMAKE_COMMAND}) +set(CMAKE_MyLang_COMPILER_ID_ARG1) +set(CMAKE_MyLang_COMPILER_ID_FLAGS_LIST) +set(CMAKE_MyLang_COMPILER_ID_DIR ${MY_BINARY_DIR}) + +file(WRITE "${MY_BINARY_DIR}/BogusVendor.cmake" "message(\"This is a BogusVendor compiler\")") +list(APPEND CMAKE_MyLang_COMPILER_ID_VENDORS BogusVendor) +set(CMAKE_MyLang_COMPILER_ID_VENDOR_FLAGS_BogusVendor -P BogusVendor.cmake) +set(CMAKE_MyLang_COMPILER_ID_VENDOR_REGEX_BogusVendor ThisDoesNotMatch_BogusVendor) + +file(WRITE "${MY_BINARY_DIR}/MyVendor.cmake" "message(\"This is a MyVendor compiler\")") +list(APPEND CMAKE_MyLang_COMPILER_ID_VENDORS MyVendor) +set(CMAKE_MyLang_COMPILER_ID_VENDOR_FLAGS_MyVendor -P MyVendor.cmake) +set(CMAKE_MyLang_COMPILER_ID_VENDOR_REGEX_MyVendor MyVendor) + +set(CMAKE_BINARY_DIR ${MY_BINARY_DIR}) +cmake_determine_compiler_id_vendor(MyLang) + +if("${CMAKE_MyLang_COMPILER_ID}" STREQUAL "MyVendor") + message(STATUS "Found MyVendor compiler id!") +else() + message(FATAL_ERROR "Did not find MyVendor compiler id: [${CMAKE_MyLang_COMPILER_ID}]") +endif() diff --git a/Tests/CMakeTests/ConfigureFile-BadArg.cmake b/Tests/CMakeTests/ConfigureFile-BadArg.cmake new file mode 100644 index 000000000..769fae1ab --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-BadArg.cmake @@ -0,0 +1 @@ +configure_file(.) diff --git a/Tests/CMakeTests/ConfigureFile-DirInput.cmake b/Tests/CMakeTests/ConfigureFile-DirInput.cmake new file mode 100644 index 000000000..920ea280c --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-DirInput.cmake @@ -0,0 +1 @@ +configure_file(. .) diff --git a/Tests/CMakeTests/ConfigureFile-DirOutput.cmake b/Tests/CMakeTests/ConfigureFile-DirOutput.cmake new file mode 100644 index 000000000..d682a2d85 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-DirOutput.cmake @@ -0,0 +1,5 @@ +file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-DirOutput.txt "DirOutput test file\n") +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ConfigureFile-DirOutput) +configure_file(ConfigureFile-DirOutput.txt ConfigureFile-DirOutput) +file(READ ${CMAKE_CURRENT_BINARY_DIR}/ConfigureFile-DirOutput/ConfigureFile-DirOutput.txt out) +message("${out}") diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake new file mode 100644 index 000000000..3b09eb0c3 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out COPYONLY NEWLINE_STYLE DOS) diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake new file mode 100644 index 000000000..133a67a8a --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out NEWLINE_STYLE) diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake new file mode 100644 index 000000000..b7e619ca2 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake @@ -0,0 +1,17 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) + +function(test_eol style in out) + file(WRITE ${file_name} "${in}") + configure_file(${file_name} ${file_name}.out NEWLINE_STYLE ${style}) + file(READ ${file_name}.out new HEX) + if(NOT "${new}" STREQUAL "${out}") + message(FATAL_ERROR "No ${style} line endings") + endif() +endfunction() + +test_eol(DOS "a\n" "610d0a") +test_eol(WIN32 "b\n" "620d0a") +test_eol(CRLF "c\n" "630d0a") + +test_eol(UNIX "d\n" "640a") +test_eol(LF "e\n" "650a") diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake new file mode 100644 index 000000000..e8887c127 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out NEWLINE_STYLE FOO) diff --git a/Tests/CMakeTests/ConfigureFile-Relative.cmake b/Tests/CMakeTests/ConfigureFile-Relative.cmake new file mode 100644 index 000000000..532580a21 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-Relative.cmake @@ -0,0 +1,4 @@ +file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-Relative-In.txt "Relative test file\n") +configure_file(ConfigureFile-Relative-In.txt ConfigureFile-Relative-Out.txt) +file(READ ${CMAKE_CURRENT_BINARY_DIR}/ConfigureFile-Relative-Out.txt out) +message("${out}") diff --git a/Tests/CMakeTests/ConfigureFileTest.cmake.in b/Tests/CMakeTests/ConfigureFileTest.cmake.in new file mode 100644 index 000000000..6cc61d90c --- /dev/null +++ b/Tests/CMakeTests/ConfigureFileTest.cmake.in @@ -0,0 +1,28 @@ +set(DirInput-RESULT 1) +set(DirInput-STDERR "is a directory") +set(DirOutput-RESULT 0) +set(DirOutput-STDERR "DirOutput test file") +set(Relative-RESULT 0) +set(Relative-STDERR "Relative test file") +set(BadArg-RESULT 1) +set(BadArg-STDERR "called with incorrect number of arguments") +set(NewLineStyle-NoArg-RESULT 1) +set(NewLineStyle-NoArg-STDERR "NEWLINE_STYLE must set a style:") +set(NewLineStyle-WrongArg-RESULT 1) +set(NewLineStyle-WrongArg-STDERR "NEWLINE_STYLE sets an unknown style") +set(NewLineStyle-ValidArg-RESULT 0) +set(NewLineStyle-ValidArg-STDERR ) +set(NewLineStyle-COPYONLY-RESULT 1) +set(NewLineStyle-COPYONLY-STDERR "COPYONLY could not be used in combination") + +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") +check_cmake_test(ConfigureFile + DirInput + DirOutput + Relative + BadArg + NewLineStyle-NoArg + NewLineStyle-WrongArg + NewLineStyle-ValidArg + NewLineStyle-COPYONLY + ) diff --git a/Tests/CMakeTests/DummyToolchain.cmake b/Tests/CMakeTests/DummyToolchain.cmake new file mode 100644 index 000000000..6a602015b --- /dev/null +++ b/Tests/CMakeTests/DummyToolchain.cmake @@ -0,0 +1,8 @@ +set(CMAKE_SYSTEM_NAME Dumdidum) +set(CMAKE_SYSTEM_VERSION "1.0") + +set(CMAKE_C_COMPILER /opt/foo/bin/arm-elf-gcc) +set(CMAKE_C_OUTPUT_EXTENSION ".foo") + +set(CMAKE_CXX_COMPILER /opt/bar/bin/cl.exe) +set(CMAKE_CXX_OUTPUT_EXTENSION ".bar") diff --git a/Tests/CMakeTests/ELF/elf32lsb.bin b/Tests/CMakeTests/ELF/elf32lsb.bin Binary files differnew file mode 100644 index 000000000..803ac43f3 --- /dev/null +++ b/Tests/CMakeTests/ELF/elf32lsb.bin diff --git a/Tests/CMakeTests/ELF/elf32msb.bin b/Tests/CMakeTests/ELF/elf32msb.bin Binary files differnew file mode 100644 index 000000000..d04aaf76c --- /dev/null +++ b/Tests/CMakeTests/ELF/elf32msb.bin diff --git a/Tests/CMakeTests/ELF/elf64lsb.bin b/Tests/CMakeTests/ELF/elf64lsb.bin Binary files differnew file mode 100644 index 000000000..a21e3eaa6 --- /dev/null +++ b/Tests/CMakeTests/ELF/elf64lsb.bin diff --git a/Tests/CMakeTests/ELF/elf64msb.bin b/Tests/CMakeTests/ELF/elf64msb.bin Binary files differnew file mode 100644 index 000000000..bbe255189 --- /dev/null +++ b/Tests/CMakeTests/ELF/elf64msb.bin diff --git a/Tests/CMakeTests/ELFTest.cmake.in b/Tests/CMakeTests/ELFTest.cmake.in new file mode 100644 index 000000000..0271abb1f --- /dev/null +++ b/Tests/CMakeTests/ELFTest.cmake.in @@ -0,0 +1,48 @@ +set(names + elf32lsb.bin + elf32msb.bin + elf64lsb.bin + elf64msb.bin + ) + +# Prepare binaries on which to operate. +set(in "@CMAKE_CURRENT_SOURCE_DIR@/ELF") +set(out "@CMAKE_CURRENT_BINARY_DIR@/ELF-Out") +file(REMOVE_RECURSE "${out}") +file(MAKE_DIRECTORY "${out}") +foreach(f ${names}) + file(COPY ${in}/${f} DESTINATION ${out}) + list(APPEND files "${out}/${f}") +endforeach() + +foreach(f ${files}) + # Check for the initial RPATH. + file(RPATH_CHECK FILE "${f}" RPATH "/sample/rpath") + if(NOT EXISTS "${f}") + message(FATAL_ERROR "RPATH_CHECK removed ${f}") + endif() + + # Change the RPATH. + file(RPATH_CHANGE FILE "${f}" + OLD_RPATH "/sample/rpath" + NEW_RPATH "/rpath/sample") + set(rpath) + file(STRINGS "${f}" rpath REGEX "/rpath/sample" LIMIT_COUNT 1) + if(NOT rpath) + message(FATAL_ERROR "RPATH not changed in ${f}") + endif() + + # Remove the RPATH. + file(RPATH_REMOVE FILE "${f}") + set(rpath) + file(STRINGS "${f}" rpath REGEX "/rpath/sample" LIMIT_COUNT 1) + if(rpath) + message(FATAL_ERROR "RPATH not removed from ${f}") + endif() + + # Check again...this should remove the file. + file(RPATH_CHECK FILE "${f}" RPATH "/sample/rpath") + if(EXISTS "${f}") + message(FATAL_ERROR "RPATH_CHECK did not remove ${f}") + endif() +endforeach() diff --git a/Tests/CMakeTests/EndStuffTest.cmake.in b/Tests/CMakeTests/EndStuffTest.cmake.in new file mode 100644 index 000000000..de5dd5073 --- /dev/null +++ b/Tests/CMakeTests/EndStuffTest.cmake.in @@ -0,0 +1,18 @@ +# Execute each test listed in: +# +set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/EndStuffTestScript.cmake") +set(number_of_tests_expected 9) + +include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake") +execute_all_script_tests(${scriptname} number_of_tests_executed) + +# And verify that number_of_tests_executed is at least as many as we know +# about as of this writing... +# +message(STATUS "scriptname='${scriptname}'") +message(STATUS "number_of_tests_executed='${number_of_tests_executed}'") +message(STATUS "number_of_tests_expected='${number_of_tests_expected}'") + +if(number_of_tests_executed LESS number_of_tests_expected) + message(FATAL_ERROR "error: some test cases were skipped") +endif() diff --git a/Tests/CMakeTests/EndStuffTestScript.cmake b/Tests/CMakeTests/EndStuffTestScript.cmake new file mode 100644 index 000000000..9f4081801 --- /dev/null +++ b/Tests/CMakeTests/EndStuffTestScript.cmake @@ -0,0 +1,70 @@ +message(STATUS "testname='${testname}'") + +if(testname STREQUAL bad_else) # fail + file(WRITE "${dir}/${testname}.cmake" +"else() +") + execute_process(COMMAND ${CMAKE_COMMAND} -P "${dir}/${testname}.cmake" + RESULT_VARIABLE rv) + if(NOT rv EQUAL 0) + message(FATAL_ERROR "${testname} failed") + endif() + +elseif(testname STREQUAL bad_elseif) # fail + file(WRITE "${dir}/${testname}.cmake" +"elseif() +") + execute_process(COMMAND ${CMAKE_COMMAND} -P "${dir}/${testname}.cmake" + RESULT_VARIABLE rv) + if(NOT rv EQUAL 0) + message(FATAL_ERROR "${testname} failed") + endif() + +elseif(testname STREQUAL bad_endforeach) # fail + endforeach() + +elseif(testname STREQUAL bad_endfunction) # fail + endfunction() + +elseif(testname STREQUAL bad_endif) # fail + file(WRITE "${dir}/${testname}.cmake" +"cmake_minimum_required(VERSION 2.8) +endif() +") + execute_process(COMMAND ${CMAKE_COMMAND} -P "${dir}/${testname}.cmake" + RESULT_VARIABLE rv) + if(NOT rv EQUAL 0) + message(FATAL_ERROR "${testname} failed") + endif() + +elseif(testname STREQUAL endif_low_min_version) # pass + file(WRITE "${dir}/${testname}.cmake" +"cmake_minimum_required(VERSION 1.2) +endif() +") + execute_process(COMMAND ${CMAKE_COMMAND} -P "${dir}/${testname}.cmake" + RESULT_VARIABLE rv) + if(NOT rv EQUAL 0) + message(FATAL_ERROR "${testname} failed") + endif() + +elseif(testname STREQUAL endif_no_min_version) # pass + file(WRITE "${dir}/${testname}.cmake" +"endif() +") + execute_process(COMMAND ${CMAKE_COMMAND} -P "${dir}/${testname}.cmake" + RESULT_VARIABLE rv) + if(NOT rv EQUAL 0) + message(FATAL_ERROR "${testname} failed") + endif() + +elseif(testname STREQUAL bad_endmacro) # fail + endmacro() + +elseif(testname STREQUAL bad_endwhile) # fail + endwhile() + +else() # fail + message(FATAL_ERROR "testname='${testname}' - error: no such test in '${CMAKE_CURRENT_LIST_FILE}'") + +endif() diff --git a/Tests/CMakeTests/ExecuteScriptTests.cmake b/Tests/CMakeTests/ExecuteScriptTests.cmake new file mode 100644 index 000000000..c71585a02 --- /dev/null +++ b/Tests/CMakeTests/ExecuteScriptTests.cmake @@ -0,0 +1,63 @@ +# This function calls the ${scriptname} file to execute one test case: +# +function(execute_one_script_test scriptname testname expected_result) + message("execute_one_script_test") + message("testname=[${testname}]") + + execute_process( + COMMAND ${CMAKE_COMMAND} + -D "dir:STRING=${dir}" + -D "testname:STRING=${testname}" + -P "${scriptname}" + OUTPUT_VARIABLE out + ERROR_VARIABLE err + RESULT_VARIABLE result + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_STRIP_TRAILING_WHITESPACE + ) + + message("out=[${out}]") + message("err=[${err}]") + + if(expected_result STREQUAL "fail") + # case expected to fail, result should be non-0... + # error if it's 0 + if("${result}" STREQUAL "0") + message(SEND_ERROR "script failed: testname='${testname}' [${result}] actually passed, but expected to fail...") + endif() + else() + # case expected to pass, result should be 0... + # error if it's non-0 + if(NOT "${result}" STREQUAL "0") + message(SEND_ERROR "script failed: testname='${testname}' [${result}] actually failed, but expected to pass...") + endif() + endif() + + message("") +endfunction() + + +# This function reads the script file and calls execute_one_script_test for +# each testname case listed in the script. To add new cases, simply edit the +# script file and add an elseif() clause that matches 'regex' below. +# +function(execute_all_script_tests scriptname result) + file(READ "${scriptname}" script) + + string(REPLACE ";" "\\\\;" script "${script}") + string(REPLACE "\n" "E;" script "${script}") + + set(count 0) + set(regex "^ *(if|elseif) *\\( *testname +STREQUAL +\\\"*([^\\\"\\)]+)\\\"* *\\) *# *(fail|pass) *E$") + + foreach(line ${script}) + if(line MATCHES "${regex}") + math(EXPR count "${count} + 1") + string(REGEX REPLACE "${regex}" "\\2" testname "${line}") + string(REGEX REPLACE "${regex}" "\\3" expected_result "${line}") + execute_one_script_test(${scriptname} ${testname} ${expected_result}) + endif() + endforeach() + + set(${result} ${count} PARENT_SCOPE) +endfunction() diff --git a/Tests/CMakeTests/File-Copy-BadArg.cmake b/Tests/CMakeTests/File-Copy-BadArg.cmake new file mode 100644 index 000000000..91952fc60 --- /dev/null +++ b/Tests/CMakeTests/File-Copy-BadArg.cmake @@ -0,0 +1 @@ +file(COPY FileTest.cmake DESTINATION tmp PATTERN * BADARG) diff --git a/Tests/CMakeTests/File-Copy-BadPerm.cmake b/Tests/CMakeTests/File-Copy-BadPerm.cmake new file mode 100644 index 000000000..b5cc42f00 --- /dev/null +++ b/Tests/CMakeTests/File-Copy-BadPerm.cmake @@ -0,0 +1 @@ +file(COPY FileTest.cmake DESTINATION tmp FILE_PERMISSIONS BADPERM) diff --git a/Tests/CMakeTests/File-Copy-BadRegex.cmake b/Tests/CMakeTests/File-Copy-BadRegex.cmake new file mode 100644 index 000000000..41340f623 --- /dev/null +++ b/Tests/CMakeTests/File-Copy-BadRegex.cmake @@ -0,0 +1 @@ +file(COPY FileTest.cmake DESTINATION tmp REGEX "(") diff --git a/Tests/CMakeTests/File-Copy-EarlyArg.cmake b/Tests/CMakeTests/File-Copy-EarlyArg.cmake new file mode 100644 index 000000000..03993de38 --- /dev/null +++ b/Tests/CMakeTests/File-Copy-EarlyArg.cmake @@ -0,0 +1 @@ +file(COPY FileTest.cmake DESTINATION tmp PERMISSIONS) diff --git a/Tests/CMakeTests/File-Copy-LateArg.cmake b/Tests/CMakeTests/File-Copy-LateArg.cmake new file mode 100644 index 000000000..43d216874 --- /dev/null +++ b/Tests/CMakeTests/File-Copy-LateArg.cmake @@ -0,0 +1 @@ +file(COPY FileTest.cmake DESTINATION tmp PATTERN * FILE_PERMISSIONS) diff --git a/Tests/CMakeTests/File-Copy-NoDest.cmake b/Tests/CMakeTests/File-Copy-NoDest.cmake new file mode 100644 index 000000000..f6c6c6d7e --- /dev/null +++ b/Tests/CMakeTests/File-Copy-NoDest.cmake @@ -0,0 +1 @@ +file(COPY FileTest.cmake) diff --git a/Tests/CMakeTests/File-Copy-NoFile.cmake b/Tests/CMakeTests/File-Copy-NoFile.cmake new file mode 100644 index 000000000..d5853d396 --- /dev/null +++ b/Tests/CMakeTests/File-Copy-NoFile.cmake @@ -0,0 +1 @@ +file(COPY does_not_exist.txt DESTINATION tmp) diff --git a/Tests/CMakeTests/File-HASH-Input.txt b/Tests/CMakeTests/File-HASH-Input.txt new file mode 100644 index 000000000..a1d315b2d --- /dev/null +++ b/Tests/CMakeTests/File-HASH-Input.txt @@ -0,0 +1 @@ +sample input string diff --git a/Tests/CMakeTests/File-MD5-BadArg1.cmake b/Tests/CMakeTests/File-MD5-BadArg1.cmake new file mode 100644 index 000000000..ac5f67ae2 --- /dev/null +++ b/Tests/CMakeTests/File-MD5-BadArg1.cmake @@ -0,0 +1 @@ +file(MD5) diff --git a/Tests/CMakeTests/File-MD5-BadArg2.cmake b/Tests/CMakeTests/File-MD5-BadArg2.cmake new file mode 100644 index 000000000..2acc0757e --- /dev/null +++ b/Tests/CMakeTests/File-MD5-BadArg2.cmake @@ -0,0 +1 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt) diff --git a/Tests/CMakeTests/File-MD5-BadArg4.cmake b/Tests/CMakeTests/File-MD5-BadArg4.cmake new file mode 100644 index 000000000..79b27558d --- /dev/null +++ b/Tests/CMakeTests/File-MD5-BadArg4.cmake @@ -0,0 +1 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt md5 extra_arg) diff --git a/Tests/CMakeTests/File-MD5-NoFile.cmake b/Tests/CMakeTests/File-MD5-NoFile.cmake new file mode 100644 index 000000000..1b91bc8d8 --- /dev/null +++ b/Tests/CMakeTests/File-MD5-NoFile.cmake @@ -0,0 +1 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/DoesNotExist.cmake md5) diff --git a/Tests/CMakeTests/File-MD5-Works.cmake b/Tests/CMakeTests/File-MD5-Works.cmake new file mode 100644 index 000000000..0fabe54a4 --- /dev/null +++ b/Tests/CMakeTests/File-MD5-Works.cmake @@ -0,0 +1,2 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt md5) +message("${md5}") diff --git a/Tests/CMakeTests/File-SHA1-Works.cmake b/Tests/CMakeTests/File-SHA1-Works.cmake new file mode 100644 index 000000000..f2ab5d747 --- /dev/null +++ b/Tests/CMakeTests/File-SHA1-Works.cmake @@ -0,0 +1,2 @@ +file(SHA1 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha1) +message("${sha1}") diff --git a/Tests/CMakeTests/File-SHA224-Works.cmake b/Tests/CMakeTests/File-SHA224-Works.cmake new file mode 100644 index 000000000..3e86b172f --- /dev/null +++ b/Tests/CMakeTests/File-SHA224-Works.cmake @@ -0,0 +1,2 @@ +file(SHA224 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha224) +message("${sha224}") diff --git a/Tests/CMakeTests/File-SHA256-Works.cmake b/Tests/CMakeTests/File-SHA256-Works.cmake new file mode 100644 index 000000000..b72d89e95 --- /dev/null +++ b/Tests/CMakeTests/File-SHA256-Works.cmake @@ -0,0 +1,2 @@ +file(SHA256 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha256) +message("${sha256}") diff --git a/Tests/CMakeTests/File-SHA384-Works.cmake b/Tests/CMakeTests/File-SHA384-Works.cmake new file mode 100644 index 000000000..0eeca33cb --- /dev/null +++ b/Tests/CMakeTests/File-SHA384-Works.cmake @@ -0,0 +1,2 @@ +file(SHA384 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha384) +message("${sha384}") diff --git a/Tests/CMakeTests/File-SHA512-Works.cmake b/Tests/CMakeTests/File-SHA512-Works.cmake new file mode 100644 index 000000000..d74ee4429 --- /dev/null +++ b/Tests/CMakeTests/File-SHA512-Works.cmake @@ -0,0 +1,2 @@ +file(SHA512 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha512) +message("${sha512}") diff --git a/Tests/CMakeTests/FileDownloadInput.png b/Tests/CMakeTests/FileDownloadInput.png Binary files differnew file mode 100644 index 000000000..7bbcee413 --- /dev/null +++ b/Tests/CMakeTests/FileDownloadInput.png diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in new file mode 100644 index 000000000..9dc2ebb27 --- /dev/null +++ b/Tests/CMakeTests/FileDownloadTest.cmake.in @@ -0,0 +1,43 @@ +set(url "file://@CMAKE_CURRENT_SOURCE_DIR@/FileDownloadInput.png") +set(dir "@CMAKE_CURRENT_BINARY_DIR@/downloads") + +message(STATUS "FileDownload:1") +file(DOWNLOAD + ${url} + ${dir}/file1.png + TIMEOUT 2 + ) + +message(STATUS "FileDownload:2") +file(DOWNLOAD + ${url} + ${dir}/file2.png + TIMEOUT 2 + SHOW_PROGRESS + ) + +# Two calls in a row, exactly the same arguments. +# Since downloaded file should exist already for 2nd call, +# the 2nd call will short-circuit and return early... +# +if(EXISTS ${dir}/file3.png) + file(REMOVE ${dir}/file3.png) +endif() + +message(STATUS "FileDownload:3") +file(DOWNLOAD + ${url} + ${dir}/file3.png + TIMEOUT 2 + EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1 + ) + +message(STATUS "FileDownload:4") +file(DOWNLOAD + ${url} + ${dir}/file3.png + TIMEOUT 2 + STATUS status + EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1 + ) +message(STATUS "${status}") diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in new file mode 100644 index 000000000..3c3d85ddc --- /dev/null +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -0,0 +1,74 @@ +set(Copy-BadArg-RESULT 1) +set(Copy-BadArg-STDERR "unknown argument \"BADARG\"") +set(Copy-BadPerm-RESULT 1) +set(Copy-BadPerm-STDERR "COPY given invalid permission \"BADPERM\"") +set(Copy-BadRegex-RESULT 1) +set(Copy-BadRegex-STDERR "could not compile REGEX") +set(Copy-EarlyArg-RESULT 1) +set(Copy-EarlyArg-STDERR "option PERMISSIONS may not appear before") +set(Copy-LateArg-RESULT 1) +set(Copy-LateArg-STDERR "option FILE_PERMISSIONS may not appear after") +set(Copy-NoDest-RESULT 1) +set(Copy-NoDest-STDERR "given no DESTINATION") +set(Copy-NoFile-RESULT 1) +set(Copy-NoFile-STDERR "COPY cannot find.*/does_not_exist\\.txt") +set(MD5-NoFile-RESULT 1) +set(MD5-NoFile-STDERR "file MD5 failed to read file") +set(MD5-BadArg1-RESULT 1) +set(MD5-BadArg1-STDERR "file must be called with at least two arguments") +set(MD5-BadArg2-RESULT 1) +set(MD5-BadArg2-STDERR "file MD5 requires a file name and output variable") +set(MD5-BadArg4-RESULT 1) +set(MD5-BadArg4-STDERR "file MD5 requires a file name and output variable") +set(MD5-Works-RESULT 0) +set(MD5-Works-STDERR "10d20ddb981a6202b84aa1ce1cb7fce3") +set(SHA1-Works-RESULT 0) +set(SHA1-Works-STDERR "83f093e04289b21a9415f408ad50be8b57ad2f34") +set(SHA224-Works-RESULT 0) +set(SHA224-Works-STDERR "e995a7789922c4ef9279d94e763c8375934180a51baa7147bc48edf7") +set(SHA256-Works-RESULT 0) +set(SHA256-Works-STDERR "d1c5915d8b71150726a1eef75a29ec6bea8fd1bef6b7299ef8048760b0402025") +set(SHA384-Works-RESULT 0) +set(SHA384-Works-STDERR "1de9560b4e030e02051ea408200ffc55d70c97ac64ebf822461a5c786f495c36df43259b14483bc8d364f0106f4971ee") +set(SHA512-Works-RESULT 0) +set(SHA512-Works-STDERR "3982a1b4e651768bec70ab1fb97045cb7a659f4ba7203d501c52ab2e803071f9d5fd272022df15f27727fc67f8cd022e710e29010b2a9c0b467c111e2f6abf51") + +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") +check_cmake_test(File + Copy-BadArg + Copy-BadPerm + Copy-BadRegex + Copy-EarlyArg + Copy-LateArg + Copy-NoDest + Copy-NoFile + MD5-NoFile + MD5-BadArg1 + MD5-BadArg2 + MD5-BadArg4 + MD5-Works + SHA1-Works + SHA224-Works + SHA256-Works + SHA384-Works + SHA512-Works + ) + +# Also execute each test listed in FileTestScript.cmake: +# +set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/FileTestScript.cmake") +set(number_of_tests_expected 62) + +include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake") +execute_all_script_tests(${scriptname} number_of_tests_executed) + +# And verify that number_of_tests_executed is at least as many as we know +# about as of this writing... +# +message(STATUS "scriptname='${scriptname}'") +message(STATUS "number_of_tests_executed='${number_of_tests_executed}'") +message(STATUS "number_of_tests_expected='${number_of_tests_expected}'") + +if(number_of_tests_executed LESS number_of_tests_expected) + message(FATAL_ERROR "error: some test cases were skipped") +endif() diff --git a/Tests/CMakeTests/FileTestScript.cmake b/Tests/CMakeTests/FileTestScript.cmake new file mode 100644 index 000000000..9a4356973 --- /dev/null +++ b/Tests/CMakeTests/FileTestScript.cmake @@ -0,0 +1,227 @@ +message(STATUS "testname='${testname}'") + +if(testname STREQUAL empty) # fail + file() + +elseif(testname STREQUAL bogus) # fail + file(BOGUS ffff) + +elseif(testname STREQUAL different_not_enough_args) # fail + file(DIFFERENT ffff) + +elseif(testname STREQUAL download_not_enough_args) # fail + file(DOWNLOAD ffff) + +elseif(testname STREQUAL read_not_enough_args) # fail + file(READ ffff) + +elseif(testname STREQUAL rpath_check_not_enough_args) # fail + file(RPATH_CHECK ffff) + +elseif(testname STREQUAL rpath_remove_not_enough_args) # fail + file(RPATH_REMOVE ffff) + +elseif(testname STREQUAL strings_not_enough_args) # fail + file(STRINGS ffff) + +elseif(testname STREQUAL to_native_path_not_enough_args) # fail + file(TO_NATIVE_PATH ffff) + +elseif(testname STREQUAL read_with_offset) # pass + file(READ ${CMAKE_CURRENT_LIST_FILE} v OFFSET 42 LIMIT 30) + message("v='${v}'") + +elseif(testname STREQUAL strings_bad_length_minimum) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v LENGTH_MINIMUM bogus) + +elseif(testname STREQUAL strings_bad_length_maximum) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v LENGTH_MAXIMUM bogus) + +elseif(testname STREQUAL strings_bad_limit_count) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v LIMIT_COUNT bogus) + +elseif(testname STREQUAL strings_bad_limit_input) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v LIMIT_INPUT bogus) + +elseif(testname STREQUAL strings_bad_limit_output) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v LIMIT_OUTPUT bogus) + +elseif(testname STREQUAL strings_bad_regex) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v REGEX "(") + +elseif(testname STREQUAL strings_unknown_arg) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v BOGUS) + +elseif(testname STREQUAL strings_bad_filename) # fail + file(STRINGS ffff v LIMIT_COUNT 10) + +elseif(testname STREQUAL strings_use_limit_count) # pass + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v LIMIT_COUNT 10) + message("v='${v}'") + +elseif(testname STREQUAL strings_use_no_hex_conversion) # pass + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v NO_HEX_CONVERSION) + message("v='${v}'") + +elseif(testname STREQUAL glob_recurse_follow_symlinks_no_expression) # fail + file(GLOB_RECURSE v FOLLOW_SYMLINKS) + +elseif(testname STREQUAL glob_recurse_relative_no_directory) # fail + file(GLOB_RECURSE v RELATIVE) + +elseif(testname STREQUAL glob_recurse_relative_no_expression) # fail + file(GLOB_RECURSE v RELATIVE dddd) + +elseif(testname STREQUAL glob_non_full_path) # pass + file(GLOB_RECURSE v ffff*.*) + message("v='${v}'") + +elseif(testname STREQUAL make_directory_non_full_path) # pass + file(MAKE_DIRECTORY FileTestScriptDDDD) + if(NOT EXISTS FileTestScriptDDDD) + message(FATAL_ERROR "error: non-full-path MAKE_DIRECTORY failed") + endif() + file(REMOVE_RECURSE FileTestScriptDDDD) + if(EXISTS FileTestScriptDDDD) + message(FATAL_ERROR "error: non-full-path REMOVE_RECURSE failed") + endif() + +elseif(testname STREQUAL different_no_variable) # fail + file(DIFFERENT FILES) + +elseif(testname STREQUAL different_no_files) # fail + file(DIFFERENT v FILES) + +elseif(testname STREQUAL different_unknown_arg) # fail + file(DIFFERENT v FILES ffffLHS ffffRHS BOGUS) + +elseif(testname STREQUAL different_different) # pass + file(DIFFERENT v FILES ffffLHS ffffRHS) + message("v='${v}'") + +elseif(testname STREQUAL different_same) # pass + file(DIFFERENT v FILES + ${CMAKE_CURRENT_LIST_FILE} ${CMAKE_CURRENT_LIST_FILE}) + message("v='${v}'") + +elseif(testname STREQUAL rpath_change_unknown_arg) # fail + file(RPATH_CHANGE BOGUS) + +elseif(testname STREQUAL rpath_change_bad_file) # fail + file(RPATH_CHANGE FILE) + +elseif(testname STREQUAL rpath_change_bad_old_rpath) # fail + file(RPATH_CHANGE FILE ffff OLD_RPATH) + +elseif(testname STREQUAL rpath_change_bad_new_rpath) # fail + file(RPATH_CHANGE FILE ffff OLD_RPATH rrrr NEW_RPATH) + +elseif(testname STREQUAL rpath_change_file_does_not_exist) # fail + file(RPATH_CHANGE FILE ffff OLD_RPATH rrrr NEW_RPATH RRRR) + +elseif(testname STREQUAL rpath_change_file_is_not_executable) # fail + file(RPATH_CHANGE FILE ${CMAKE_CURRENT_LIST_FILE} + OLD_RPATH rrrr NEW_RPATH RRRR) + +elseif(testname STREQUAL rpath_remove_unknown_arg) # fail + file(RPATH_REMOVE BOGUS) + +elseif(testname STREQUAL rpath_remove_bad_file) # fail + file(RPATH_REMOVE FILE) + +elseif(testname STREQUAL rpath_remove_file_does_not_exist) # fail + file(RPATH_REMOVE FILE ffff) + +#elseif(testname STREQUAL rpath_remove_file_is_not_executable) # fail +# file(RPATH_REMOVE FILE ${CMAKE_CURRENT_LIST_FILE}) + +elseif(testname STREQUAL rpath_check_unknown_arg) # fail + file(RPATH_CHECK BOGUS) + +elseif(testname STREQUAL rpath_check_bad_file) # fail + file(RPATH_CHECK FILE) + +elseif(testname STREQUAL rpath_check_bad_rpath) # fail + file(RPATH_CHECK FILE ffff RPATH) + +elseif(testname STREQUAL rpath_check_file_does_not_exist) # pass + file(RPATH_CHECK FILE ffff RPATH rrrr) + +elseif(testname STREQUAL rpath_check_file_is_not_executable) # pass + file(WRITE ffff_rpath_check "") + + if(NOT EXISTS ffff_rpath_check) + message(FATAL_ERROR "error: non-full-path WRITE failed") + endif() + + file(RPATH_CHECK FILE ffff_rpath_check RPATH rrrr) + # careful: if the file does not have the given RPATH, it is deleted... + + if(EXISTS ffff_rpath_check) + message(FATAL_ERROR "error: non-full-path RPATH_CHECK failed") + endif() + +elseif(testname STREQUAL relative_path_wrong_number_of_args) # fail + file(RELATIVE_PATH v dir) + +elseif(testname STREQUAL relative_path_non_full_path_dir) # fail + file(RELATIVE_PATH v dir file) + +elseif(testname STREQUAL relative_path_non_full_path_file) # fail + file(RELATIVE_PATH v /dir file) + +elseif(testname STREQUAL rename_wrong_number_of_args) # fail + file(RENAME ffff) + +elseif(testname STREQUAL rename_input_file_does_not_exist) # fail + file(RENAME ffff FFFFGGGG) + +elseif(testname STREQUAL to_native_path) # pass + file(TO_NATIVE_PATH /a/b/c\;/d/e/f:/g/h/i v) + message("v='${v}'") + +elseif(testname STREQUAL download_wrong_number_of_args) # fail + file(DOWNLOAD zzzz://bogus/ffff) + +elseif(testname STREQUAL download_file_with_no_path) # fail + file(DOWNLOAD zzzz://bogus/ffff ffff) + +elseif(testname STREQUAL download_missing_time) # fail + file(DOWNLOAD zzzz://bogus/ffff ./ffff TIMEOUT) + +elseif(testname STREQUAL download_missing_log_var) # fail + file(DOWNLOAD zzzz://bogus/ffff ./ffff TIMEOUT 2 LOG) + +elseif(testname STREQUAL download_missing_status_var) # fail + file(DOWNLOAD zzzz://bogus/ffff ./ffff TIMEOUT 2 LOG l STATUS) + +elseif(testname STREQUAL download_with_bogus_protocol) # pass + file(DOWNLOAD zzzz://bogus/ffff ./ffff TIMEOUT 2 LOG l STATUS s) + file(REMOVE ./ffff) + message("l='${l}'") + message("s='${s}'") + +elseif(testname STREQUAL upload_wrong_number_of_args) # fail + file(UPLOAD ./ffff) + +elseif(testname STREQUAL upload_missing_time) # fail + file(UPLOAD ./ffff zzzz://bogus/ffff TIMEOUT) + +elseif(testname STREQUAL upload_missing_log_var) # fail + file(UPLOAD ./ffff zzzz://bogus/ffff TIMEOUT 2 LOG) + +elseif(testname STREQUAL upload_missing_status_var) # fail + file(UPLOAD ./ffff zzzz://bogus/ffff TIMEOUT 2 LOG l STATUS) + +elseif(testname STREQUAL upload_file_that_doesnt_exist) # fail + file(UPLOAD ./ffff zzzz://bogus/ffff) + +elseif(testname STREQUAL upload_with_bogus_protocol) # pass + file(UPLOAD ${CMAKE_CURRENT_LIST_FILE} zzzz://bogus/ffff TIMEOUT 2 LOG l STATUS s) + message("l='${l}'") + message("s='${s}'") + +else() # fail + message(FATAL_ERROR "testname='${testname}' - error: no such test in '${CMAKE_CURRENT_LIST_FILE}'") + +endif() diff --git a/Tests/CMakeTests/FileUploadTest.cmake.in b/Tests/CMakeTests/FileUploadTest.cmake.in new file mode 100644 index 000000000..8577aefd2 --- /dev/null +++ b/Tests/CMakeTests/FileUploadTest.cmake.in @@ -0,0 +1,49 @@ +file(REMOVE_RECURSE "@CMAKE_CURRENT_BINARY_DIR@/uploads") + +if(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/uploads/file1.png") + message(FATAL_ERROR "error: file1.png exists - should have been deleted") +endif() +if(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/uploads/file2.png") + message(FATAL_ERROR "error: file2.png exists - should have been deleted") +endif() + +file(MAKE_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/uploads") + +set(filename "@CMAKE_CURRENT_SOURCE_DIR@/FileDownloadInput.png") +set(urlbase "file://@CMAKE_CURRENT_BINARY_DIR@/uploads") + +message(STATUS "FileUpload:1") +file(UPLOAD + ${filename} + ${urlbase}/file1.png + TIMEOUT 2 + ) + +message(STATUS "FileUpload:2") +file(UPLOAD + ${filename} + ${urlbase}/file2.png + STATUS status + LOG log + SHOW_PROGRESS + ) + +execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum + "@CMAKE_CURRENT_BINARY_DIR@/uploads/file1.png" + OUTPUT_VARIABLE sum1 + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT sum1 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file1.png$") + message(FATAL_ERROR "file1.png did not upload correctly (sum1='${sum1}')") +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum + "@CMAKE_CURRENT_BINARY_DIR@/uploads/file2.png" + OUTPUT_VARIABLE sum2 + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT sum2 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file2.png$") + message(FATAL_ERROR "file2.png did not upload correctly (sum2='${sum2}')") +endif() + +message(STATUS "log='${log}'") +message(STATUS "status='${status}'") +message(STATUS "DONE") diff --git a/Tests/CMakeTests/FindBaseTest.cmake.in b/Tests/CMakeTests/FindBaseTest.cmake.in new file mode 100644 index 000000000..47c1692db --- /dev/null +++ b/Tests/CMakeTests/FindBaseTest.cmake.in @@ -0,0 +1,62 @@ +set(MY_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@") + +# The find_* commands do path normalization so we should do so too +# before comparing results. +get_filename_component(MY_SOURCE_DIR "${MY_SOURCE_DIR}" ABSOLUTE) + +set(_HEADER cmake_i_do_not_exist_in_the_system.h) +set(_HEADER_FULL "${MY_SOURCE_DIR}/include/${_HEADER}") +set(_HEADER_FULL_A "${MY_SOURCE_DIR}/A/include/${_HEADER}") + +# at first check that the header isn't found without special measures +find_file(FOO_H_1 ${_HEADER}) +if(FOO_H_1) + message(FATAL_ERROR "${_HEADER} found: ${FOO_H_1}, it should not exist !") +endif(FOO_H_1) + +# The HINTS option should override the system but the PATHS option +# should not. +set(CMAKE_SYSTEM_PREFIX_PATH ${MY_SOURCE_DIR}) +find_file(TEST_H_1 ${_HEADER} HINTS ${MY_SOURCE_DIR}/A/include) +find_file(TEST_H_2 ${_HEADER} PATHS ${MY_SOURCE_DIR}/A/include) +if(NOT "${TEST_H_1}" STREQUAL "${_HEADER_FULL_A}") + message(FATAL_ERROR "Did not find \"${_HEADER_FULL_A}\"\ngot \"${TEST_H_1}\" instead!") +endif(NOT "${TEST_H_1}" STREQUAL "${_HEADER_FULL_A}") +if(NOT "${TEST_H_2}" STREQUAL "${_HEADER_FULL}") + message(FATAL_ERROR "Did not find \"${_HEADER_FULL}\"\ngot \"${TEST_H_2}\" instead!") +endif(NOT "${TEST_H_2}" STREQUAL "${_HEADER_FULL}") +set(CMAKE_SYSTEM_PREFIX_PATH) + +# with this it still should not be found, since the include/ subdir is still missing +set(CMAKE_INCLUDE_PATH "${MY_SOURCE_DIR}") +find_file(FOO_H_2 ${_HEADER}) +if(FOO_H_2) + message(FATAL_ERROR "${_HEADER} found: ${FOO_H_2}, it should not exist !") +endif(FOO_H_2) + +# now with the PATH_SUFFIX it should be found +find_file(FOO_H_3 NAMES ${_HEADER} PATH_SUFFIXES include ) +if(NOT "${FOO_H_3}" STREQUAL "${_HEADER_FULL}") + message(FATAL_ERROR "Did not find \"${_HEADER_FULL}\"\ngot ${FOO_H_3} instead !") +endif(NOT "${FOO_H_3}" STREQUAL "${_HEADER_FULL}") + +# without PATH_SUFFIX, but with a CMAKE_INCLUDE_PATH it should not be found +set(CMAKE_INCLUDE_PATH /include) +find_file(FOO_H_4 ${_HEADER}) +if(FOO_H_4) + message(FATAL_ERROR "${_HEADER} found: ${FOO_H_4}, it should not exist !") +endif(FOO_H_4) + +# when setting CMAKE_FIND_ROOT_PATH to the current source dir, +# together with the CMAKE_INCLUDE_PATH it should be found +set(CMAKE_FIND_ROOT_PATH blub "${MY_SOURCE_DIR}") +find_file(FOO_H_5 ${_HEADER}) +if(NOT "${FOO_H_5}" STREQUAL "${_HEADER_FULL}") + message(FATAL_ERROR "Did not find \"${_HEADER_FULL}\"\ngot ${FOO_H_5} instead !") +endif(NOT "${FOO_H_5}" STREQUAL "${_HEADER_FULL}") + +# by explicitly disabling CMAKE_FIND_ROOT_PATH again it shouldn't be found +find_file(FOO_H_6 ${_HEADER} NO_CMAKE_FIND_ROOT_PATH) +if(FOO_H_6) + message(FATAL_ERROR "${_HEADER} found: ${FOO_H_6}, it should not exist !") +endif(FOO_H_6) diff --git a/Tests/CMakeTests/GetFilenameComponentRealpathTest.cmake.in b/Tests/CMakeTests/GetFilenameComponentRealpathTest.cmake.in new file mode 100644 index 000000000..7adc240f0 --- /dev/null +++ b/Tests/CMakeTests/GetFilenameComponentRealpathTest.cmake.in @@ -0,0 +1,72 @@ +set(bindir ${CMAKE_CURRENT_BINARY_DIR}) + +# +# Test nonexistent REALPATH & ABSOLUTE resolution +# +get_filename_component(nonexistent1 ${bindir}/THIS_IS_A_NONEXISTENT_FILE REALPATH) +get_filename_component(nonexistent2 ${bindir}/THIS_IS_A_NONEXISTENT_FILE ABSOLUTE) +if(NOT nonexistent1 STREQUAL "${bindir}/THIS_IS_A_NONEXISTENT_FILE") + message(FATAL_ERROR "REALPATH is not preserving nonexistent files") +endif() +if(NOT nonexistent2 STREQUAL "${bindir}/THIS_IS_A_NONEXISTENT_FILE") + message(FATAL_ERROR "ABSOLUTE is not preserving nonexistent files") +endif() + +# +# Test treatment of relative paths +# +foreach(c REALPATH ABSOLUTE) + get_filename_component(dir "subdir/THIS_IS_A_NONEXISTENT_FILE" ${c}) + if(NOT "${dir}" STREQUAL "${bindir}/subdir/THIS_IS_A_NONEXISTENT_FILE") + message(FATAL_ERROR + "${c} does not handle relative paths. Expected:\n" + " ${bindir}/subdir/THIS_IS_A_NONEXISTENT_FILE\n" + "but got:\n" + " ${nonexistent1}\n" + ) + endif() +endforeach() + +# +# Test symbolic link resolution +# +if(UNIX) + # file1 => file2 => file3 (real) + file(WRITE ${bindir}/file3 "test file") + + find_program(LN NAMES "ln") + if(LN) + # Create symlinks using "ln -s" + if(NOT EXISTS ${bindir}/file2) + execute_process(COMMAND ${LN} "-s" "${bindir}/file3" "${bindir}/file2") + endif() + if(NOT EXISTS ${bindir}/file1) + execute_process(COMMAND ${LN} "-s" "${bindir}/file2" "${bindir}/file1") + endif() + + get_filename_component(file1 ${bindir}/file1 REALPATH) + get_filename_component(file2 ${bindir}/file2 REALPATH) + get_filename_component(file3 ${bindir}/file3 REALPATH) + + if(NOT file3 STREQUAL "${bindir}/file3") + message(FATAL_ERROR "CMake fails resolving REALPATH file file3") + endif() + + if(NOT file2 STREQUAL "${bindir}/file3") + message(FATAL_ERROR "CMake fails resolving simple symlink") + endif() + + if(NOT file1 STREQUAL "${bindir}/file3") + message(FATAL_ERROR "CMake fails resolving double symlink") + endif() + + # cleanup + file(REMOVE ${bindir}/file1) + file(REMOVE ${bindir}/file2) + if(EXISTS file1 OR EXISTS file2) + message(FATAL_ERROR "removal of file1 or file2 failed") + endif() + endif(LN) + + file(REMOVE ${bindir}/file3) +endif() diff --git a/Tests/CMakeTests/GetPrerequisitesTest.cmake.in b/Tests/CMakeTests/GetPrerequisitesTest.cmake.in new file mode 100644 index 000000000..daf467bcc --- /dev/null +++ b/Tests/CMakeTests/GetPrerequisitesTest.cmake.in @@ -0,0 +1,159 @@ +# Test of the functions in the CMake Modules file: +# +include(GetPrerequisites) + +set(CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@") +set(CMAKE_CONFIGURATION_TYPES "@CMAKE_CONFIGURATION_TYPES@") +set(CMAKE_EXECUTABLE_SUFFIX "@CMAKE_EXECUTABLE_SUFFIX@") + + +message(STATUS "=============================================================================") +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +message(STATUS "") +message(STATUS "CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}'") +message(STATUS "CMAKE_CONFIGURATION_TYPES='${CMAKE_CONFIGURATION_TYPES}'") +message(STATUS "CMAKE_EXECUTABLE_SUFFIX='${CMAKE_EXECUTABLE_SUFFIX}'") +message(STATUS "CTEST_CONFIGURATION_TYPE='${CTEST_CONFIGURATION_TYPE}'") +message(STATUS "") + + +function(stresstest_list_prerequisites file) + message(STATUS "=============================================================================") + message(STATUS "stresstest_list_prerequisites file='${file}'") + message(STATUS "") + + get_filename_component(file_full "${file}" ABSOLUTE) + + message(STATUS "list_prerequisites '${file_full}' 0 0 0") + list_prerequisites("${file_full}" 0 0 0) + message(STATUS "") + + message(STATUS "list_prerequisites '${file_full}' 0 0 1") + list_prerequisites("${file_full}" 0 0 1) + message(STATUS "") + + message(STATUS "list_prerequisites '${file_full}' 0 1 0") + list_prerequisites("${file_full}" 0 1 0) + message(STATUS "") + + message(STATUS "list_prerequisites '${file_full}' 0 1 1") + list_prerequisites("${file_full}" 0 1 1) + message(STATUS "") + + message(STATUS "list_prerequisites '${file_full}' 1 0 0") + list_prerequisites("${file_full}" 1 0 0) + message(STATUS "") + + message(STATUS "list_prerequisites '${file_full}' 1 0 1") + list_prerequisites("${file_full}" 1 0 1) + message(STATUS "") + + message(STATUS "list_prerequisites '${file_full}' 1 1 0") + list_prerequisites("${file_full}" 1 1 0) + message(STATUS "") + + message(STATUS "list_prerequisites '${file_full}' 1 1 1") + list_prerequisites("${file_full}" 1 1 1) + message(STATUS "") + + message(STATUS "=============================================================================") + message(STATUS "") +endfunction(stresstest_list_prerequisites) + + +function(test_cmake_executables) + message(STATUS "=============================================================================") + message(STATUS "Loop over all executable files in the same directory with CMake") + message(STATUS "") + + get_filename_component(cmake_bin_dir "${CMAKE_COMMAND}" PATH) + list_prerequisites_by_glob(GLOB "${cmake_bin_dir}/*" 0 0 1) +endfunction(test_cmake_executables) + + +message(STATUS "=============================================================================") +message(STATUS "Simplest test - list all the direct prerequisites of CMake itself") +message(STATUS "") +list_prerequisites("${CMAKE_COMMAND}" 0 0 1) +message(STATUS "") + +message(STATUS "=============================================================================") +string(LENGTH "$ENV{PATH}" PATH_LENGTH_BEGIN) +message(STATUS "Begin PATH length is: ${PATH_LENGTH_BEGIN}") +message(STATUS "") + + +# Leave the code for these tests in here, but turn them off by default... they +# take longer than they're worth during development... +# +set(do_testdefaults 0) +if(do_testdefaults) + message(STATUS "=============================================================================") + message(STATUS "Test default argument values to list_prerequisites function...") + message(STATUS "") + list_prerequisites("${CMAKE_COMMAND}") + message(STATUS "") +endif(do_testdefaults) + + +set(do_stresstest 0) +if(do_stresstest) + message(STATUS "=============================================================================") + message(STATUS "stresstest_list_prerequisites with CMake itself...") + message(STATUS "") + stresstest_list_prerequisites("${CMAKE_COMMAND}") + message(STATUS "") +endif(do_stresstest) + + +test_cmake_executables() + + +message(STATUS "=============================================================================") +message(STATUS "Test overriding 'gp_tool' with bogus value") +message(STATUS "") +set(gp_tool "bogus") +list_prerequisites("${CMAKE_COMMAND}" 0 0 0) +set(gp_tool) +message(STATUS "") + + +message(STATUS "=============================================================================") +message(STATUS "Test overriding 'gp_tool' with value unlikely to be found") +message(STATUS "") +if(APPLE) + set(gp_tool "dumpbin") +else() + set(gp_tool "otool") +endif() +set(gp_cmd "gp_cmd-NOTFOUND") +list_prerequisites("${CMAKE_COMMAND}" 0 0 0) +set(gp_cmd) +set(gp_tool) +message(STATUS "") + + +message(STATUS "=============================================================================") +message(STATUS "All variables: (Make sure functions/macros are not leaving stuff around...") +message(STATUS " Only variables predefined by CMake and defined in this") +message(STATUS " test script file should be listed here...)") +message(STATUS "") +get_cmake_property(vs VARIABLES) +foreach(v ${vs}) + message(STATUS "${v}='${${v}}'") +endforeach(v) +message(STATUS "") + +message(STATUS "=============================================================================") +string(LENGTH "$ENV{PATH}" PATH_LENGTH_END) +message(STATUS "Final PATH length is: ${PATH_LENGTH_END}") + +if(PATH_LENGTH_END GREATER ${PATH_LENGTH_BEGIN}) + message(FATAL_ERROR "list_prerequisties is endlessly appending the path of gp_tool to the PATH.") +endif() +message(STATUS "") + + +message(STATUS "=============================================================================") +message(STATUS "End of test") +message(STATUS "") diff --git a/Tests/CMakeTests/GetProperty-Bad-Argument.cmake b/Tests/CMakeTests/GetProperty-Bad-Argument.cmake new file mode 100644 index 000000000..382dabb50 --- /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 000000000..cdbfa807c --- /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 000000000..ea8566b50 --- /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 000000000..9992dabed --- /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 000000000..44bf3ebc5 --- /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 000000000..6c2c3620e --- /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 000000000..497700cb3 --- /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 000000000..f0d004dc4 --- /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 000000000..9719fe775 --- /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 000000000..bee230d9b --- /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 000000000..89773c810 --- /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 000000000..8f1fa23af --- /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 000000000..045bd56ec --- /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 000000000..9190f80ad --- /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 000000000..ab96e5b52 --- /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/If-Invalid-Argument.cmake b/Tests/CMakeTests/If-Invalid-Argument.cmake new file mode 100644 index 000000000..b4fb97f41 --- /dev/null +++ b/Tests/CMakeTests/If-Invalid-Argument.cmake @@ -0,0 +1,2 @@ +if (NOT foo bar STREQUAL "foo bar") +endif() diff --git a/Tests/CMakeTests/IfTest.cmake.in b/Tests/CMakeTests/IfTest.cmake.in new file mode 100644 index 000000000..639e22672 --- /dev/null +++ b/Tests/CMakeTests/IfTest.cmake.in @@ -0,0 +1,166 @@ +# Prepare variable definitions. +set(VAR_UNDEFINED) +set(VAR_PATH /some/path/to/a/file.txt) +set(FALSE_NAMES OFF NO FALSE N FOO-NOTFOUND IGNORE Off No False Ignore off n no false ignore) +set(TRUE_NAMES ON YES TRUE Y On Yes True on yes true y) +foreach(_arg "" 0 1 2 ${TRUE_NAMES} ${FALSE_NAMES}) + set(VAR_${_arg} "${_arg}") +endforeach() + +macro(test_vars _old) + # Variables set to false or not set. + foreach(_var "" 0 ${FALSE_NAMES} UNDEFINED) + if(VAR_${_var}) + message(FATAL_ERROR "${_old}if(VAR_${_var}) is true!") + else() + message(STATUS "${_old}if(VAR_${_var}) is false") + endif() + + if(NOT VAR_${_var}) + message(STATUS "${_old}if(NOT VAR_${_var}) is true") + else() + message(FATAL_ERROR "${_old}if(NOT VAR_${_var}) is false!") + endif() + endforeach() + + # Variables set to true. + foreach(_var 1 2 ${TRUE_NAMES} PATH) + if(VAR_${_var}) + message(STATUS "${_old}if(VAR_${_var}) is true") + else() + message(FATAL_ERROR "${_old}if(VAR_${_var}) is false!") + endif() + + if(NOT VAR_${_var}) + message(FATAL_ERROR "${_old}if(NOT VAR_${_var}) is true!") + else() + message(STATUS "${_old}if(NOT VAR_${_var}) is false") + endif() + endforeach() +endmacro() + +#----------------------------------------------------------------------------- +# Test the OLD behavior of CMP0012. +cmake_policy(SET CMP0012 OLD) + +# False constants not recognized (still false). +foreach(_false "" ${FALSE_NAMES}) + if("${_false}") + message(FATAL_ERROR "OLD if(${_false}) is true!") + else() + message(STATUS "OLD if(${_false}) is false") + endif() + + if(NOT "${_false}") + message(STATUS "OLD if(NOT ${_false}) is true") + else() + message(FATAL_ERROR "OLD if(NOT ${_false}) is false!") + endif() +endforeach() + +# True constants not recognized. +foreach(_false ${TRUE_NAMES}) + if(${_false}) + message(FATAL_ERROR "OLD if(${_false}) is true!") + else() + message(STATUS "OLD if(${_false}) is false") + endif() + + if(NOT ${_false}) + message(STATUS "OLD if(NOT ${_false}) is true") + else() + message(FATAL_ERROR "OLD if(NOT ${_false}) is false!") + endif() +endforeach() + +# Numbers not recognized properly. +foreach(_num 2 -2 2.0 -2.0 2x -2x) + if(${_num}) + message(FATAL_ERROR "OLD if(${_num}) is true!") + else() + message(STATUS "OLD if(${_num}) is false") + endif() + + if(NOT ${_num}) + message(FATAL_ERROR "OLD if(NOT ${_num}) is true!") + else() + message(STATUS "OLD if(NOT ${_num}) is false") + endif() +endforeach() + +test_vars("OLD ") + +#----------------------------------------------------------------------------- + +# Test the NEW behavior of CMP0012. +cmake_policy(SET CMP0012 NEW) + +# Test false constants. +foreach(_false "" 0 ${FALSE_NAMES}) + if("${_false}") + message(FATAL_ERROR "if(${_false}) is true!") + else() + message(STATUS "if(${_false}) is false") + endif() + + if(NOT "${_false}") + message(STATUS "if(NOT ${_false}) is true") + else() + message(FATAL_ERROR "if(NOT ${_false}) is false!") + endif() +endforeach() + +# Test true constants. +foreach(_true 1 ${TRUE_NAMES}) + if(${_true}) + message(STATUS "if(${_true}) is true") + else() + message(FATAL_ERROR "if(${_true}) is false!") + endif() + + if(NOT ${_true}) + message(FATAL_ERROR "if(NOT ${_true}) is true!") + else() + message(STATUS "if(NOT ${_true}) is false") + endif() +endforeach() + +# Numbers recognized properly. +foreach(_num 2 -2 2.0 -2.0) + if(${_num}) + message(STATUS "if(${_num}) is true") + else() + message(FATAL_ERROR "if(${_num}) is false!") + endif() + + if(NOT ${_num}) + message(FATAL_ERROR "if(NOT ${_num}) is true!") + else() + message(STATUS "if(NOT ${_num}) is false") + endif() +endforeach() + +# Bad numbers not recognized. +foreach(_bad 2x -2x) + if(${_bad}) + message(FATAL_ERROR "if(${_bad}) is true!") + else() + message(STATUS "if(${_bad}) is false") + endif() + + if(NOT ${_bad}) + message(STATUS "if(NOT ${_bad}) is true") + else() + message(FATAL_ERROR "if(NOT ${_bad}) is false!") + endif() +endforeach() + +test_vars("") + +set(Invalid-Argument-RESULT 1) +set(Invalid-Argument-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?If-Invalid-Argument.cmake:1 \\(if\\):.*Unknown arguments specified.*") + +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") +check_cmake_test(If + Invalid-Argument +) diff --git a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in new file mode 100644 index 000000000..dbe95005e --- /dev/null +++ b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in @@ -0,0 +1,420 @@ +# This is not supposed to be included by user code, but we need to +# test it. +include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake) + +#----------------------------------------------------------------------------- +# Linux + +# gcc dummy.c -v +set(linux64_gcc_text " /usr/lib/gcc/x86_64-linux-gnu/4.3.3/collect2 --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.3.3/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../.. -L/usr/lib/x86_64-linux-gnu /tmp/ccEO9iux.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.3.3/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/crtn.o") +set(linux64_gcc_libs "c") +set(linux64_gcc_dirs "/usr/lib/gcc/x86_64-linux-gnu/4.3.3;/usr/lib;/lib;/usr/lib/x86_64-linux-gnu") +list(APPEND platforms linux64_gcc) + +# g++ dummy.cxx -v +set(linux64_g++_text " /usr/lib/gcc/x86_64-linux-gnu/4.3.3/collect2 --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.3.3/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../.. -L/usr/lib/x86_64-linux-gnu /tmp/ccalRBlq.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.3.3/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/crtn.o") +set(linux64_g++_libs "stdc++;m;c") +set(linux64_g++_dirs "/usr/lib/gcc/x86_64-linux-gnu/4.3.3;/usr/lib;/lib;/usr/lib/x86_64-linux-gnu") +list(APPEND platforms linux64_g++) + +# f95 dummy.f -v +set(linux64_f95_text " /usr/lib/gcc/x86_64-linux-gnu/4.3.3/collect2 --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.3.3/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../.. -L/usr/lib/x86_64-linux-gnu /tmp/ccAVcN7N.o -lgfortranbegin -lgfortran -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.3.3/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/crtn.o") +set(linux64_f95_libs "gfortranbegin;gfortran;m;c") +set(linux64_f95_dirs "/usr/lib/gcc/x86_64-linux-gnu/4.3.3;/usr/lib;/lib;/usr/lib/x86_64-linux-gnu") +list(APPEND platforms linux64_f95) + +# suncc dummy.c '-#' +set(linux64_suncc_text "/usr/bin/ld --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /opt/sun/sunstudio12/prod/lib/amd64/crti.o /opt/sun/sunstudio12/prod/lib/amd64/crt1x.o /opt/sun/sunstudio12/prod/lib/amd64/values-xa.o dummy.o -Y \"/opt/sun/sunstudio12/prod/lib/amd64:/lib64:/usr/lib64\" -Qy -lc /opt/sun/sunstudio12/prod/lib/amd64/libc_supp.a /opt/sun/sunstudio12/prod/lib/amd64/crtn.o") +set(linux64_suncc_libs "c;/opt/sun/sunstudio12/prod/lib/amd64/libc_supp.a") +set(linux64_suncc_dirs "/opt/sun/sunstudio12/prod/lib/amd64;/lib64;/usr/lib64") +list(APPEND platforms linux64_suncc) + +# sunCC dummy.cxx -v +set(linux64_sunCC_text "/opt/sun/sunstudio12/prod/lib/amd64/ld -u __1cH__CimplKcplus_init6F_v_ --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -R/opt/sun/sunstudio12/lib/rw7/amd64:/opt/sun/sunstudio12/lib/amd64:/opt/sun/sunstudio12/rtlibs/amd64:/opt/sun/lib/rtlibs/amd64:/opt/SUNWspro/lib/amd64:/lib64:/usr/lib64 -o a.out /opt/sun/sunstudio12/prod/lib/amd64/crti.o /opt/sun/sunstudio12/prod/lib/amd64/CCrti.o /opt/sun/sunstudio12/prod/lib/amd64/crt1x.o -Y P,/opt/sun/sunstudio12/lib/rw7/amd64:/opt/sun/sunstudio12/lib/amd64:/opt/sun/sunstudio12/rtlibs/amd64:/opt/sun/sunstudio12/prod/lib/rw7/amd64:/opt/sun/sunstudio12/prod/lib/amd64:/lib64:/usr/lib64 dummy.o -lCstd -lCrun -lm -lc /opt/sun/sunstudio12/prod/lib/amd64/libc_supp.a /opt/sun/sunstudio12/prod/lib/amd64/CCrtn.o /opt/sun/sunstudio12/prod/lib/amd64/crtn.o >&/tmp/ld.04973.2.err") +set(linux64_sunCC_libs "Cstd;Crun;m;c;/opt/sun/sunstudio12/prod/lib/amd64/libc_supp.a") +set(linux64_sunCC_dirs "/opt/sun/sunstudio12/lib/rw7/amd64;/opt/sun/sunstudio12/lib/amd64;/opt/sun/sunstudio12/rtlibs/amd64;/opt/sun/sunstudio12/prod/lib/rw7/amd64;/opt/sun/sunstudio12/prod/lib/amd64;/lib64;/usr/lib64") +list(APPEND platforms linux64_sunCC) + +# sunf90 dummy.f -v +set(linux64_sunf90_text "/usr/bin/ld --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -R/opt/sun/sunstudio12/lib/amd64:/opt/sun/sunstudio12/rtlibs/amd64:/opt/sun/lib/rtlibs/amd64 -o a.out /opt/sun/sunstudio12/prod/lib/amd64/crti.o /opt/sun/sunstudio12/prod/lib/amd64/crt1x.o /opt/sun/sunstudio12/prod/lib/amd64/values-xi.o -Y P,/opt/sun/sunstudio12/lib/amd64:/opt/sun/sunstudio12/rtlibs/amd64:/opt/sun/sunstudio12/prod/lib/amd64:/lib64:/usr/lib64 dummy.o -lfui -lfai -lfsu -Bdynamic -lmtsk -lpthread -lm -lc /opt/sun/sunstudio12/prod/lib/amd64/libc_supp.a /opt/sun/sunstudio12/prod/lib/amd64/crtn.o") +set(linux64_sunf90_libs "fui;fai;fsu;mtsk;pthread;m;c;/opt/sun/sunstudio12/prod/lib/amd64/libc_supp.a") +set(linux64_sunf90_dirs "/opt/sun/sunstudio12/lib/amd64;/opt/sun/sunstudio12/rtlibs/amd64;/opt/sun/sunstudio12/prod/lib/amd64;/lib64;/usr/lib64") +list(APPEND platforms linux64_sunf90) + +# icc dummy.c -v +set(linux64_icc_text "ld /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crt1.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtbegin.o --eh-frame-hdr -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /tmp/iccBP8OfN.o -L/opt/compiler/intel/compiler/11.0/lib/intel64 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../.. -L/lib64 -L/lib -L/usr/lib64 -L/usr/lib -Bstatic -limf -lsvml -Bdynamic -lm -Bstatic -lipgo -ldecimal -lirc -Bdynamic -lgcc_s -lgcc -Bstatic -lirc -Bdynamic -lc -lgcc_s -lgcc -Bstatic -lirc_s -Bdynamic -ldl -lc /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtend.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crtn.o") +set(linux64_icc_libs "imf;svml;m;ipgo;decimal;irc;irc;c;irc_s;dl;c") +set(linux64_icc_dirs "/opt/compiler/intel/compiler/11.0/lib/intel64;/usr/lib64/gcc/x86_64-suse-linux/4.1.2;/usr/lib64;/lib64;/usr/x86_64-suse-linux/lib;/lib;/usr/lib") +list(APPEND platforms linux64_icc) + +# icxx dummy.cxx -v +set(linux64_icxx_text "ld /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crt1.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtbegin.o --eh-frame-hdr -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /tmp/icpc270GoT.o -L/opt/compiler/intel/compiler/11.0/lib/intel64 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../.. -L/lib64 -L/lib -L/usr/lib64 -L/usr/lib -Bstatic -limf -lsvml -Bdynamic -lm -Bstatic -lipgo -ldecimal -Bdynamic -lstdc++ -Bstatic -lirc -Bdynamic -lgcc_s -lgcc -Bstatic -lirc -Bdynamic -lc -lgcc_s -lgcc -Bstatic -lirc_s -Bdynamic -ldl -lc /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtend.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crtn.o") +set(linux64_icxx_libs "imf;svml;m;ipgo;decimal;stdc++;irc;irc;c;irc_s;dl;c") +set(linux64_icxx_dirs "/opt/compiler/intel/compiler/11.0/lib/intel64;/usr/lib64/gcc/x86_64-suse-linux/4.1.2;/usr/lib64;/lib64;/usr/x86_64-suse-linux/lib;/lib;/usr/lib") +list(APPEND platforms linux64_icxx) + +# ifort dummy.f -v +set(linux64_ifort_text "ld --eh-frame-hdr -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out -L/opt/compiler/intel/compiler/11.0/lib/intel64 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../.. -L/lib64 -L/lib -L/usr/lib64 -L/usr/lib /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crt1.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtbegin.o /opt/compiler/intel/compiler/11.0/lib/intel64/for_main.o dum.cxx -Bstatic -lifport -lifcore -limf -lsvml -Bdynamic -lm -Bstatic -lipgo -lirc -Bdynamic -lpthread -lc -lgcc_s -lgcc -Bstatic -lirc_s -Bdynamic -ldl -lc /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtend.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crtn.o") +set(linux64_ifort_libs "ifport;ifcore;imf;svml;m;ipgo;irc;pthread;c;irc_s;dl;c") +set(linux64_ifort_dirs "/opt/compiler/intel/compiler/11.0/lib/intel64;/usr/lib64/gcc/x86_64-suse-linux/4.1.2;/usr/lib64;/lib64;/usr/x86_64-suse-linux/lib;/lib;/usr/lib") +list(APPEND platforms linux64_ifort) + +# pgcc dummy.c -v +set(linux64_pgcc_text "/usr/bin/ld /usr/lib64/crt1.o /usr/lib64/crti.o /opt/compiler/pgi/linux86-64/8.0-3/lib/trace_init.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtbegin.o -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /opt/compiler/pgi/linux86-64/8.0-3/lib/pgi.ld -L/opt/compiler/pgi/linux86-64/8.0-3/lib -L/usr/lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2 /tmp/pgcc7OscXa5ur7Zk.o -rpath /opt/compiler/pgi/linux86-64/8.0-3/lib -lnspgc -lpgc -lm -lgcc -lc -lgcc /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtend.o /usr/lib64/crtn.o") +set(linux64_pgcc_libs "nspgc;pgc;m;c") +set(linux64_pgcc_dirs "/opt/compiler/pgi/linux86-64/8.0-3/lib;/usr/lib64;/usr/lib64/gcc/x86_64-suse-linux/4.1.2") +list(APPEND platforms linux64_pgcc) + +# pgCC dummy.cxx -v +set(linux64_pgCC_text "/usr/bin/ld /usr/lib64/crt1.o /usr/lib64/crti.o /opt/compiler/pgi/linux86-64/8.0-3/lib/trace_init.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtbegin.o -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /opt/compiler/pgi/linux86-64/8.0-3/lib/pgi.ld -L/opt/compiler/pgi/linux86-64/8.0-3/lib -L/usr/lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2 /tmp/pgCCFhjcDt1fs1Ki.o -rpath /opt/compiler/pgi/linux86-64/8.0-3/lib -lstd -lC -lnspgc -lpgc -lm -lgcc -lc -lgcc /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtend.o /usr/lib64/crtn.o") +set(linux64_pgCC_libs "std;C;nspgc;pgc;m;c") +set(linux64_pgCC_dirs "/opt/compiler/pgi/linux86-64/8.0-3/lib;/usr/lib64;/usr/lib64/gcc/x86_64-suse-linux/4.1.2") +list(APPEND platforms linux64_pgCC) + +# pgf90 dummy.f -v +set(linux64_pgf90_text "/usr/bin/ld /usr/lib64/crt1.o /usr/lib64/crti.o /opt/compiler/pgi/linux86-64/8.0-3/lib/trace_init.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtbegin.o /opt/compiler/pgi/linux86-64/8.0-3/lib/f90main.o -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /opt/compiler/pgi/linux86-64/8.0-3/lib/pgi.ld -L/opt/compiler/pgi/linux86-64/8.0-3/lib -L/usr/lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2 /tmp/pgf90QOIc_eB9xY5h.o -rpath /opt/compiler/pgi/linux86-64/8.0-3/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lnspgc -lpgc -lrt -lpthread -lm -lgcc -lc -lgcc /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtend.o /usr/lib64/crtn.o") +set(linux64_pgf90_libs "pgf90;pgf90_rpm1;pgf902;pgf90rtl;pgftnrtl;nspgc;pgc;rt;pthread;m;c") +set(linux64_pgf90_dirs "/opt/compiler/pgi/linux86-64/8.0-3/lib;/usr/lib64;/usr/lib64/gcc/x86_64-suse-linux/4.1.2") +list(APPEND platforms linux64_pgf90) + +# nagfor dummy.f -Wl,-v +set(linux64_nagfor_text " /usr/libexec/gcc/x86_64-redhat-linux/4.4.5/collect2 --no-add-needed --eh-frame-hdr --build-id -m elf_x86_64 --hash-style=gnu -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/lib/gcc/x86_64-redhat-linux/4.4.5/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.4.5/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.4.5/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/4.4.5 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.5 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.5/../../.. /usr/local/NAG/lib/f90_init.o /usr/local/NAG/lib/quickfit.o dummy.o -rpath /usr/local/NAG/lib /usr/local/NAG/lib/libf53.so /usr/local/NAG/lib/libf53.a -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-redhat-linux/4.4.5/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.4.5/../../../../lib64/crtn.o") +set(linux64_nagfor_libs "/usr/local/NAG/lib/f90_init.o;/usr/local/NAG/lib/quickfit.o;/usr/local/NAG/lib/libf53.a;m;c") +set(linux64_nagfor_dirs "/usr/lib/gcc/x86_64-redhat-linux/4.4.5;/usr/lib64;/lib64;/usr/lib") +set(linux64_nagfor_obj_regex "^/usr/local/NAG/lib") +list(APPEND platforms linux64_nagfor) + +# absoft dummy.f -X -v +set(linux64_absoft_text "collect2 version 4.4.5 (x86-64 Linux/ELF) +/usr/bin/ld --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.4.5/crtbegin.o -L/opt/absoft11.1/lib64 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.5 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.5 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../.. /tmp/E3Bii1/dummy.o -v -laf90math -lafio -lamisc -labsoftmain -laf77math -lm -lmv -lpthread -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.4.5/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crtn.o") +set(linux64_absoft_libs "af90math;afio;amisc;absoftmain;af77math;m;mv;pthread;c") +set(linux64_absoft_dirs "/opt/absoft11.1/lib64;/usr/lib/gcc/x86_64-linux-gnu/4.4.5;/usr/lib;/lib") +list(APPEND platforms linux64_absoft) + +# gcc dummy.c -v # in strange path +set(linux64_test1_text " +/this/might/match/as/a/linker/ld/but/it/is/not because the ld is not the last path component +${linux64_gcc_text}") +set(linux64_test1_libs "${linux64_gcc_libs}") +set(linux64_test1_dirs "${linux64_gcc_dirs}") +list(APPEND platforms linux64_test1) + +#----------------------------------------------------------------------------- +# Mac + +# gcc -arch i686 dummy.c -v +set(mac_i686_gcc_text " /usr/libexec/gcc/i686-apple-darwin10/4.2.1/collect2 -dynamic -arch i386 -macosx_version_min 10.6.0 -weak_reference_mismatches non-weak -o a.out -lcrt1.10.6.o -L/usr/lib/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../.. /var/tmp//ccnhXAGL.o -lSystem -lgcc -lSystem") +set(mac_i686_gcc_libs "") +set(mac_i686_gcc_dirs "/usr/lib/i686-apple-darwin10/4.2.1;/usr/lib/gcc/i686-apple-darwin10/4.2.1;/usr/lib") +list(APPEND platforms mac_i686_gcc) + +# g++ -arch i686 dummy.cxx -v +set(mac_i686_g++_text " /usr/libexec/gcc/i686-apple-darwin10/4.2.1/collect2 -dynamic -arch i386 -macosx_version_min 10.6.0 -weak_reference_mismatches non-weak -o a.out -lcrt1.10.6.o -L/usr/lib/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../.. /var/tmp//ccEXXICh.o -lstdc++ -lSystem -lgcc -lSystem") +set(mac_i686_g++_libs "stdc++") +set(mac_i686_g++_dirs "/usr/lib/i686-apple-darwin10/4.2.1;/usr/lib/gcc/i686-apple-darwin10/4.2.1;/usr/lib") +list(APPEND platforms mac_i686_g++) + +# gfortran dummy.f -v +set(mac_i686_gfortran_text " /usr/libexec/gcc/i386-apple-darwin9.7.0/4.4.1/collect2 -dynamic -arch i386 -macosx_version_min 10.6.0 -weak_reference_mismatches non-weak -o a.out -lcrt1.10.5.o -L/usr/lib/gcc/i386-apple-darwin9.7.0/4.4.1 -L/usr/lib/gcc -L/usr/lib/gcc/i386-apple-darwin9.7.0/4.4.1/../../.. /var/tmp//ccgqbX5P.o -lgfortranbegin -lgfortran -lgcc_s.10.5 -lgcc -lSystem") +set(mac_i686_gfortran_libs "gfortranbegin;gfortran") +set(mac_i686_gfortran_dirs "/usr/lib/gcc/i386-apple-darwin9.7.0/4.4.1;/usr/lib/gcc;/usr/lib") +list(APPEND platforms mac_i686_gfortran) + +# gcc -arch ppc dummy.c -v +set(mac_ppc_gcc_text " /usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/collect2 -dynamic -arch ppc -macosx_version_min 10.6.0 -weak_reference_mismatches non-weak -o a.out -lcrt1.10.5.o -L/usr/lib/powerpc-apple-darwin10/4.2.1 -L/usr/lib/gcc/powerpc-apple-darwin10/4.2.1 -L/usr/lib/gcc/powerpc-apple-darwin10/4.2.1 -L/usr/lib/gcc/powerpc-apple-darwin10/4.2.1/../../../powerpc-apple-darwin10/4.2.1 -L/usr/lib/gcc/powerpc-apple-darwin10/4.2.1/../../.. /var/tmp//ccdcolsP.o -lgcc -lSystemStubs -lSystem") +set(mac_ppc_gcc_libs "") +set(mac_ppc_gcc_dirs "/usr/lib/powerpc-apple-darwin10/4.2.1;/usr/lib/gcc/powerpc-apple-darwin10/4.2.1;/usr/lib") +list(APPEND platforms mac_ppc_gcc) + +# g++ -arch ppc dummy.cxx -v +set(mac_ppc_g++_text " /usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/collect2 -dynamic -arch ppc -macosx_version_min 10.6.0 -weak_reference_mismatches non-weak -o a.out -lcrt1.10.5.o -L/usr/lib/powerpc-apple-darwin10/4.2.1 -L/usr/lib/gcc/powerpc-apple-darwin10/4.2.1 -L/usr/lib/gcc/powerpc-apple-darwin10/4.2.1 -L/usr/lib/gcc/powerpc-apple-darwin10/4.2.1/../../../powerpc-apple-darwin10/4.2.1 -L/usr/lib/gcc/powerpc-apple-darwin10/4.2.1/../../.. /var/tmp//ccbjB6Lj.o -lstdc++ -lgcc -lSystemStubs -lSystem") +set(mac_ppc_g++_libs "stdc++") +set(mac_ppc_g++_dirs "/usr/lib/powerpc-apple-darwin10/4.2.1;/usr/lib/gcc/powerpc-apple-darwin10/4.2.1;/usr/lib") +list(APPEND platforms mac_ppc_g++) + +# absoft dummy.f -X -v +set(mac_absoft_text "collect2 version 4.2.1 (Apple Inc. build 5664) (i686 Darwin) +/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld -dynamic -arch i386 -macosx_version_min 10.6.6 -weak_reference_mismatches non-weak -o a.out -lcrt1.10.6.o -L/Applications/Absoft11.1/lib -L/usr/lib/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../.. /var/folders/04/04+Djjm8GZWBmuEdp2Gsw++++TM/-Tmp-//bTAoJc/dummy.o -v -Y 10 -laf90math -lafio -lamisc -labsoftmain -laf77math -lm -lmv -lSystem -lgcc -lSystem +") +set(mac_absoft_libs "af90math;afio;amisc;absoftmain;af77math;m;mv") +set(mac_absoft_dirs "/Applications/Absoft11.1/lib;/usr/lib/i686-apple-darwin10/4.2.1;/usr/lib/gcc/i686-apple-darwin10/4.2.1;/usr/lib") +list(APPEND platforms mac_absoft) + +#----------------------------------------------------------------------------- +# Sun + +# cc dummy.c '-#'/ +set(sun_cc_text "/usr/ccs/bin/ld /opt/SUNWspro/prod/lib/crti.o /opt/SUNWspro/prod/lib/crt1.o /opt/SUNWspro/prod/lib/misalign.o /opt/SUNWspro/prod/lib/values-xa.o dummy.o -Y \"P,/opt/SUNWspro/prod/lib/v8plus:/opt/SUNWspro/prod/lib:/usr/ccs/lib:/lib:/usr/lib\" -Qy -lc /opt/SUNWspro/prod/lib/crtn.o") +set(sun_cc_libs "c") +set(sun_cc_dirs "/opt/SUNWspro/prod/lib/v8plus;/opt/SUNWspro/prod/lib;/usr/ccs/lib;/lib;/usr/lib") +list(APPEND platforms sun_cc) + +# CC dummy.cxx -v +set(sun_CC_text "/usr/ccs/bin/ld -u __1cH__CimplKcplus_init6F_v_ -zld32=-S/opt/SUNWspro/prod/lib/libldstab_ws.so -zld64=-S/opt/SUNWspro/prod/lib/v9/libldstab_ws.so -zld32=-S/opt/SUNWspro/prod/lib/libCCexcept.so.1 -zld64=-S/opt/SUNWspro/prod/lib/v9/libCCexcept.so.1 -R/opt/SUNWspro/lib/rw7:/opt/SUNWspro/lib/v8plus:/opt/SUNWspro/lib:/usr/ccs/lib:/lib:/usr/lib -o a.out /opt/SUNWspro/prod/lib/crti.o /opt/SUNWspro/prod/lib/CCrti.o /opt/SUNWspro/prod/lib/crt1.o /opt/SUNWspro/prod/lib/misalign.o /opt/SUNWspro/prod/lib/values-xa.o -Y P,/opt/SUNWspro/lib/rw7:/opt/SUNWspro/lib/v8plus:/opt/SUNWspro/prod/lib/rw7:/opt/SUNWspro/prod/lib/v8plus:/opt/SUNWspro/lib:/opt/SUNWspro/prod/lib:/usr/ccs/lib:/lib:/usr/lib dummy.o -lCstd -lCrun -lm -lc /opt/SUNWspro/prod/lib/CCrtn.o /opt/SUNWspro/prod/lib/crtn.o >&/tmp/ld.14846.2.err") +set(sun_CC_libs "Cstd;Crun;m;c") +set(sun_CC_dirs "/opt/SUNWspro/lib/rw7;/opt/SUNWspro/lib/v8plus;/opt/SUNWspro/prod/lib/rw7;/opt/SUNWspro/prod/lib/v8plus;/opt/SUNWspro/lib;/opt/SUNWspro/prod/lib;/usr/ccs/lib;/lib;/usr/lib") +list(APPEND platforms sun_CC) + +# f77 dummy.f -v +set(sun_f77_text "/usr/ccs/bin/ld -t -R/opt/SUNWspro/lib/v8plus:/opt/SUNWspro/lib -o a.out /opt/SUNWspro/prod/lib/crti.o /opt/SUNWspro/prod/lib/crt1.o /opt/SUNWspro/prod/lib/misalign.o /opt/SUNWspro/prod/lib/values-xi.o -Y P,/opt/SUNWspro/lib/v8plus:/opt/SUNWspro/prod/lib/v8plus:/opt/SUNWspro/lib:/opt/SUNWspro/prod/lib:/usr/ccs/lib:/lib:/usr/lib dummy.o -lf77compat -zallextract -lompstubs -zdefaultextract -lfui -lfai -lfai2 -lfsumai -lfprodai -lfminlai -lfmaxlai -lfminvai -lfmaxvai -lfsu -lsunmath -lm -lc /opt/SUNWspro/prod/lib/crtn.o") +set(sun_f77_libs "f77compat;-zallextract;ompstubs;-zdefaultextract;fui;fai;fai2;fsumai;fprodai;fminlai;fmaxlai;fminvai;fmaxvai;fsu;sunmath;m;c") +set(sun_f77_dirs "/opt/SUNWspro/lib/v8plus;/opt/SUNWspro/prod/lib/v8plus;/opt/SUNWspro/lib;/opt/SUNWspro/prod/lib;/usr/ccs/lib;/lib;/usr/lib") +list(APPEND platforms sun_f77) + +# f90 dummy.f -v +set(sun_f90_text "/usr/ccs/bin/ld -t -R/opt/SUNWspro/lib/v8plus:/opt/SUNWspro/lib -o a.out /opt/SUNWspro/prod/lib/crti.o /opt/SUNWspro/prod/lib/crt1.o /opt/SUNWspro/prod/lib/misalign.o /opt/SUNWspro/prod/lib/values-xi.o -Y P,/opt/SUNWspro/lib/v8plus:/opt/SUNWspro/prod/lib/v8plus:/opt/SUNWspro/lib:/opt/SUNWspro/prod/lib:/usr/ccs/lib:/lib:/usr/lib dummy.o -zallextract -lompstubs -zdefaultextract -lfui -lfai -lfai2 -lfsumai -lfprodai -lfminlai -lfmaxlai -lfminvai -lfmaxvai -lfsu -lsunmath -lm -lc /opt/SUNWspro/prod/lib/crtn.o") +set(sun_f90_libs "-zallextract;ompstubs;-zdefaultextract;fui;fai;fai2;fsumai;fprodai;fminlai;fmaxlai;fminvai;fmaxvai;fsu;sunmath;m;c") +set(sun_f90_dirs "/opt/SUNWspro/lib/v8plus;/opt/SUNWspro/prod/lib/v8plus;/opt/SUNWspro/lib;/opt/SUNWspro/prod/lib;/usr/ccs/lib;/lib;/usr/lib") +list(APPEND platforms sun_f90) + +#----------------------------------------------------------------------------- +# AIX + +# xlc -q32 dummy.c -V +set(aix_xlc_32_text "/bin/ld -b32 /lib/crt0.o -bpT:0x10000000 -bpD:0x20000000 dummy.o -L/usr/vac/lib -lxlopt -lxl -lc") +set(aix_xlc_32_libs "xlopt;xl;c") +set(aix_xlc_32_dirs "/usr/vac/lib") +list(APPEND platforms aix_xlc_32) + +# xlc -q64 dummy.c -V +set(aix_xlc_64_text "/bin/ld -b64 /lib/crt0_64.o -bpT:0x100000000 -bpD:0x110000000 dummy.o -L/usr/vac/lib -lxlopt -lxl -lc") +set(aix_xlc_64_libs "xlopt;xl;c") +set(aix_xlc_64_dirs "/usr/vac/lib") +list(APPEND platforms aix_xlc_64) + +# xlC -q32 dummy.cxx -V +set(aix_xlC_32_text " +/bin/ld -b32 /lib/crt0.o -bpT:0x10000000 -bpD:0x20000000 dummy.o -L/usr/vac/lib -lxlopt -lxl -L/usr/vacpp/lib -lC -lm -lc -bnobind >/tmp/xlcLDW0agyh +/bin/ld -b32 /lib/crt0.o -bpT:0x10000000 -bpD:0x20000000 dummy.o -L/usr/vac/lib -lxlopt -lxl -L/usr/vacpp/lib -lC -lm -lc |") +set(aix_xlC_32_libs "xlopt;xl;C;m;c") +set(aix_xlC_32_dirs "/usr/vac/lib;/usr/vacpp/lib") +list(APPEND platforms aix_xlC_32) + +# xlC -q64 dummy.cxx -V +set(aix_xlC_64_text " +/bin/ld -b64 /lib/crt0_64.o -bpT:0x100000000 -bpD:0x110000000 dummy.o -L/usr/vac/lib -lxlopt -lxl -L/usr/vacpp/lib -lC -lm -lc -bnobind >/tmp/xlcLD5nUnah +/bin/ld -b64 /lib/crt0_64.o -bpT:0x100000000 -bpD:0x110000000 dummy.o -L/usr/vac/lib -lxlopt -lxl -L/usr/vacpp/lib -lC -lm -lc |") +set(aix_xlC_64_libs "xlopt;xl;C;m;c") +set(aix_xlC_64_dirs "/usr/vac/lib;/usr/vacpp/lib") +list(APPEND platforms aix_xlC_64) + +# xlf -q32 dummy.f -V +set(aix_xlf_32_text "/bin/ld -b32 /lib/crt0.o -bpT:0x10000000 -bpD:0x20000000 -bh:4 -bh:4 -bh:4 -bh:4 dummy.o -lxlf90 -L/usr/lpp/xlf/lib -lxlopt -lxlf -lxlomp_ser -lm -lc") +set(aix_xlf_32_libs "xlf90;xlopt;xlf;xlomp_ser;m;c") +set(aix_xlf_32_dirs "/usr/lpp/xlf/lib") +list(APPEND platforms aix_xlf_32) + +# xlf -q64 dummy.f -V +set(aix_xlf_64_text "/bin/ld -b64 /lib/crt0_64.o -bpT:0x100000000 -bpD:0x110000000 -bh:4 -bh:4 -bh:4 -bh:4 dummy.o -lxlf90 -L/usr/lpp/xlf/lib -lxlopt -lxlf -lxlomp_ser -lm -lc") +set(aix_xlf_64_libs "xlf90;xlopt;xlf;xlomp_ser;m;c") +set(aix_xlf_64_dirs "/usr/lpp/xlf/lib") +list(APPEND platforms aix_xlf_64) + +# xlf90 -q32 dummy.f -V +set(aix_xlf90_32_text "/bin/ld -b32 /lib/crt0.o -bpT:0x10000000 -bpD:0x20000000 -bh:4 dummy.o -lxlf90 -L/usr/lpp/xlf/lib -lxlopt -lxlf -lxlomp_ser -lm -lc") +set(aix_xlf90_32_libs "xlf90;xlopt;xlf;xlomp_ser;m;c") +set(aix_xlf90_32_dirs "/usr/lpp/xlf/lib") +list(APPEND platforms aix_xlf90_32) + +# xlf90 -q64 dummy.f -V +set(aix_xlf90_64_text "/bin/ld -b64 /lib/crt0_64.o -bpT:0x100000000 -bpD:0x110000000 -bh:4 dummy.o -lxlf90 -L/usr/lpp/xlf/lib -lxlopt -lxlf -lxlomp_ser -lm -lc") +set(aix_xlf90_64_libs "xlf90;xlopt;xlf;xlomp_ser;m;c") +set(aix_xlf90_64_dirs "/usr/lpp/xlf/lib") +list(APPEND platforms aix_xlf90_64) + +#----------------------------------------------------------------------------- +# HP + +# cc dummy.c -v +set(hp_cc_old_text "cc: LPATH is /usr/lib/pa1.1:/usr/lib:/opt/langtools/lib: +/usr/ccs/bin/ld /opt/langtools/lib/crt0.o -u main dummy.o -lc") +set(hp_cc_old_libs "c") +set(hp_cc_old_dirs "/usr/lib/pa1.1;/usr/lib;/opt/langtools/lib") +list(APPEND platforms hp_cc_old) + +# aCC dummy.cxx -v +set(hp_aCC_old_text "LPATH=/usr/lib/pa1.1:/usr/lib:/opt/langtools/lib + /usr/ccs/bin/ld -o a.out /opt/aCC/lib/crt0.o -u ___exit -u main -L /opt/aCC/lib /opt/aCC/lib/cpprt0.o dummy.o -lstd -lstream -lCsup -lm -lcl -lc /usr/lib/libdld.sl >/var/tmp/AAAa27787 2>&1") +set(hp_aCC_old_libs "std;stream;Csup;m;cl;c") +set(hp_aCC_old_dirs "/usr/lib/pa1.1;/usr/lib;/opt/langtools/lib;/opt/aCC/lib") +list(APPEND platforms hp_aCC_old) + +# cc dummy.c -v +set(hp_cc_32_text "LPATH=/usr/lib/hpux32:/opt/langtools/lib/hpux32 + /usr/ccs/bin/ld -o a.out -u___exit -umain dummy.o -lc") +set(hp_cc_32_libs "c") +set(hp_cc_32_dirs "/usr/lib/hpux32;/opt/langtools/lib/hpux32") +list(APPEND platforms hp_cc_32) + +# cc +DD64 dummy.c -v +set(hp_cc_64_text "LPATH=/usr/lib/hpux64:/opt/langtools/lib/hpux64 + /usr/ccs/bin/ld -o a.out -u___exit -umain dummy.o -lc") +set(hp_cc_64_libs "c") +set(hp_cc_64_dirs "/usr/lib/hpux64;/opt/langtools/lib/hpux64") +list(APPEND platforms hp_cc_64) + +# aCC dummy.cxx -v +set(hp_aCC_32_text "LPATH=/usr/lib/hpux32:/opt/langtools/lib/hpux32 + /usr/ccs/bin/ld -o a.out -u___exit -umain -L/opt/aCC/lib/hpux32 dummy.o -lstd_v2 -lCsup -lm -lunwind -lCsup -lc -ldl >/var/tmp/AAAa03601 2>&1") +set(hp_aCC_32_libs "std_v2;Csup;m;unwind;Csup;c;dl") +set(hp_aCC_32_dirs "/usr/lib/hpux32;/opt/langtools/lib/hpux32;/opt/aCC/lib/hpux32") +list(APPEND platforms hp_aCC_32) + +# aCC +DD64 dummy.cxx -v +set(hp_aCC_64_text "LPATH=/usr/lib/hpux64:/opt/langtools/lib/hpux64 + /usr/ccs/bin/ld -o a.out -u___exit -umain -L/opt/aCC/lib/hpux64 dummy.o -lstd_v2 -lCsup -lm -lunwind -lCsup -lc -ldl >/var/tmp/AAAa03597 2>&1") +set(hp_aCC_64_libs "std_v2;Csup;m;unwind;Csup;c;dl") +set(hp_aCC_64_dirs "/usr/lib/hpux64;/opt/langtools/lib/hpux64;/opt/aCC/lib/hpux64") +list(APPEND platforms hp_aCC_64) + +# f90 dummy.f -v +set(hp_f90_32_text "LPATH is: /usr/lib/hpux32/:/opt/langtools/lib/hpux32/ +/usr/ccs/bin/ld -u f90\$sgemm -u f90\$sgemv -u f90\$dgemm -u f90\$dgemv dummy.c +vnoshlibunsats -l:libF90.a -l:libIO77.a -lm -lc -lunwind -luca") +set(hp_f90_32_libs "-l:libF90.a;-l:libIO77.a;m;c;unwind;uca") +set(hp_f90_32_dirs "/usr/lib/hpux32;/opt/langtools/lib/hpux32") +list(APPEND platforms hp_f90_32) + +# f90 +DD64 dummy.f -v +set(hp_f90_64_text "LPATH is: /usr/lib/hpux64/:/opt/langtools/lib/hpux64/ +/usr/ccs/bin/ld -u f90\$sgemm -u f90\$sgemv -u f90\$dgemm -u f90\$dgemv dummy.c +vnoshlibunsats -l:libF90.a -l:libIO77.a -lm -lc -lunwind -luca") +set(hp_f90_64_libs "-l:libF90.a;-l:libIO77.a;m;c;unwind;uca") +set(hp_f90_64_dirs "/usr/lib/hpux64;/opt/langtools/lib/hpux64") +list(APPEND platforms hp_f90_64) + +#----------------------------------------------------------------------------- +# IRIX + +# cc -o32 dummy.c -v +set(irix64_cc_o32_text "/usr/lib/ld -elf -_SYSTYPE_SVR4 -require_dynamic_link _rld_new_interface -no_unresolved -Wx,-G 0 -o32 -mips2 -call_shared -g0 -KPIC -L/usr/lib/ -nocount /usr/lib/crt1.o -count dummy.o -nocount -lc /usr/lib/crtn.o") +set(irix64_cc_o32_libs "c") +set(irix64_cc_o32_dirs "/usr/lib") +list(APPEND platforms irix64_cc_o32) + +# cc -n32 dummy.c -v +set(irix64_cc_n32_text "/usr/lib32/cmplrs/ld32 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -n32 -L/usr/lib32/mips4/r10000 -L/usr/lib32/mips4 -L/usr/lib32 /usr/lib32/mips4/crt1.o dummy.o -dont_warn_unused -Bdynamic -lc /usr/lib32/mips4/crtn.o -warn_unused") +set(irix64_cc_n32_libs "c") +set(irix64_cc_n32_dirs "/usr/lib32/mips4/r10000;/usr/lib32/mips4;/usr/lib32") +list(APPEND platforms irix64_cc_n32) + +# cc -64 dummy.c -v +set(irix64_cc_64_text "/usr/lib32/cmplrs/ld64 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -64 -L/usr/lib64/mips4/r10000 -L/usr/lib64/mips4 -L/usr/lib64 /usr/lib64/mips4/crt1.o dummy.o -dont_warn_unused -Bdynamic -lc /usr/lib64/mips4/crtn.o -warn_unused") +set(irix64_cc_64_libs "c") +set(irix64_cc_64_dirs "/usr/lib64/mips4/r10000;/usr/lib64/mips4;/usr/lib64") +list(APPEND platforms irix64_cc_64) + +# CC -o32 dummy.cxx -v +set(irix64_CC_o32_text "/usr/lib/ld -elf -cxx -woff 134 -_SYSTYPE_SVR4 -require_dynamic_link _rld_new_interface -no_unresolved -Wx,-G 0 -o32 -mips2 -call_shared -g0 -KPIC -L/usr/lib/ -nocount /usr/lib/crt1.o /usr/lib/c++init.o -count dummy.o -nocount -dont_warn_unused -lC -warn_unused -lc /usr/lib/crtn.o") +set(irix64_CC_o32_libs "C;c") +set(irix64_CC_o32_dirs "/usr/lib") +list(APPEND platforms irix64_CC_o32) + +# CC -n32 dummy.cxx -v +set(irix64_CC_n32_text "/usr/lib32/cmplrs/ld32 -call_shared -init _main -fini _fini -no_unresolved -transitive_link -demangle -elf -_SYSTYPE_SVR4 -LANG:std -show -mips4 -n32 -L/usr/lib32/mips4/r10000 -L/usr/lib32/mips4 -L/usr/lib32 -cxx -woff 134 /usr/lib32/mips4/crt1.o /usr/lib32/c++init.o dummy.o -dont_warn_unused -lCsup -lC -lCio -Bdynamic -lc /usr/lib32/mips4/crtn.o -warn_unused") +set(irix64_CC_n32_libs "Csup;C;Cio;c") +set(irix64_CC_n32_dirs "/usr/lib32/mips4/r10000;/usr/lib32/mips4;/usr/lib32") +list(APPEND platforms irix64_CC_n32) + +# CC -64 dummy.cxx -v +set(irix64_CC_64_text "/usr/lib32/cmplrs/ld64 -call_shared -init _main -fini _fini -no_unresolved -transitive_link -demangle -elf -_SYSTYPE_SVR4 -LANG:std -show -mips4 -64 -L/usr/lib64/mips4/r10000 -L/usr/lib64/mips4 -L/usr/lib64 -cxx -woff 134 /usr/lib64/mips4/crt1.o /usr/lib64/c++init.o dummy.o -dont_warn_unused -lCsup -lC -lCio -Bdynamic -lc /usr/lib64/mips4/crtn.o -warn_unused") +set(irix64_CC_64_libs "Csup;C;Cio;c") +set(irix64_CC_64_dirs "/usr/lib64/mips4/r10000;/usr/lib64/mips4;/usr/lib64") +list(APPEND platforms irix64_CC_64) + +# f77 -o32 dummy.f -v +set(irix64_f77_o32_text "/usr/lib/ld -elf -_SYSTYPE_SVR4 -require_dynamic_link _rld_new_interface -no_unresolved -Wx,-G 0 -o32 -mips2 -call_shared -g0 -KPIC -L/usr/lib/ -nocount /usr/lib/crt1.o -count dummy.o -nocount -lftn -lm -lc /usr/lib/crtn.o") +set(irix64_f77_o32_libs "ftn;m;c") +set(irix64_f77_o32_dirs "/usr/lib") +list(APPEND platforms irix64_f77_o32) + +# f77 -n32 dummy.f -v +set(irix64_f77_n32_text "/usr/lib32/cmplrs/ld32 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -n32 -L/usr/lib32/mips4/r10000 -L/usr/lib32/mips4 -L/usr/lib32 /usr/lib32/mips4/crt1.o dummy.o -dont_warn_unused -lftn -lm -Bdynamic -lc /usr/lib32/mips4/crtn.o -warn_unused") +set(irix64_f77_n32_libs "ftn;m;c") +set(irix64_f77_n32_dirs "/usr/lib32/mips4/r10000;/usr/lib32/mips4;/usr/lib32") +list(APPEND platforms irix64_f77_n32) + +# f77 -64 dummy.f -v +set(irix64_f77_64_text "/usr/lib32/cmplrs/ld64 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -64 -L/usr/lib64/mips4/r10000 -L/usr/lib64/mips4 -L/usr/lib64 /usr/lib64/mips4/crt1.o dummy.o -dont_warn_unused -lftn -lm -Bdynamic -lc /usr/lib64/mips4/crtn.o -warn_unused") +set(irix64_f77_64_libs "ftn;m;c") +set(irix64_f77_64_dirs "/usr/lib64/mips4/r10000;/usr/lib64/mips4;/usr/lib64") +list(APPEND platforms irix64_f77_64) + +# f90 -o32 dummy.f -v +#f90 ERROR: specified abi -o32 not supported. + +# f90 -n32 dummy.f -v +set(irix64_f90_n32_text "/usr/lib32/cmplrs/ld32 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -n32 -L/usr/lib32/mips4/r10000 -L/usr/lib32/mips4 -L/usr/lib32 /usr/lib32/mips4/crt1.o dummy.o -dont_warn_unused -lfortran -lffio -lftn -lm -Bdynamic -lc /usr/lib32/mips4/crtn.o -warn_unused") +set(irix64_f90_n32_libs "fortran;ffio;ftn;m;c") +set(irix64_f90_n32_dirs "/usr/lib32/mips4/r10000;/usr/lib32/mips4;/usr/lib32") +list(APPEND platforms irix64_f90_n32) + +# f90 -64 dummy.f -v +set(irix64_f90_64_text "/usr/lib32/cmplrs/ld64 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -64 -L/usr/lib64/mips4/r10000 -L/usr/lib64/mips4 -L/usr/lib64 /usr/lib64/mips4/crt1.o dummy.o -dont_warn_unused -lfortran -lffio -lftn -lm -Bdynamic -lc /usr/lib64/mips4/crtn.o -warn_unused") +set(irix64_f90_64_libs "fortran;ffio;ftn;m;c") +set(irix64_f90_64_dirs "/usr/lib64/mips4/r10000;/usr/lib64/mips4;/usr/lib64") +list(APPEND platforms irix64_f90_64) + +#----------------------------------------------------------------------------- +# Cygwin + +# gcc dummy.c -v +set(cygwin_gcc_text " /usr/lib/gcc/i686-pc-cygwin/3.4.4/collect2.exe -Bdynamic --dll-search-prefix=cyg /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../crt0.o -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../.. /home/user/AppData/Local/Temp/cczg1Arh.o -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc") +set(cygwin_gcc_libs "cygwin;user32;kernel32;advapi32;shell32") +set(cygwin_gcc_dirs "/usr/lib/gcc/i686-pc-cygwin/3.4.4;/usr/lib") +list(APPEND platforms cygwin_gcc) + +# g++ dummy.cxx -v +set(cygwin_g++_text " /usr/lib/gcc/i686-pc-cygwin/3.4.4/collect2.exe -Bdynamic --dll-search-prefix=cyg /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../crt0.o -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../.. /home/user/AppData/Local/Temp/ccsvcDO6.o -lstdc++ -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc") +set(cygwin_g++_libs "stdc++;cygwin;user32;kernel32;advapi32;shell32") +set(cygwin_g++_dirs "/usr/lib/gcc/i686-pc-cygwin/3.4.4;/usr/lib") +list(APPEND platforms cygwin_g++) + +# gfortran dummy.f -v +set(cygwin_gfortran_text "Configured with: ... LD=/opt/gcc-tools/bin/ld.exe + /usr/lib/gcc/i686-pc-cygwin/4.3.2/collect2.exe -Bdynamic --dll-search-prefix=cyg -u ___register_frame_info -u ___deregister_frame_info /usr/lib/gcc/i686-pc-cygwin/4.3.2/../../../crt0.o /usr/lib/gcc/i686-pc-cygwin/4.3.2/crtbegin.o -L/usr/lib/gcc/i686-pc-cygwin/4.3.2 -L/usr/lib/gcc/i686-pc-cygwin/4.3.2 -L/usr/lib/gcc/i686-pc-cygwin/4.3.2/../../.. /home/user/AppData/Local/Temp/ccqRWKWg.o -lgfortranbegin -lgfortran -lgcc_s -lgcc_s -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc_s -lgcc_s -lgcc /usr/lib/gcc/i686-pc-cygwin/4.3.2/crtend.o +") +set(cygwin_gfortran_libs "gfortranbegin;gfortran;cygwin;user32;kernel32;advapi32;shell32") +set(cygwin_gfortran_dirs "/usr/lib/gcc/i686-pc-cygwin/4.3.2;/usr/lib") +list(APPEND platforms cygwin_gfortran) + +#----------------------------------------------------------------------------- +# MSYS + +# gcc dummy.c -v +set(msys_gcc_text " C:/some-mingw/bin/../libexec/gcc/mingw32/3.4.5/collect2.exe -Bdynamic /some-mingw/lib/crt2.o C:/some-mingw/bin/../lib/gcc/mingw32/3.4.5/crtbegin.o -LC:/some-mingw/bin/../lib/gcc/mingw32/3.4.5 -LC:/some-mingw/bin/../lib/gcc -L/some-mingw/lib -LC:/some-mingw/bin/../lib/gcc/mingw32/3.4.5/../../.. C:/home/user/AppData/Local/Temp/cckQmvRt.o -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt C:/some-mingw/bin/../lib/gcc/mingw32/3.4.5/crtend.o") +set(msys_gcc_libs "mingw32;moldname;mingwex;msvcrt;user32;kernel32;advapi32;shell32;mingw32;moldname;mingwex;msvcrt") +set(msys_gcc_dirs "C:/some-mingw/lib/gcc/mingw32/3.4.5;C:/some-mingw/lib/gcc;/some-mingw/lib;C:/some-mingw/lib") +list(APPEND platforms msys_gcc) + +# g++ dummy.cxx -v +set(msys_g++_text " C:/some-mingw/bin/../libexec/gcc/mingw32/3.4.5/collect2.exe -Bdynamic /some-mingw/lib/crt2.o C:/some-mingw/bin/../lib/gcc/mingw32/3.4.5/crtbegin.o -LC:/some-mingw/bin/../lib/gcc/mingw32/3.4.5 -LC:/some-mingw/bin/../lib/gcc -L/some-mingw/lib -LC:/some-mingw/bin/../lib/gcc/mingw32/3.4.5/../../.. C:/home/user/AppData/Local/Temp/cci5hYPk.o -lstdc++ -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt C:/some-mingw/bin/../lib/gcc/mingw32/3.4.5/crtend.o") +set(msys_g++_libs "stdc++;mingw32;moldname;mingwex;msvcrt;user32;kernel32;advapi32;shell32;mingw32;moldname;mingwex;msvcrt") +set(msys_g++_dirs "C:/some-mingw/lib/gcc/mingw32/3.4.5;C:/some-mingw/lib/gcc;/some-mingw/lib;C:/some-mingw/lib") +list(APPEND platforms msys_g++) + +# g77 dummy.f -v +set(msys_g77_text " C:/some-mingw/bin/../libexec/gcc/mingw32/3.4.5/collect2.exe -Bdynamic /some-mingw/lib/crt2.o C:/some-mingw/bin/../lib/gcc/mingw32/3.4.5/crtbegin.o -LC:/some-mingw/bin/../lib/gcc/mingw32/3.4.5 -LC:/some-mingw/bin/../lib/gcc -L/some-mingw/lib -LC:/some-mingw/bin/../lib/gcc/mingw32/3.4.5/../../.. C:/home/user/AppData/Local/Temp/ccabRxQ1.o -lfrtbegin -lg2c -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt C:/some-mingw/bin/../lib/gcc/mingw32/3.4.5/crtend.o") +set(msys_g77_libs "frtbegin;g2c;mingw32;moldname;mingwex;msvcrt;user32;kernel32;advapi32;shell32;mingw32;moldname;mingwex;msvcrt") +set(msys_g77_dirs "C:/some-mingw/lib/gcc/mingw32/3.4.5;C:/some-mingw/lib/gcc;/some-mingw/lib;C:/some-mingw/lib") +list(APPEND platforms msys_g77) + + +#----------------------------------------------------------------------------- +# Test parsing for all above examples. + +foreach(p IN LISTS platforms) + cmake_parse_implicit_link_info("${${p}_text}" libs dirs log "${${p}_obj_regex}") + + foreach(v libs dirs) + if(NOT "${${v}}" STREQUAL "${${p}_${v}}") + message(FATAL_ERROR + "cmake_parse_implicit_link_info failed\n" + "Expected '${p}' implicit ${v}\n" + " [${${p}_${v}}]\n" + "but got\n" + " [${${v}}]\n" + "Parse log was:\n" + "${log}" + ) + endif() + endforeach() +endforeach() diff --git a/Tests/CMakeTests/IncludeTest.cmake.in b/Tests/CMakeTests/IncludeTest.cmake.in new file mode 100644 index 000000000..eca679b4a --- /dev/null +++ b/Tests/CMakeTests/IncludeTest.cmake.in @@ -0,0 +1,41 @@ +# this one must silently fail +include(I_am_not_here OPTIONAL) + +# this one must be found and the result must be put into _includedFile +include(CMake RESULT_VARIABLE _includedFile) + +set(fileOne "${_includedFile}") +set(fileTwo "${CMAKE_ROOT}/Modules/CMake.cmake") +if(WIN32) + string(TOLOWER "${fileOne}" fileOne) + string(TOLOWER "${fileTwo}" fileTwo) +endif(WIN32) + +if(NOT "${fileOne}" STREQUAL "${fileTwo}") + message(FATAL_ERROR "Wrong CMake.cmake was included: \"${fileOne}\" expected \"${fileTwo}\"") +endif(NOT "${fileOne}" STREQUAL "${fileTwo}") + +# this one must return NOTFOUND in _includedFile +include(I_do_not_exist OPTIONAL RESULT_VARIABLE _includedFile) + +if(_includedFile) + message(FATAL_ERROR "File \"I_do_not_exist\" was included, although it shouldn't exist,\nIncluded file is \"${_includedFile}\"") +endif(_includedFile) + +# and this one must succeed too +include(CMake OPTIONAL RESULT_VARIABLE _includedFile) +set(fileOne "${_includedFile}") +set(fileTwo "${CMAKE_ROOT}/Modules/CMake.cmake") +if(WIN32) + string(TOLOWER "${fileOne}" fileOne) + string(TOLOWER "${fileTwo}" fileTwo) +endif(WIN32) + +if(NOT "${fileOne}" STREQUAL "${fileTwo}") + message(FATAL_ERROR "Wrong CMake.cmake was included: \"${fileOne}\" expected \"${fileTwo}\"") +endif(NOT "${fileOne}" STREQUAL "${fileTwo}") + +# Check that CMAKE_CURRENT_LIST_DIR is working: +# Needs to be a file in the build tree, which is correct cmake script +# but doesn't do a lot, if possible only set() commands: +include(${CMAKE_CURRENT_LIST_DIR}/../../CTestCustom.cmake) diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in new file mode 100644 index 000000000..cf6f91a70 --- /dev/null +++ b/Tests/CMakeTests/ListTest.cmake.in @@ -0,0 +1,88 @@ +MACRO(TEST command expected) + IF("x${result}" STREQUAL "x${expected}") + #MESSAGE("TEST \"${command}\" success: \"${result}\" expected: \"${expected}\"") + ELSE("x${result}" STREQUAL "x${expected}") + MESSAGE(SEND_ERROR "${CMAKE_CURRENT_LIST_LINE}: TEST \"${command}\" failed: \"${result}\" expected: \"${expected}\"") + ENDIF("x${result}" STREQUAL "x${expected}") +ENDMACRO(TEST command expected) + +SET(mylist andy bill ken brad) + +LIST(LENGTH mylist result) +TEST("LENGTH mylist result" "4") +LIST(LENGTH "mylist" result) +TEST("LENGTH \"mylist\" result" "4") + +LIST(LENGTH "nonexiting_list1" result) +TEST("LENGTH \"nonexiting_list1\" result" "0") + +LIST(GET mylist 3 2 1 0 result) +TEST("GET mylist 3 2 1 0 result" "brad;ken;bill;andy") + +LIST(GET mylist 0 item0) +LIST(GET mylist 1 item1) +LIST(GET mylist 2 item2) +LIST(GET mylist 3 item3) +SET(result "${item3}" "${item0}" "${item1}" "${item2}") +TEST("GET individual 3 2 1 0 result" "brad;andy;bill;ken") + +LIST(GET mylist -1 -2 -3 -4 result) +TEST("GET mylist -1 -2 -3 -4 result" "brad;ken;bill;andy") + +LIST(GET mylist -1 2 -3 0 result) +TEST("GET mylist -1 2 -3 0 ${result}" "brad;ken;bill;andy") + +LIST(GET "nonexiting_list2" 1 result) +TEST("GET \"nonexiting_list2\" 1 result" "NOTFOUND") + +SET(result andy) +LIST(APPEND result brad) +TEST("APPEND result brad" "andy;brad") + +LIST(APPEND "nonexiting_list3" brad) +SET(result "${nonexiting_list3}") +TEST("APPEND \"nonexiting_list3\" brad" "brad") + +LIST(INSERT "nonexiting_list4" 0 andy bill brad ken) +SET(result "${nonexiting_list4}") +TEST("APPEND \"nonexiting_list4\" andy bill brad ken" "andy;bill;brad;ken") + +SET(result andy brad) +LIST(INSERT result -1 bill ken) +TEST("INSERT result -1 bill ken" "andy;bill;ken;brad") + +SET(result andy bill brad ken bob) +LIST(REMOVE_ITEM result bob) +TEST("REMOVE_ITEM result bob" "andy;bill;brad;ken") + +SET(result andy bill bob brad ken peter) +LIST(REMOVE_ITEM result peter bob) +TEST("REMOVE_ITEM result peter bob" "andy;bill;brad;ken") + +SET(result bob andy bill bob brad ken bob) +LIST(REMOVE_ITEM result bob) +TEST("REMOVE_ITEM result bob" "andy;bill;brad;ken") + +SET(result andy bill bob brad ken peter) +LIST(REMOVE_AT result 2 -1) +TEST("REMOVE_AT result 2 -1" "andy;bill;brad;ken") + +# ken is at index 2, nobody is not in the list so -1 should be returned +SET(mylist andy bill ken brad) +LIST(FIND mylist ken result) +TEST("FIND mylist ken result" "2") + +LIST(FIND mylist nobody result) +TEST("FIND mylist nobody result" "-1") + +SET(result ken bill andy brad) +LIST(SORT result) +TEST("SORT result" "andy;bill;brad;ken") + +SET(result andy bill brad ken) +LIST(REVERSE result) +TEST("REVERSE result" "ken;brad;bill;andy") + +SET(result bill andy bill brad ken ken ken) +LIST(REMOVE_DUPLICATES result) +TEST("REMOVE_DUPLICATES result" "bill;andy;brad;ken") diff --git a/Tests/CMakeTests/MathTest.cmake.in b/Tests/CMakeTests/MathTest.cmake.in new file mode 100644 index 000000000..91cd9220a --- /dev/null +++ b/Tests/CMakeTests/MathTest.cmake.in @@ -0,0 +1,18 @@ +# Execute each test listed in: +# +set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/MathTestScript.cmake") +set(number_of_tests_expected 4) + +include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake") +execute_all_script_tests(${scriptname} number_of_tests_executed) + +# And verify that number_of_tests_executed is at least as many as we know +# about as of this writing... +# +message(STATUS "scriptname='${scriptname}'") +message(STATUS "number_of_tests_executed='${number_of_tests_executed}'") +message(STATUS "number_of_tests_expected='${number_of_tests_expected}'") + +if(number_of_tests_executed LESS number_of_tests_expected) + message(FATAL_ERROR "error: some test cases were skipped") +endif() diff --git a/Tests/CMakeTests/MathTestScript.cmake b/Tests/CMakeTests/MathTestScript.cmake new file mode 100644 index 000000000..1b7f8a6f3 --- /dev/null +++ b/Tests/CMakeTests/MathTestScript.cmake @@ -0,0 +1,18 @@ +message(STATUS "testname='${testname}'") + +if(testname STREQUAL empty) # fail + math() + +elseif(testname STREQUAL bogus) # fail + math(BOGUS) + +elseif(testname STREQUAL not_enough_args) # fail + math(EXPR x) + +elseif(testname STREQUAL cannot_parse) # fail + math(EXPR x "1 + 2 +") + +else() # fail + message(FATAL_ERROR "testname='${testname}' - error: no such test in '${CMAKE_CURRENT_LIST_FILE}'") + +endif() diff --git a/Tests/CMakeTests/MessageTest.cmake.in b/Tests/CMakeTests/MessageTest.cmake.in new file mode 100644 index 000000000..a9833b99c --- /dev/null +++ b/Tests/CMakeTests/MessageTest.cmake.in @@ -0,0 +1,30 @@ +execute_process( + COMMAND ${CMAKE_COMMAND} -P + "@CMAKE_CURRENT_SOURCE_DIR@/MessageTestScript.cmake" + OUTPUT_VARIABLE out + ERROR_VARIABLE err + RESULT_VARIABLE result + ) + +message("out=[${out}]") +message("err=[${err}]") + +if(NOT "${result}" STREQUAL "0") + message(FATAL_ERROR "message script failed: [${result}]") +endif() + +if(NOT "${out}" MATCHES "message-status") + message(FATAL_ERROR "message(STATUS) did not go to stdout") +endif() + +if(NOT "${err}" MATCHES "message-default") + message(FATAL_ERROR "message() did not go to stderr by default") +endif() + +if(NOT "${err}" MATCHES "CMake Warning at[^\n]*:\r?\n message-warning") + message(FATAL_ERROR "message(WARNING) did not appear properly") +endif() + +if(NOT "${err}" MATCHES "CMake Warning \\(dev\\) at[^\n]*:\r?\n message-author") + message(FATAL_ERROR "message(AUTHOR_WARNING) did not appear properly") +endif() diff --git a/Tests/CMakeTests/MessageTestScript.cmake b/Tests/CMakeTests/MessageTestScript.cmake new file mode 100644 index 000000000..c56f88e15 --- /dev/null +++ b/Tests/CMakeTests/MessageTestScript.cmake @@ -0,0 +1,4 @@ +message("message-default") +message(STATUS "message-status") +message(WARNING "message-warning") +message(AUTHOR_WARNING "message-author") diff --git a/Tests/CMakeTests/ModuleNoticesTest.cmake.in b/Tests/CMakeTests/ModuleNoticesTest.cmake.in new file mode 100644 index 000000000..8ecebd338 --- /dev/null +++ b/Tests/CMakeTests/ModuleNoticesTest.cmake.in @@ -0,0 +1,46 @@ +# Regex to match copyright/license notices. +# We require the Kitware copyright on the first line, but this can +# match any additional copyright holder notices. +set(notice_regex " +#============================================================================= +# Copyright (20[0-9][0-9]-)?20[0-9][0-9] [^\n]+( +# Copyright (20[0-9][0-9]-)?20[0-9][0-9] [^\n]+)* +# +# Distributed under the OSI-approved BSD License \\(the \"License\"\\); +# see accompanying file Copyright\\.txt for details\\. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\\. +# See the License for more information\\. +#============================================================================= +# \\(To distribute this file outside of CMake, substitute the full +# License text for the above reference.\\) +") +string(REPLACE "\n" "\r?\n" notice_regex "${notice_regex}") +string(REPLACE "\r\r" "\r" notice_regex "${notice_regex}") + +# Modules that do not require our notice. +set(notice_exceptions + FindCUDA.cmake # MIT License, distributed here from upstream project + ) + +# Load the list of modules to check. +set(dir "@CMake_SOURCE_DIR@/Modules") +file(GLOB all_modules RELATIVE "${dir}" "${dir}/*.cmake") +list(REMOVE_ITEM all_modules ${notice_exceptions}) + +# Check each module. +set(notice_missing) +foreach(module ${all_modules}) + message(STATUS "module: ${module}") + file(READ "${dir}/${module}" module_content) + if(NOT "${module_content}" MATCHES "${notice_regex}") + set(notice_missing "${notice_missing} ${module}\n") + endif() +endforeach() + +# Report the list of bad modules. +if(notice_missing) + message(FATAL_ERROR + "Some modules do not have a valid copyright notice:\n${notice_missing}") +endif() diff --git a/Tests/CMakeTests/ProcessorCountTest.cmake.in b/Tests/CMakeTests/ProcessorCountTest.cmake.in new file mode 100644 index 000000000..98f6ab16d --- /dev/null +++ b/Tests/CMakeTests/ProcessorCountTest.cmake.in @@ -0,0 +1,72 @@ +include(ProcessorCount) + +ProcessorCount(processor_count) + +message("### 1. This line should be the first line of text in the test output.") +message("### 2. If there was output from this test before line #1, then the") +message("### 3. ProcessorCount(...) function call is emitting output that it shouldn't...") + +message("processor_count='${processor_count}'") + +execute_process( + COMMAND "@CMAKE_BINARY_DIR@/Source/kwsys/$ENV{CMAKE_CONFIG_TYPE}/cmsysTestsCxx" + testSystemInformation + OUTPUT_VARIABLE tsi_out + ERROR_VARIABLE tsi_err) +string(REGEX REPLACE "(.*)GetNumberOfPhysicalCPU:.([0-9]*)(.*)" "\\2" + system_info_processor_count "${tsi_out}") + +message("system_info_processor_count='${system_info_processor_count}'") + +if(system_info_processor_count EQUAL processor_count) + message("processor count matches system information") +endif() + +message("") +message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +message("") +message("tsi_out='${tsi_out}'") +message("tsi_err='${tsi_err}'") +message("") + +# Evaluate possible error conditions: +# +set(err 0) +set(fatal 0) + +if(processor_count EQUAL 0) + set(err 1) + set(fatal 1) + message("err 1") + message("could not determine number of processors +- Additional code for this platform needed in ProcessorCount.cmake?") + message("") +endif() + +if(NOT system_info_processor_count EQUAL processor_count) + set(err 2) + message("err 2") + message("SystemInformation and ProcessorCount.cmake disagree:\n" + "processor_count='${processor_count}'\n" + "SystemInformation processor_count='${system_info_processor_count}'") + message("") +endif() + +if(NOT processor_count MATCHES "^[0-9]+$") + set(err 3) + set(fatal 1) + message("err 3") + message("ProcessorCount function returned a non-integer") + message("") +endif() + +if(NOT system_info_processor_count MATCHES "^[0-9]+$") + set(err 4) + message("err 4") + message("SystemInformation ProcessorCount function returned a non-integer") + message("") +endif() + +if(fatal) + message(FATAL_ERROR "processor_count='${processor_count}' - see previous test output for more details - it is likely more/different code is needed in ProcessorCount.cmake to fix this test failure - processor_count should be a non-zero positive integer (>=1) for all supported CMake platforms") +endif() diff --git a/Tests/CMakeTests/PushCheckStateTest.cmake.in b/Tests/CMakeTests/PushCheckStateTest.cmake.in new file mode 100644 index 000000000..e707b9a92 --- /dev/null +++ b/Tests/CMakeTests/PushCheckStateTest.cmake.in @@ -0,0 +1,30 @@ +include(CMakePushCheckState) + +set(CMAKE_REQUIRED_DEFINITIONS defs1 ) + +cmake_push_check_state() + +set(CMAKE_REQUIRED_DEFINITIONS defs2) + +cmake_push_check_state() + +set(CMAKE_REQUIRED_DEFINITIONS defs3) + +cmake_pop_check_state() + +if (NOT "${CMAKE_REQUIRED_DEFINITIONS}" STREQUAL "defs2") + set(fatal TRUE) + message("ERROR: "CMAKE_REQUIRED_DEFINITIONS is \"${CMAKE_REQUIRED_DEFINITIONS}\" (expected \"defs2\")" ) +endif() + +cmake_pop_check_state() + +if (NOT "${CMAKE_REQUIRED_DEFINITIONS}" STREQUAL "defs1") + set(fatal TRUE) + message("ERROR: "CMAKE_REQUIRED_DEFINITIONS is \"${CMAKE_REQUIRED_DEFINITIONS}\" (expected \"defs1\")" ) +endif() + + +if(fatal) + message(FATAL_ERROR "cmake_push_check_state() test failed") +endif() diff --git a/Tests/CMakeTests/SeparateArgumentsTest.cmake.in b/Tests/CMakeTests/SeparateArgumentsTest.cmake.in new file mode 100644 index 000000000..48964b8cb --- /dev/null +++ b/Tests/CMakeTests/SeparateArgumentsTest.cmake.in @@ -0,0 +1,25 @@ +set(old_out "a b c") +separate_arguments(old_out) +set(old_exp "a;b;;c") + +set(unix_cmd "a \"b c\" 'd e' \";\" \\ \\'\\\" '\\'' \"\\\"\"") +set(unix_exp "a;b c;d e;\;; '\";';\"") +separate_arguments(unix_out UNIX_COMMAND "${unix_cmd}") + +set(windows_cmd "a \"b c\" 'd e' \";\" \\ \"c:\\windows\\path\\\\\" \\\"") +set(windows_exp "a;b c;'d;e';\;;\\;c:\\windows\\path\\;\"") +separate_arguments(windows_out WINDOWS_COMMAND "${windows_cmd}") + +foreach(mode old unix windows) + if(NOT "${${mode}_out}" STREQUAL "${${mode}_exp}") + message(FATAL_ERROR "separate_arguments ${mode}-style failed. " + "Expected\n [${${mode}_exp}]\nbut got\n [${${mode}_out}]\n") + endif() +endforeach() + +set(nothing) +separate_arguments(nothing) +if(DEFINED nothing) + message(FATAL_ERROR "separate_arguments null-case failed: " + "nothing=[${nothing}]") +endif() diff --git a/Tests/CMakeTests/String-MD5-BadArg1.cmake b/Tests/CMakeTests/String-MD5-BadArg1.cmake new file mode 100644 index 000000000..89464769b --- /dev/null +++ b/Tests/CMakeTests/String-MD5-BadArg1.cmake @@ -0,0 +1 @@ +string(MD5) diff --git a/Tests/CMakeTests/String-MD5-BadArg2.cmake b/Tests/CMakeTests/String-MD5-BadArg2.cmake new file mode 100644 index 000000000..abbbf879a --- /dev/null +++ b/Tests/CMakeTests/String-MD5-BadArg2.cmake @@ -0,0 +1 @@ +string(MD5 md5) diff --git a/Tests/CMakeTests/String-MD5-BadArg4.cmake b/Tests/CMakeTests/String-MD5-BadArg4.cmake new file mode 100644 index 000000000..edd442762 --- /dev/null +++ b/Tests/CMakeTests/String-MD5-BadArg4.cmake @@ -0,0 +1 @@ +string(MD5 md5 input extra_arg) diff --git a/Tests/CMakeTests/String-MD5-Works.cmake b/Tests/CMakeTests/String-MD5-Works.cmake new file mode 100644 index 000000000..4ef7a0754 --- /dev/null +++ b/Tests/CMakeTests/String-MD5-Works.cmake @@ -0,0 +1,2 @@ +string(MD5 md5 "sample input string\n") +message("${md5}") diff --git a/Tests/CMakeTests/String-SHA1-Works.cmake b/Tests/CMakeTests/String-SHA1-Works.cmake new file mode 100644 index 000000000..2f3b51b61 --- /dev/null +++ b/Tests/CMakeTests/String-SHA1-Works.cmake @@ -0,0 +1,2 @@ +string(SHA1 sha1 "sample input string\n") +message("${sha1}") diff --git a/Tests/CMakeTests/String-SHA224-Works.cmake b/Tests/CMakeTests/String-SHA224-Works.cmake new file mode 100644 index 000000000..5b7f880ee --- /dev/null +++ b/Tests/CMakeTests/String-SHA224-Works.cmake @@ -0,0 +1,2 @@ +string(SHA224 sha224 "sample input string\n") +message("${sha224}") diff --git a/Tests/CMakeTests/String-SHA256-Works.cmake b/Tests/CMakeTests/String-SHA256-Works.cmake new file mode 100644 index 000000000..e3e89ae5d --- /dev/null +++ b/Tests/CMakeTests/String-SHA256-Works.cmake @@ -0,0 +1,2 @@ +string(SHA256 sha256 "sample input string\n") +message("${sha256}") diff --git a/Tests/CMakeTests/String-SHA384-Works.cmake b/Tests/CMakeTests/String-SHA384-Works.cmake new file mode 100644 index 000000000..828a19031 --- /dev/null +++ b/Tests/CMakeTests/String-SHA384-Works.cmake @@ -0,0 +1,2 @@ +string(SHA384 sha384 "sample input string\n") +message("${sha384}") diff --git a/Tests/CMakeTests/String-SHA512-Works.cmake b/Tests/CMakeTests/String-SHA512-Works.cmake new file mode 100644 index 000000000..e17db5c6e --- /dev/null +++ b/Tests/CMakeTests/String-SHA512-Works.cmake @@ -0,0 +1,2 @@ +string(SHA512 sha512 "sample input string\n") +message("${sha512}") diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in new file mode 100644 index 000000000..49e7dc90c --- /dev/null +++ b/Tests/CMakeTests/StringTest.cmake.in @@ -0,0 +1,50 @@ +set(MD5-BadArg1-RESULT 1) +set(MD5-BadArg1-STDERR "string MD5 requires an output variable") +set(MD5-BadArg2-RESULT 1) +set(MD5-BadArg2-STDERR "string MD5 requires an output variable and an input string") +set(MD5-BadArg4-RESULT 1) +set(MD5-BadArg4-STDERR "string MD5 requires an output variable and an input string") +set(MD5-Works-RESULT 0) +set(MD5-Works-STDERR "10d20ddb981a6202b84aa1ce1cb7fce3") +set(SHA1-Works-RESULT 0) +set(SHA1-Works-STDERR "83f093e04289b21a9415f408ad50be8b57ad2f34") +set(SHA224-Works-RESULT 0) +set(SHA224-Works-STDERR "e995a7789922c4ef9279d94e763c8375934180a51baa7147bc48edf7") +set(SHA256-Works-RESULT 0) +set(SHA256-Works-STDERR "d1c5915d8b71150726a1eef75a29ec6bea8fd1bef6b7299ef8048760b0402025") +set(SHA384-Works-RESULT 0) +set(SHA384-Works-STDERR "1de9560b4e030e02051ea408200ffc55d70c97ac64ebf822461a5c786f495c36df43259b14483bc8d364f0106f4971ee") +set(SHA512-Works-RESULT 0) +set(SHA512-Works-STDERR "3982a1b4e651768bec70ab1fb97045cb7a659f4ba7203d501c52ab2e803071f9d5fd272022df15f27727fc67f8cd022e710e29010b2a9c0b467c111e2f6abf51") + +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") +check_cmake_test(String + MD5-BadArg1 + MD5-BadArg2 + MD5-BadArg4 + MD5-Works + SHA1-Works + SHA224-Works + SHA256-Works + SHA384-Works + SHA512-Works + ) + +# Execute each test listed in StringTestScript.cmake: +# +set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/StringTestScript.cmake") +set(number_of_tests_expected 69) + +include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake") +execute_all_script_tests(${scriptname} number_of_tests_executed) + +# And verify that number_of_tests_executed is at least as many as we know +# about as of this writing... +# +message(STATUS "scriptname='${scriptname}'") +message(STATUS "number_of_tests_executed='${number_of_tests_executed}'") +message(STATUS "number_of_tests_expected='${number_of_tests_expected}'") + +if(number_of_tests_executed LESS number_of_tests_expected) + message(FATAL_ERROR "error: some test cases were skipped") +endif() diff --git a/Tests/CMakeTests/StringTestScript.cmake b/Tests/CMakeTests/StringTestScript.cmake new file mode 100644 index 000000000..7a264a0e2 --- /dev/null +++ b/Tests/CMakeTests/StringTestScript.cmake @@ -0,0 +1,279 @@ +message(STATUS "testname='${testname}'") + +if(testname STREQUAL empty) # fail + string() + +elseif(testname STREQUAL bogus) # fail + string(BOGUS) + +elseif(testname STREQUAL random) # pass + string(RANDOM r) + message(STATUS "r='${r}'") + +elseif(testname STREQUAL toupper_no_variable) # fail + string(TOUPPER) + +elseif(testname STREQUAL ascii_no_variable) # fail + string(ASCII) + +elseif(testname STREQUAL ascii_code_too_small) # fail + string(ASCII -1 bummer) + +elseif(testname STREQUAL ascii_code_too_large) # fail + string(ASCII 288 bummer) + +elseif(testname STREQUAL configure_no_input) # fail + string(CONFIGURE) + +elseif(testname STREQUAL configure_no_variable) # fail + string(CONFIGURE "this is @testname@") + +elseif(testname STREQUAL configure_escape_quotes) # pass + string(CONFIGURE "this is @testname@" v ESCAPE_QUOTES) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL configure_bogus) # fail + string(CONFIGURE "this is @testname@" v ESCAPE_QUOTES BOGUS) + +elseif(testname STREQUAL regex_no_mode) # fail + string(REGEX) + +elseif(testname STREQUAL regex_match_not_enough_args) # fail + string(REGEX MATCH) + +elseif(testname STREQUAL regex_matchall_not_enough_args) # fail + string(REGEX MATCHALL) + +elseif(testname STREQUAL regex_replace_not_enough_args) # fail + string(REGEX REPLACE) + +elseif(testname STREQUAL regex_bogus_mode) # fail + string(REGEX BOGUS) + +elseif(testname STREQUAL regex_match_multiple_inputs) # pass + string(REGEX MATCH ".*" v input1 input2 input3 input4) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL regex_match_bad_regex) # fail + string(REGEX MATCH "(.*" v input) + +elseif(testname STREQUAL regex_match_empty_string) # fail + string(REGEX MATCH "x*" v "") + +elseif(testname STREQUAL regex_match_no_match) # pass + string(REGEX MATCH "xyz" v "abc") + message(STATUS "v='${v}'") + +elseif(testname STREQUAL regex_matchall_multiple_inputs) # pass + string(REGEX MATCHALL "input" v input1 input2 input3 input4) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL regex_matchall_bad_regex) # fail + string(REGEX MATCHALL "(.*" v input) + +elseif(testname STREQUAL regex_matchall_empty_string) # fail + string(REGEX MATCHALL "x*" v "") + +elseif(testname STREQUAL regex_replace_ends_with_backslash) # fail + string(REGEX REPLACE "input" "output\\" v input1 input2 input3 input4) + +elseif(testname STREQUAL regex_replace_ends_with_escaped_backslash) # pass + string(REGEX REPLACE "input" "output\\\\" v input1 input2 input3 input4) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL regex_replace_has_linefeed) # pass + string(REGEX REPLACE "input" "output\\n" v input1 input2 input3 input4) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL regex_replace_has_bogus_escape) # fail + string(REGEX REPLACE "input" "output\\a" v input1 input2 input3 input4) + +elseif(testname STREQUAL regex_replace_bad_regex) # fail + string(REGEX REPLACE "this (.*" "with that" v input) + +elseif(testname STREQUAL regex_replace_empty_string) # fail + string(REGEX REPLACE "x*" "that" v "") + +elseif(testname STREQUAL regex_replace_index_too_small) # fail + string(REGEX REPLACE "^this (.*)$" "with \\1 \\-1" v "this input") + +elseif(testname STREQUAL regex_replace_index_too_large) # fail + string(REGEX REPLACE "^this (.*)$" "with \\1 \\2" v "this input") + +elseif(testname STREQUAL compare_no_mode) # fail + string(COMPARE) + +elseif(testname STREQUAL compare_bogus_mode) # fail + string(COMPARE BOGUS) + +elseif(testname STREQUAL compare_not_enough_args) # fail + string(COMPARE EQUAL) + +elseif(testname STREQUAL replace_not_enough_args) # fail + string(REPLACE) + +elseif(testname STREQUAL replace_multiple_inputs) # pass + string(REPLACE "input" "output" v input1 input2 input3 input4) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL substring_not_enough_args) # fail + string(SUBSTRING) + +elseif(testname STREQUAL substring_begin_too_large) # fail + string(SUBSTRING "abcdefg" 25 100 v) + +elseif(testname STREQUAL substring_end_too_large) # fail + string(SUBSTRING "abcdefg" 1 100 v) + +elseif(testname STREQUAL substring_begin_less_than_zero) # fail + string(SUBSTRING "abcdefg" -2 4 v) + +elseif(testname STREQUAL substring_end_less_than_begin) # fail + string(SUBSTRING "abcdefg" 6 3 v) + +elseif(testname STREQUAL length_not_enough_args) # fail + string(LENGTH) + +elseif(testname STREQUAL strip_not_enough_args) # fail + string(STRIP) + +elseif(testname STREQUAL random_not_enough_args) # fail + string(RANDOM) + +elseif(testname STREQUAL random_3_args) # fail + string(RANDOM LENGTH 9) + +elseif(testname STREQUAL random_5_args) # fail + string(RANDOM LENGTH 9 ALPHABET "aceimnorsuvwxz") + +elseif(testname STREQUAL random_with_length) # pass + string(RANDOM LENGTH 9 v) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL random_with_alphabet) # pass + string(RANDOM ALPHABET "aceimnorsuvwxz" v) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL random_bad_length) # fail + string(RANDOM LENGTH 0 v) + +elseif(testname STREQUAL random_empty_alphabet) # pass + string(RANDOM ALPHABET "" v) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL random_with_length_and_alphabet) # pass + string(RANDOM LENGTH 9 ALPHABET "aceimnorsuvwxz" v) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL random_with_various_alphabets) # pass + # small alphabet + string(RANDOM LENGTH 32 ALPHABET "ACGT" v) + message(STATUS "v='${v}'") + + # smaller alphabet + string(RANDOM LENGTH 32 ALPHABET "AB" v) + message(STATUS "v='${v}'") + + # smallest alphabet + string(RANDOM LENGTH 32 ALPHABET "Z" v) + message(STATUS "v='${v}'") + + # smallest length and alphabet + string(RANDOM LENGTH 1 ALPHABET "Q" v) + message(STATUS "v='${v}'") + + # seed values -- 2 same, then 1 different + string(RANDOM LENGTH 32 ALPHABET "ACGT" RANDOM_SEED 987654 v) + message(STATUS "v='${v}'") + string(RANDOM LENGTH 32 ALPHABET "ACGT" RANDOM_SEED 987654 v) + message(STATUS "v='${v}'") + string(RANDOM LENGTH 32 ALPHABET "ACGT" RANDOM_SEED 876543 v) + message(STATUS "v='${v}'") + + # alphabet of many colors - use all the crazy keyboard characters + string(RANDOM LENGTH 78 ALPHABET "~`!@#$%^&*()_-+={}[]\\|:\\;'\",.<>/?" v) + message(STATUS "v='${v}'") + + message(STATUS "CMAKE_SCRIPT_MODE_FILE='${CMAKE_SCRIPT_MODE_FILE}'") + +elseif(testname STREQUAL string_find_with_no_parameter) # fail + string(FIND) + +elseif(testname STREQUAL string_find_with_one_parameter) # fail + string(FIND "CMake is great.") + +elseif(testname STREQUAL string_find_with_two_parameters) # fail + string(FIND "CMake is great." "a") + +elseif(testname STREQUAL string_find_with_three_parameters) # pass + string(FIND "CMake is great." "a" v) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL string_find_with_four_parameters) # fail + string(FIND "CMake is great." "a" v v2) + +elseif(testname STREQUAL string_find_reverse_with_no_parameter) # fail + string(FIND REVERSE) + +elseif(testname STREQUAL string_find_reverse_with_one_parameter) # fail + string(FIND "CMake is great." REVERSE) + +elseif(testname STREQUAL string_find_reverse_with_two_parameters) # fail + string(FIND "CMake is great." "a" REVERSE) + +elseif(testname STREQUAL string_find_reverse_with_three_parameters) # pass + string(FIND "CMake is great." "a" v REVERSE) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL string_find_reverse_with_four_parameters_part1) # fail + string(FIND "CMake is great." "a" v v2 REVERSE) + +elseif(testname STREQUAL string_find_reverse_with_four_parameters_part2) # fail + string(FIND "CMake is great." "a" v REVERSE v2) + +elseif(testname STREQUAL string_find_with_no_possible_result) # pass + string(FIND "CMake is a great application." "z" v) + message(STATUS "v='${v}'") + if(NOT(-1 EQUAL ${v})) + message(SEND_ERROR "FIND sub-command should return -1 but returned ${v}.") + endif(NOT(-1 EQUAL ${v})) + +elseif(testname STREQUAL string_find_reverse_with_no_possible_result) # pass + string(FIND "CMake is a great application." "z" v REVERSE) + message(STATUS "v='${v}'") + if(NOT(-1 EQUAL ${v})) + message(SEND_ERROR "FIND REVERSE sub-command should return -1 but returned ${v}.") + endif(NOT(-1 EQUAL ${v})) + +elseif(testname STREQUAL string_find_with_required_result) # pass + string(FIND "CMake is a great application." "g" v) + message(STATUS "v='${v}'") + if(NOT(11 EQUAL ${v})) + message(SEND_ERROR "FIND sub-command should return 11 but returned ${v}.") + endif(NOT(11 EQUAL ${v})) + +elseif(testname STREQUAL string_find_reverse_with_required_result) # pass + string(FIND "CMake is a great application." "e" v REVERSE) + message(STATUS "v='${v}'") + if(NOT(13 EQUAL ${v})) + message(SEND_ERROR "FIND REVERSE sub-command should return 13 but returned ${v}.") + endif(NOT(13 EQUAL ${v})) + +elseif(testname STREQUAL string_find_word_reverse_with_required_result) # pass + string(FIND "The command should find REVERSE in this string. Or maybe this REVERSE?!" "REVERSE" v) + message(STATUS "v='${v}'") + if(NOT(24 EQUAL ${v})) + message(SEND_ERROR "FIND sub-command should return 24 but returned ${v}.") + endif(NOT(24 EQUAL ${v})) + +elseif(testname STREQUAL string_find_reverse_word_reverse_with_required_result) # pass + string(FIND "The command should find REVERSE in this string. Or maybe this REVERSE?!" "REVERSE" v REVERSE) + message(STATUS "v='${v}'") + if(NOT(62 EQUAL ${v})) + message(SEND_ERROR "FIND sub-command should return 62 but returned ${v}.") + endif(NOT(62 EQUAL ${v})) + +else() # fail + message(FATAL_ERROR "testname='${testname}' - error: no such test in '${CMAKE_CURRENT_LIST_FILE}'") + +endif() diff --git a/Tests/CMakeTests/ToolchainTest.cmake.in b/Tests/CMakeTests/ToolchainTest.cmake.in new file mode 100644 index 000000000..e4a2e4813 --- /dev/null +++ b/Tests/CMakeTests/ToolchainTest.cmake.in @@ -0,0 +1,139 @@ +############################################################ +# some preparations so that the CMakeDetermineXXX.cmake files will work in scripted mode + +# overwrite MARK_AS_ADVANCED(), since this is used in CMakeDetermineCCompiler.cmake +# which will complain that it can"t be used in script mode +macro(MARK_AS_ADVANCED) +endmacro(MARK_AS_ADVANCED) +# set this to a place where we are allowed to write +set(CMAKE_PLATFORM_ROOT_BIN "${CMAKE_CURRENT_BINARY_DIR}") + +# don't run the compiler detection +set(CMAKE_C_COMPILER_ID_RUN 1) +set(CMAKE_CXX_COMPILER_ID_RUN 1) + +set(MY_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@") + +# at first load CMakeDetermineSystem.cmake without toolchain file +set(CMAKE_TOOLCHAIN_FILE) +include(CMakeDetermineSystem) + +# check that CMAKE_SYSTEM_XXX and CMAKE_HOST_SYSTEM_xxx are identical +if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "${CMAKE_HOST_SYSTEM_NAME}") + message(FATAL_ERROR "CMAKE_SYSTEM_NAME and CMAKE_HOST_SYSTEM_NAME not identical: \"${CMAKE_SYSTEM_NAME}\" vs. \"${CMAKE_HOST_SYSTEM_NAME}\"") +endif(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "${CMAKE_HOST_SYSTEM_NAME}") + +if(NOT "${CMAKE_SYSTEM}" STREQUAL "${CMAKE_HOST_SYSTEM}") + message(FATAL_ERROR "CMAKE_SYSTEM and CMAKE_HOST_SYSTEM not identical: \"${CMAKE_SYSTEM}\" vs. \"${CMAKE_HOST_SYSTEM}\"") +endif(NOT "${CMAKE_SYSTEM}" STREQUAL "${CMAKE_HOST_SYSTEM}") + +if(NOT "${CMAKE_SYSTEM_VERSION}" STREQUAL "${CMAKE_HOST_SYSTEM_VERSION}") + message(FATAL_ERROR "CMAKE_SYSTEM_VERSION and CMAKE_HOST_SYSTEM_VERSION not identical: \"${CMAKE_SYSTEM_VERSION}\" vs. \"${CMAKE_HOST_SYSTEM_VERSION}\"") +endif(NOT "${CMAKE_SYSTEM_VERSION}" STREQUAL "${CMAKE_HOST_SYSTEM_VERSION}") + +if(NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}") + message(FATAL_ERROR "CMAKE_SYSTEM_PROCESSOR and CMAKE_HOST_SYSTEM_PROCESSOR not identical: \"${CMAKE_SYSTEM_PROCESSOR}\" vs. \"${CMAKE_HOST_SYSTEM_PROCESSOR}\"") +endif(NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}") + +# save the values so we can compare them to CMAKE_HOST_SYSTEM_XXX in the toolchain case + +set(NATIVE_SYSTEM "${CMAKE_SYSTEM}") +set(NATIVE_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}") +set(NATIVE_SYSTEM_VERSION "${CMAKE_SYSTEM_VERSION}") +set(NATIVE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}") + +# reset them so they will be detected again now +set(CMAKE_SYSTEM) +set(CMAKE_SYSTEM_NAME) +set(CMAKE_SYSTEM_VERSION) +set(CMAKE_SYSTEM_PROCESSOR) +set(CMAKE_HOST_SYSTEM) +set(CMAKE_HOST_SYSTEM_NAME) +set(CMAKE_HOST_SYSTEM_VERSION) +set(CMAKE_HOST_SYSTEM_PROCESSOR) + + +############################################################ + +# now define a toolchain file and check that everything is +# detected correctly and nothing predefined is overwritten + +set(CMAKE_TOOLCHAIN_FILE "${MY_SOURCE_DIR}/DummyToolchain.cmake") + +include(CMakeDetermineSystem) +# make cmake think we are cross compiling for test to work +set(CMAKE_CROSSCOMPILING TRUE) +set(CMAKE_C_COMPILER_ID "GNU") +include(CMakeDetermineCCompiler) +include(CMakeDetermineCXXCompiler) + +############################################################# + +# check the results from DetermineSystem + +if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Dumdidum") + message(FATAL_ERROR "CMAKE_SYSTEM_NAME overwritten: \"${CMAKE_SYSTEM_NAME}\", was: \"Dumdidum\"") +endif(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Dumdidum") + +if(NOT "${CMAKE_SYSTEM}" STREQUAL "Dumdidum-1.0") + message(FATAL_ERROR "CMAKE_SYSTEM wrong: \"${CMAKE_SYSTEM}\", expected: \"Dumdidum-1.0\"") +endif(NOT "${CMAKE_SYSTEM}" STREQUAL "Dumdidum-1.0") +set(fileOne "${_INCLUDED_TOOLCHAIN_FILE}") +set(fileTwo "${MY_SOURCE_DIR}/DummyToolchain.cmake") +if(WIN32) + string(TOLOWER "${fileOne}" fileOne) + string(TOLOWER "${fileTwo}" fileTwo) +endif(WIN32) + +if(NOT "${fileOne}" STREQUAL "${fileTwo}") + message(FATAL_ERROR "Wrong toolchain was loaded: \"${fileOne}\" expected \"${fileTwo}\"") +endif(NOT "${fileOne}" STREQUAL "${fileTwo}") + +# check that CMAKE_HOST_SYSTEM_XXX and _SYSTEM_xxx detected above are identical +if(NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "${NATIVE_SYSTEM_NAME}") + message(FATAL_ERROR "CMAKE_HOST_SYSTEM_NAME and NATIVE_SYSTEM_NAME not identical: \"${CMAKE_HOST_SYSTEM_NAME}\" vs. \"${NATIVE_SYSTEM_NAME}\"") +endif(NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "${NATIVE_SYSTEM_NAME}") +if(NOT "${CMAKE_HOST_SYSTEM}" STREQUAL "${NATIVE_SYSTEM}") + message(FATAL_ERROR "CMAKE_HOST_SYSTEM and NATIVE_SYSTEM not identical: \"${CMAKE_HOST_SYSTEM}\" vs. \"${NATIVE_SYSTEM}\"") +endif(NOT "${CMAKE_HOST_SYSTEM}" STREQUAL "${NATIVE_SYSTEM}") +if(NOT "${CMAKE_HOST_SYSTEM_VERSION}" STREQUAL "${NATIVE_SYSTEM_VERSION}") + message(FATAL_ERROR "CMAKE_HOST_SYSTEM_VERSION and NATIVE_SYSTEM_VERSION not identical: \"${CMAKE_HOST_SYSTEM_VERSION}\" vs. \"${NATIVE_SYSTEM_VERSION}\"") +endif(NOT "${CMAKE_HOST_SYSTEM_VERSION}" STREQUAL "${NATIVE_SYSTEM_VERSION}") +if(NOT "${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "${NATIVE_SYSTEM_PROCESSOR}") + message(FATAL_ERROR "CMAKE_HOST_SYSTEM_PROCESSOR and NATIVE_SYSTEM_PROCESSOR not identical: \"${CMAKE_HOST_SYSTEM_PROCESSOR}\" vs. \"${NATIVE_SYSTEM_PROCESSOR}\"") +endif(NOT "${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "${NATIVE_SYSTEM_PROCESSOR}") + +############################################################# + +# check the results from DetermineCCompiler + +if(NOT "${_CMAKE_TOOLCHAIN_PREFIX}" STREQUAL "arm-elf-") + message(FATAL_ERROR "wrong toolchain prefix detected: \"${_CMAKE_TOOLCHAIN_PREFIX}\", expected: \"arm-elf-\"") +endif(NOT "${_CMAKE_TOOLCHAIN_PREFIX}" STREQUAL "arm-elf-") + +if(NOT "${_CMAKE_USER_C_COMPILER_PATH}" STREQUAL "/opt/foo/bin") + message(FATAL_ERROR "wrong C compiler location detected: \"${_CMAKE_USER_C_COMPILER_PATH}\", expected: \"/opt/foo/bin\"") +endif(NOT "${_CMAKE_USER_C_COMPILER_PATH}" STREQUAL "/opt/foo/bin") + +if(NOT "${CMAKE_C_OUTPUT_EXTENSION}" STREQUAL ".foo") + message(FATAL_ERROR "C output extension overwritten: \"${CMAKE_C_OUTPUT_EXTENSION}\", was: \".foo\"") +endif(NOT "${CMAKE_C_OUTPUT_EXTENSION}" STREQUAL ".foo") + +############################################################# + +# check the results from DetermineCXXCompiler + +if(NOT "${_CMAKE_USER_CXX_COMPILER_PATH}" STREQUAL "/opt/bar/bin") + message(FATAL_ERROR "wrong CXX compiler location detected: \"${_CMAKE_USER_CXX_COMPILER_PATH}\", expected: \"/opt/bar/bin\"") +endif(NOT "${_CMAKE_USER_CXX_COMPILER_PATH}" STREQUAL "/opt/bar/bin") + +if(NOT "${CMAKE_CXX_OUTPUT_EXTENSION}" STREQUAL ".bar") + message(FATAL_ERROR "C output extension overwritten: \"${CMAKE_CXX_OUTPUT_EXTENSION}\", was: \".bar\"") +endif(NOT "${CMAKE_CXX_OUTPUT_EXTENSION}" STREQUAL ".bar") + +message(STATUS "CMAKE_SYSTEM: \"${CMAKE_SYSTEM}\"") +message(STATUS "_CMAKE_TOOLCHAIN_PREFIX: \"${_CMAKE_TOOLCHAIN_PREFIX}\"") +message(STATUS "_CMAKE_USER_C_COMPILER_PATH: \"${_CMAKE_USER_C_COMPILER_PATH}\"") +message(STATUS "_CMAKE_USER_CXX_COMPILER_PATH: \"${_CMAKE_USER_CXX_COMPILER_PATH}\"") +message(STATUS "CMAKE_C_OUTPUT_EXTENSION: \"${CMAKE_C_OUTPUT_EXTENSION}\"") +message(STATUS "CMAKE_CXX_OUTPUT_EXTENSION: \"${CMAKE_CXX_OUTPUT_EXTENSION}\"") diff --git a/Tests/CMakeTests/VariableWatchTest.cmake.in b/Tests/CMakeTests/VariableWatchTest.cmake.in new file mode 100644 index 000000000..bdb4f7ec4 --- /dev/null +++ b/Tests/CMakeTests/VariableWatchTest.cmake.in @@ -0,0 +1,31 @@ +MESSAGE("Start") + +VARIABLE_WATCH(TESTVAR MESSAGE) +VARIABLE_WATCH(TESTVAR1) + +macro(testwatch var access file stack) + MESSAGE("There was a ${access} access done on the variable: ${var} in file ${file}") + MESSAGE("List file stack is: ${stack}") + set(${var}_watched 1) +endmacro(testwatch) + +VARIABLE_WATCH(somevar testwatch) + +set(TESTVAR1 "1") +set(TESTVAR "1") +set(TESTVAR1 "0") +set(TESTVAR "0") + + +message("Variable: ${somevar}") +if(NOT somevar_watched) + message(SEND_ERROR "'somevar' watch failed!") +endif() +set(somevar_watched) + +set(somevar "1") +message("Variable: ${somevar}") +if(NOT somevar_watched) + message(SEND_ERROR "'somevar' watch failed!") +endif() +remove(somevar) diff --git a/Tests/CMakeTests/VersionTest.cmake.in b/Tests/CMakeTests/VersionTest.cmake.in new file mode 100644 index 000000000..215bb2b96 --- /dev/null +++ b/Tests/CMakeTests/VersionTest.cmake.in @@ -0,0 +1,9 @@ +set(min_ver 2.7.20090305) +cmake_minimum_required(VERSION ${min_ver}) + +if("${CMAKE_VERSION}" VERSION_LESS "${min_ver}") + message(FATAL_ERROR + "CMAKE_VERSION=[${CMAKE_VERSION}] is less than [${min_ver}]") +else() + message("CMAKE_VERSION=[${CMAKE_VERSION}] is not less than [${min_ver}]") +endif() diff --git a/Tests/CMakeTests/While-Endwhile-Alone-Args.cmake b/Tests/CMakeTests/While-Endwhile-Alone-Args.cmake new file mode 100644 index 000000000..886d98c7c --- /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 000000000..82c09a07b --- /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 000000000..5c338d697 --- /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 000000000..32eaa2698 --- /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 000000000..1abaaaf2b --- /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 000000000..4693f2d8f --- /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/CMakeTests/include/cmake_i_do_not_exist_in_the_system.h b/Tests/CMakeTests/include/cmake_i_do_not_exist_in_the_system.h new file mode 100644 index 000000000..2392aee71 --- /dev/null +++ b/Tests/CMakeTests/include/cmake_i_do_not_exist_in_the_system.h @@ -0,0 +1 @@ +/* empty header file */ |