diff options
author | Brad King <brad.king@kitware.com> | 2011-01-27 19:39:55 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2011-01-27 19:39:55 (GMT) |
commit | dd2f81491e6e17681dd18882a8ccfa01fa32a3f7 (patch) | |
tree | 6b782de32aeb462333d70747f269b1725e723e00 /Tests | |
parent | 949d32c3067830a1376950fc78dbcde39bc378a8 (diff) | |
parent | 7679f9fab099e729b61320927a9e0b8d03546f7f (diff) | |
download | CMake-dd2f81491e6e17681dd18882a8ccfa01fa32a3f7.zip CMake-dd2f81491e6e17681dd18882a8ccfa01fa32a3f7.tar.gz CMake-dd2f81491e6e17681dd18882a8ccfa01fa32a3f7.tar.bz2 |
Merge branch 'dev/add_test-working-directory' into dev/strict-mode
Conflicts:
Tests/CMakeLists.txt
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/BuildDepends/CMakeLists.txt | 23 | ||||
-rw-r--r-- | Tests/BuildDepends/Project/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/BuildDepends/Project/linkdep.cxx | 4 | ||||
-rw-r--r-- | Tests/CMakeLists.txt | 47 | ||||
-rw-r--r-- | Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in | 9 | ||||
-rw-r--r-- | Tests/Contracts/cse-snapshot/CMakeLists.txt | 114 | ||||
-rw-r--r-- | Tests/Contracts/cse-snapshot/Dashboard.cmake.in | 76 | ||||
-rw-r--r-- | Tests/Contracts/cse-snapshot/RunTest.cmake | 3 | ||||
-rw-r--r-- | Tests/Contracts/vtk542/CMakeLists.txt | 30 | ||||
-rw-r--r-- | Tests/Contracts/vtk542/RunTest.cmake | 1 | ||||
-rw-r--r-- | Tests/CustomCommand/CMakeLists.txt | 7 | ||||
-rw-r--r-- | Tests/ExportImport/Import/A/CMakeLists.txt | 56 | ||||
-rw-r--r-- | Tests/ExportImport/Import/A/imp_lib1.c | 2 | ||||
-rw-r--r-- | Tests/StringFileTest/CMakeLists.txt | 24 | ||||
-rw-r--r-- | Tests/TestsWorkingDirectory/CMakeLists.txt | 29 | ||||
-rw-r--r-- | Tests/TestsWorkingDirectory/main.cxx | 56 | ||||
-rw-r--r-- | Tests/VSExternalInclude/CMakeLists.txt | 8 |
17 files changed, 485 insertions, 9 deletions
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 8714640..31392b5 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -34,6 +34,12 @@ if(WIN32 AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel") set(_cmake_options "-DCMAKE_EXE_LINKER_FLAGS=") endif() +if("${CMAKE_GENERATOR}" MATCHES "Make") + set(TEST_LINK_DEPENDS ${BuildDepends_BINARY_DIR}/Project/linkdep.txt) + file(WRITE ${TEST_LINK_DEPENDS} "1") +endif() +list(APPEND _cmake_options "-DTEST_LINK_DEPENDS=${TEST_LINK_DEPENDS}") + file(MAKE_DIRECTORY ${BuildDepends_BINARY_DIR}/Project) message("Creating Project/foo.cxx") write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx @@ -131,6 +137,10 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx "static const char* zot_macro_tgt = \"zot_macro_tgt changed\";\n") +if(TEST_LINK_DEPENDS) + file(WRITE ${TEST_LINK_DEPENDS} "2") +endif() + help_xcode_depends() message("Building project second time") @@ -194,3 +204,16 @@ if("${out}" STREQUAL "${VALUE_CHANGED}") else("${out}" STREQUAL "${VALUE_CHANGED}") message(SEND_ERROR "Project did not rebuild properly!") endif("${out}" STREQUAL "${VALUE_CHANGED}") + +if(TEST_LINK_DEPENDS) + set(linkdep ${BuildDepends_BINARY_DIR}/Project/linkdep${CMAKE_EXECUTABLE_SUFFIX}) + if(${linkdep} IS_NEWER_THAN ${TEST_LINK_DEPENDS}) + message("LINK_DEPENDS worked") + else() + message(SEND_ERROR "LINK_DEPENDS failed. Executable + ${linkdep} +is not newer than dependency + ${TEST_LINK_DEPENDS} +") + endif() +endif() diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index e9d1296..70a2f37 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -80,3 +80,8 @@ set_property( DIRECTORY PROPERTY IMPLICIT_DEPENDS_INCLUDE_TRANSFORM "ZOT_DIR(%)=<zot_%_dir.hxx>" ) + +if(TEST_LINK_DEPENDS) + add_executable(linkdep linkdep.cxx) + set_property(TARGET linkdep PROPERTY LINK_DEPENDS ${TEST_LINK_DEPENDS}) +endif() diff --git a/Tests/BuildDepends/Project/linkdep.cxx b/Tests/BuildDepends/Project/linkdep.cxx new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/BuildDepends/Project/linkdep.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 27cff3f..6a9ec29 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -11,7 +11,7 @@ MACRO(ADD_TEST_MACRO NAME COMMAND) --build-generator ${CMAKE_TEST_GENERATOR} --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project ${proj} - --test-command ${COMMAND}) + --test-command ${COMMAND} ${ARGN}) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}") ENDMACRO(ADD_TEST_MACRO) @@ -21,7 +21,11 @@ IF(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) FILE(MAKE_DIRECTORY "${TEST_HOME}") FILE(WRITE "${TEST_HOME}/.cvspass" ":pserver:anoncvs@www.cmake.org:/cvsroot/KWSys A\n") SET(TEST_HOME_ENV_CODE "# Fake a user home directory to avoid polluting the real one. -SET(ENV{HOME} \"${TEST_HOME}\")") +# But provide original ENV{HOME} value in ENV{CTEST_REAL_HOME} for tests that +# need access to the real HOME directory. +SET(ENV{CTEST_REAL_HOME} \"\$ENV{HOME}\") +SET(ENV{HOME} \"${TEST_HOME}\") +") ENDIF() # Choose a default configuration for CTest tests. @@ -1164,6 +1168,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ PASS_REGULAR_EXPRESSION "uninitialized variable 'USED_VARIABLE'") LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUninitialized") + ADD_TEST(TestsWorkingDirectory ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/TestsWorkingDirectory" + "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project TestsWorkingDirectoryProj + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory" + --force-new-ctest-process + --test-command ${CMAKE_CTEST_COMMAND} -V + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory") + # Make sure CTest can handle a test with no newline in output. ADD_TEST(CTest.NoNewline ${CMAKE_CMAKE_COMMAND} -E echo_append "This line has no newline!") @@ -1852,6 +1869,32 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ -D source_dir:STRING=${CMAKE_CURRENT_SOURCE_DIR}/Tutorial/Step3 -D CMAKE_CTEST_COMMAND:STRING=${CMAKE_CTEST_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeWizardTest.cmake) + # If the cache variable CMAKE_CONTRACT_PROJECTS is set + # then the dashboard will run a contract with CMake test of that + # name. For example CMAKE_CONTRACT_PROJECTS = vtk542 would run + # the vtk542 contract test. + # For each Contract test, the project should provide a directory + # with at least one CMakeLists.txt file that uses ExternalProject + # to download and configure the project. The directory should also + # contain a RunTest.cmake file that has a single set of the format: + # SET(project_RUN_TEST testToRun) + # The testToRun should be a test executable that can be run to + # smoke test the build. + FOREACH(project ${CMAKE_CONTRACT_PROJECTS}) + INCLUDE(Contracts/${project}/RunTest.cmake) + ADD_TEST_MACRO(Contracts.${project} + ${${project}_RUN_TEST}) + # Contract test timeout in seconds. + # Default to 6 hours. + IF(DEFINED ${project}_TEST_TIMEOUT) + SET(timeout ${${project}_TEST_TIMEOUT}) + ELSEIF(CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT) + SET(timeout ${CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT}) + ELSE() + SET(timeout 21600) + ENDIF() + SET_TESTS_PROPERTIES(Contracts.${project} PROPERTIES TIMEOUT ${timeout}) + ENDFOREACH() ENDIF(BUILD_TESTING) SUBDIRS(CMakeTests) diff --git a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in index 0ab2a67..3fb4652 100644 --- a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in +++ b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in @@ -77,6 +77,13 @@ set(linux64_pgf90_libs "pgf90;pgf90_rpm1;pgf902;pgf90rtl;pgftnrtl;nspgc;pgc;rt;p 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) + # 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 @@ -380,7 +387,7 @@ 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) + cmake_parse_implicit_link_info("${${p}_text}" libs dirs log "${${p}_obj_regex}") foreach(v libs dirs) if(NOT "${${v}}" STREQUAL "${${p}_${v}}") diff --git a/Tests/Contracts/cse-snapshot/CMakeLists.txt b/Tests/Contracts/cse-snapshot/CMakeLists.txt new file mode 100644 index 0000000..9134210 --- /dev/null +++ b/Tests/Contracts/cse-snapshot/CMakeLists.txt @@ -0,0 +1,114 @@ +cmake_minimum_required(VERSION 2.8) +project(cse-snapshot) + +include(ExternalProject) + +include("${CMAKE_CURRENT_SOURCE_DIR}/LocalOverrides.cmake" OPTIONAL) +include("${CMAKE_CURRENT_BINARY_DIR}/LocalOverrides.cmake" OPTIONAL) + +if(NOT DEFINED HOME) + if(DEFINED ENV{CTEST_REAL_HOME}) + set(HOME "$ENV{CTEST_REAL_HOME}") + else() + set(HOME "$ENV{HOME}") + endif() +endif() +message(STATUS "HOME='${HOME}'") + +if(NOT DEFINED repo) + set(repo "git://public.kitware.com/cse.git") +endif() +message(STATUS "repo='${repo}'") + +if(NOT DEFINED tag) + set(tag "cc1dcb95439a21ab1d58f444d93481598414196e") +endif() +message(STATUS "tag='${tag}'") + +string(SUBSTRING "${tag}" 0 8 shorttag) + +set(base_dir "${HOME}/.cmake/Contracts/${PROJECT_NAME}/${shorttag}") +set(binary_dir "${base_dir}/build") +set(script_dir "${base_dir}") +set(source_dir "${base_dir}/src") + +if(NOT DEFINED BUILDNAME) + set(BUILDNAME "CMakeContract-${shorttag}") +endif() +message(STATUS "BUILDNAME='${BUILDNAME}'") + +if(NOT DEFINED SITE) + site_name(SITE) +endif() +message(STATUS "SITE='${SITE}'") + +if(NOT DEFINED PROCESSOR_COUNT) + # Unknown: + set(PROCESSOR_COUNT 0) + + # Linux: + set(cpuinfo_file "/proc/cpuinfo") + if(EXISTS "${cpuinfo_file}") + file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$") + list(LENGTH procs PROCESSOR_COUNT) + endif() + + # Mac: + if(APPLE) + find_program(cmd_sysctl "sysctl") + if(cmd_sysctl) + execute_process(COMMAND ${cmd_sysctl} -n hw.ncpu + OUTPUT_VARIABLE PROCESSOR_COUNT + OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() + endif() + + # Windows: + if(WIN32) + set(PROCESSOR_COUNT "$ENV{NUMBER_OF_PROCESSORS}") + endif() +endif() +message(STATUS "PROCESSOR_COUNT='${PROCESSOR_COUNT}'") + +find_package(Git) +if(NOT GIT_EXECUTABLE) + message(FATAL_ERROR "error: could not find git") + # adjust PATH to find git, or set GIT_EXECUTABLE in LocalOverrides.cmake +endif() +message(STATUS "GIT_EXECUTABLE='${GIT_EXECUTABLE}'") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/Dashboard.cmake.in" + "${script_dir}/Dashboard.cmake" + @ONLY) + +# Source dir for this project exists outside the CMake build tree because it +# is absolutely huge. +# +if(EXISTS "${source_dir}/.git") + # If it exists already, download is a complete no-op: + ExternalProject_Add(download-${PROJECT_NAME} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +else() + # If it does not yet exist, download clones the git repository: + ExternalProject_Add(download-${PROJECT_NAME} + SOURCE_DIR "${source_dir}" + GIT_REPOSITORY "${repo}" + GIT_TAG "${tag}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +endif() + +ExternalProject_Add(build-${PROJECT_NAME} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND ${CMAKE_CTEST_COMMAND} -S "${script_dir}/Dashboard.cmake" + INSTALL_COMMAND "" + DEPENDS download-${PROJECT_NAME} + ) diff --git a/Tests/Contracts/cse-snapshot/Dashboard.cmake.in b/Tests/Contracts/cse-snapshot/Dashboard.cmake.in new file mode 100644 index 0000000..138eb3f --- /dev/null +++ b/Tests/Contracts/cse-snapshot/Dashboard.cmake.in @@ -0,0 +1,76 @@ +# This "ctest -S" script may be configured to drive a nightly dashboard on any +# Linux machine. +# +set(CTEST_BINARY_DIRECTORY "@binary_dir@") +set(CTEST_BUILD_NAME "@BUILDNAME@") +set(CTEST_SITE "@SITE@") +set(CTEST_SOURCE_DIRECTORY "@source_dir@") +set(PROCESSOR_COUNT "@PROCESSOR_COUNT@") + +# Assume a Linux build, with a make that supports -j. Modify this script if +# assumption is ever invalid. +# +if(PROCESSOR_COUNT) + set(CTEST_BUILD_FLAGS "-j${PROCESSOR_COUNT}") +endif() + +set(CTEST_CMAKE_GENERATOR "Unix Makefiles") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +message("Cleaning binary dir '${CTEST_BINARY_DIRECTORY}'") +ctest_empty_binary_directory("${CTEST_BINARY_DIRECTORY}") + +# Intentionally no ctest_update step in this script. This script is run as a +# "Contract" test on a CMake dashboard submission using the just-built ctest +# as the driver. The download step in the Contract CMakeLists file takes care +# of setting up the source tree before calling this ctest -S script. The idea +# is that the source tree will be the same every day, so there should not be +# an "update" step for this build. + +message("Configuring CSE in binary dir '${CTEST_BINARY_DIRECTORY}'") +set_property(GLOBAL PROPERTY SubProject "CSE-toplevel") +set_property(GLOBAL PROPERTY Label "CSE-toplevel") + +ctest_start("Experimental") + +set(CSE_TOPLEVEL_OPTIONS + -DEXTERNAL_PROJECT_DASHBOARD_BUILD:BOOL=ON + -DEXTERNAL_PROJECT_TESTS:BOOL=ON + -DCSE_INSTALL_PREFIX:PATH=${CTEST_BINARY_DIRECTORY}/built + -DCSE_SUBSET:STRING=ALL + -DCTEST_SITE:STRING=${CTEST_SITE} +) + +ctest_configure(OPTIONS "${CSE_TOPLEVEL_OPTIONS}") + +# The configure step produces a file listing the CSE packages and dependencies. +# This file also generates Project.xml and stores it in ${PROJECT_XML}. +# +set(subprojects "") +if(EXISTS "${CTEST_BINARY_DIRECTORY}/CSEBuildtimeDepends.cmake") + message("Including CSEBuildtimeDepends.cmake") + include("${CTEST_BINARY_DIRECTORY}/CSEBuildtimeDepends.cmake") + set(subprojects ${CSE_ALL_SORTED}) + message("Submitting Project.xml") + ctest_submit(FILES ${PROJECT_XML}) +endif() + +message("Submitting CSE configure results") +ctest_submit() + +if(subprojects) + message("Building by looping over subprojects...") + foreach(subproject ${subprojects}) + message("########## ${subproject} ##########") + set_property(GLOBAL PROPERTY SubProject "${subproject}") + set_property(GLOBAL PROPERTY Label "${subproject}") + ctest_build(TARGET "${subproject}" APPEND) + message("Submitting ${subproject} build results") + ctest_submit(PARTS build) + endforeach() +else() + message("Building all...") + ctest_build(APPEND) + message("Submitting build results") + ctest_submit(PARTS build) +endif() diff --git a/Tests/Contracts/cse-snapshot/RunTest.cmake b/Tests/Contracts/cse-snapshot/RunTest.cmake new file mode 100644 index 0000000..7eb6301 --- /dev/null +++ b/Tests/Contracts/cse-snapshot/RunTest.cmake @@ -0,0 +1,3 @@ +set(exe "$ENV{HOME}/.cmake/Contracts/cse-snapshot/510345e4/build/built/Release/git-1.6.5.2/bin/git") +set(args help clone) +set(cse-snapshot_RUN_TEST ${exe} ${args}) diff --git a/Tests/Contracts/vtk542/CMakeLists.txt b/Tests/Contracts/vtk542/CMakeLists.txt new file mode 100644 index 0000000..cfb8b16 --- /dev/null +++ b/Tests/Contracts/vtk542/CMakeLists.txt @@ -0,0 +1,30 @@ +# The VTK external project for CMake +# --------------------------------------------------------------------------- +cmake_minimum_required(VERSION 2.8) +project(vtk542) +include(ExternalProject) + + +set(vtk_source "${CMAKE_CURRENT_BINARY_DIR}/VTK-source") +set(vtk_binary "${CMAKE_CURRENT_BINARY_DIR}/VTK-build") + +ExternalProject_Add(VTK + DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR} + URL "http://www.vtk.org/files/release/5.4/vtk-5.4.2.tar.gz" + URL_MD5 c2c797091d4b2128d9a1bd32c4b78227 + SOURCE_DIR ${vtk_source} + BINARY_DIR ${vtk_binary} + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS + -DBUILD_EXAMPLES:BOOL=ON + -DBUILD_TESTING:BOOL=ON + INSTALL_COMMAND "" + ) +# make it so that each build will run make in the VTK build tree +ExternalProject_Add_Step(VTK forcebuild + COMMAND ${CMAKE_COMMAND} + -E remove ${CMAKE_CURRENT_BUILD_DIR}/VTK-prefix/src/VTK-stamp/VTK-build + DEPENDEES configure + DEPENDERS build + ALWAYS 1 + ) diff --git a/Tests/Contracts/vtk542/RunTest.cmake b/Tests/Contracts/vtk542/RunTest.cmake new file mode 100644 index 0000000..4f48e5c --- /dev/null +++ b/Tests/Contracts/vtk542/RunTest.cmake @@ -0,0 +1 @@ +SET(vtk542_RUN_TEST VTK-build/bin/CommonCxxTests otherArrays) diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 76208d4..13f4233 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -55,7 +55,7 @@ ADD_CUSTOM_COMMAND( # Test creating files from a custom target # ################################################################ -ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/doc1.dvi +ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}//doc1.dvi # test 2 slashes DEPENDS ${PROJECT_SOURCE_DIR}/doc1.tex COMMAND ${CMAKE_COMMAND} ARGS -E copy ${PROJECT_SOURCE_DIR}/doc1.tex @@ -130,6 +130,7 @@ ADD_CUSTOM_COMMAND( ################################################################ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/foo.pre DEPENDS ${PROJECT_SOURCE_DIR}/foo.in + TDocument # Ensure doc1.h generates before this target COMMAND ${CMAKE_COMMAND} ARGS -E copy ${PROJECT_SOURCE_DIR}/foo.in ${PROJECT_BINARY_DIR}/foo.pre @@ -181,10 +182,6 @@ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/generated.c TARGET_LINK_LIBRARIES(CustomCommand GeneratedHeader) -# must add a dependency on TDocument otherwise it might never build and -# the CustomCommand executable really needs doc1.h -ADD_DEPENDENCIES(CustomCommand TDocument) - ############################################################################## # Test for using just the target name as executable in the COMMAND # section. Has to be recognized and replaced by CMake with the output diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 34b8717..e65e362 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -75,8 +75,64 @@ foreach(c DEBUG RELWITHDEBINFO) set_property(TARGET imp_testExe1b PROPERTY COMPILE_DEFINITIONS_${c} EXE_DBG) endforeach(c) +#----------------------------------------------------------------------------- +# Create a custom target to generate a header for the libraries below. +# Drive the header generation through an indirect chain of imported +# target dependencies. + +# testLib2tmp1.h +add_custom_command( + OUTPUT testLib2tmp1.h + VERBATIM COMMAND + ${CMAKE_COMMAND} -E echo "extern int testLib2(void);" > testLib2tmp1.h + ) + +# hdr_testLib2tmp1 needs testLib2tmp1.h +add_custom_target(hdr_testLib2tmp1 DEPENDS testLib2tmp1.h) + +# exp_testExe2 needs hdr_testLib2tmp1 +add_dependencies(exp_testExe2 hdr_testLib2tmp1) + +# testLib2tmp.h needs exp_testExe2 +add_custom_command( + OUTPUT testLib2tmp.h + VERBATIM COMMAND exp_testExe2 + COMMAND ${CMAKE_COMMAND} -E copy testLib2tmp1.h testLib2tmp.h + ) + +# hdr_testLib2tmp needs testLib2tmp.h +add_custom_target(hdr_testLib2tmp DEPENDS testLib2tmp.h) + +add_library(dep_testLib2tmp UNKNOWN IMPORTED) +set_property(TARGET dep_testLib2tmp PROPERTY + IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/testLib2tmp.h) + +# dep_testLib2tmp needs hdr_testLib2tmp +add_dependencies(dep_testLib2tmp hdr_testLib2tmp) + +# testLib2.h needs dep_testLib2tmp +add_custom_command( + OUTPUT testLib2.h + VERBATIM COMMAND ${CMAKE_COMMAND} -E copy testLib2tmp.h testLib2.h + DEPENDS dep_testLib2tmp + ) + +# hdr_testLib2 needs testLib2.h +add_custom_target(hdr_testLib2 DEPENDS testLib2.h) + +add_library(dep_testLib2 UNKNOWN IMPORTED) + +# dep_testLib2 needs hdr_testLib2 +add_dependencies(dep_testLib2 hdr_testLib2) + +# exp_testLib2 and bld_testLib2 both need dep_testLib2 +add_dependencies(bld_testLib2 dep_testLib2) +add_dependencies(exp_testLib2 dep_testLib2) + +#----------------------------------------------------------------------------- # Create a library to be linked by another directory in this project # to test transitive linking to otherwise invisible imported targets. +include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_library(imp_lib1 STATIC imp_lib1.c) target_link_libraries(imp_lib1 exp_testLib2) add_library(imp_lib1b STATIC imp_lib1.c) diff --git a/Tests/ExportImport/Import/A/imp_lib1.c b/Tests/ExportImport/Import/A/imp_lib1.c index d8c66e6..5b3215e 100644 --- a/Tests/ExportImport/Import/A/imp_lib1.c +++ b/Tests/ExportImport/Import/A/imp_lib1.c @@ -1,4 +1,4 @@ -extern int testLib2(void); +#include "testLib2.h" int imp_lib1(void) { diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt index 2e052bf..7792a35 100644 --- a/Tests/StringFileTest/CMakeLists.txt +++ b/Tests/StringFileTest/CMakeLists.txt @@ -256,3 +256,27 @@ endif() if(NOT "${var_b}" STREQUAL "x") message(FATAL_ERROR "count incorrect \"b\": [${var_b}]") endif() + +# Test SUBSTRING command +SET(ST_INPUTSTRING "0123456789") +STRING(SUBSTRING ${ST_INPUTSTRING} 3 0 ST_EMPTY) +STRING(SUBSTRING ${ST_INPUTSTRING} 1 1 ST_ONE) +STRING(SUBSTRING ${ST_INPUTSTRING} 0 10 ST_ALL) +STRING(SUBSTRING ${ST_INPUTSTRING} 0 -1 ST_ALL_MINUS) +STRING(SUBSTRING ${ST_INPUTSTRING} 9 -1 ST_NINE) + +IF(ST_EMPTY) + MESSAGE(SEND_ERROR "SUBSTRING with length 0 does not return an empty string") +ENDIF(ST_EMPTY) +IF(NOT ST_ONE STREQUAL "1") + MESSAGE(SEND_ERROR "SUBSTING command does not cut the correct selected character, was \"" ${ST_ONE} "\", should be \"1\"") +ENDIF(NOT ST_ONE STREQUAL "1") +IF(NOT ST_INPUTSTRING STREQUAL ST_ALL) + MESSAGE(SEND_ERROR "SUBSTRING does not return the whole string when selected with length") +ENDIF(NOT ST_INPUTSTRING STREQUAL ST_ALL) +IF(NOT ST_INPUTSTRING STREQUAL ST_ALL_MINUS) + MESSAGE(SEND_ERROR "SUBSTRING does not return the whole string when selected with -1") +ENDIF(NOT ST_INPUTSTRING STREQUAL ST_ALL_MINUS) +IF(NOT ST_NINE STREQUAL "9") + MESSAGE(SEND_ERROR "SUBSTRING does not return the tail when selected with -1") +ENDIF(NOT ST_NINE STREQUAL "9") diff --git a/Tests/TestsWorkingDirectory/CMakeLists.txt b/Tests/TestsWorkingDirectory/CMakeLists.txt new file mode 100644 index 0000000..5fbcd2a --- /dev/null +++ b/Tests/TestsWorkingDirectory/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 2.6) +project(WorkingDirectoryProj) + +add_executable(WorkingDirectory main.cxx) + +enable_testing() + +add_test(NAME WorkingDirectory1 COMMAND WorkingDirectory) +add_test(NAME WorkingDirectory2 COMMAND WorkingDirectory) +add_test(WorkingDirectory3 WorkingDirectory) + +set_tests_properties(WorkingDirectory1 PROPERTIES + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + PASS_REGULAR_EXPRESSION "Working directory: ${CMAKE_BINARY_DIR}" +) + +string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_BINARY_DIR}") + +set_tests_properties(WorkingDirectory2 PROPERTIES + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.." + PASS_REGULAR_EXPRESSION "Working directory: ${_parent_dir}" +) + +string(REGEX REPLACE "/[^/]*$" "" _wd_exe "${CMAKE_BINARY_DIR}") +get_filename_component(_default_cwd "${_wd_exe}" ABSOLUTE) + +set_tests_properties(WorkingDirectory3 PROPERTIES + PASS_REGULAR_EXPRESSION "Working directory: ${_default_cwd}" +) diff --git a/Tests/TestsWorkingDirectory/main.cxx b/Tests/TestsWorkingDirectory/main.cxx new file mode 100644 index 0000000..6636da0 --- /dev/null +++ b/Tests/TestsWorkingDirectory/main.cxx @@ -0,0 +1,56 @@ +#include <stdio.h> +#include <stdlib.h> + +#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) + +#include <io.h> +#include <direct.h> + +#if defined(__WATCOMC__) +#include <direct.h> +#define _getcwd getcwd +#endif + +inline const char* Getcwd(char* buf, unsigned int len) +{ + const char* ret = _getcwd(buf, len); + if(!ret) + { + fprintf(stderr, "No current working directory.\n"); + abort(); + } + // make sure the drive letter is capital + if(strlen(buf) > 1 && buf[1] == ':') + { + buf[0] = toupper(buf[0]); + } + return ret; +} + +#else +#include <sys/types.h> +#include <fcntl.h> +#include <unistd.h> + +inline const char* Getcwd(char* buf, unsigned int len) +{ + const char* ret = getcwd(buf, len); + if(!ret) + { + fprintf(stderr, "No current working directory\n"); + abort(); + } + return ret; +} + +#endif + +int main(int argc, char *argv[]) +{ + char buf[2048]; + const char *cwd = Getcwd(buf, sizeof(buf)); + + fprintf(stdout, "Working directory: %s\n", cwd); + + return 0; +} diff --git a/Tests/VSExternalInclude/CMakeLists.txt b/Tests/VSExternalInclude/CMakeLists.txt index 931e636..1e68968 100644 --- a/Tests/VSExternalInclude/CMakeLists.txt +++ b/Tests/VSExternalInclude/CMakeLists.txt @@ -50,3 +50,11 @@ IF(MSVC10) ADD_DEPENDENCIES(VSExternalInclude lib1) ENDIF() +# Interaction testing between the FOLDER target property and +# INCLUDE_EXTERNAL_MSPROJECT targets: +set_target_properties(VSExternalInclude PROPERTIES FOLDER folder1/folder2) +set_target_properties(lib1 PROPERTIES FOLDER folder1/folder2) +set_target_properties(lib2 PROPERTIES FOLDER folder1/folder2) +add_custom_target(EmptyCustomTarget) +set_target_properties(EmptyCustomTarget PROPERTIES FOLDER folder1/folder2) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) |