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 | |
download | cmake-016a8fd987d100a88ecf87f98b8b4ddc61da57fd.tar.gz cmake-016a8fd987d100a88ecf87f98b8b4ddc61da57fd.tar.bz2 cmake-016a8fd987d100a88ecf87f98b8b4ddc61da57fd.zip |
Imported Upstream version 2.8.9upstream/2.8.9
Diffstat (limited to 'Tests')
1419 files changed, 40816 insertions, 0 deletions
diff --git a/Tests/.NoDartCoverage b/Tests/.NoDartCoverage new file mode 100644 index 000000000..3c9972938 --- /dev/null +++ b/Tests/.NoDartCoverage @@ -0,0 +1 @@ +# do not do coverage in this directory diff --git a/Tests/Architecture/CMakeLists.txt b/Tests/Architecture/CMakeLists.txt new file mode 100644 index 000000000..927ce3fed --- /dev/null +++ b/Tests/Architecture/CMakeLists.txt @@ -0,0 +1,59 @@ +cmake_minimum_required(VERSION 2.8) +project(Architecture C) + +function(test_for_xcode4 result_var) + set(${result_var} 0 PARENT_SCOPE) + if(APPLE) + execute_process(COMMAND xcodebuild -version + OUTPUT_VARIABLE ov RESULT_VARIABLE rv + ) + if("${rv}" STREQUAL "0") + if(ov MATCHES "^Xcode 4.[0-9].*$") + set(${result_var} 1 PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + +test_for_xcode4(is_xcode4) + +set(arch0 i386) +set(arch1 ppc) + +if(is_xcode4) + # Xcode 4, use modern architectures as defaults + # Arch 'ppc' no longer works: tools no longer available starting with Xcode 4 + set(arch0 i386) + set(arch1 x86_64) +endif() + +add_library(foo foo.c) +if(CMAKE_OSX_ARCHITECTURES) + get_property(archs TARGET foo PROPERTY OSX_ARCHITECTURES) + if(NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "${archs}") + message(FATAL_ERROR + "OSX_ARCHITECTURES property not initialized by CMAKE_OSX_ARCHITECTURES.\n" + "Expected [${CMAKE_OSX_ARCHITECTURES}], got [${archs}]." + ) + endif() + list(LENGTH archs archs_len) + if(archs_len GREATER 1) + list(GET archs 0 arch0) + list(GET archs 1 arch1) + endif() +endif() + +message("is_xcode4='${is_xcode4}'") +message("archs='${archs}'") +message("arch0='${arch0}'") +message("arch1='${arch1}'") + +set_property(TARGET foo PROPERTY OSX_ARCHITECTURES ${arch0}) +set_property(TARGET foo PROPERTY OSX_ARCHITECTURES_DEBUG ${arch1}) + +add_executable(bar bar.c) +target_link_libraries(bar foo) + +set_property(TARGET bar PROPERTY OUTPUT_NAME Architecture) +set_property(TARGET bar PROPERTY OSX_ARCHITECTURES ${arch1}) +set_property(TARGET bar PROPERTY OSX_ARCHITECTURES_DEBUG ${arch0}) diff --git a/Tests/Architecture/bar.c b/Tests/Architecture/bar.c new file mode 100644 index 000000000..923c89c9a --- /dev/null +++ b/Tests/Architecture/bar.c @@ -0,0 +1,2 @@ +extern int foo(void); +int main() { return foo(); } diff --git a/Tests/Architecture/foo.c b/Tests/Architecture/foo.c new file mode 100644 index 000000000..e35694ba0 --- /dev/null +++ b/Tests/Architecture/foo.c @@ -0,0 +1 @@ +int foo(void) { return 0; } diff --git a/Tests/ArgumentExpansion/CMakeLists.txt b/Tests/ArgumentExpansion/CMakeLists.txt new file mode 100644 index 000000000..a24636f58 --- /dev/null +++ b/Tests/ArgumentExpansion/CMakeLists.txt @@ -0,0 +1,60 @@ +cmake_minimum_required(VERSION 2.8) + +project(ArgumentExpansion) + +function (argument_tester expected expected_len) + list(LENGTH ARGN argn_len) + list(LENGTH ${expected} expected_received_len) + + if (NOT ${expected_received_len} EQUAL ${expected_len}) + message(STATUS "Unexpected: Expanding expected values isn't working") + endif (NOT ${expected_received_len} EQUAL ${expected_len}) + + if (${argn_len} EQUAL ${expected_len}) + set(i 0) + while (i LESS ${argn_len}) + list(GET ARGN ${i} argn_value) + list(GET ${expected} ${i} expected_value) + + if (NOT "${argn_value}" STREQUAL "${expected_value}") + message(STATUS "Unexpected: Argument ${i} doesn't match") + message(STATUS " Expected: ${expected_value}") + message(STATUS " Received: ${argn_value}") + endif () + + math(EXPR i "${i} + 1") + endwhile (i LESS ${argn_len}) + else (${argn_len} EQUAL ${expected_len}) + message(STATUS "Unexpected: Lengths of arguments don't match") + message(STATUS " Expected: ${expected_len}") + message(STATUS " Received: ${argn_len}") + endif (${argn_len} EQUAL ${expected_len}) +endfunction (argument_tester expected) + +set(empty_test) +message(STATUS "Test: Empty arguments") +argument_tester(empty_test 0 ${empty_test}) + +set(single_arg_test + "single arg") +message(STATUS "Test: Single argument") +argument_tester(single_arg_test 1 ${single_arg_test}) + +set(multiple_arg_test + "first arg" + "second arg") +message(STATUS "Test: Multiple arguments") +argument_tester(multiple_arg_test 2 ${multiple_arg_test}) + +set(nested_list_arg_test + "${multiple_arg_test}" + "first arg" + "second arg") +message(STATUS "Test: Nested list argument flattens") +argument_tester(nested_list_arg_test 4 ${nested_list_arg_test}) + +set(semicolon_arg_test + "pre\;post") +set(semicolon_arg_test_flat "pre;post") +message(STATUS "Test: Semicolon argument flattens") +argument_tester(semicolon_arg_test_flat 2 ${semicolon_arg_test}) diff --git a/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt new file mode 100644 index 000000000..456e4961f --- /dev/null +++ b/Tests/Assembler/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required (VERSION 2.6) +project(Assembler C) +message("CTEST_FULL_OUTPUT ") +set(CMAKE_VERBOSE_MAKEFILE 1) + +set(SRCS) + +# (at least) the following toolchains can process assembler files directly +# and also generate assembler files from C: +if("${CMAKE_GENERATOR}" MATCHES "Makefile") + if(("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|HP|SunPro|XL)$") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND UNIX)) + set(C_FLAGS "${CMAKE_C_FLAGS}") + separate_arguments(C_FLAGS) + set(SRCS main.s) + add_custom_command( + OUTPUT main.s + COMMAND ${CMAKE_C_COMPILER} ${C_FLAGS} -S ${CMAKE_CURRENT_SOURCE_DIR}/main.c -o main.s + DEPENDS main.c + VERBATIM + ) + endif(("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|HP|SunPro|XL)$") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND UNIX)) +endif("${CMAKE_GENERATOR}" MATCHES "Makefile") + + +if(SRCS) + set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}") + enable_language(ASM OPTIONAL) +else(SRCS) + message(STATUS "No assembler enabled, using C") + set(SRCS main.c) +endif(SRCS) + +add_executable(HelloAsm ${SRCS}) diff --git a/Tests/Assembler/main-linux-x86-gas.s b/Tests/Assembler/main-linux-x86-gas.s new file mode 100644 index 000000000..da8e84591 --- /dev/null +++ b/Tests/Assembler/main-linux-x86-gas.s @@ -0,0 +1,28 @@ + .section .rodata + .align 4 +.LC0: + .string "hello assembler world, %d arguments given\n" + .text +.globl main + .type main, @function +main: + leal 4(%esp), %ecx + andl $-16, %esp + pushl -4(%ecx) + pushl %ebp + movl %esp, %ebp + pushl %ecx + subl $20, %esp + movl (%ecx), %eax + movl %eax, 4(%esp) + movl $.LC0, (%esp) + call printf + movl $0, %eax + addl $20, %esp + popl %ecx + popl %ebp + leal -4(%ecx), %esp + ret + .size main, .-main + .ident "GCC: (GNU) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)" + .section .note.GNU-stack,"",@progbits diff --git a/Tests/Assembler/main.c b/Tests/Assembler/main.c new file mode 100644 index 000000000..95de0b5d1 --- /dev/null +++ b/Tests/Assembler/main.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +#ifdef __CLASSIC_C__ +int main(){ + int argc; + char*argv[]; +#else +int main(int argc, char*argv[]){ +#endif + printf("hello assembler world, %d arguments given\n", argc); + return 0; +} diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt new file mode 100644 index 000000000..5e36d11b4 --- /dev/null +++ b/Tests/BuildDepends/CMakeLists.txt @@ -0,0 +1,225 @@ +# this test creates a static library and an executable +# the source to the library is then changed +# and the build is done on the executable and if things +# are working the executable should relink with the new +# value. The subdir Project contains the CMakelists.txt +# and source files for the test project. +cmake_minimum_required (VERSION 2.6) +project(BuildDepends) + +# This entire test takes place during the initial +# configure step. It should not run again when the +# project is built. +set(CMAKE_SUPPRESS_REGENERATION 1) + +# Xcode needs some help with the fancy dependencies in this test. +if("${CMAKE_GENERATOR}" MATCHES "Xcode") + set(HELP_XCODE 1) +endif("${CMAKE_GENERATOR}" MATCHES "Xcode") +function(help_xcode_depends) + if(HELP_XCODE) + file(GLOB_RECURSE MACRO_OBJS + ${BuildDepends_BINARY_DIR}/Project/zot_macro_*.o* + ) + if(MACRO_OBJS) + message("Helping Xcode by removing objects [${MACRO_OBJS}]") + file(REMOVE ${MACRO_OBJS}) + endif(MACRO_OBJS) + endif(HELP_XCODE) +endfunction(help_xcode_depends) + +if("${CMAKE_GENERATOR}" MATCHES "Ninja") + set(HELP_NINJA 1) # TODO Why is this needed? +endif() + +# The Intel compiler causes the MSVC linker to crash during +# incremental linking, so avoid the /INCREMENTAL:YES flag. +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}") + +list(APPEND _cmake_options "-DCMAKE_FORCE_DEPFILES=1") + +file(MAKE_DIRECTORY ${BuildDepends_BINARY_DIR}/Project) +message("Creating Project/foo.cxx") +write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx + "const char* foo() { return \"foo\";}" ) + +file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot.hxx.in + "static const char* zot = \"zot\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_custom.hxx.in + "static const char* zot_custom = \"zot_custom\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx + "static const char* zot_macro_dir = \"zot_macro_dir\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx + "static const char* zot_macro_tgt = \"zot_macro_tgt\";\n") + +help_xcode_depends() + +message("Building project first time") +try_compile(RESULT + ${BuildDepends_BINARY_DIR}/Project + ${BuildDepends_SOURCE_DIR}/Project + testRebuild + CMAKE_FLAGS ${_cmake_options} + OUTPUT_VARIABLE OUTPUT) +if(HELP_XCODE) + try_compile(RESULT + ${BuildDepends_BINARY_DIR}/Project + ${BuildDepends_SOURCE_DIR}/Project + testRebuild + OUTPUT_VARIABLE OUTPUT) + try_compile(RESULT + ${BuildDepends_BINARY_DIR}/Project + ${BuildDepends_SOURCE_DIR}/Project + testRebuild + OUTPUT_VARIABLE OUTPUT) +endif(HELP_XCODE) + +message("Output from first build:\n${OUTPUT}") +if(NOT RESULT) + message(SEND_ERROR "Could not build test project (1)!") +endif(NOT RESULT) + +set(bar ${BuildDepends_BINARY_DIR}/Project/bar${CMAKE_EXECUTABLE_SUFFIX}) +if(EXISTS + "${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}" ) + message("found debug") + set(bar + "${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}") +endif(EXISTS + "${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}") +set(zot ${BuildDepends_BINARY_DIR}/Project/zot${CMAKE_EXECUTABLE_SUFFIX}) +if(EXISTS + "${BuildDepends_BINARY_DIR}/Project/Debug/zot${CMAKE_EXECUTABLE_SUFFIX}" ) + message("found debug") + set(zot + "${BuildDepends_BINARY_DIR}/Project/Debug/zot${CMAKE_EXECUTABLE_SUFFIX}") +endif(EXISTS + "${BuildDepends_BINARY_DIR}/Project/Debug/zot${CMAKE_EXECUTABLE_SUFFIX}") + +message("Running ${bar} ") +execute_process(COMMAND ${bar} OUTPUT_VARIABLE out RESULT_VARIABLE runResult) +string(REGEX REPLACE "[\r\n]" " " out "${out}") +message("Run result: ${runResult} Output: \"${out}\"") + +if("${out}" STREQUAL "foo ") + message("Worked!") +else("${out}" STREQUAL "foo ") + message(SEND_ERROR "Project did not initially build properly: ${out}") +endif("${out}" STREQUAL "foo ") + +message("Running ${zot} ") +execute_process(COMMAND ${zot} OUTPUT_VARIABLE out RESULT_VARIABLE runResult) +string(REGEX REPLACE "[\r\n]" " " out "${out}") +message("Run result: ${runResult} Output: \"${out}\"") + +set(VALUE_UNCHANGED "[zot] [zot_custom] [zot_macro_dir] [zot_macro_tgt] ") +if("${out}" STREQUAL "${VALUE_UNCHANGED}") + message("Worked!") +else("${out}" STREQUAL "${VALUE_UNCHANGED}") + message(SEND_ERROR "Project did not initially build properly: ${out}") +endif("${out}" STREQUAL "${VALUE_UNCHANGED}") + +message("Waiting 3 seconds...") +# any additional argument will cause ${bar} to wait forever +execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out) + +message("Modifying Project/foo.cxx") +write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx + "const char* foo() { return \"foo changed\";}" ) +file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot.hxx.in + "static const char* zot = \"zot changed\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_custom.hxx.in + "static const char* zot_custom = \"zot_custom changed\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx + "static const char* zot_macro_dir = \"zot_macro_dir changed\";\n") +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") +try_compile(RESULT + ${BuildDepends_BINARY_DIR}/Project + ${BuildDepends_SOURCE_DIR}/Project + testRebuild + CMAKE_FLAGS ${_cmake_options} + OUTPUT_VARIABLE OUTPUT) + +# Xcode is in serious need of help here +if(HELP_XCODE OR HELP_NINJA) + try_compile(RESULT + ${BuildDepends_BINARY_DIR}/Project + ${BuildDepends_SOURCE_DIR}/Project + testRebuild + OUTPUT_VARIABLE OUTPUT) + try_compile(RESULT + ${BuildDepends_BINARY_DIR}/Project + ${BuildDepends_SOURCE_DIR}/Project + testRebuild + OUTPUT_VARIABLE OUTPUT) +endif() + +message("Output from second build:\n${OUTPUT}") +if(NOT RESULT) + message(SEND_ERROR "Could not build test project (2)!") +endif(NOT RESULT) +if(EXISTS + "${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}" ) + message("found debug") +endif(EXISTS + "${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}") +if(EXISTS + "${BuildDepends_BINARY_DIR}/Project/Debug/zot${CMAKE_EXECUTABLE_SUFFIX}" ) + message("found debug") +endif(EXISTS + "${BuildDepends_BINARY_DIR}/Project/Debug/zot${CMAKE_EXECUTABLE_SUFFIX}") + +message("Running ${bar} ") +execute_process(COMMAND ${bar} OUTPUT_VARIABLE out RESULT_VARIABLE runResult) +string(REGEX REPLACE "[\r\n]" " " out "${out}") +message("Run result: ${runResult} Output: \"${out}\"") + +if("${out}" STREQUAL "foo changed ") + message("Worked!") +else("${out}" STREQUAL "foo changed ") + message(SEND_ERROR "Project did not rebuild properly!") +endif("${out}" STREQUAL "foo changed ") + +message("Running ${zot} ") +execute_process(COMMAND ${zot} OUTPUT_VARIABLE out RESULT_VARIABLE runResult) +string(REGEX REPLACE "[\r\n]" " " out "${out}") +message("Run result: ${runResult} Output: \"${out}\"") + +set(VALUE_CHANGED + "[zot changed] [zot_custom changed] [zot_macro_dir changed] [zot_macro_tgt changed] " + ) +if("${out}" STREQUAL "${VALUE_CHANGED}") + message("Worked!") +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 new file mode 100644 index 000000000..ed8b8bf5d --- /dev/null +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -0,0 +1,109 @@ +cmake_minimum_required(VERSION 2.6) +project(testRebuild) + +function(test_for_xcode4 result_var) + set(${result_var} 0 PARENT_SCOPE) + if(APPLE) + execute_process(COMMAND xcodebuild -version + OUTPUT_VARIABLE ov RESULT_VARIABLE rv + ) + if("${rv}" STREQUAL "0") + if(ov MATCHES "^Xcode 4.[0-9].*$") + set(${result_var} 1 PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + +if(APPLE) + # only use multi-arch if the sysroot exists on this machine + # Ninja needs -M which could not be used with multiple -arch flags + if(EXISTS "${CMAKE_OSX_SYSROOT}" AND NOT "${CMAKE_GENERATOR}" MATCHES "Ninja") + set(CMAKE_OSX_ARCHITECTURES "ppc;i386") + test_for_xcode4(is_xcode4) + if(is_xcode4) + # Xcode 4, use modern architectures as defaults + # Arch 'ppc' no longer works: tools no longer available starting with Xcode 4 + set(CMAKE_OSX_ARCHITECTURES i386 x86_64) + endif() + endif() +endif(APPLE) + +add_library(foo STATIC ${testRebuild_BINARY_DIR}/foo.cxx) +set_target_properties(foo PROPERTIES OUTPUT_NAME "foolib") +# Add a generated header that regenerates when the generator is +# rebuilt. +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/regen.h + COMMAND generator ${CMAKE_CURRENT_BINARY_DIR}/regen.h regen + DEPENDS generator # adds file-level dependency to re-run rule + ) + +# Add a generated header that does NOT regenerate when the generator +# is rebuilt. +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/noregen.h + COMMAND generator ${CMAKE_CURRENT_BINARY_DIR}/noregen.h noregen + ) + +# Test that the generator rebuilds when the static library source file +# changes. This should cause regen.h to be recreated also. +add_executable(generator generator.cxx) +target_link_libraries(generator foo) +set_target_properties(generator PROPERTIES OUTPUT_NAME "gen") + +# Build an executable to drive the build and rebuild. +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +add_executable(bar bar.cxx + ${CMAKE_CURRENT_BINARY_DIR}/regen.h + ${CMAKE_CURRENT_BINARY_DIR}/noregen.h + ) + +#----------------------------------------------------------------------------- +IF("${CMAKE_GENERATOR}" MATCHES "Make") + # Test the IMPLICIT_DEPENDS feature. + SET(ZOT_DEPENDS IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/dep.cxx) + SET(ZOT_CUSTOM_DEP + IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/dep_custom.cxx) +ELSE("${CMAKE_GENERATOR}" MATCHES "Make") + # No IMPLICIT_DEPENDS...just depend directly. + SET(ZOT_DEPENDS DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/zot.hxx.in) + SET(ZOT_CUSTOM_DEP DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/zot_custom.hxx.in) +ENDIF("${CMAKE_GENERATOR}" MATCHES "Make") +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zot.hxx + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/zot.hxx.in + ${CMAKE_CURRENT_BINARY_DIR}/zot.hxx + ${ZOT_DEPENDS} + ) + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zot_custom.hxx + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/zot_custom.hxx.in + ${CMAKE_CURRENT_BINARY_DIR}/zot_custom.hxx + ${ZOT_CUSTOM_DEP} + ) +add_custom_target(zot_custom ALL DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/zot_custom.hxx) + +add_executable(zot zot.cxx ${CMAKE_CURRENT_BINARY_DIR}/zot.hxx + zot_macro_dir.cxx zot_macro_tgt.cxx) +add_dependencies(zot zot_custom) + +# Test the #include line macro transformation rule support. +set_property( + TARGET zot + PROPERTY IMPLICIT_DEPENDS_INCLUDE_TRANSFORM "ZOT_TGT(%)=<zot_%_tgt.hxx>" + ) + +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/bar.cxx b/Tests/BuildDepends/Project/bar.cxx new file mode 100644 index 000000000..25d8bd21b --- /dev/null +++ b/Tests/BuildDepends/Project/bar.cxx @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <string.h> +#include <regen.h> +#include <noregen.h> + +int main(int argc, char** argv) +{ + /* Make sure the noregen header was not regenerated. */ + if(strcmp("foo", noregen_string) != 0) + { + printf("FAILED: noregen.h was regenerated!\n"); + return 1; + } + + /* Print out the string that should have been regenerated. */ + printf("%s\n", regen_string); + fflush(stdout); + // if any argument is used, wait forever + if (argc>1) + { + // wait that we get killed... + for(;;); + } + return 0; +} diff --git a/Tests/BuildDepends/Project/dep.cxx b/Tests/BuildDepends/Project/dep.cxx new file mode 100644 index 000000000..6cfebe37c --- /dev/null +++ b/Tests/BuildDepends/Project/dep.cxx @@ -0,0 +1 @@ +#include <zot.hxx.in> diff --git a/Tests/BuildDepends/Project/dep_custom.cxx b/Tests/BuildDepends/Project/dep_custom.cxx new file mode 100644 index 000000000..b6ac54847 --- /dev/null +++ b/Tests/BuildDepends/Project/dep_custom.cxx @@ -0,0 +1 @@ +#include <zot_custom.hxx.in> diff --git a/Tests/BuildDepends/Project/generator.cxx b/Tests/BuildDepends/Project/generator.cxx new file mode 100644 index 000000000..92a122de8 --- /dev/null +++ b/Tests/BuildDepends/Project/generator.cxx @@ -0,0 +1,24 @@ +#include <stdio.h> + +extern const char* foo(); + +int main(int argc, const char* argv[]) +{ + if(argc < 3) + { + fprintf(stderr, "Must specify output file and symbol prefix!"); + return 1; + } + if(FILE* fout = fopen(argv[1], "w")) + { + fprintf(fout, "static const char* %s_string = \"%s\";\n", argv[2], + foo()); + fclose(fout); + } + else + { + fprintf(stderr, "Could not open output file \"%s\"", argv[1]); + return 1; + } + return 0; +} diff --git a/Tests/BuildDepends/Project/linkdep.cxx b/Tests/BuildDepends/Project/linkdep.cxx new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/BuildDepends/Project/linkdep.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/BuildDepends/Project/zot.cxx b/Tests/BuildDepends/Project/zot.cxx new file mode 100644 index 000000000..775fd3b43 --- /dev/null +++ b/Tests/BuildDepends/Project/zot.cxx @@ -0,0 +1,14 @@ +#include <zot.hxx> +#include <zot_custom.hxx> +#include <stdio.h> + +const char* zot_macro_dir_f(); +const char* zot_macro_tgt_f(); + +int main() +{ + printf("[%s] [%s] [%s] [%s]\n", zot, zot_custom, + zot_macro_dir_f(), zot_macro_tgt_f()); + fflush(stdout); + return 0; +} diff --git a/Tests/BuildDepends/Project/zot_macro_dir.cxx b/Tests/BuildDepends/Project/zot_macro_dir.cxx new file mode 100644 index 000000000..733a4b37f --- /dev/null +++ b/Tests/BuildDepends/Project/zot_macro_dir.cxx @@ -0,0 +1,7 @@ +#define ZOT_DIR(x) <zot_##x##_dir.hxx> +#include ZOT_DIR(macro) + +const char* zot_macro_dir_f() +{ + return zot_macro_dir; +} diff --git a/Tests/BuildDepends/Project/zot_macro_tgt.cxx b/Tests/BuildDepends/Project/zot_macro_tgt.cxx new file mode 100644 index 000000000..182ee16fd --- /dev/null +++ b/Tests/BuildDepends/Project/zot_macro_tgt.cxx @@ -0,0 +1,7 @@ +#define ZOT_TGT(x) <zot_##x##_tgt.hxx> +#include ZOT_TGT(macro) + +const char* zot_macro_tgt_f() +{ + return zot_macro_tgt; +} diff --git a/Tests/BundleGeneratorTest/BundleIcon.icns b/Tests/BundleGeneratorTest/BundleIcon.icns Binary files differnew file mode 100644 index 000000000..8808dd62d --- /dev/null +++ b/Tests/BundleGeneratorTest/BundleIcon.icns diff --git a/Tests/BundleGeneratorTest/CMakeLists.txt b/Tests/BundleGeneratorTest/CMakeLists.txt new file mode 100644 index 000000000..e1fc2c1d4 --- /dev/null +++ b/Tests/BundleGeneratorTest/CMakeLists.txt @@ -0,0 +1,33 @@ +PROJECT(BundleGeneratorTest) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.7) + +# Build a shared library and install it in lib/ +ADD_LIBRARY(Library SHARED Library.cxx) +INSTALL(TARGETS Library DESTINATION lib) + +# Build an executable and install it in bin/ +ADD_EXECUTABLE(Executable Executable.cxx) +TARGET_LINK_LIBRARIES(Executable Library) +INSTALL(TARGETS Executable DESTINATION bin) + +# Use the bundle-generator for packaging ... +SET(CPACK_GENERATOR "Bundle") +SET(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/BundleIcon.icns") +SET(CPACK_BUNDLE_NAME "BundleGeneratorTest") +SET(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist") +SET(CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/StartupCommand") +SET(CPACK_PACKAGE_DESCRIPTION "Project for testing OSX bundle generation") + +# The custom volume icon is a copy of the normal Mac OSX volume icon, but +# on a white background. This is to differentiate it from the normal one +# so that you can verify that the custom icon is being used by doing a +# visual inspection of the mounted volume... This was added when fixing +# issue #7523... +# +SET(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/CustomVolumeIcon.icns") + +SET(CPACK_PACKAGE_NAME "BundleGeneratorTest") +SET(CPACK_PACKAGE_VERSION "0.1") + +INCLUDE(CPack) diff --git a/Tests/BundleGeneratorTest/CustomVolumeIcon.icns b/Tests/BundleGeneratorTest/CustomVolumeIcon.icns Binary files differnew file mode 100644 index 000000000..3862a5191 --- /dev/null +++ b/Tests/BundleGeneratorTest/CustomVolumeIcon.icns diff --git a/Tests/BundleGeneratorTest/Executable.cxx b/Tests/BundleGeneratorTest/Executable.cxx new file mode 100644 index 000000000..8107f783a --- /dev/null +++ b/Tests/BundleGeneratorTest/Executable.cxx @@ -0,0 +1,8 @@ +extern void print_message(const char* const Message); + +int main(int argc, char* argv[]) +{ + print_message("Howdy, World!\n"); + return 0; +} + diff --git a/Tests/BundleGeneratorTest/Info.plist b/Tests/BundleGeneratorTest/Info.plist new file mode 100644 index 000000000..e5a7d0047 --- /dev/null +++ b/Tests/BundleGeneratorTest/Info.plist @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> + <dict> + <key>CFBundleExecutable</key> + <string>BundleGeneratorTest</string> + <key>CFBundleIconFile</key> + <string>BundleGeneratorTest.icns</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + </dict> +</plist> diff --git a/Tests/BundleGeneratorTest/Library.cxx b/Tests/BundleGeneratorTest/Library.cxx new file mode 100644 index 000000000..1403c6824 --- /dev/null +++ b/Tests/BundleGeneratorTest/Library.cxx @@ -0,0 +1,7 @@ +#include <iostream> + +void print_message(const char* const Message) +{ + std::cout << Message; +} + diff --git a/Tests/BundleGeneratorTest/StartupCommand b/Tests/BundleGeneratorTest/StartupCommand new file mode 100755 index 000000000..5bc5ad237 --- /dev/null +++ b/Tests/BundleGeneratorTest/StartupCommand @@ -0,0 +1,12 @@ +#!/bin/sh + +BUNDLE="`echo "$0" | sed -e 's/\/Contents\/MacOS\/.*//'`" +RESOURCES="$BUNDLE/Contents/Resources" + +echo "BUNDLE: $BUNDLE" +echo "RESOURCES: $RESOURCES" + +export DYLD_LIBRARY_PATH=$RESOURCES/lib + +exec "$RESOURCES/bin/Executable" + diff --git a/Tests/BundleTest/BundleLib.cxx b/Tests/BundleTest/BundleLib.cxx new file mode 100644 index 000000000..b68ee25dd --- /dev/null +++ b/Tests/BundleTest/BundleLib.cxx @@ -0,0 +1,70 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> + +#include <CoreFoundation/CoreFoundation.h> + +int fileExists(char* filename) +{ +#ifndef R_OK +# define R_OK 04 +#endif + if ( access(filename, R_OK) != 0 ) + { + printf("Cannot find file: %s\n", filename); + return 0; + } + return 1; +} + +int findBundleFile(char* exec, const char* file) +{ + int res; + char* nexec = strdup(exec); + char* fpath = (char*)malloc(strlen(exec) + 100); + int cc; + int cnt = 0; + printf("Process executable name: %s\n", exec); + + // Remove the executable name and directory name + for ( cc = strlen(nexec)-1; cc > 0; cc -- ) + { + if ( nexec[cc] == '/' ) + { + nexec[cc] = 0; + if ( cnt == 1 ) + { + break; + } + cnt ++; + } + } + printf("Process executable path: %s\n", nexec); + sprintf(fpath, "%s/%s", nexec, file); + printf("Check for file: %s\n", fpath); + res = fileExists(fpath); + free(nexec); + free(fpath); + return res; +} + +int foo(char *exec) +{ + // Call a CoreFoundation function... + // + CFBundleRef br = CFBundleGetMainBundle(); + (void) br; + + int res1 = findBundleFile(exec, "Resources/randomResourceFile.plist"); + int res2 = findBundleFile(exec, "MacOS/SomeRandomFile.txt"); + int res3 = findBundleFile(exec, "MacOS/ChangeLog.txt"); + if ( !res1 || + !res2 || + !res3 ) + { + return 1; + } + + return 0; +} diff --git a/Tests/BundleTest/BundleSubDir/CMakeLists.txt b/Tests/BundleTest/BundleSubDir/CMakeLists.txt new file mode 100644 index 000000000..322b2a7d2 --- /dev/null +++ b/Tests/BundleTest/BundleSubDir/CMakeLists.txt @@ -0,0 +1,36 @@ +ADD_CUSTOM_COMMAND( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist" + COMMAND /bin/cp + ARGS "${BundleTest_SOURCE_DIR}/randomResourceFile.plist.in" + "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist") + +SET_SOURCE_FILES_PROPERTIES( + "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist" + PROPERTIES + MACOSX_PACKAGE_LOCATION Resources + ) + +SET_SOURCE_FILES_PROPERTIES( + "${BundleTest_SOURCE_DIR}/SomeRandomFile.txt" + "${BundleTest_SOURCE_DIR}/../../ChangeLog.txt" + PROPERTIES + MACOSX_PACKAGE_LOCATION MacOS + ) + +ADD_EXECUTABLE(SecondBundle + MACOSX_BUNDLE + "${BundleTest_SOURCE_DIR}/BundleTest.cxx" + "${BundleTest_SOURCE_DIR}/SomeRandomFile.txt" + "${BundleTest_SOURCE_DIR}/../../ChangeLog.txt" + "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist" + ) +TARGET_LINK_LIBRARIES(SecondBundle BundleTestLib) + +# Test bundle installation. +INSTALL(TARGETS SecondBundle DESTINATION Applications) + +# Test whether bundles respect the output name. Since the library is +# installed into a location that uses this output name this will fail if the +# bundle does not respect the name. Also the executable will not be found by +# the test driver if this does not work. +SET_TARGET_PROPERTIES(SecondBundle PROPERTIES OUTPUT_NAME SecondBundleExe) diff --git a/Tests/BundleTest/BundleTest.cxx b/Tests/BundleTest/BundleTest.cxx new file mode 100644 index 000000000..a66d601d3 --- /dev/null +++ b/Tests/BundleTest/BundleTest.cxx @@ -0,0 +1,20 @@ +#include <stdio.h> + +#include <CoreFoundation/CoreFoundation.h> + +extern int foo(char* exec); + +int main(int argc, char* argv[]) +{ + printf("Started with: %d arguments\n", argc); + + // Call a CoreFoundation function... but pull in the link dependency on "-framework + // CoreFoundation" via CMake's dependency chaining mechanism. This code exists to + // verify that the chaining mechanism works with "-framework blah" style + // link dependencies. + // + CFBundleRef br = CFBundleGetMainBundle(); + (void) br; + + return foo(argv[0]); +} diff --git a/Tests/BundleTest/CMakeLists.txt b/Tests/BundleTest/CMakeLists.txt new file mode 100644 index 000000000..5342f49bd --- /dev/null +++ b/Tests/BundleTest/CMakeLists.txt @@ -0,0 +1,104 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(BundleTest) +SET(MACOSX_BUNDLE_INFO_STRING "bundle_info_string") +SET(CMAKE_MacOSX_Content_COMPILE_OBJECT "\"${CMAKE_COMMAND}\" -E copy_if_different <SOURCE> <OBJECT>") + +ADD_CUSTOM_COMMAND( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist" + COMMAND /bin/cp + ARGS "${CMAKE_CURRENT_SOURCE_DIR}/randomResourceFile.plist.in" + "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist") + +SET_SOURCE_FILES_PROPERTIES( + "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist" + PROPERTIES + MACOSX_PACKAGE_LOCATION Resources + ) + +SET_SOURCE_FILES_PROPERTIES( + SomeRandomFile.txt + "${BundleTest_SOURCE_DIR}/../../ChangeLog.txt" + PROPERTIES + MACOSX_PACKAGE_LOCATION MacOS + ) + +SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/foobar") + +# Test building a bundle linking to a shared library where the +# shared library links to CoreFoundation, but the executable does not +# explicitly link to CoreFoundation, but the executable does *depend* +# on CoreFoundation. There should be a link failure for the executable +# if CMake's dependency chaining for libraries with "-framework +# blah" style dependencies gets broken... +# +ADD_LIBRARY(BundleTestLib SHARED BundleLib.cxx) +TARGET_LINK_LIBRARIES(BundleTestLib "-framework CoreFoundation") + +ADD_EXECUTABLE(BundleTest + MACOSX_BUNDLE + BundleTest.cxx + SomeRandomFile.txt + "${BundleTest_SOURCE_DIR}/../../ChangeLog.txt" + "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist" + ) +TARGET_LINK_LIBRARIES(BundleTest BundleTestLib) +# +# DO NOT: TARGET_LINK_LIBRARIES(BundleTest "-framework CoreFoundation") +# (see above comments about CoreFoundation) +# + +# Test bundle installation. +#INSTALL(TARGETS BundleTestLib DESTINATION Applications/BundleTestExe.app/Contents/Plugins) +INSTALL(TARGETS BundleTestLib DESTINATION Applications/SecondBundleExe.app/Contents/Plugins) +INSTALL(TARGETS BundleTest DESTINATION Applications) + +# Test whether bundles respect the output name. Since the library is +# installed into a location that uses this output name this will fail if the +# bundle does not respect the name. Also the executable will not be found by +# the test driver if this does not work. +SET_TARGET_PROPERTIES(BundleTest PROPERTIES OUTPUT_NAME BundleTestExe) + +# Test executable versioning if it is supported. +IF(NOT XCODE) + SET_TARGET_PROPERTIES(BundleTest PROPERTIES VERSION 1) +ENDIF(NOT XCODE) + +# Make sure the executable can find its installed library. +SET_TARGET_PROPERTIES(BundleTestLib PROPERTIES + INSTALL_NAME_DIR "@executable_path/../Plugins") + +INCLUDE(CPack) + +# test the framework find stuff +IF(EXISTS /usr/lib/libtcl.dylib + AND EXISTS /System/Library/Frameworks/Tcl.framework) + SET(TCL NOTFOUND) + FIND_LIBRARY(TCL tcl) + MESSAGE("frame: ${TCL}") + IF(NOT "${TCL}" MATCHES .framework) + MESSAGE(FATAL_ERROR "Could not find tcl framework, found ${TCL}") + ENDIF(NOT "${TCL}" MATCHES .framework) + SET(TCL NOTFOUND) + SET(CMAKE_FIND_FRAMEWORK LAST) + FIND_LIBRARY(TCL tcl) + IF("${TCL}" MATCHES .framework) + MESSAGE(FATAL_ERROR "Found framework and should have found dylib ${TCL}") + ENDIF("${TCL}" MATCHES .framework) + SET(TCL NOTFOUND) + SET(CMAKE_FIND_FRAMEWORK NEVER) + FIND_LIBRARY(TCL tcl) + IF("${TCL}" MATCHES .framework) + MESSAGE(FATAL_ERROR "Found framework and should have found dylib ${TCL}") + ENDIF("${TCL}" MATCHES .framework) + MESSAGE("not frame: ${TCL}") + SET(TCL NOTFOUND) + SET(CMAKE_FIND_FRAMEWORK FIRST) + FIND_LIBRARY(TCL tcl) + IF(NOT "${TCL}" MATCHES .framework) + MESSAGE(FATAL_ERROR "Could not find tcl framework, found ${TCL}") + ENDIF(NOT "${TCL}" MATCHES .framework) + MESSAGE("frame: ${TCL}") +ENDIF(EXISTS /usr/lib/libtcl.dylib + AND EXISTS /System/Library/Frameworks/Tcl.framework) + +SUBDIRS(BundleSubDir) diff --git a/Tests/BundleTest/SomeRandomFile.txt b/Tests/BundleTest/SomeRandomFile.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/BundleTest/SomeRandomFile.txt diff --git a/Tests/BundleTest/randomResourceFile.plist.in b/Tests/BundleTest/randomResourceFile.plist.in new file mode 100644 index 000000000..cfe3222b6 --- /dev/null +++ b/Tests/BundleTest/randomResourceFile.plist.in @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>Package</key> + <string>CMake</string> +</dict> +</plist> + diff --git a/Tests/BundleUtilities/CMakeLists.txt b/Tests/BundleUtilities/CMakeLists.txt new file mode 100644 index 000000000..8f24afe9a --- /dev/null +++ b/Tests/BundleUtilities/CMakeLists.txt @@ -0,0 +1,133 @@ +cmake_minimum_required(VERSION 2.8) +project(BundleUtilities) + +###### the various types of dependencies we can have + +# a shared library +add_library(shared SHARED shared.cpp shared.h) + +# another shared library +add_library(shared2 SHARED shared2.cpp shared2.h) + + +# a framework library +add_library(framework SHARED framework.cpp framework.h) +# TODO: fix problems with local frameworks without rpaths +#set_target_properties(framework PROPERTIES FRAMEWORK 1) + +# make sure rpaths are not helping BundleUtilities or the executables +set_target_properties(shared shared2 framework PROPERTIES + SKIP_BUILD_RPATH 1) + + +###### test a Bundle application using dependencies + +# a loadable module (depends on shared2) +# testbundleutils1 will load this at runtime +add_library(module1 MODULE module.cpp module.h) +set_target_properties(module1 PROPERTIES PREFIX "") +get_target_property(module_loc module1 LOCATION) +target_link_libraries(module1 shared2) + +# a bundle application +add_executable(testbundleutils1 MACOSX_BUNDLE testbundleutils1.cpp) +target_link_libraries(testbundleutils1 shared framework ${CMAKE_DL_LIBS}) +get_target_property(loc testbundleutils1 LOCATION) + +set_target_properties(testbundleutils1 module1 PROPERTIES + INSTALL_RPATH "${CMAKE_CURRENT_BINARY_DIR}/testdir1" + BUILD_WITH_INSTALL_RPATH 1) + +# add custom target to install and test the app +add_custom_target(testbundleutils1_test ALL + COMMAND ${CMAKE_COMMAND} + "-DINPUT=${loc}" + "-DMODULE=${module_loc}" + "-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" + "-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir1" + -P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake" + DEPENDS testbundleutils1 module1 + ) + +add_dependencies(testbundleutils1_test testbundleutils1) + + + +###### test a non-Bundle application using dependencies + +# a loadable module (depends on shared2) +# testbundleutils2 will load this at runtime +add_library(module2 MODULE module.cpp module.h) +set_target_properties(module2 PROPERTIES PREFIX "") +get_target_property(module_loc module2 LOCATION) +target_link_libraries(module2 shared2) + +# a non-bundle application +add_executable(testbundleutils2 testbundleutils2.cpp) +target_link_libraries(testbundleutils2 shared framework ${CMAKE_DL_LIBS}) +get_target_property(loc testbundleutils2 LOCATION) + +set_target_properties(testbundleutils2 module2 PROPERTIES + INSTALL_RPATH "${CMAKE_CURRENT_BINARY_DIR}/testdir2" + BUILD_WITH_INSTALL_RPATH 1) + +# add custom target to install and test the app +add_custom_target(testbundleutils2_test ALL + COMMAND ${CMAKE_COMMAND} + "-DINPUT=${loc}" + "-DMODULE=${module_loc}" + "-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" + "-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir2" + -P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake" + DEPENDS testbundleutils1 module2 + ) +add_dependencies(testbundleutils2_test testbundleutils2) + + +if(APPLE AND NOT CMAKE_SYSTEM_VERSION VERSION_LESS 9.0) +###### Test a Bundle application using dependencies +###### and @rpaths on Mac OS X 10.5 or greater + + # a shared library + add_library(shared-3 SHARED shared.cpp shared.h) + + # another shared library + add_library(shared2-3 SHARED shared2.cpp shared2.h) + + # a framework library + add_library(framework-3 SHARED framework.cpp framework.h) + set_target_properties(framework-3 PROPERTIES FRAMEWORK 1) + + # build dependencies with @rpath install name + set_target_properties(shared-3 shared2-3 framework-3 PROPERTIES + INSTALL_NAME_DIR "@rpath" + BUILD_WITH_INSTALL_RPATH 1) + + # a loadable module (depends on shared2) + # testbundleutils1 will load this at runtime + add_library(module3 MODULE module.cpp module.h) + set_target_properties(module3 PROPERTIES PREFIX "" LINK_FLAGS "-Wl,-rpath,@loader_path/") + get_target_property(module_loc module3 LOCATION) + target_link_libraries(module3 shared2-3) + + # a non-bundle application + add_executable(testbundleutils3 testbundleutils3.cpp) + target_link_libraries(testbundleutils3 shared-3 framework-3 ${CMAKE_DL_LIBS}) + get_target_property(loc testbundleutils3 LOCATION) + + set_target_properties(testbundleutils3 module3 PROPERTIES + LINK_FLAGS "-Wl,-rpath,@loader_path/") + + # add custom target to install and test the app + add_custom_target(testbundleutils3_test ALL + COMMAND ${CMAKE_COMMAND} + "-DINPUT=${loc}" + "-DMODULE=${module_loc}" + "-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" + "-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir3" + -P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake" + DEPENDS testbundleutils3 module3 + ) + + add_dependencies(testbundleutils3_test testbundleutils3) +endif() diff --git a/Tests/BundleUtilities/bundleutils.cmake b/Tests/BundleUtilities/bundleutils.cmake new file mode 100644 index 000000000..46765e733 --- /dev/null +++ b/Tests/BundleUtilities/bundleutils.cmake @@ -0,0 +1,45 @@ + +# clean passed in arguments +get_filename_component(INPUT ${INPUT} ABSOLUTE) +get_filename_component(INPUTDIR ${INPUTDIR} ABSOLUTE) + +message("INPUT = ${INPUT}") +message("MODULE = ${MODULE}") +message("INPUTDIR = ${INPUTDIR}") +message("OUTPUTDIR = ${OUTPUTDIR}") + +# compute location to install/test things +file(RELATIVE_PATH relative_exe "${INPUTDIR}" "${INPUT}") +set(OUTPUT "${OUTPUTDIR}/${relative_exe}") +message("OUTPUT = ${OUTPUT}") +get_filename_component(EXE_DIR "${OUTPUT}" PATH) +get_filename_component(MODULE_NAME "${MODULE}" NAME) +set(OUTPUT_MODULE "${EXE_DIR}/${MODULE_NAME}") +message("OUTPUTMODULE = ${OUTPUT_MODULE}") + +# clean output dir +file(REMOVE_RECURSE "${OUTPUTDIR}") +# copy the app and plugin to installation/testing directory +configure_file("${INPUT}" "${OUTPUT}" COPYONLY) +configure_file("${MODULE}" "${OUTPUT_MODULE}" COPYONLY) + +# have BundleUtilities grab all dependencies and +# check that the app runs + +# for this test we'll override location to put all dependencies +# (in the same dir as the app) +# this shouldn't be necessary except for the non-bundle case on Mac +function(gp_item_default_embedded_path_override item path) + set(path "@executable_path" PARENT_SCOPE) +endfunction(gp_item_default_embedded_path_override) + +include(BundleUtilities) +fixup_bundle("${OUTPUT}" "${OUTPUT_MODULE}" "${INPUTDIR}") + +# make sure we can run the app +message("Executing ${OUTPUT} in ${EXE_DIR}") +execute_process(COMMAND "${OUTPUT}" RESULT_VARIABLE result OUTPUT_VARIABLE out ERROR_VARIABLE out WORKING_DIRECTORY "${EXE_DIR}") + +if(NOT result STREQUAL "0") + message(FATAL_ERROR " failed to execute test program\n${out}") +endif(NOT result STREQUAL "0") diff --git a/Tests/BundleUtilities/framework.cpp b/Tests/BundleUtilities/framework.cpp new file mode 100644 index 000000000..abda195ed --- /dev/null +++ b/Tests/BundleUtilities/framework.cpp @@ -0,0 +1,8 @@ + +#include "framework.h" +#include "stdio.h" + +void framework() +{ + printf("framework\n"); +} diff --git a/Tests/BundleUtilities/framework.h b/Tests/BundleUtilities/framework.h new file mode 100644 index 000000000..bdd10f05d --- /dev/null +++ b/Tests/BundleUtilities/framework.h @@ -0,0 +1,17 @@ + +#ifndef framework_h +#define framework_h + +#ifdef WIN32 +# ifdef framework_EXPORTS +# define FRAMEWORK_EXPORT __declspec(dllexport) +# else +# define FRAMEWORK_EXPORT __declspec(dllimport) +# endif +#else +# define FRAMEWORK_EXPORT +#endif + +void FRAMEWORK_EXPORT framework(); + +#endif diff --git a/Tests/BundleUtilities/module.cpp b/Tests/BundleUtilities/module.cpp new file mode 100644 index 000000000..ee1b542fb --- /dev/null +++ b/Tests/BundleUtilities/module.cpp @@ -0,0 +1,10 @@ + +#include "module.h" +#include "stdio.h" +#include "shared2.h" + +void module() +{ + printf("module\n"); + shared2(); +} diff --git a/Tests/BundleUtilities/module.h b/Tests/BundleUtilities/module.h new file mode 100644 index 000000000..0659bc742 --- /dev/null +++ b/Tests/BundleUtilities/module.h @@ -0,0 +1,7 @@ + +#ifndef module_h +#define module_h + +void module(); + +#endif diff --git a/Tests/BundleUtilities/shared.cpp b/Tests/BundleUtilities/shared.cpp new file mode 100644 index 000000000..e5e7dc5ae --- /dev/null +++ b/Tests/BundleUtilities/shared.cpp @@ -0,0 +1,8 @@ + +#include "shared.h" +#include "stdio.h" + +void shared() +{ + printf("shared\n"); +} diff --git a/Tests/BundleUtilities/shared.h b/Tests/BundleUtilities/shared.h new file mode 100644 index 000000000..3588fb88e --- /dev/null +++ b/Tests/BundleUtilities/shared.h @@ -0,0 +1,17 @@ + +#ifndef shared_h +#define shared_h + +#ifdef WIN32 +# ifdef shared_EXPORTS +# define SHARED_EXPORT __declspec(dllexport) +# else +# define SHARED_EXPORT __declspec(dllimport) +# endif +#else +# define SHARED_EXPORT +#endif + +void SHARED_EXPORT shared(); + +#endif diff --git a/Tests/BundleUtilities/shared2.cpp b/Tests/BundleUtilities/shared2.cpp new file mode 100644 index 000000000..84af5d061 --- /dev/null +++ b/Tests/BundleUtilities/shared2.cpp @@ -0,0 +1,8 @@ + +#include "shared2.h" +#include "stdio.h" + +void shared2() +{ + printf("shared2\n"); +} diff --git a/Tests/BundleUtilities/shared2.h b/Tests/BundleUtilities/shared2.h new file mode 100644 index 000000000..d53546cb0 --- /dev/null +++ b/Tests/BundleUtilities/shared2.h @@ -0,0 +1,17 @@ + +#ifndef shared2_h +#define shared2_h + +#ifdef WIN32 +# ifdef shared2_EXPORTS +# define SHARED2_EXPORT __declspec(dllexport) +# else +# define SHARED2_EXPORT __declspec(dllimport) +# endif +#else +# define SHARED2_EXPORT +#endif + +void SHARED2_EXPORT shared2(); + +#endif diff --git a/Tests/BundleUtilities/testbundleutils1.cpp b/Tests/BundleUtilities/testbundleutils1.cpp new file mode 100644 index 000000000..23d3cbd2e --- /dev/null +++ b/Tests/BundleUtilities/testbundleutils1.cpp @@ -0,0 +1,33 @@ + +#include "framework.h" +#include "shared.h" +#include "stdio.h" + +#if defined(WIN32) +#include <windows.h> +#else +#include "dlfcn.h" +#endif + +int main(int, char**) +{ + framework(); + shared(); + +#if defined(WIN32) + HANDLE lib = LoadLibraryA("module1.dll"); + if(!lib) + { + printf("Failed to open module1\n"); + } +#else + void* lib = dlopen("module1.so", RTLD_LAZY); + if(!lib) + { + printf("Failed to open module1\n%s\n", dlerror()); + } +#endif + + + return lib == 0 ? 1 : 0; +} diff --git a/Tests/BundleUtilities/testbundleutils2.cpp b/Tests/BundleUtilities/testbundleutils2.cpp new file mode 100644 index 000000000..319be8984 --- /dev/null +++ b/Tests/BundleUtilities/testbundleutils2.cpp @@ -0,0 +1,33 @@ + +#include "framework.h" +#include "shared.h" +#include "stdio.h" + +#if defined(WIN32) +#include <windows.h> +#else +#include "dlfcn.h" +#endif + +int main(int, char**) +{ + framework(); + shared(); + +#if defined(WIN32) + HANDLE lib = LoadLibraryA("module2.dll"); + if(!lib) + { + printf("Failed to open module2\n"); + } +#else + void* lib = dlopen("module2.so", RTLD_LAZY); + if(!lib) + { + printf("Failed to open module2\n%s\n", dlerror()); + } +#endif + + + return lib == 0 ? 1 : 0; +} diff --git a/Tests/BundleUtilities/testbundleutils3.cpp b/Tests/BundleUtilities/testbundleutils3.cpp new file mode 100644 index 000000000..9df13e988 --- /dev/null +++ b/Tests/BundleUtilities/testbundleutils3.cpp @@ -0,0 +1,33 @@ + +#include "framework.h" +#include "shared.h" +#include "stdio.h" + +#if defined(WIN32) +#include <windows.h> +#else +#include "dlfcn.h" +#endif + +int main(int, char**) +{ + framework(); + shared(); + +#if defined(WIN32) + HANDLE lib = LoadLibraryA("module3.dll"); + if(!lib) + { + printf("Failed to open module3\n"); + } +#else + void* lib = dlopen("module3.so", RTLD_LAZY); + if(!lib) + { + printf("Failed to open module3\n%s\n", dlerror()); + } +#endif + + + return lib == 0 ? 1 : 0; +} diff --git a/Tests/CFBundleTest/CMakeLists.txt b/Tests/CFBundleTest/CMakeLists.txt new file mode 100644 index 000000000..8fd9efdc6 --- /dev/null +++ b/Tests/CFBundleTest/CMakeLists.txt @@ -0,0 +1,56 @@ +#this is adapted from FireBreath (http://www.firebreath.org) + +cmake_minimum_required(VERSION 2.8) + +project(CFBundleTest) + +include(PluginConfig.cmake) + +message ("Creating Mac Browser Plugin project ${PROJECT_NAME}") +set(SOURCES + np_macmain.cpp + Localized.r + ${CMAKE_CURRENT_BINARY_DIR}/Info.plist + ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings + ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc +) + +add_library( ${PROJECT_NAME} MODULE + ${SOURCES} + ) + +set (RCFILES ${CMAKE_CURRENT_SOURCE_DIR}/Localized.r) + +configure_file(Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) +configure_file(InfoPlist.strings.in ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings) + +# Compile the resource file +find_program(RC_COMPILER Rez NO_DEFAULT_PATHS PATHS /Developer/Tools) +if(NOT RC_COMPILER) + message(FATAL_ERROR "could not find Rez to build resources from .r file...") +endif() + +execute_process(COMMAND + ${RC_COMPILER} ${RCFILES} -useDF -o ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc + ) + +set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc + PROPERTIES GENERATED 1 + ) +# note that for some reason, the makefile and xcode generators use a different +# property to indicate where the Info.plist file is :-/ For that reason, we +# specify it twice so it will work both places +set_target_properties(CFBundleTest PROPERTIES + BUNDLE 1 + BUNDLE_EXTENSION plugin + XCODE_ATTRIBUTE_WRAPPER_EXTENSION plugin #sets the extension to .plugin + XCODE_ATTRIBUTE_MACH_O_TYPE mh_bundle + XCODE_ATTRIBUTE_INFOPLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/Info.plist + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist + LINK_FLAGS "-Wl,-exported_symbols_list,\"${CMAKE_CURRENT_SOURCE_DIR}/ExportList_plugin.txt\"") + +set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings + ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc + PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/English.lproj") diff --git a/Tests/CFBundleTest/ExportList_plugin.txt b/Tests/CFBundleTest/ExportList_plugin.txt new file mode 100644 index 000000000..31d6f640d --- /dev/null +++ b/Tests/CFBundleTest/ExportList_plugin.txt @@ -0,0 +1,3 @@ +_NP_GetEntryPoints +_NP_Initialize +_NP_Shutdown diff --git a/Tests/CFBundleTest/Info.plist.in b/Tests/CFBundleTest/Info.plist.in new file mode 100644 index 000000000..638002f34 --- /dev/null +++ b/Tests/CFBundleTest/Info.plist.in @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>${PLUGIN_NAME}</string> + <key>CFBundleGetInfoString</key> + <string>${PLUGIN_NAME} ${FBSTRING_PLUGIN_VERSION}, ${FBSTRING_LegalCopyright}</string> + <key>CFBundleIdentifier</key> + <string>com.${ACTIVEX_PROGID}</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>BRPL</string> + <key>CFBundleShortVersionString</key> + <string>${PLUGIN_NAME} ${FBSTRING_PLUGIN_VERSION}</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>${FBSTRING_PLUGIN_VERSION}</string> + <key>CFPlugInDynamicRegisterFunction</key> + <string></string> + <key>CFPlugInDynamicRegistration</key> + <string>NO</string> + <key>CFPlugInFactories</key> + <dict> + <key>00000000-0000-0000-0000-000000000000</key> + <string>MyFactoryFunction</string> + </dict> + <key>CFPlugInTypes</key> + <dict> + <key>00000000-0000-0000-0000-000000000000</key> + <array> + <string>00000000-0000-0000-0000-000000000000</string> + </array> + </dict> + <key>CFPlugInUnloadFunction</key> + <string></string> + <key>WebPluginName</key> + <string>${FBSTRING_ProductName}</string> + <key>WebPluginDescription</key> + <string>${FBSTRING_FileDescription}</string> + <key>WebPluginMIMETypes</key> + <dict> + <key>${FBSTRING_MIMEType}</key> + <dict> + <key>WebPluginTypeDescription</key> + <string>${FBSTRING_FileDescription}</string> + </dict> + </dict> +</dict> +</plist> diff --git a/Tests/CFBundleTest/InfoPlist.strings.in b/Tests/CFBundleTest/InfoPlist.strings.in new file mode 100644 index 000000000..790ead05d --- /dev/null +++ b/Tests/CFBundleTest/InfoPlist.strings.in @@ -0,0 +1,4 @@ +/* Localized versions of Info.plist keys */ + +CFBundleName = "${PLUGIN_NAME}.plugin"; +NSHumanReadableCopyright = "${FBSTRING_LegalCopyright}"; diff --git a/Tests/CFBundleTest/Localized.r b/Tests/CFBundleTest/Localized.r new file mode 100644 index 000000000..e988e262c --- /dev/null +++ b/Tests/CFBundleTest/Localized.r @@ -0,0 +1,18 @@ +#include <CoreServices/CoreServices.r> + +resource 'STR#' (126) +{ { + "${FBSTRING_LegalCopyright}", + "${FBSTRING_ProductName}" +} }; + +resource 'STR#' (127) +{ { + "${FBSTRING_FileDescription}" +} }; + +resource 'STR#' (128) +{ { + "${FBSTRING_MIMEType}", + "${FBSTRING_FileExtents}" +} }; diff --git a/Tests/CFBundleTest/Localized.rsrc b/Tests/CFBundleTest/Localized.rsrc Binary files differnew file mode 100644 index 000000000..cbf35235b --- /dev/null +++ b/Tests/CFBundleTest/Localized.rsrc diff --git a/Tests/CFBundleTest/PluginConfig.cmake b/Tests/CFBundleTest/PluginConfig.cmake new file mode 100644 index 000000000..763ddcc1c --- /dev/null +++ b/Tests/CFBundleTest/PluginConfig.cmake @@ -0,0 +1,21 @@ +#/**********************************************************\ +# Auto-Generated Plugin Configuration file +# for CFTestPlugin +#\**********************************************************/ + +set(PLUGIN_NAME "CFTestPlugin") +set(PLUGIN_PREFIX "CFTP") +set(COMPANY_NAME "FBDevTeam") + +set(MOZILLA_PLUGINID "@firebreath.googlecode.com/CFTestPlugin") + +# strings +set(FBSTRING_CompanyName "Firebreath Dev Team") +set(FBSTRING_FileDescription "CFBundle Test Plugin - Plugin for testing cmake patch to improve FireBreath project generation") +set(FBSTRING_PLUGIN_VERSION "1.0.0") +set(FBSTRING_LegalCopyright "Copyright 2010 Firebreath Dev Team") +set(FBSTRING_PluginFileName "np${PLUGIN_NAME}.dll") +set(FBSTRING_ProductName "CFTestPlugin") +set(FBSTRING_FileExtents "") +set(FBSTRING_PluginName "CFTestPlugin") +set(FBSTRING_MIMEType "application/x-fbtestplugin") diff --git a/Tests/CFBundleTest/README.txt b/Tests/CFBundleTest/README.txt new file mode 100644 index 000000000..86c146333 --- /dev/null +++ b/Tests/CFBundleTest/README.txt @@ -0,0 +1,16 @@ + +CFBundle test project. The generated .plugin/ bundle from either makefiles or Xcode should look like this: + +./Contents +./Contents/Info.plist +./Contents/MacOS +./Contents/MacOS/CFBundleTest +./Contents/Resources +./Contents/Resources/English.lproj +./Contents/Resources/English.lproj/InfoPlist.strings +./Contents/Resources/English.lproj/Localized.rsrc + +file Contents/MacOS/CFBundleTest should return something like: +Contents/MacOS/CFBundleTest: Mach-O 64-bit bundle x86_64 + +It is okay if it is a 32 bit binary; if it is not Mach-O, or is spelled differently, it is not okay. diff --git a/Tests/CFBundleTest/VerifyResult.cmake b/Tests/CFBundleTest/VerifyResult.cmake new file mode 100644 index 000000000..e62290052 --- /dev/null +++ b/Tests/CFBundleTest/VerifyResult.cmake @@ -0,0 +1,32 @@ +if(NOT DEFINED CTEST_CONFIGURATION_TYPE) + message(FATAL_ERROR "expected variable CTEST_CONFIGURATION_TYPE not defined") +endif() + +if(NOT DEFINED dir) + message(FATAL_ERROR "expected variable dir not defined") +endif() + +if(NOT DEFINED gen) + message(FATAL_ERROR "expected variable gen not defined") +endif() + +message(STATUS "CTEST_CONFIGURATION_TYPE='${CTEST_CONFIGURATION_TYPE}'") +message(STATUS "dir='${dir}'") +message(STATUS "gen='${gen}'") + +if(gen MATCHES "Make" OR + "${CTEST_CONFIGURATION_TYPE}" STREQUAL "" OR + "${CTEST_CONFIGURATION_TYPE}" STREQUAL "." OR + "${CTEST_CONFIGURATION_TYPE}" STREQUAL "NoConfig") + set(expected_filename "${dir}/CFBundleTest.plugin/Contents/MacOS/CFBundleTest") +else() + set(expected_filename "${dir}/${CTEST_CONFIGURATION_TYPE}/CFBundleTest.plugin/Contents/MacOS/CFBundleTest") +endif() + +if(NOT EXISTS "${expected_filename}") + message(FATAL_ERROR "test fails: expected output file does not exist [${expected_filename}]") +endif() + +file(COPY "${expected_filename}" + DESTINATION "${dir}/LatestBuildResult" + ) diff --git a/Tests/CFBundleTest/np_macmain.cpp b/Tests/CFBundleTest/np_macmain.cpp new file mode 100644 index 000000000..78004d002 --- /dev/null +++ b/Tests/CFBundleTest/np_macmain.cpp @@ -0,0 +1,49 @@ +/***********************************************************\ + Written by: Richard Bateman (taxilian) + + Based on the default np_macmain.cpp from FireBreath + http://firebreath.googlecode.com + + This file has been stripped to prevent it from accidently + doing anything useful. +\***********************************************************/ + + +#include <stdio.h> + +typedef void (*NPP_ShutdownProcPtr)(void); +typedef short NPError; + +#pragma GCC visibility push(default) + +struct NPNetscapeFuncs; +struct NPPluginFuncs; + +extern "C" { + NPError NP_Initialize(NPNetscapeFuncs *browserFuncs); + NPError NP_GetEntryPoints(NPPluginFuncs *pluginFuncs); + NPError NP_Shutdown(void); +} + +#pragma GCC visibility pop + +void initPluginModule() +{ +} + +NPError NP_GetEntryPoints(NPPluginFuncs* pFuncs) +{ + printf("NP_GetEntryPoints()\n"); + return 0; +} + +NPError NP_Initialize(NPNetscapeFuncs* pFuncs) +{ + printf("NP_Initialize()\n"); + return 0; +} + +NPError NP_Shutdown() +{ + return 0; +} diff --git a/Tests/CMakeBuildTest.cmake.in b/Tests/CMakeBuildTest.cmake.in new file mode 100644 index 000000000..a8bb75090 --- /dev/null +++ b/Tests/CMakeBuildTest.cmake.in @@ -0,0 +1,59 @@ +# create the binary directory +make_directory("@CMAKE_BUILD_TEST_BINARY_DIR@") + +# remove the CMakeCache.txt file from the source dir +# if there is one, so that in-source cmake tests +# still pass +message("Remove: @CMAKE_BUILD_TEST_SOURCE_DIR@/CMakeCache.txt") +file(REMOVE "@CMAKE_BUILD_TEST_SOURCE_DIR@/CMakeCache.txt") + +# run cmake in the binary directory +message("running: ${CMAKE_COMMAND}") +execute_process(COMMAND "${CMAKE_COMMAND}" + "@CMAKE_BUILD_TEST_SOURCE_DIR@" + "-G@CMAKE_TEST_GENERATOR@" + WORKING_DIRECTORY "@CMAKE_BUILD_TEST_BINARY_DIR@" + RESULT_VARIABLE RESULT) +if(RESULT) + message(FATAL_ERROR "Error running cmake command") +endif(RESULT) + +# Now use the --build option to build the project +message("running: ${CMAKE_COMMAND} --build") +execute_process(COMMAND "${CMAKE_COMMAND}" + --build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug + RESULT_VARIABLE RESULT) +if(RESULT) + message(FATAL_ERROR "Error running cmake --build") +endif(RESULT) + +# check for configuration types +set(CMAKE_CONFIGURATION_TYPES @CMAKE_CONFIGURATION_TYPES@) +# run the executable out of the Debug directory if there +# are configuration types +if(CMAKE_CONFIGURATION_TYPES) + set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/Debug/@CMAKE_BUILD_TEST_EXE@") +else(CMAKE_CONFIGURATION_TYPES) + set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/@CMAKE_BUILD_TEST_EXE@") +endif(CMAKE_CONFIGURATION_TYPES) +# run the test results +message("running [${RUN_TEST}]") +execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT) +if(RESULT) + message(FATAL_ERROR "Error running test @CMAKE_BUILD_TEST_EXE@") +endif(RESULT) + +# build it again with clean and only @CMAKE_BUILD_TEST_EXE@ target +execute_process(COMMAND "${CMAKE_COMMAND}" + --build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug + --clean-first --target @CMAKE_BUILD_TEST_EXE@ + RESULT_VARIABLE RESULT) +if(RESULT) + message(FATAL_ERROR "Error running cmake --build") +endif(RESULT) + +# run it again after clean +execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT) +if(RESULT) + message(FATAL_ERROR "Error running test @CMAKE_BUILD_TEST_EXE@ after clean ") +endif(RESULT) diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt new file mode 100644 index 000000000..1faa88848 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -0,0 +1,58 @@ +cmake_minimum_required(VERSION 2.8) + +project(target_link_libraries) + +file(WRITE + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + "int main() { return 0; } +" +) + +add_executable( + target_link_libraries + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" +) + +macro(ASSERT_PROPERTY _target _property _value) + get_target_property(_out ${_target} ${_property}) + if (NOT _out) + set(_out "") + endif() + if (NOT "${_out}" STREQUAL "${_value}") + message(SEND_ERROR "Target ${_target} does not have property ${_property} with value ${_value}. Actual value: ${_out}") + endif() +endmacro() + +include(GenerateExportHeader) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_library(depA SHARED depA.cpp) +generate_export_header(depA) + +add_library(depB SHARED depB.cpp) +generate_export_header(depB) + +target_link_libraries(depB LINK_PRIVATE depA) + +add_library(depC SHARED depC.cpp) +generate_export_header(depC) + +target_link_libraries(depC LINK_PUBLIC depA) + +assert_property(depA LINK_INTERFACE_LIBRARIES "") +assert_property(depB LINK_INTERFACE_LIBRARIES "") +assert_property(depC LINK_INTERFACE_LIBRARIES "depA") + +add_executable(targetA targetA.cpp) + +target_link_libraries(targetA LINK_INTERFACE_LIBRARIES depA depB) + +assert_property(targetA LINK_INTERFACE_LIBRARIES "depA;depB") + +set_target_properties(targetA PROPERTIES LINK_INTERFACE_LIBRARIES "") + +assert_property(targetA LINK_INTERFACE_LIBRARIES "") + +target_link_libraries(targetA depB depC) + +assert_property(targetA LINK_INTERFACE_LIBRARIES "") diff --git a/Tests/CMakeCommands/target_link_libraries/depA.cpp b/Tests/CMakeCommands/target_link_libraries/depA.cpp new file mode 100644 index 000000000..c2e8e7b9a --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depA.cpp @@ -0,0 +1,7 @@ + +#include "depA.h" + +int DepA::foo() +{ + return 0; +} diff --git a/Tests/CMakeCommands/target_link_libraries/depA.h b/Tests/CMakeCommands/target_link_libraries/depA.h new file mode 100644 index 000000000..7a859488b --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depA.h @@ -0,0 +1,7 @@ + +#include "depa_export.h" + +struct DEPA_EXPORT DepA +{ + int foo(); +}; diff --git a/Tests/CMakeCommands/target_link_libraries/depB.cpp b/Tests/CMakeCommands/target_link_libraries/depB.cpp new file mode 100644 index 000000000..97e5be274 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depB.cpp @@ -0,0 +1,11 @@ + +#include "depB.h" + +#include "depA.h" + +int DepB::foo() +{ + DepA a; + + return 0; +} diff --git a/Tests/CMakeCommands/target_link_libraries/depB.h b/Tests/CMakeCommands/target_link_libraries/depB.h new file mode 100644 index 000000000..e617813ba --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depB.h @@ -0,0 +1,7 @@ + +#include "depb_export.h" + +struct DEPB_EXPORT DepB +{ + int foo(); +}; diff --git a/Tests/CMakeCommands/target_link_libraries/depC.cpp b/Tests/CMakeCommands/target_link_libraries/depC.cpp new file mode 100644 index 000000000..60bed592f --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depC.cpp @@ -0,0 +1,13 @@ + +#include "depC.h" + +int DepC::foo() +{ + return 0; +} + +DepA DepC::getA() +{ + DepA a; + return a; +} diff --git a/Tests/CMakeCommands/target_link_libraries/depC.h b/Tests/CMakeCommands/target_link_libraries/depC.h new file mode 100644 index 000000000..4d65c9eb3 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depC.h @@ -0,0 +1,12 @@ + +#include "depc_export.h" + +#include "depA.h" + +struct DEPC_EXPORT DepC +{ + int foo(); + + DepA getA(); + +}; diff --git a/Tests/CMakeCommands/target_link_libraries/targetA.cpp b/Tests/CMakeCommands/target_link_libraries/targetA.cpp new file mode 100644 index 000000000..3c6472e9a --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/targetA.cpp @@ -0,0 +1,12 @@ + +#include "depB.h" +#include "depC.h" + +int main(int argc, char **argv) +{ + DepA a; + DepB b; + DepC c; + + return a.foo() + b.foo() + c.foo(); +} diff --git a/Tests/CMakeInstall.cmake b/Tests/CMakeInstall.cmake new file mode 100644 index 000000000..5f814d91b --- /dev/null +++ b/Tests/CMakeInstall.cmake @@ -0,0 +1,51 @@ +# Define option CMake_TEST_INSTALL, and enable by default for dashboards. +set(_default 0) +if(DEFINED ENV{DASHBOARD_TEST_FROM_CTEST}) + set(_default 1) +endif() +option(CMake_TEST_INSTALL "Test CMake Installation" ${_default}) +mark_as_advanced(CMake_TEST_INSTALL) + +if(CMake_TEST_INSTALL) + # Do not build during the test. + set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1) + + # Install to a test directory. + set(CMake_TEST_INSTALL_PREFIX ${CMake_BINARY_DIR}/Tests/CMakeInstall) + set(CMAKE_INSTALL_PREFIX "${CMake_TEST_INSTALL_PREFIX}") + + if(CMAKE_CONFIGURATION_TYPES) + # There are multiple configurations. Make sure the tested + # configuration is the one that is installed. + set(CMake_TEST_INSTALL_CONFIG -C "\${CTEST_CONFIGURATION_TYPE}") + else() + set(CMake_TEST_INSTALL_CONFIG) + endif() + + # The CTest of the CMake used to build this CMake. + if(CMAKE_CTEST_COMMAND) + set(CMake_TEST_INSTALL_CTest ${CMAKE_CTEST_COMMAND}) + else() + set(CMake_TEST_INSTALL_CTest ${CMake_BIN_DIR}/ctest) + endif() + + # Add a test to install CMake through the build system install target. + add_test(CMake.Install + ${CMake_TEST_INSTALL_CTest} + ${CMake_TEST_INSTALL_CONFIG} + --build-and-test ${CMake_SOURCE_DIR} ${CMake_BINARY_DIR} + --build-generator ${CMAKE_GENERATOR} # Not CMAKE_TEST_GENERATOR + --build-project CMake + --build-makeprogram ${CMAKE_MAKE_PROGRAM} # Not CMAKE_TEST_MAKEPROGRAM + --build-nocmake + --build-noclean + --build-target install) + + # Avoid running this test simultaneously with other tests: + set_tests_properties(CMake.Install PROPERTIES RUN_SERIAL ON) + + # TODO: Make all other tests depend on this one, and then drive them + # with the installed CTest. +else() + set(CMake_TEST_INSTALL_PREFIX) +endif() diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt new file mode 100644 index 000000000..4e819f470 --- /dev/null +++ b/Tests/CMakeLib/CMakeLists.txt @@ -0,0 +1,39 @@ +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMake_BINARY_DIR}/Source + ${CMake_SOURCE_DIR}/Source + ) + +set(CMakeLib_TESTS + testGeneratedFileStream + testSystemTools + testUTF8 + testXMLParser + testXMLSafe + ) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testXMLParser.h.in + ${CMAKE_CURRENT_BINARY_DIR}/testXMLParser.h @ONLY) + +create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS}) +add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS}) +target_link_libraries(CMakeLibTests CMakeLib) + +# Xcode 2.x forgets to create the output directory before linking +# the individual architectures. +if(CMAKE_OSX_ARCHITECTURES AND XCODE + AND NOT "${XCODE_VERSION}" MATCHES "^[^12]") + add_custom_command( + TARGET CMakeLibTests + PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}" + ) +endif() + +foreach(test ${CMakeLib_TESTS}) + add_test(CMakeLib.${test} CMakeLibTests ${test}) +endforeach() + +if(TEST_CompileCommandOutput) + add_executable(runcompilecommands run_compile_commands.cxx) + target_link_libraries(runcompilecommands CMakeLib) +endif() diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx new file mode 100644 index 000000000..dc1ce24f7 --- /dev/null +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -0,0 +1,141 @@ +#include "cmSystemTools.h" + +class CompileCommandParser { +public: + class CommandType: public std::map<cmStdString, cmStdString> + { + public: + cmStdString const& at(cmStdString const& k) const + { + const_iterator i = this->find(k); + if(i != this->end()) { return i->second; } + static cmStdString emptyString; + return emptyString; + } + }; + typedef std::vector<CommandType> TranslationUnitsType; + + CompileCommandParser(std::ifstream *input) + { + this->Input = input; + } + + void Parse() + { + NextNonWhitespace(); + ParseTranslationUnits(); + } + + const TranslationUnitsType& GetTranslationUnits() + { + return this->TranslationUnits; + } + +private: + void ParseTranslationUnits() + { + this->TranslationUnits = TranslationUnitsType(); + ExpectOrDie('[', "at start of compile command file\n"); + do + { + ParseTranslationUnit(); + this->TranslationUnits.push_back(this->Command); + } while(Expect(',')); + ExpectOrDie(']', "at end of array"); + } + + void ParseTranslationUnit() + { + this->Command = CommandType(); + if(!Expect('{')) return; + if(Expect('}')) return; + do + { + ParseString(); + std::string name = this->String; + ExpectOrDie(':', "between name and value"); + ParseString(); + std::string value = this->String; + this->Command[name] = value; + } while(Expect(',')); + ExpectOrDie('}', "at end of object"); + } + + void ParseString() + { + this->String = ""; + if(!Expect('"')) return; + while (!Expect('"')) + { + Expect('\\'); + this->String.append(1,C); + Next(); + } + } + + bool Expect(char c) + { + if(this->C == c) + { + NextNonWhitespace(); + return true; + } + return false; + } + + void ExpectOrDie(char c, const std::string & message) + { + if (!Expect(c)) + ErrorExit(std::string("'") + c + "' expected " + message + "."); + } + + void NextNonWhitespace() + { + do { Next(); } while (IsWhitespace()); + } + + void Next() + { + this->C = char(Input->get()); + if (this->Input->bad()) ErrorExit("Unexpected end of file."); + } + + void ErrorExit(const std::string &message) { + std::cout << "ERROR: " << message; + exit(1); + } + + bool IsWhitespace() + { + return (this->C == ' ' || this->C == '\t' || + this->C == '\n' || this->C == '\r'); + } + + char C; + TranslationUnitsType TranslationUnits; + CommandType Command; + std::string String; + std::ifstream *Input; +}; + +int main () +{ + std::ifstream file("compile_commands.json"); + CompileCommandParser parser(&file); + parser.Parse(); + for(CompileCommandParser::TranslationUnitsType::const_iterator + it = parser.GetTranslationUnits().begin(), + end = parser.GetTranslationUnits().end(); it != end; ++it) + { + std::vector<cmStdString> command; + cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command); + if (!cmSystemTools::RunSingleCommand( + command, 0, 0, it->at("directory").c_str())) + { + std::cout << "ERROR: Failed to run command \"" + << command[0] << "\"" << std::endl; + exit(1); + } + } + return 0; +} diff --git a/Tests/CMakeLib/testGeneratedFileStream.cxx b/Tests/CMakeLib/testGeneratedFileStream.cxx new file mode 100644 index 000000000..f8ca4af94 --- /dev/null +++ b/Tests/CMakeLib/testGeneratedFileStream.cxx @@ -0,0 +1,100 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#include "cmGeneratedFileStream.h" +#include "cmSystemTools.h" + +#define cmFailed(m1, m2) \ + std::cout << "FAILED: " << m1 << m2 << "\n"; failed=1 + +int testGeneratedFileStream(int, char*[]) +{ + int failed = 0; + cmGeneratedFileStream gm; + std::string file1 = "generatedFile1"; + std::string file2 = "generatedFile2"; + std::string file3 = "generatedFile3"; + std::string file4 = "generatedFile4"; + std::string file1tmp = file1 + ".tmp"; + std::string file2tmp = file2 + ".tmp"; + std::string file3tmp = file3 + ".tmp"; + std::string file4tmp = file4 + ".tmp"; + gm.Open(file1.c_str()); + gm << "This is generated file 1"; + gm.Close(); + gm.Open(file2.c_str()); + gm << "This is generated file 2"; + gm.Close(); + gm.Open(file3.c_str()); + gm << "This is generated file 3"; + gm.Close(); + gm.Open(file4.c_str()); + gm << "This is generated file 4"; + gm.Close(); + if ( cmSystemTools::FileExists(file1.c_str()) ) + { + if ( cmSystemTools::FileExists(file2.c_str()) ) + { + if ( cmSystemTools::FileExists(file3.c_str()) ) + { + if ( cmSystemTools::FileExists(file4.c_str()) ) + { + if ( cmSystemTools::FileExists(file1tmp.c_str()) ) + { + cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file1tmp.c_str()); + } + else if ( cmSystemTools::FileExists(file2tmp.c_str()) ) + { + cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file2tmp.c_str()); + } + else if ( cmSystemTools::FileExists(file3tmp.c_str()) ) + { + cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file3tmp.c_str()); + } + else if ( cmSystemTools::FileExists(file4tmp.c_str()) ) + { + cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file4tmp.c_str()); + } + else + { + std::cout << "cmGeneratedFileStream works\n"; + } + } + else + { + cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file4.c_str()); + } + } + else + { + cmFailed("Something wrong with cmGeneratedFileStream. Found file: ", file3.c_str()); + } + } + else + { + cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file2.c_str()); + } + } + else + { + cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file1.c_str()); + } + cmSystemTools::RemoveFile(file1.c_str()); + cmSystemTools::RemoveFile(file2.c_str()); + cmSystemTools::RemoveFile(file3.c_str()); + cmSystemTools::RemoveFile(file4.c_str()); + cmSystemTools::RemoveFile(file1tmp.c_str()); + cmSystemTools::RemoveFile(file2tmp.c_str()); + cmSystemTools::RemoveFile(file3tmp.c_str()); + cmSystemTools::RemoveFile(file4tmp.c_str()); + + return failed; +} diff --git a/Tests/CMakeLib/testSystemTools.cxx b/Tests/CMakeLib/testSystemTools.cxx new file mode 100644 index 000000000..9309ae332 --- /dev/null +++ b/Tests/CMakeLib/testSystemTools.cxx @@ -0,0 +1,33 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#include "cmSystemTools.h" + +#define cmPassed(m) std::cout << "Passed: " << m << "\n" +#define cmFailed(m) std::cout << "FAILED: " << m << "\n"; failed=1 + +int testSystemTools(int, char*[]) +{ + int failed = 0; + // ---------------------------------------------------------------------- + // Test cmSystemTools::UpperCase + std::string str = "abc"; + std::string strupper = "ABC"; + if(cmSystemTools::UpperCase(str) == strupper) + { + cmPassed("cmSystemTools::UpperCase is working"); + } + else + { + cmFailed("cmSystemTools::UpperCase is working"); + } + return failed; +} diff --git a/Tests/CMakeLib/testUTF8.cxx b/Tests/CMakeLib/testUTF8.cxx new file mode 100644 index 000000000..4ab96cf01 --- /dev/null +++ b/Tests/CMakeLib/testUTF8.cxx @@ -0,0 +1,125 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#include <cm_utf8.h> + +#include <string.h> +#include <stdio.h> + +typedef char test_utf8_char[5]; + +static void test_utf8_char_print(test_utf8_char const c) +{ + unsigned char const* d = reinterpret_cast<unsigned char const*>(c); + printf("[0x%02X,0x%02X,0x%02X,0x%02X]", + (int)d[0], (int)d[1], (int)d[2], (int)d[3]); +} + +struct test_utf8_entry +{ + int n; + test_utf8_char str; + unsigned int chr; +}; + +static test_utf8_entry const good_entry[] = { + {1, "\x20\x00\x00\x00", 0x0020}, /* Space. */ + {2, "\xC2\xA9\x00\x00", 0x00A9}, /* Copyright. */ + {3, "\xE2\x80\x98\x00", 0x2018}, /* Open-single-quote. */ + {3, "\xE2\x80\x99\x00", 0x2019}, /* Close-single-quote. */ + {4, "\xF0\xA3\x8E\xB4", 0x233B4}, /* Example from RFC 3629. */ + {0, {0,0,0,0,0}, 0} +}; + +static test_utf8_char const bad_chars[] = { + "\x80\x00\x00\x00", + "\xC0\x00\x00\x00", + "\xE0\x00\x00\x00", + "\xE0\x80\x80\x00", + "\xF0\x80\x80\x80", + {0,0,0,0,0} +}; + +static void report_good(bool passed, test_utf8_char const c) +{ + printf("%s: decoding good ", passed?"pass":"FAIL"); + test_utf8_char_print(c); + printf(" (%s) ", c); +} + +static void report_bad(bool passed, test_utf8_char const c) +{ + printf("%s: decoding bad ", passed?"pass":"FAIL"); + test_utf8_char_print(c); + printf(" "); +} + +static bool decode_good(test_utf8_entry const entry) +{ + unsigned int uc; + if(const char* e = cm_utf8_decode_character(entry.str, entry.str+4, &uc)) + { + int used = static_cast<int>(e-entry.str); + if(uc != entry.chr) + { + report_good(false, entry.str); + printf("expected 0x%04X, got 0x%04X\n", entry.chr, uc); + return false; + } + if(used != entry.n) + { + report_good(false, entry.str); + printf("had %d bytes, used %d\n", entry.n, used); + return false; + } + report_good(true, entry.str); + printf("got 0x%04X\n", uc); + return true; + } + report_good(false, entry.str); + printf("failed\n"); + return false; +} + +static bool decode_bad(test_utf8_char const s) +{ + unsigned int uc = 0xFFFFu; + const char* e = cm_utf8_decode_character(s, s+4, &uc); + if(e) + { + report_bad(false, s); + printf("expected failure, got 0x%04X\n", uc); + return false; + } + report_bad(true, s); + printf("failed as expected\n"); + return true; +} + +int testUTF8(int, char*[]) +{ + int result = 0; + for(test_utf8_entry const* e = good_entry; e->n; ++e) + { + if(!decode_good(*e)) + { + result = 1; + } + } + for(test_utf8_char const* c = bad_chars; (*c)[0]; ++c) + { + if(!decode_bad(*c)) + { + result = 1; + } + } + return result; +} diff --git a/Tests/CMakeLib/testXMLParser.cxx b/Tests/CMakeLib/testXMLParser.cxx new file mode 100644 index 000000000..54ed5dc90 --- /dev/null +++ b/Tests/CMakeLib/testXMLParser.cxx @@ -0,0 +1,17 @@ +#include "testXMLParser.h" + +#include "cmXMLParser.h" + +#include <cmsys/ios/iostream> + +int testXMLParser(int, char*[]) +{ + // TODO: Derive from parser and check attributes. + cmXMLParser parser; + if(!parser.ParseFile(SOURCE_DIR "/testXMLParser.xml")) + { + cmsys_ios::cerr << "cmXMLParser failed!" << cmsys_ios::endl; + return 1; + } + return 0; +} diff --git a/Tests/CMakeLib/testXMLParser.h.in b/Tests/CMakeLib/testXMLParser.h.in new file mode 100644 index 000000000..da0b2757b --- /dev/null +++ b/Tests/CMakeLib/testXMLParser.h.in @@ -0,0 +1,6 @@ +#ifndef testXMLParser_h +#define testXMLParser_h + +#define SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@" + +#endif diff --git a/Tests/CMakeLib/testXMLParser.xml b/Tests/CMakeLib/testXMLParser.xml new file mode 100644 index 000000000..5a13f070a --- /dev/null +++ b/Tests/CMakeLib/testXMLParser.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Document> + <Element attr="1"/> +</Document> diff --git a/Tests/CMakeLib/testXMLSafe.cxx b/Tests/CMakeLib/testXMLSafe.cxx new file mode 100644 index 000000000..60442fab7 --- /dev/null +++ b/Tests/CMakeLib/testXMLSafe.cxx @@ -0,0 +1,47 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#include <cmXMLSafe.h> + +#include "cmStandardIncludes.h" + +struct test_pair +{ + const char* in; + const char* out; +}; + +static test_pair const pairs[] = { + {"copyright \xC2\xA9", "copyright \xC2\xA9"}, + {"form-feed \f", "form-feed [NON-XML-CHAR-0xC]"}, + {"angles <>", "angles <>"}, + {"ampersand &", "ampersand &"}, + {"bad-byte \x80", "bad-byte [NON-UTF-8-BYTE-0x80]"}, + {0,0} +}; + +int testXMLSafe(int, char*[]) +{ + int result = 0; + for(test_pair const* p = pairs; p->in; ++p) + { + cmXMLSafe xs(p->in); + cmOStringStream oss; + oss << xs; + std::string out = oss.str(); + if(out != p->out) + { + printf("expected [%s], got [%s]\n", p->out, out.c_str()); + result = 1; + } + } + return result; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt new file mode 100644 index 000000000..27ae3a072 --- /dev/null +++ b/Tests/CMakeLists.txt @@ -0,0 +1,2404 @@ +# a macro for tests that have a simple format where the name matches the +# directory and project +MACRO(ADD_TEST_MACRO NAME COMMAND) + STRING(REPLACE "." "/" dir "${NAME}") + STRING(REGEX REPLACE "[^.]*\\." "" proj "${NAME}") + ADD_TEST(${NAME} ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/${dir}" + "${CMake_BINARY_DIR}/Tests/${dir}" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project ${proj} + ${${NAME}_EXTRA_OPTIONS} + --test-command ${COMMAND} ${ARGN}) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}") +ENDMACRO(ADD_TEST_MACRO) + +MACRO(REGEX_ESCAPE_STRING _OUT _IN) + # Escape special regex metacharacters with a backslash + string(REGEX REPLACE "([$^.[|*+?()]|])" "\\\\\\1" ${_OUT} "${_IN}") +ENDMACRO(REGEX_ESCAPE_STRING _OUT _IN) + +INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake) + +# Fake a user home directory to avoid polluting the real one. +IF(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) + SET(TEST_HOME "${CMake_BINARY_DIR}/Tests/CMakeFiles/TestHome") + 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. +# 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. +SET(CTestTest_CONFIG Debug) +IF(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) + SET(CTestTest_CONFIG ${CMAKE_BUILD_TYPE}) +ENDIF() + +CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in + ${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake @ONLY) + +# Testing +IF(BUILD_TESTING) + IF("${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_TEST_GENERATOR}" MATCHES Ninja AND NOT WIN32)) + SET(TEST_CompileCommandOutput 1) + ENDIF() + + ADD_SUBDIRECTORY(CMakeLib) + ADD_SUBDIRECTORY(CMakeOnly) + ADD_SUBDIRECTORY(RunCMake) + + ADD_SUBDIRECTORY(FindPackageModeMakefileTest) + + # Collect a list of all test build directories. + SET(TEST_BUILD_DIRS) + + # Should the long tests be run? + OPTION(CMAKE_RUN_LONG_TESTS + "Should the long tests be run (such as Bootstrap)." ON) + MARK_AS_ADVANCED(CMAKE_RUN_LONG_TESTS) + + IF (CMAKE_RUN_LONG_TESTS) + OPTION(CTEST_TEST_CTEST + "Should the tests that run a full sub ctest process be run?" + OFF) + MARK_AS_ADVANCED(CTEST_TEST_CTEST) + + OPTION(TEST_KDE4_STABLE_BRANCH + "Should the KDE4 stable branch test be run?" + OFF) + MARK_AS_ADVANCED(TEST_KDE4_STABLE_BRANCH) + ENDIF (CMAKE_RUN_LONG_TESTS) + + # Should tests that use CVS be run? + # + set(do_cvs_tests 0) + + if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake) + find_package(CVS QUIET) + else(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake) + find_program(CVS_EXECUTABLE NAMES cvs) + endif(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake) + + if(CVS_EXECUTABLE) + set(do_cvs_tests 1) + endif(CVS_EXECUTABLE) + + if(do_cvs_tests AND NOT UNIX) + if("${CVS_EXECUTABLE}" MATCHES "cygwin") + set(do_cvs_tests 0) + endif("${CVS_EXECUTABLE}" MATCHES "cygwin") + endif(do_cvs_tests AND NOT UNIX) + + # Should CPack tests be run? By default, yes, but... + # + # Disable packaging test on Apple 10.3 and below. PackageMaker starts + # DiskManagementTool as root and disowns it + # (http://lists.apple.com/archives/installer-dev/2005/Jul/msg00005.html). + # It is left holding open pipe handles and preventing ProcessUNIX from + # detecting end-of-data even after its immediate child exits. Then + # the test hangs until it times out and is killed. This is a + # well-known bug in kwsys process execution that I would love to get + # time to fix. + # + OPTION(CTEST_TEST_CPACK + "Should the tests that use '--build-target package' be run?" + ON) + MARK_AS_ADVANCED(CTEST_TEST_CPACK) + SET(CTEST_TEST_OSX_ARCH 0) + IF(APPLE) + EXECUTE_PROCESS( + COMMAND sw_vers -productVersion + OUTPUT_VARIABLE OSX_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + IF(OSX_VERSION MATCHES "^10\\.[0123]" OR OSX_VERSION MATCHES "ProductVersion:\t10\\.[0123]") + MESSAGE(STATUS "Forcing CTEST_TEST_CPACK=OFF on OSX < 10.4") + MESSAGE(STATUS "OSX_VERSION='${OSX_VERSION}'") + SET(CTEST_TEST_CPACK OFF) + ELSE(OSX_VERSION MATCHES "^10\\.[0123]" OR OSX_VERSION MATCHES "ProductVersion:\t10\\.[0123]") + SET(CTEST_TEST_OSX_ARCH 1) + ENDIF(OSX_VERSION MATCHES "^10\\.[0123]" OR OSX_VERSION MATCHES "ProductVersion:\t10\\.[0123]") + ENDIF(APPLE) + + # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value, + # whichever is greater. + SET(CMAKE_LONG_TEST_TIMEOUT 1500) + IF(CTEST_TEST_TIMEOUT) + SET(CMAKE_LONG_TEST_TIMEOUT ${CTEST_TEST_TIMEOUT}) + ENDIF(CTEST_TEST_TIMEOUT) + IF(CMAKE_LONG_TEST_TIMEOUT LESS 1500) + SET(CMAKE_LONG_TEST_TIMEOUT 1500) + ENDIF(CMAKE_LONG_TEST_TIMEOUT LESS 1500) + + # add a bunch of standard build-and-test style tests + ADD_TEST_MACRO(CommandLineTest CommandLineTest) + ADD_TEST_MACRO(FindPackageTest FindPackageTest) + ADD_TEST_MACRO(FindModulesExecuteAll FindModulesExecuteAll) + ADD_TEST_MACRO(StringFileTest StringFileTest) + ADD_TEST_MACRO(TryCompile TryCompile) + ADD_TEST_MACRO(TarTest TarTest) + ADD_TEST_MACRO(SystemInformation SystemInformation) + ADD_TEST_MACRO(MathTest MathTest) + # assume no resources building to test + SET(TEST_RESOURCES FALSE) + # for windows and cygwin assume we have resources + IF(WIN32 OR CYGWIN) + SET(TEST_RESOURCES TRUE) + ENDIF() + # for borland and watcom there is no resource support + IF("${CMAKE_TEST_GENERATOR}" MATCHES "WMake" OR + "${CMAKE_TEST_GENERATOR}" MATCHES "Borland") + SET(TEST_RESOURCES FALSE) + ENDIF() + IF(TEST_RESOURCES) + ADD_TEST_MACRO(VSResource VSResource) + ENDIF() + ADD_TEST_MACRO(Simple Simple) + ADD_TEST_MACRO(PreOrder PreOrder) + ADD_TEST_MACRO(MissingSourceFile MissingSourceFile) + SET_TESTS_PROPERTIES(MissingSourceFile PROPERTIES + PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file:[ \r\n]*DoesNotExist/MissingSourceFile.c") + IF(CMAKE_Fortran_COMPILER) + ADD_TEST_MACRO(FortranOnly FortranOnly) + ENDIF() + # test Visual Studio GNU Fortran mixing with cmake_add_fortran_subdirectory + # run this project if we have a working fortran compiler or + # the test is enabled with CMAKE_TEST_CMAKE_ADD_FORTRAN cache variable. + # If you enable the test, CMake should find the MinGW fortran install, + # or in some cases you might need to set the PATH so that cmake can find + # the gfortran from mingw. + IF(CMAKE_Fortran_COMPILER OR CMAKE_TEST_CMAKE_ADD_FORTRAN) + SET(CMAKE_SKIP_VSGNUFortran FALSE) + # disable test for apple builds using ifort if they are building + # more than one architecture, as ifort does not support that. + IF(APPLE AND (CMAKE_Fortran_COMPILER MATCHES ifort)) + LIST(LENGTH CMAKE_OSX_ARCHITECTURES len) + IF("${len}" GREATER 1) + MESSAGE(STATUS "Skip VSGNUFortran for ifort dual cpu mac build") + SET(CMAKE_SKIP_VSGNUFortran TRUE) + ENDIF() + ENDIF() + IF((CMAKE_C_COMPILER MATCHES lsb) + AND (CMAKE_Fortran_COMPILER MATCHES ifort)) + MESSAGE(STATUS "Skip VSGNUFortran for ifort and lsb compilers") + SET(CMAKE_SKIP_VSGNUFortran TRUE) + ENDIF() + IF(NOT CMAKE_SKIP_VSGNUFortran) + ADD_TEST_MACRO(VSGNUFortran ${CMAKE_COMMAND} -P runtest.cmake) + ENDIF() + ENDIF() + ADD_TEST_MACRO(COnly COnly) + ADD_TEST_MACRO(CxxOnly CxxOnly) + ADD_TEST_MACRO(IPO COnly/COnly) + ADD_TEST_MACRO(OutDir runtime/OutDir) + ADD_TEST_MACRO(ObjectLibrary UseCshared) + ADD_TEST_MACRO(NewlineArgs NewlineArgs) + ADD_TEST_MACRO(SetLang SetLang) + ADD_TEST_MACRO(ExternalOBJ ExternalOBJ) + ADD_TEST_MACRO(LoadCommand LoadedCommand) + ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory) + ADD_TEST_MACRO(LinkLanguage LinkLanguage) + ADD_TEST_MACRO(LinkLine LinkLine) + ADD_TEST_MACRO(MacroTest miniMacroTest) + ADD_TEST_MACRO(FunctionTest miniFunctionTest) + ADD_TEST_MACRO(ReturnTest ReturnTest) + ADD_TEST_MACRO(Properties Properties) + ADD_TEST_MACRO(Assembler HelloAsm) + ADD_TEST_MACRO(SourceGroups SourceGroups) + ADD_TEST_MACRO(Preprocess Preprocess) + ADD_TEST_MACRO(ExportImport ExportImport) + ADD_TEST_MACRO(Unset Unset) + ADD_TEST_MACRO(PolicyScope PolicyScope) + ADD_TEST_MACRO(EmptyLibrary EmptyLibrary) + SET_TESTS_PROPERTIES(EmptyLibrary PROPERTIES + PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target:test") + ADD_TEST_MACRO(CrossCompile CrossCompile) + SET_TESTS_PROPERTIES(CrossCompile PROPERTIES + PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode") + IF("${CMAKE_TEST_GENERATOR}" MATCHES "Make") + ADD_TEST_MACRO(Policy0002 Policy0002) + ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES "Make") + IF(CTEST_TEST_OSX_ARCH) + ADD_TEST_MACRO(Architecture Architecture) + SET_TESTS_PROPERTIES(Architecture PROPERTIES + PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked)") + ENDIF(CTEST_TEST_OSX_ARCH) + + LIST(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX}) + + IF(NOT QT4_FOUND) + FIND_PACKAGE(Qt4) + ENDIF(NOT QT4_FOUND) + + IF(QT4_FOUND) + # test whether the Qt4 which has been found works, on some machines + # which run nightly builds there were errors like "wrong file format" + # for libQtCore.so. So first check it works, and only if it does add + # the automoc test. + INCLUDE(CheckCXXSourceCompiles) + SET(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") + SET(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + SET(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES}) + SET(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES}) + + CHECK_CXX_SOURCE_COMPILES("#include <QCoreApplication>\n int main() {return (qApp == 0 ? 0 : 1); }\n" + QT4_WORKS) + + SET(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}") + SET(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}") + ENDIF() + + # run test for BundleUtilities on supported platforms/compilers + if(MSVC OR + CMAKE_SYSTEM_NAME MATCHES "Linux" OR + CMAKE_SYSTEM_NAME MATCHES "Darwin") + if(NOT "${CMAKE_TEST_GENERATOR}" STREQUAL "Watcom WMake") + + ADD_TEST(BundleUtilities ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/BundleUtilities" + "${CMake_BINARY_DIR}/Tests/BundleUtilities" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project BundleUtilities + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleUtilities") + + # run test for DeployQt4 on supported platforms/compilers (which depends on BundleUtilities) + # this test also depends on the existence of the standard qtiff plugin + if(QT4_WORKS AND QT_QTSQL_FOUND) + ADD_TEST(Qt4Deploy ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Qt4Deploy" + "${CMake_BINARY_DIR}/Tests/Qt4Deploy" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project Qt4Deploy + --build-options + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Deploy") + endif() + + endif() + endif() + + SET(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/COnly") + SET(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/CMakeBuildCOnly") + SET(CMAKE_BUILD_TEST_EXE COnly) + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in" + "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake" @ONLY) + ADD_TEST(CMakeBuildTest ${CMAKE_CMAKE_COMMAND} -P + "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake") + LIST(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR}) + # now do it again for a project that has two project commands + SET(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/DoubleProject") + SET(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/DoubleProject") + SET(CMAKE_BUILD_TEST_EXE just_silly) + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in" + "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake" @ONLY) + ADD_TEST(CMakeDoubleProject ${CMAKE_CMAKE_COMMAND} -P + "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake") + LIST(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR}) + + ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize) + + ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader) + + if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-fPIE run_pic_test) + else() + if (CMAKE_CXX_COMPILER_ID MATCHES "PGI" + OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale" + OR CMAKE_SYSTEM_NAME MATCHES "IRIX64" + OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") + set(run_pic_test 0) + else() + set(run_pic_test 1) + endif() + endif() + + if (run_pic_test) + ADD_TEST_MACRO(PositionIndependentTargets PositionIndependentTargets) + endif() + + ADD_TEST(LinkFlags-prepare + ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/LinkFlags" + "${CMake_BINARY_DIR}/Tests/LinkFlags" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project LinkFlags + --build-target LinkFlags + --build-options -DTEST_CONFIG=\${CTEST_CONFIGURATION_TYPE} + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkFlags") + + MACRO(ADD_LINK_FLAGS_TEST name depends) + ADD_TEST(LinkFlags-${name} + ${CMAKE_CMAKE_COMMAND} --build "${CMake_BINARY_DIR}/Tests/LinkFlags" + --target LinkFlags_${name} --config \${CTEST_CONFIGURATION_TYPE} + ) + SET_TESTS_PROPERTIES(LinkFlags-${name} PROPERTIES + PASS_REGULAR_EXPRESSION "BADFLAG" DEPENDS LinkFlags-${depends}) + ENDMACRO() + ADD_LINK_FLAGS_TEST(lib prepare) + ADD_LINK_FLAGS_TEST(dll lib) + ADD_LINK_FLAGS_TEST(exe dll) + ADD_LINK_FLAGS_TEST(lib_config exe) + ADD_LINK_FLAGS_TEST(dll_config lib_config) + ADD_LINK_FLAGS_TEST(exe_config dll_config) + + # If we are running right now with a UnixMakefiles based generator, + # build the "Simple" test with the ExtraGenerators, if available + # This doesn't test whether the generated project files work (unfortunately), + # mainly it tests that cmake doesn't crash when generating these project files. + IF(${CMAKE_TEST_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_TEST_GENERATOR} MATCHES "KDevelop") + # check which generators we have + EXEC_PROGRAM(${CMAKE_CMAKE_COMMAND} ARGS --help OUTPUT_VARIABLE cmakeOutput ) + # check for the Eclipse generator + IF ("${cmakeOutput}" MATCHES Eclipse) + ADD_TEST(Simple_EclipseGenerator ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Simple" + "${CMake_BINARY_DIR}/Tests/Simple_EclipseGenerator" + --build-two-config + --build-generator "Eclipse CDT4 - Unix Makefiles" + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project Simple + --test-command Simple) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_EclipseGenerator") + ENDIF ("${cmakeOutput}" MATCHES Eclipse) + + # check for the CodeBlocks generator + IF ("${cmakeOutput}" MATCHES CodeBlocks) + ADD_TEST(Simple_CodeBlocksGenerator ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Simple" + "${CMake_BINARY_DIR}/Tests/Simple_CodeBlocksGenerator" + --build-two-config + --build-generator "CodeBlocks - Unix Makefiles" + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project Simple + --test-command Simple) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_CodeBlocksGenerator") + ENDIF ("${cmakeOutput}" MATCHES CodeBlocks) + # check for the KDevelop3 generator + IF ("${cmakeOutput}" MATCHES KDevelop3) + ADD_TEST(Simple_KDevelop3Generator ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Simple" + "${CMake_BINARY_DIR}/Tests/Simple_KDevelop3Generator" + --build-two-config + --build-generator "KDevelop3 - Unix Makefiles" + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project Simple + --test-command Simple) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_KDevelop3Generator") + ENDIF ("${cmakeOutput}" MATCHES KDevelop3) + + ENDIF(${CMAKE_TEST_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_TEST_GENERATOR} MATCHES "KDevelop") + + # test for correct sub-project generation + # not implemented in VS6 or Xcode + IF(NOT MSVC60 AND NOT XCODE AND NOT MSVC70) + # run cmake and configure all of SubProject + # but only build the independent executable car + ADD_TEST(SubProject ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/SubProject" + "${CMake_BINARY_DIR}/Tests/SubProject" + --build-project SubProject + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-target car + --test-command car + ) + + IF(${CMAKE_TEST_GENERATOR} MATCHES "Ninja") + # The Ninja generator does not create a recursive build system. Start + # from the root directory. + SET(SubProject_SUBDIR) + ELSE() + SET(SubProject_SUBDIR "/foo") + ENDIF() + + # For stage 2, do not run cmake again. + # Then build the foo sub project which should build + # the bar library which should be referenced because + # foo links to the static library bar, but bar is not + # directly in the foo sub project + ADD_TEST(SubProject-Stage2 ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/SubProject${SubProject_SUBDIR}" + "${CMake_BINARY_DIR}/Tests/SubProject${SubProject_SUBDIR}" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-nocmake + --build-project foo + --build-target foo + --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubProject/foo" + --test-command foo + ) + SET_TESTS_PROPERTIES ( SubProject-Stage2 PROPERTIES DEPENDS SubProject) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubProject") + ENDIF(NOT MSVC60 AND NOT XCODE AND NOT MSVC70) + + IF (CMAKE_STRICT) + ADD_TEST_MACRO(DocTest DocTest) + ENDIF (CMAKE_STRICT) + # macro to add a test that will build a nightly release + # of CMake for given platform using the release scripts + MACRO(ADD_NIGHTLY_BUILD_TEST name script) + SET(_TEST_DIR "${CMake_BINARY_DIR}/Tests/${name}") + FILE(MAKE_DIRECTORY "${_TEST_DIR}") + FILE(WRITE "${_TEST_DIR}/nightly-cmake.sh" + "cd ${_TEST_DIR} +${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script} +${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake + ") + ADD_TEST(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh) + IF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY) + SET_TESTS_PROPERTIES (${name} PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + ENDIF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY) + ENDMACRO(ADD_NIGHTLY_BUILD_TEST) + IF(CMAKE_BUILD_NIGHTLY_RELEASES) + ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWindows + dash2win64_release.cmake) + ADD_NIGHTLY_BUILD_TEST(CMakeNightlyMac + dashmacmini2_release.cmake) + ADD_NIGHTLY_BUILD_TEST(CMakeNightlyMac64 + dashmacmini5_release.cmake) + ADD_NIGHTLY_BUILD_TEST(CMakeNightlyLinux + magrathea_release.cmake) + ENDIF(CMAKE_BUILD_NIGHTLY_RELEASES) + + # add tests with more complex invocations + ADD_TEST(Framework ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Framework" + "${CMake_BINARY_DIR}/Tests/Framework" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project Framework + --build-options + "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/Framework/Install" + --test-command bar) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Framework") + + ADD_TEST(TargetName ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/TargetName" + "${CMake_BINARY_DIR}/Tests/TargetName" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project TargetName + --test-command ${CMAKE_CMAKE_COMMAND} -E compare_files + ${CMake_SOURCE_DIR}/Tests/TargetName/scripts/hello_world + ${CMake_BINARY_DIR}/Tests/TargetName/scripts/hello_world) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TargetName") + + ADD_TEST(LibName ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/LibName" + "${CMake_BINARY_DIR}/Tests/LibName" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project LibName + --build-exe-dir "${CMake_BINARY_DIR}/Tests/LibName/lib" + --test-command foobar + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LibName") + + ADD_TEST(CustComDepend ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CustComDepend" + "${CMake_BINARY_DIR}/Tests/CustComDepend" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project CustComDepend + --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustComDepend/bin" + --test-command foo bar.c + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustComDepend") + + ADD_TEST(ArgumentExpansion ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/ArgumentExpansion" + "${CMake_BINARY_DIR}/Tests/ArgumentExpansion" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project ArgumentExpansion + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/ArgumentExpansion/bin" + ) + SET_TESTS_PROPERTIES(ArgumentExpansion PROPERTIES + FAIL_REGULAR_EXPRESSION "Unexpected: ") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ArgumentExpansion") + + ADD_TEST(CustomCommand ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CustomCommand" + "${CMake_BINARY_DIR}/Tests/CustomCommand" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project CustomCommand + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommand/bin" + --test-command CustomCommand + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommand") + + ADD_TEST(CustomCommandWorkingDirectory ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CustomCommandWorkingDirectory" + "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project TestWorkingDir + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command working + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory") + + #ADD_TEST(SimpleExclude ${CMAKE_CTEST_COMMAND} + # --build-and-test + # "${CMake_SOURCE_DIR}/Tests/SimpleExclude" + # "${CMake_BINARY_DIR}/Tests/SimpleExclude" + # --build-generator ${CMAKE_TEST_GENERATOR} + # --build-project SimpleExclude + # --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + # --build-two-config + # --test-command t4 + #--test-command "${CMAKE_COMMAND}" + #"-DCONFIGURATION=\${CTEST_CONFIGURATION_TYPE}" + #-P "${CMake_BINARY_DIR}/Tests/SimpleExclude/run.cmake" + #) + +# ADD_TEST(SameName ${CMAKE_CTEST_COMMAND} +# --build-and-test +# "${CMake_SOURCE_DIR}/Tests/SameName" +# "${CMake_BINARY_DIR}/Tests/SameName" +# --build-generator ${CMAKE_TEST_GENERATOR} +# --build-project SameName +# --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} +# --build-two-config +# --test-command +# "${CMake_BINARY_DIR}/Tests/SameName/Exe1/mytest2") + + ADD_TEST(OutOfSource ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/OutOfSource" + "${CMake_BINARY_DIR}/Tests/OutOfSource" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project OutOfSource + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --test-command + "${CMake_BINARY_DIR}/Tests/OutOfSource/SubDir/OutOfSourceSubdir/simple") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfSource") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfSourceDeep") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfBinary") + + ADD_TEST(BuildDepends ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/BuildDepends" + "${CMake_BINARY_DIR}/Tests/BuildDepends" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project BuildDepends + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BuildDepends") + + SET(SimpleInstallInstallDir + "${CMake_BINARY_DIR}/Tests/SimpleInstall/InstallDirectory") + ADD_TEST(SimpleInstall ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/SimpleInstall" + "${CMake_BINARY_DIR}/Tests/SimpleInstall" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project TestSimpleInstall + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --build-options + "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}" + "-DCTEST_TEST_CPACK:BOOL=${CTEST_TEST_CPACK}" + --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExe) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstall") + ADD_TEST(SimpleInstall-Stage2 ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/SimpleInstallS2" + "${CMake_BINARY_DIR}/Tests/SimpleInstallS2" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project TestSimpleInstall + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --build-options + "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}" + "-DSTAGE2:BOOL=1" + --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExeS2) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstallS2") + + # By default, run the CPackComponents test if the CTEST_TEST_CPACK + # option is ON: + # + set(CTEST_RUN_CPackComponents ${CTEST_TEST_CPACK}) + set(CTEST_package_X11_TEST ${CTEST_TEST_CPACK}) + set(CTEST_RUN_CPackComponentsForAll ${CTEST_TEST_CPACK}) + + if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") + find_program(RPMBUILD NAMES rpmbuild) + endif(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") + # Do not try to build RPM + if (NOT RPMBUILD) + set(CPACK_BINARY_RPM OFF) + endif(NOT RPMBUILD) + + find_program(NSIS_MAKENSIS_EXECUTABLE NAMES makensis + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS] + DOC "makensis program location" + ) + + # But on Windows, only run the CPackComponents test if the NSIS + # installer builder is available: + # + if(WIN32) + if(NSIS_MAKENSIS_EXECUTABLE) + set(CTEST_RUN_CPackComponents ON) + else(NSIS_MAKENSIS_EXECUTABLE) + set(CTEST_RUN_CPackComponents OFF) + set(CTEST_package_X11_TEST OFF) + endif(NSIS_MAKENSIS_EXECUTABLE) + endif(WIN32) + + IF(CTEST_RUN_CPackComponents) + set(CPackComponents_EXTRA_OPTIONS) + if(APPLE) + set(CPackComponents_EXTRA_OPTIONS -DCPACK_BINARY_DRAGNDROP:BOOL=ON) + endif(APPLE) + if(NSIS_MAKENSIS_EXECUTABLE) + set(CPackComponents_EXTRA_OPTIONS ${CPackComponents_EXTRA_OPTIONS} + -DCPACK_BINARY_NSIS:BOOL=ON) + endif(NSIS_MAKENSIS_EXECUTABLE) + + ADD_TEST(CPackComponents ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CPackComponents" + "${CMake_BINARY_DIR}/Tests/CPackComponents" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project CPackComponents + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --build-target package + --build-options + -DCPACK_BINARY_DEB:BOOL=${CPACK_BINARY_DEB} + -DCPACK_BINARY_RPM:BOOL=${CPACK_BINARY_RPM} + ${CPackComponents_EXTRA_OPTIONS} + --graphviz=CPackComponents.dot + --test-command ${CMAKE_CMAKE_COMMAND} + "-DCPackComponents_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackComponents" + -P "${CMake_SOURCE_DIR}/Tests/CPackComponents/VerifyResult.cmake") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackComponents") + ENDIF(CTEST_RUN_CPackComponents) + + IF(CTEST_RUN_CPackComponentsForAll) + # Check whether if rpmbuild command is found + # before adding RPM tests + find_program(RPMBUILD_EXECUTABLE NAMES rpmbuild) + if(RPMBUILD_EXECUTABLE) + list(APPEND ACTIVE_CPACK_GENERATORS RPM) + endif(RPMBUILD_EXECUTABLE) + # Check whether if dpkg command is found + # before adding DEB tests + find_program(DPKG_EXECUTABLE NAMES dpkg) + if(DPKG_EXECUTABLE) + list(APPEND ACTIVE_CPACK_GENERATORS DEB) + endif(DPKG_EXECUTABLE) + + # ACTIVE_CPACK_GENERATORS variable + # now contains the list of 'active generators' + set(CPackComponentsForAll_EXTRA_OPTIONS) + set(CPackRun_CPackCommand "-DCPackCommand=${CMAKE_CPACK_COMMAND}") + # set up list of CPack generators + list(APPEND GENLST "ZIP") + if(APPLE) + list(APPEND GENLST "DragNDrop") + endif(APPLE) + if (NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") + list(FIND ACTIVE_CPACK_GENERATORS "RPM" RPM_ACTIVE) + if (NOT ${RPM_ACTIVE} EQUAL -1) + list(APPEND GENLST "RPM") + endif(NOT ${RPM_ACTIVE} EQUAL -1) + endif(NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") + list(FIND ACTIVE_CPACK_GENERATORS "DEB" DEB_ACTIVE) + if (NOT ${DEB_ACTIVE} EQUAL -1) + list(APPEND GENLST "DEB") + endif(NOT ${DEB_ACTIVE} EQUAL -1) + + # set up list of component packaging ways + list(APPEND CWAYLST "default") + list(APPEND CWAYLST "OnePackPerGroup") + list(APPEND CWAYLST "IgnoreGroup") + list(APPEND CWAYLST "AllInOne") + foreach(CPackGen ${GENLST}) + set(CPackRun_CPackGen "-DCPackGen=${CPackGen}") + foreach(CPackComponentWay ${CWAYLST}) + set(CPackRun_CPackComponentWay "-DCPackComponentWay=${CPackComponentWay}") + ADD_TEST(CPackComponentsForAll-${CPackGen}-${CPackComponentWay} ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CPackComponentsForAll" + "${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project CPackComponentsForAll + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-options + -DCPACK_BINARY_${CPackGen}:BOOL=ON + ${CPackRun_CPackComponentWay} + ${CPackComponentsForAll_EXTRA_OPTIONS} + --graphviz=CPackComponentsForAll.dot + --test-command ${CMAKE_CMAKE_COMMAND} + "-DCPackComponentsForAll_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}" + "${CPackRun_CPackCommand}" + "${CPackRun_CPackGen}" + "${CPackRun_CPackComponentWay}" + -P "${CMake_SOURCE_DIR}/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}") + endforeach(CPackComponentWay) + endforeach(CPackGen) + ENDIF(CTEST_RUN_CPackComponentsForAll) + + # By default, turn this test off (because it takes a long time...) + # + if(NOT DEFINED CTEST_RUN_CPackTestAllGenerators) + set(CTEST_RUN_CPackTestAllGenerators OFF) + + # ...but: if it appears to be a coverage dashboard, or long tests are + # on, then set it to the generic CTEST_TEST_CPACK setting. + # + if(CMAKE_CXX_FLAGS MATCHES "-ftest-coverage" OR + NOT "$ENV{COVFILE}" STREQUAL "" OR + CMAKE_RUN_LONG_TESTS) + set(CTEST_RUN_CPackTestAllGenerators ${CTEST_TEST_CPACK}) + endif(CMAKE_CXX_FLAGS MATCHES "-ftest-coverage" OR + NOT "$ENV{COVFILE}" STREQUAL "" OR + CMAKE_RUN_LONG_TESTS) + endif(NOT DEFINED CTEST_RUN_CPackTestAllGenerators) + + IF(CTEST_RUN_CPackTestAllGenerators) + ADD_TEST(CPackTestAllGenerators ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CPackTestAllGenerators" + "${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project CPackTestAllGenerators + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command + ${CMAKE_CMAKE_COMMAND} + -D dir=${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators + -D cpack=${CMAKE_CPACK_COMMAND} + -P ${CMake_SOURCE_DIR}/Tests/CPackTestAllGenerators/RunCPack.cmake + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators") + ENDIF(CTEST_RUN_CPackTestAllGenerators) + + IF(CTEST_package_X11_TEST) + SET(X11_build_target_arg --build-target package) + ELSE(CTEST_package_X11_TEST) + SET(X11_build_target_arg) + ENDIF(CTEST_package_X11_TEST) + + ADD_TEST(X11 ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/X11" + "${CMake_BINARY_DIR}/Tests/X11" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project UseX11 + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + ${X11_build_target_arg} + --test-command UseX11) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/X11") + + if(NOT DEFINED CTEST_RUN_CMakeTestAllGenerators) + set(CTEST_RUN_CMakeTestAllGenerators ON) + endif(NOT DEFINED CTEST_RUN_CMakeTestAllGenerators) + + IF(CTEST_RUN_CMakeTestAllGenerators) + ADD_TEST(CMakeTestAllGenerators ${CMAKE_CMAKE_COMMAND} + -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestAllGenerators + -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR} + -P ${CMake_SOURCE_DIR}/Tests/CMakeTestAllGenerators/RunCMake.cmake + ) + LIST(APPEND TEST_BUILD_DIRS + "${CMake_BINARY_DIR}/Tests/CMakeTestAllGenerators") + ENDIF(CTEST_RUN_CMakeTestAllGenerators) + + if(NOT DEFINED CTEST_RUN_CMakeTestBadCommandLines) + set(CTEST_RUN_CMakeTestBadCommandLines ON) + endif(NOT DEFINED CTEST_RUN_CMakeTestBadCommandLines) + + IF(CTEST_RUN_CMakeTestBadCommandLines) + ADD_TEST(CMakeTestBadCommandLines ${CMAKE_CMAKE_COMMAND} + -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestBadCommandLines + -D gen=${CMAKE_TEST_GENERATOR} + -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR} + -P ${CMake_SOURCE_DIR}/Tests/CMakeTestBadCommandLines/RunCMake.cmake + ) + LIST(APPEND TEST_BUILD_DIRS + "${CMake_BINARY_DIR}/Tests/CMakeTestBadCommandLines") + ENDIF(CTEST_RUN_CMakeTestBadCommandLines) + + if(NOT DEFINED CTEST_RUN_CMakeTestMultipleConfigures) + set(CTEST_RUN_CMakeTestMultipleConfigures ON) + endif(NOT DEFINED CTEST_RUN_CMakeTestMultipleConfigures) + + IF(CTEST_RUN_CMakeTestMultipleConfigures) + ADD_TEST(CMakeTestMultipleConfigures ${CMAKE_CMAKE_COMMAND} + -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures + -D gen=${CMAKE_TEST_GENERATOR} + -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR} + -P ${CMake_SOURCE_DIR}/Tests/CMakeTestMultipleConfigures/RunCMake.cmake + ) + LIST(APPEND TEST_BUILD_DIRS + "${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures") + ENDIF(CTEST_RUN_CMakeTestMultipleConfigures) + + ADD_TEST(LoadedCommandOneConfig ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig" + "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project LoadCommand + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command LoadedCommand + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig") + + ADD_TEST(complex ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Complex" + "${CMake_BINARY_DIR}/Tests/Complex" + --build-two-config + --build-config-sample "${CMAKE_CTEST_COMMAND}" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project Complex + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Complex/bin" + --build-options + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + --test-command complex + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Complex") + + ADD_TEST(complexOneConfig ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/ComplexOneConfig" + "${CMake_BINARY_DIR}/Tests/ComplexOneConfig" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project Complex + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexOneConfig/bin" + --build-options + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + --test-command complex) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ComplexOneConfig") + # because of the registry write these tests depend on each other + SET_TESTS_PROPERTIES ( complex PROPERTIES DEPENDS complexOneConfig) + + ADD_TEST(Example ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Example" + "${CMake_BINARY_DIR}/Example" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project HELLO + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Example/Demo" + --test-command helloDemo + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Example") + + ADD_TEST(Environment ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Environment" + "${CMake_BINARY_DIR}/Tests/Environment" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project EnvironmentProj + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Environment" + --force-new-ctest-process + --test-command ${CMAKE_CTEST_COMMAND} -V + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment") + + IF(QT4_WORKS AND QT_QTGUI_FOUND) + ADD_TEST(QtAutomoc ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutomoc" + "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project QtAutomoc + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --force-new-ctest-process + --build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + --test-command ${CMAKE_CTEST_COMMAND} -V + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc") + ENDIF() + + ADD_TEST(ExternalProject ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/ExternalProject" + "${CMake_BINARY_DIR}/Tests/ExternalProject" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project ExternalProjectTest + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProject" + --force-new-ctest-process + --test-command ${CMAKE_CTEST_COMMAND} -V + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProject") + SET_TESTS_PROPERTIES(ExternalProject PROPERTIES + TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + + # do each of the tutorial steps + FOREACH(STP RANGE 1 7) + ADD_TEST(TutorialStep${STP} ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Tutorial/Step${STP}" + "${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project Tutorial + --test-command Tutorial 25.0) + ENDFOREACH(STP) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Tutorial") + + ADD_TEST(testing ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Testing" + "${CMake_BINARY_DIR}/Tests/Testing" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project Testing + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} + ) + SET_TESTS_PROPERTIES(testing PROPERTIES PASS_REGULAR_EXPRESSION "Passed") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Testing") + + ADD_TEST(wrapping ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Wrapping" + "${CMake_BINARY_DIR}/Tests/Wrapping" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project Wrapping + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" + --test-command wrapping + ) + ADD_TEST(qtwrapping ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Wrapping" + "${CMake_BINARY_DIR}/Tests/Wrapping" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project Wrapping + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" + --test-command qtwrapping + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Wrapping") + + ADD_TEST(testdriver1 ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/TestDriver" + "${CMake_BINARY_DIR}/Tests/TestDriver" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" + --build-project TestDriverTest + --test-command TestDriverTest test1 + ) + + ADD_TEST(testdriver2 ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/TestDriver" + "${CMake_BINARY_DIR}/Tests/TestDriver" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" + --build-project TestDriverTest + --test-command TestDriverTest test2 + ) + + ADD_TEST(testdriver3 ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/TestDriver" + "${CMake_BINARY_DIR}/Tests/TestDriver" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin" + --build-project TestDriverTest + --test-command TestDriverTest subdir/test3 + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestDriver") + + ADD_TEST(Dependency ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Dependency" + "${CMake_BINARY_DIR}/Tests/Dependency" + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Dependency/Exec" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project Dependency + --test-command exec + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Dependency") + + IF("${CMAKE_SYSTEM_NAME}" MATCHES syllable) + +# RPATH isn't supported under Syllable, so the tests don't +# find their libraries. In order to fix that LIBRARY_OUTPUT_DIR +# in the tests would have to be adjusted to ${EXECUTABLE_OUTPUT_DIR}/lib . +# For now we just require on Syllable that the user adjusts the DLL_PATH +# environment variable, so except the two tests below all other tests will succeed. + + SET(_DLL_PATH "$ENV{DLL_PATH}") + IF(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.(:.*)?$") + MESSAGE(FATAL_ERROR "In order to successfully run the CMake test suite on Syllable you need to add \"\\@bindir\\@/.\" to the DLL_PATH environment variable") + ENDIF(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.(:.*)?$") + IF(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.\\./lib(:.*)?$") + MESSAGE(FATAL_ERROR "In order to successfully run the CMake test suite on Syllable you need to add \"\\@bindir\\@/../lib\" to the DLL_PATH environment variable") + ENDIF(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.\\./lib(:.*)?$") + + ELSE("${CMAKE_SYSTEM_NAME}" MATCHES syllable) + + ADD_TEST(JumpWithLibOut ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Jump" + "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut" + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Executable" + --build-project Jump + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-options + -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Lib + --test-command jumpExecutable + ) + + ADD_TEST(JumpNoLibOut ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Jump" + "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut" + --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable" + --build-run-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable" + --build-project Jump + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command jumpExecutable + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Jump") + + ADD_TEST(Plugin ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Plugin" + "${CMake_BINARY_DIR}/Tests/Plugin" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project Plugin + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --test-command bin/example) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Plugin") + + IF(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG) + ADD_TEST_MACRO(RuntimePath RuntimePath) + ENDIF(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG) + ENDIF("${CMAKE_SYSTEM_NAME}" MATCHES syllable) + + ADD_TEST(linkorder1 ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/LinkLineOrder" + "${CMake_BINARY_DIR}/Tests/LinkLineOrder" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project LinkLineOrder + --test-command Exec1 + ) + + ADD_TEST(linkorder2 ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/LinkLineOrder" + "${CMake_BINARY_DIR}/Tests/LinkLineOrder" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project LinkLineOrder + --test-command Exec2 + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkLineOrder") + SET_TESTS_PROPERTIES ( qtwrapping PROPERTIES DEPENDS wrapping) + SET_TESTS_PROPERTIES ( testdriver1 PROPERTIES DEPENDS qtwrapping) + SET_TESTS_PROPERTIES ( testdriver2 PROPERTIES DEPENDS testdriver1) + SET_TESTS_PROPERTIES ( testdriver3 PROPERTIES DEPENDS testdriver2) + SET_TESTS_PROPERTIES ( linkorder2 PROPERTIES DEPENDS linkorder1) + SET_TESTS_PROPERTIES ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall) + + # Test static linking on toolchains known to support it. + IF("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU)$" + AND NOT APPLE AND NOT WIN32 AND NOT CYGWIN + AND EXISTS "/usr/lib/libm.a") + ADD_TEST(LinkStatic ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/LinkStatic" + "${CMake_BINARY_DIR}/Tests/LinkStatic" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project LinkStatic + --build-options -DMATH_LIBRARY:FILEPATH=/usr/lib/libm.a + --test-command LinkStatic + ) + ENDIF() + + IF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) + ADD_TEST(kwsys ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Source/kwsys" + "${CMake_BINARY_DIR}/Tests/kwsys" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project kwsys + --test-command kwsysTestsCxx testIOS + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/kwsys") + ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) + SET(MAKE_IS_GNU ) + IF(${CMAKE_TEST_MAKEPROGRAM} MATCHES make) + EXEC_PROGRAM( + ${CMAKE_TEST_MAKEPROGRAM} ARGS no_such_target --version + RETURN_VALUE res OUTPUT_VARIABLE out + ) + IF("${res}" EQUAL 0) + IF("${out}" MATCHES "GNU") + SET(MAKE_IS_GNU 1) + ENDIF("${out}" MATCHES "GNU") + ENDIF("${res}" EQUAL 0) + ENDIF(${CMAKE_TEST_MAKEPROGRAM} MATCHES make) + + # only add this test on platforms that support it + # some old versions of make simply cannot handle spaces in paths + IF (MAKE_IS_GNU OR + "${CMAKE_TEST_MAKEPROGRAM}" MATCHES "nmake|gmake|wmake" OR + "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio|XCode|Borland") + ADD_TEST(SubDirSpaces ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/SubDirSpaces" + "${CMake_BINARY_DIR}/Tests/SubDirSpaces" + --build-exe-dir + "${CMake_BINARY_DIR}/Tests/SubDirSpaces/Executable Sources" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project SUBDIR + --test-command test + "${CMake_BINARY_DIR}/Tests/SubDirSpaces/ShouldBeHere" + "${CMake_BINARY_DIR}/Tests/SubDirSpaces/testfromsubdir.obj" + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDirSpaces") + ENDIF (MAKE_IS_GNU OR + "${CMAKE_TEST_MAKEPROGRAM}" MATCHES "nmake|gmake|wmake" OR + "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio|XCode|Borland") + + IF (WIN32) + ADD_TEST(SubDir ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/SubDir" + "${CMake_BINARY_DIR}/Tests/SubDir" + --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project SUBDIR + --test-command test + "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere" + "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.obj" + ) + ELSE (WIN32) + ADD_TEST(SubDir ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/SubDir" + "${CMake_BINARY_DIR}/Tests/SubDir" + --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project SUBDIR + --test-command test + "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere" + "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.o" + ) + ENDIF (WIN32) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDir") + + IF(CMAKE_TEST_MSVC) + ADD_TEST_MACRO(ForceInclude foo) + ADD_TEST_MACRO(PrecompiledHeader foo) + ENDIF() + IF(CMAKE_TEST_MSVC OR + "${CMAKE_TEST_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles") + ADD_TEST_MACRO(ModuleDefinition example_exe) + ENDIF() + + ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables) + + IF("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile") + ADD_TEST(MakeClean ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/MakeClean" + "${CMake_BINARY_DIR}/Tests/MakeClean" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project MakeClean + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/MakeClean" + --test-command check_clean + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MakeClean") + ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile") + + if(NOT DEFINED CTEST_RUN_MFC) + set(CTEST_RUN_MFC OFF) + + if(MSVC) + set(CTEST_RUN_MFC ON) + + # Look for evidence that this is a VCExpress build. If so, avoid + # the MFC test by default. + string(TOLOWER "${CMAKE_TEST_MAKEPROGRAM}" mkprog) + if(mkprog MATCHES "vcexpress") + message(STATUS + "CMAKE_TEST_MAKEPROGRAM indicates vcexpress, avoiding MFC test") + set(CTEST_RUN_MFC OFF) + endif() + + # Since MSBuild might also be the "makeprogram" for a VCExpress + # build tree, use one more heuristic, too. The string representing + # the .vcproj file type contains "VCExpress" on machines where an + # express edition of VS was installed last: + if(CTEST_RUN_MFC) + execute_process(COMMAND cmd /c assoc .vcproj + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE ov) + if(ov MATCHES "VCExpress") + message(STATUS + ".vcproj file association indicates VCExpress, avoiding MFC test") + set(CTEST_RUN_MFC OFF) + endif() + endif() + + # For the Watcom WMake generator, avoid the MFC test by default. + if(CTEST_RUN_MFC) + if("${CMAKE_TEST_GENERATOR}" MATCHES "WMake") + message(STATUS + "using the Watcom WMake generator, avoiding MFC test") + set(CTEST_RUN_MFC OFF) + endif() + endif() + + # Last resort, after quick checks are done. Do a try_compile, and avoid + # the MFC test if the simplest possible MFC app cannot be compiled. + if(CTEST_RUN_MFC AND NOT DEFINED HAVE_MFC) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/MFC/try_compile/CMakeLists.txt + ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/CMakeLists.txt + COPYONLY + ) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.cpp + ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.cpp + COPYONLY + ) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.h + ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.h + COPYONLY + ) + + message(STATUS "Looking for MFC") + + try_compile(HAVE_MFC + ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/build + ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile + try_compile_mfc + OUTPUT_VARIABLE HAVE_MFC_OUTPUT) + + if(HAVE_MFC) + message(STATUS "Looking for MFC - found") + set(HAVE_MFC 1 CACHE INTERNAL "Have MFC") + file(APPEND + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if MFC exists passed with the following output:\n" + "${HAVE_MFC_OUTPUT}\n\n") + else() + message(STATUS "Looking for MFC - not found") + set(HAVE_MFC "" CACHE INTERNAL "Have MFC") + file(APPEND + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if MFC exists failed with the following output:\n" + "${HAVE_MFC_OUTPUT}\n\n") + endif() + endif() + + if(CTEST_RUN_MFC AND NOT HAVE_MFC) + message(STATUS + "cannot compile simplest ever MFC app, avoiding MFC test") + set(CTEST_RUN_MFC OFF) + endif() + endif() + endif() + + if(CTEST_RUN_MFC) + add_test(MFC ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/MFC" + "${CMake_BINARY_DIR}/Tests/MFC" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project mfc_driver + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command ${CMAKE_CTEST_COMMAND} + -C \${CTEST_CONFIGURATION_TYPE} -VV) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC") + endif() + + IF(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio") + IF(NOT MSVC60) + ADD_TEST_MACRO(SBCS SBCS) + ENDIF(NOT MSVC60) + + ADD_TEST(VSExternalInclude ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VSExternalInclude" + "${CMake_BINARY_DIR}/Tests/VSExternalInclude" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project VSExternalInclude + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command VSExternalInclude) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExternalInclude") + + ADD_TEST(VSMidl ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VSMidl" + "${CMake_BINARY_DIR}/Tests/VSMidl" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project VSMidl + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command VSMidl) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl") + ENDIF(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio") + + IF (APPLE) + if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + SET(BundleTestInstallDir + "${CMake_BINARY_DIR}/Tests/BundleTest/InstallDirectory") + ADD_TEST(BundleTest ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/BundleTest" + "${CMake_BINARY_DIR}/Tests/BundleTest" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project BundleTest + --build-target install +# --build-target package + --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}" + "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}" + --test-command + ${BundleTestInstallDir}/Applications/SecondBundleExe.app/Contents/MacOS/SecondBundleExe) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleTest") + + ADD_TEST(CFBundleTest ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CFBundleTest" + "${CMake_BINARY_DIR}/Tests/CFBundleTest" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project CFBundleTest + --test-command + ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=\${CTEST_CONFIGURATION_TYPE} + -Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest + -Dgen=${CMAKE_TEST_GENERATOR} + -P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest") + + ADD_TEST_MACRO(ObjC++ ObjC++) + ENDIF (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + ENDIF (APPLE) + + IF(APPLE AND CTEST_TEST_CPACK) + ADD_TEST(BundleGeneratorTest ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/BundleGeneratorTest" + "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project BundleGeneratorTest + --build-target package + --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/BundleGeneratorTest/InstallDirectory" + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest") + ENDIF(APPLE AND CTEST_TEST_CPACK) + + ADD_TEST(WarnUnusedUnusedViaSet ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaSet" + "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-noclean + --build-project WarnUnusedUnusedViaSet + --build-options "--warn-unused-vars") + SET_TESTS_PROPERTIES(WarnUnusedUnusedViaSet PROPERTIES + PASS_REGULAR_EXPRESSION "unused variable \\(changing definition\\) 'UNUSED_VARIABLE'") + SET_TESTS_PROPERTIES(WarnUnusedUnusedViaSet PROPERTIES + FAIL_REGULAR_EXPRESSION "unused variable \\(unsetting\\) 'UNUSED_VARIABLE'") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet") + + ADD_TEST(WarnUnusedUnusedViaUnset ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaUnset" + "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-noclean + --build-project WarnUnusedUnusedViaUnset + --build-options "--warn-unused-vars") + SET_TESTS_PROPERTIES(WarnUnusedUnusedViaUnset PROPERTIES + PASS_REGULAR_EXPRESSION "CMake Warning .*:7 \\(set\\):") + SET_TESTS_PROPERTIES(WarnUnusedUnusedViaUnset PROPERTIES + FAIL_REGULAR_EXPRESSION "CMake Warning .*:5 \\(set\\):") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset") + + ADD_TEST(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VariableUsage" + "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-noclean + --build-project WarnUnusedCliUnused + --build-options "-DUNUSED_CLI_VARIABLE=Unused") + SET_TESTS_PROPERTIES(WarnUnusedCliUnused PROPERTIES + PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused") + + ADD_TEST(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VariableUsage" + "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-noclean + --build-project WarnUnusedCliUsed + --build-options "-DUSED_VARIABLE=Usage proven") + SET_TESTS_PROPERTIES(WarnUnusedCliUsed PROPERTIES + PASS_REGULAR_EXPRESSION "Usage proven") + SET_TESTS_PROPERTIES(WarnUnusedCliUsed PROPERTIES + FAIL_REGULAR_EXPRESSION "CMake Warning: The variable, 'USED_VARIABLE'") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed") + + ADD_TEST(WarnUninitialized ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VariableUsage" + "${CMake_BINARY_DIR}/Tests/WarnUninitialized" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-noclean + --build-project WarnUninitialized + --build-options "--warn-uninitialized") + SET_TESTS_PROPERTIES(WarnUninitialized PROPERTIES + 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 -C \${CTEST_CONFIGURATION_TYPE} + ) + 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!") + + # A simple test for ctest in script mode + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake" @ONLY) +# ADD_TEST(CTest.ScriptMode ${CMAKE_CTEST_COMMAND} +# -S "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake" +# ) + + SET(CTEST_TEST_UPDATE 1) + IF(CTEST_TEST_UPDATE) + # Test CTest Update with Subversion + FIND_PACKAGE(Subversion QUIET) + IF(Subversion_FOUND) + GET_FILENAME_COMPONENT(_Subversion_BIN_DIR + ${Subversion_SVN_EXECUTABLE} PATH) + FIND_PROGRAM(Subversion_SVNADMIN_EXECUTABLE svnadmin + HINTS ${_Subversion_BIN_DIR} + ) + MARK_AS_ADVANCED(Subversion_SVNADMIN_EXECUTABLE) + IF(NOT Subversion_SVNADMIN_EXECUTABLE) + SET(Subversion_FOUND FALSE) + ENDIF(NOT Subversion_SVNADMIN_EXECUTABLE) + ENDIF(Subversion_FOUND) + IF(Subversion_FOUND) + SET(CTestUpdateSVN_DIR "CTest UpdateSVN") + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestUpdateSVN.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake" @ONLY) + ADD_TEST(CTest.UpdateSVN ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake" + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateSVN_DIR}") + ENDIF(Subversion_FOUND) + + # Test CTest Update with CVS + IF(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake) + FIND_PACKAGE(CVS QUIET) + ELSE(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake) + FIND_PROGRAM(CVS_EXECUTABLE NAMES cvs) + SET(CVS_FOUND ${CVS_EXECUTABLE}) + ENDIF(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake) + SET(CTEST_TEST_UPDATE_CVS ${CVS_FOUND}) + IF(CTEST_TEST_UPDATE_CVS AND NOT UNIX) + IF("${CVS_EXECUTABLE}" MATCHES "cygwin") + MESSAGE(STATUS "No CTest.UpdateCVS test with cygwin cvs.exe outside cygwin!") + SET(CTEST_TEST_UPDATE_CVS 0) + ENDIF("${CVS_EXECUTABLE}" MATCHES "cygwin") + ENDIF(CTEST_TEST_UPDATE_CVS AND NOT UNIX) + IF(CTEST_TEST_UPDATE_CVS) + SET(CTestUpdateCVS_DIR "CTest UpdateCVS") + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestUpdateCVS.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake" @ONLY) + ADD_TEST(CTest.UpdateCVS ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake" + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateCVS_DIR}") + ENDIF(CTEST_TEST_UPDATE_CVS) + + # Test CTest Update with BZR + FIND_PROGRAM(BZR_EXECUTABLE NAMES bzr) + MARK_AS_ADVANCED(BZR_EXECUTABLE) + SET(CTEST_TEST_UPDATE_BZR 0) + IF(BZR_EXECUTABLE) + IF(NOT "${BZR_EXECUTABLE}" MATCHES "cygwin" OR UNIX) + SET(CTEST_TEST_UPDATE_BZR 1) + ENDIF(NOT "${BZR_EXECUTABLE}" MATCHES "cygwin" OR UNIX) + ENDIF(BZR_EXECUTABLE) + IF(CTEST_TEST_UPDATE_BZR) + # Check if xmloutput plugin is there + EXECUTE_PROCESS(COMMAND ${BZR_EXECUTABLE} xmlplugins RESULT_VARIABLE xmlplugres + OUTPUT_QUIET ERROR_QUIET) + IF( NOT ${xmlplugres} ) + SET(CTestUpdateBZR_DIR "CTest UpdateBZR") + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake" @ONLY) + ADD_TEST(CTest.UpdateBZR ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake" + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}") + SET(CTestUpdateBZR_DIR "CTest UpdateBZR_CLocale") + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake" @ONLY) + ADD_TEST(CTest.UpdateBZR.CLocale ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake" + ) + SET_TESTS_PROPERTIES(CTest.UpdateBZR.CLocale PROPERTIES ENVIRONMENT LC_ALL=C) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}") + ENDIF( NOT ${xmlplugres} ) + ENDIF(CTEST_TEST_UPDATE_BZR) + + # Test CTest Update with GIT + FIND_PROGRAM(GIT_EXECUTABLE NAMES git) + MARK_AS_ADVANCED(GIT_EXECUTABLE) + SET(CTEST_TEST_UPDATE_GIT 0) + IF(GIT_EXECUTABLE) + IF(NOT "${GIT_EXECUTABLE}" MATCHES "cygwin" OR UNIX) + SET(CTEST_TEST_UPDATE_GIT 1) + ENDIF(NOT "${GIT_EXECUTABLE}" MATCHES "cygwin" OR UNIX) + ENDIF(GIT_EXECUTABLE) + IF(CTEST_TEST_UPDATE_GIT) + SET(CTestUpdateGIT_DIR "CTest UpdateGIT") + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestUpdateGIT.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake" @ONLY) + ADD_TEST(CTest.UpdateGIT ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake" + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateGIT_DIR}") + ENDIF(CTEST_TEST_UPDATE_GIT) + + # Test CTest Update with HG + FIND_PROGRAM(HG_EXECUTABLE NAMES hg) + MARK_AS_ADVANCED(HG_EXECUTABLE) + SET(CTEST_TEST_UPDATE_HG 0) + IF(HG_EXECUTABLE) + IF(NOT "${HG_EXECUTABLE}" MATCHES "cygwin" OR UNIX) + SET(CTEST_TEST_UPDATE_HG 1) + ENDIF(NOT "${HG_EXECUTABLE}" MATCHES "cygwin" OR UNIX) + ENDIF(HG_EXECUTABLE) + IF(CTEST_TEST_UPDATE_HG) + SET(CTestUpdateHG_DIR "CTest UpdateHG") + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestUpdateHG.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake" @ONLY) + ADD_TEST(CTest.UpdateHG ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake" + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateHG_DIR}") + ENDIF(CTEST_TEST_UPDATE_HG) + ENDIF(CTEST_TEST_UPDATE) + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoBuild.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestNoBuild ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut1.log" + ) + SET_TESTS_PROPERTIES(CTestTestNoBuild PROPERTIES + FAIL_REGULAR_EXPRESSION "Error" WILL_FAIL true) + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoExe.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestNoExe ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut2.log" + ) + SET_TESTS_PROPERTIES(CTestTestNoExe PROPERTIES DEPENDS CTestTestNoBuild + PASS_REGULAR_EXPRESSION "Could not find executable" + FAIL_REGULAR_EXPRESSION "SegFault") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestUpload/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestUpload ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestUpload/testOut.log" + ) + SET_TESTS_PROPERTIES(CTestTestUpload PROPERTIES + PASS_REGULAR_EXPRESSION "Upload\\.xml") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestConfigFileInBuildDir1 ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/testOut1.log" + ) + REGEX_ESCAPE_STRING(CTEST_TEST_ESCAPED_SOURCE_DIR "${CMake_SOURCE_DIR}") + SET_TESTS_PROPERTIES(CTestTestConfigFileInBuildDir1 PROPERTIES DEPENDS CTestTestNoBuild + PASS_REGULAR_EXPRESSION + "Reading ctest configuration file: ${CTEST_TEST_ESCAPED_SOURCE_DIR}.Tests.CTestTestConfigFileInBuildDir.CTestConfig.cmake") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/test2.cmake" + @ONLY ESCAPE_QUOTES) + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake" + "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/CTestConfig.cmake" + @ONLY ESCAPE_QUOTES COPYONLY) + ADD_TEST(CTestTestConfigFileInBuildDir2 ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/test2.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/testOut2.log" + ) + REGEX_ESCAPE_STRING(CTEST_TEST_ESCAPED_BINARY_DIR "${CMake_BINARY_DIR}") + SET_TESTS_PROPERTIES(CTestTestConfigFileInBuildDir2 PROPERTIES DEPENDS CTestTestNoBuild + REQUIRED_FILES ${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/CTestConfig.cmake + PASS_REGULAR_EXPRESSION + "Reading ctest configuration file: ${CTEST_TEST_ESCAPED_BINARY_DIR}.Tests.CTestTestConfigFileInBuildDir2.CTestConfig.cmake") + + # test coverage for mumps + # create a MumpsCoverage dir in the binary tree under Testing to + # avoid the .NoDartCoverage files in the cmake testing tree + configure_file( + "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/DartConfiguration.tcl.in" + "${CMake_BINARY_DIR}/Testing/MumpsCoverage/DartConfiguration.tcl") + configure_file( + "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/gtm_coverage.mcov.in" + "${CMake_BINARY_DIR}/Testing/MumpsCoverage/gtm_coverage.mcov") + file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA" + DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCoverage") + add_test(NAME CTestGTMCoverage + COMMAND cmake -E chdir + ${CMake_BINARY_DIR}/Testing/MumpsCoverage + $<TARGET_FILE:ctest> -T Coverage --debug) + set_tests_properties(CTestGTMCoverage PROPERTIES + PASS_REGULAR_EXPRESSION + "Process file.*XINDEX.m.*Total LOC:.*127.*Percentage Coverage: 85.83.*" + ENVIRONMENT COVFILE=) + + configure_file( + "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/DartConfiguration.cache.tcl.in" + "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/DartConfiguration.tcl") + configure_file( + "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/cache_coverage.cmcov.in" + "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/cache_coverage.cmcov") + file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA" + DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage") + add_test(NAME CTestCacheCoverage + COMMAND cmake -E chdir + ${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage + $<TARGET_FILE:ctest> -T Coverage --debug) + set_tests_properties(CTestCacheCoverage PROPERTIES + PASS_REGULAR_EXPRESSION + "Process file.*XINDEX.m.*Total LOC:.*125.*Percentage Coverage: 85.60.*" + ENVIRONMENT COVFILE=) + # Use macro, not function so that build can still be driven by CMake 2.4. + # After 2.6 is required, this could be a function without the extra 'set' + # calls. + # + macro(add_config_tests cfg) + set(cfg "${cfg}") + set(base "${CMake_BINARY_DIR}/Tests/CTestConfig") + + # Test -S script with a -C config arg to ctest: + configure_file( + "${CMake_SOURCE_DIR}/Tests/CTestConfig/script.cmake.in" + "${base}/${cfg}-script.cmake" + @ONLY ESCAPE_QUOTES) + add_test(CTestConfig.Script.${cfg} ${CMAKE_CTEST_COMMAND} + -C ${cfg} + -S "${base}/${cfg}-script.cmake" -VV + --output-log "${base}/${cfg}-script.log" + ) + + # Test -D dashboard with a -C config arg to ctest. + # (Actual commands inside a cmake -P script because we need to be able to set + # the working directory reliably...) + configure_file( + "${CMake_SOURCE_DIR}/Tests/CTestConfig/dashboard.cmake.in" + "${base}/${cfg}-dashboard.cmake" + @ONLY ESCAPE_QUOTES) + add_test(CTestConfig.Dashboard.${cfg} ${CMAKE_CMAKE_COMMAND} + -P "${base}/${cfg}-dashboard.cmake" -VV + ) + endmacro() + + add_config_tests(Debug) + add_config_tests(MinSizeRel) + add_config_tests(Release) + add_config_tests(RelWithDebInfo) + + # Test -S script with some -D variable definition args to ctest: + add_test(CTestConfig.ScriptWithArgs ${CMAKE_CTEST_COMMAND} + -C "Release" + -D arg1=this + -D arg2=that + -D "arg3=the other" + "-Darg4=this is the fourth" + -Darg5=the_fifth + -Darg6:STRING=value-with-type + -S "${CMake_SOURCE_DIR}/Tests/CTestConfig/ScriptWithArgs.cmake" -VV + --output-log "${CMake_BINARY_DIR}/Tests/CTestConfig/ScriptWithArgs.log" + ) + + ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries) + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestCrash ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCrash/testOutput.log" + ) + # with watcom the SEGFAULT is not found, it just fails + IF(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake") + SET_TESTS_PROPERTIES(CTestTestCrash PROPERTIES + PASS_REGULAR_EXPRESSION "Failed") + ELSE(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake") + SET_TESTS_PROPERTIES(CTestTestCrash PROPERTIES + PASS_REGULAR_EXPRESSION "(Illegal|SegFault)") + ENDIF(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestBadExe/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestBadExe ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/testOutput.log" + ) + SET(CTestTestBadExe_REGEX "BAD_COMMAND") + # some cygwin can not be made to produce a BAD_COMMAND error + # the best we can get from it is a failed test + IF(CYGWIN) + SET(CTestTestBadExe_REGEX "(\\*\\*\\*Failed)|BAD_COMMAND") + ENDIF() + SET_TESTS_PROPERTIES(CTestTestBadExe PROPERTIES + PASS_REGULAR_EXPRESSION "${CTestTestBadExe_REGEX}") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestParallel/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestParallel ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log" + ) + + ADD_TEST(CTestTestPrintLabels ${CMAKE_CTEST_COMMAND} --print-labels) + SET_TESTS_PROPERTIES(CTestTestPrintLabels PROPERTIES LABELS "Label1;Label2") + SET_TESTS_PROPERTIES(CTestTestPrintLabels PROPERTIES PASS_REGULAR_EXPRESSION + "All Labels:.* Label1.* Label2") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestResourceLock/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestResourceLock ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/output.log" + ) + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestScheduler/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestScheduler ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/testOutput.log" + ) + SET_TESTS_PROPERTIES(CTestTestScheduler PROPERTIES + PASS_REGULAR_EXPRESSION "Start 1.*Start 2.*Start 3.*Start 4.*Start 4.*Start 3.*Start 2.*Start 1" + RESOURCE_LOCK "CostData") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestCostSerial/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestCostSerial ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/testOutput.log" + ) + SET_TESTS_PROPERTIES(CTestTestCostSerial PROPERTIES + PASS_REGULAR_EXPRESSION "Start 2.*Start 3.*Start 1.*Start 2.*Start 3.*Start 1" + RESOURCE_LOCK "CostData") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestStopTime/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/test.cmake" + @ONLY ESCAPE_QUOTES) + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestStopTime/GetDate.cmake" + "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/GetDate.cmake" + COPYONLY) + ADD_TEST(CTestTestStopTime ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/testOutput.log" + ) + SET_TESTS_PROPERTIES(CTestTestStopTime PROPERTIES + PASS_REGULAR_EXPRESSION "The stop time has been passed") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestSubdir/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestSubdir ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/testOutput.log" + ) + #make sure all 3 subdirs were added + SET_TESTS_PROPERTIES(CTestTestSubdir PROPERTIES + PASS_REGULAR_EXPRESSION "0 tests failed out of 3") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestTimeout/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestTimeout ${CMAKE_CTEST_COMMAND} + -C "\${CTestTest_CONFIG}" + -S "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/testOutput.log" + ) + SET_TESTS_PROPERTIES(CTestTestTimeout PROPERTIES + PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*CheckChild *\\.+ *Passed") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestZeroTimeout/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestZeroTimeout ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake" -V + --output-log + "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/testOutput.log") + SET_TESTS_PROPERTIES(CTestTestZeroTimeout PROPERTIES + FAIL_REGULAR_EXPRESSION "\\*\\*\\*Timeout") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestDepends/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestDepends ${CMAKE_CTEST_COMMAND} + -C "\${CTestTest_CONFIG}" + -S "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestDepends/testOutput.log" + ) + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestCycle/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestCycle ${CMAKE_CTEST_COMMAND} + -C "\${CTestTest_CONFIG}" + -S "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCycle/testOutput.log" + ) + SET_TESTS_PROPERTIES(CTestTestCycle PROPERTIES + PASS_REGULAR_EXPRESSION "a cycle exists in the test dependency graph") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake" + @ONLY ESCAPE_QUOTES) + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/hello.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/hello.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestRunScript ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/testOutput.log" + ) + + ADD_TEST(CTestTestShowOnly ${CMAKE_CTEST_COMMAND} -N) + + ADD_TEST(CTestBatchTest ${CMAKE_CTEST_COMMAND} -B) + + # Use macro, not function so that build can still be driven by CMake 2.4. + # After 2.6 is required, this could be a function without the extra 'set' + # calls. + # + macro(add_failed_submit_test name source build in out log regex) + # Have variables named source, build and drop_method because the + # configure_file call expects those variables to be defined. + # + set(source "${source}") + set(build "${build}") + configure_file("${in}" "${out}" @ONLY) + add_test(${name} ${CMAKE_CTEST_COMMAND} -S "${out}" -V --output-log "${log}") + set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${regex}") + endmacro() + + set(regex "(Problems when submitting via S*CP") + set(regex "${regex}|Error message was: ") + set(regex "${regex}([Cc]ould *n.t resolve host") + set(regex "${regex}|[Cc]ould *n.t connect to host") + set(regex "${regex}|Empty reply from server") + set(regex "${regex}|The requested URL returned error") + set(regex "${regex}|libcurl was built with SSL disabled. https: not supported)") + set(regex "${regex}|Submission method .xmlrpc. not compiled into CTest") + set(regex "${regex}|Submission problem") + set(regex "${regex}|Submission successful)") + + set(ctest_coverage_labels_args "") + + foreach(drop_method cp ftp http https scp xmlrpc) + # Cycle through these values each time through the loop: + if(ctest_coverage_labels_args STREQUAL "") + set(ctest_coverage_labels_args "LABELS Everything") + elseif(ctest_coverage_labels_args STREQUAL "LABELS Everything") + set(ctest_coverage_labels_args "LABELS 0ArgTest") + else() + set(ctest_coverage_labels_args "") + endif() + + add_failed_submit_test(CTestTestFailedSubmit-${drop_method} + "${CMake_SOURCE_DIR}/Tests/CTestTest/SmallAndFast" + "${CMake_BINARY_DIR}/Tests/CTestTestFailedSubmits/${drop_method}" + "${CMake_SOURCE_DIR}/Tests/CTestTestFailedSubmits/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestFailedSubmits/test-${drop_method}.cmake" + "${CMake_BINARY_DIR}/Tests/CTestTestFailedSubmits/test-${drop_method}.log" + "${regex}" + ) + endforeach() + + + IF (CMAKE_TESTS_CDASH_SERVER) + SET(regex "^([^:]+)://([^/]+)(/.*)$") + + IF ("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}") + SET(protocol "${CMAKE_MATCH_1}") + SET(server "${CMAKE_MATCH_2}") + SET(path "${CMAKE_MATCH_3}") + ELSE ("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}") + SET(protocol "http") + SET(server "www.cdash.org") + SET(path "/CDash") + MESSAGE("warning: CMAKE_TESTS_CDASH_SERVER does not match expected regex...") + MESSAGE(" ...using default url='${protocol}://${server}${path}' for CTestTest[23]") + ENDIF ("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}") + ENDIF (CMAKE_TESTS_CDASH_SERVER) + + + IF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER) + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestTest/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTest ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log" + ) + + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTest2 ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" + ) + + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestTestChecksum/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" @ONLY + ESCAPE_QUOTES) + ADD_TEST(CTestTestChecksum ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" -V + --output-log + "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/testOutput.log" + ) + SET_TESTS_PROPERTIES(CTestTestChecksum PROPERTIES PASS_REGULAR_EXPRESSION + "Submission failed: Checksum failed for file") + + # these tests take a long time, make sure they have it + # if timeouts have not already been set + GET_TEST_PROPERTY(CTestTest TIMEOUT PREVIOUS_TIMEOUT) + IF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + SET_TESTS_PROPERTIES ( CTestTest + PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + ENDIF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + + GET_TEST_PROPERTY(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT) + IF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + SET_TESTS_PROPERTIES ( CTestTest2 + PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + ENDIF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + ENDIF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER) + + IF (CMAKE_RUN_LONG_TESTS AND TEST_KDE4_STABLE_BRANCH) + IF(UNIX) + IF(NOT QT4_FOUND) + FIND_PACKAGE(Qt4) + ENDIF(NOT QT4_FOUND) + + SET(TRY_BUILD_KDE4 TRUE) + IF(QT4_FOUND) + # check whether it's Qt 4.5 in a cmake 2.4. compatible way: + IF(NOT EXISTS "${QT_QTNETWORK_INCLUDE_DIR}/QAbstractNetworkCache") + SET(TRY_BUILD_KDE4 FALSE) + ENDIF(NOT EXISTS "${QT_QTNETWORK_INCLUDE_DIR}/QAbstractNetworkCache") + ELSE(QT4_FOUND) + SET(TRY_BUILD_KDE4 FALSE) + ENDIF(QT4_FOUND) + + FIND_PACKAGE(Perl) + IF(NOT PERL_FOUND) + SET(TRY_BUILD_KDE4 FALSE) + ENDIF(NOT PERL_FOUND) + + FIND_PACKAGE(ZLIB) + IF(NOT ZLIB_FOUND) + SET(TRY_BUILD_KDE4 FALSE) + ENDIF(NOT ZLIB_FOUND) + + IF(TRY_BUILD_KDE4) + FILE(MAKE_DIRECTORY ${CMake_BINARY_DIR}/Tests/KDE4StableBranchTest) + SET(TEST_KDE4_BASE_DIR ${CMake_BINARY_DIR}/Tests/KDE4StableBranchTest) + CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/KDE4StableBranchTest/test_kde4.sh.in ${CMake_BINARY_DIR}/Tests/KDE4StableBranchTest/test_kde4.sh @ONLY) + EXECUTE_PROCESS(COMMAND chmod 755 ${CMake_BINARY_DIR}/Tests/KDE4StableBranchTest/test_kde4.sh ) + ADD_TEST(KDE4StableBranchTest ${CMake_BINARY_DIR}/Tests/KDE4StableBranchTest/test_kde4.sh) + ENDIF(TRY_BUILD_KDE4) + + ENDIF(UNIX) + ENDIF (CMAKE_RUN_LONG_TESTS AND TEST_KDE4_STABLE_BRANCH) + + IF("${CMAKE_TEST_GENERATOR}" MATCHES Xcode) + SET(CMAKE_SKIP_BOOTSTRAP_TEST 1) + ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES Xcode) + IF(EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt") + # If there is CMakeLists.txt in the binary tree, assume in-source build + SET(CMAKE_SKIP_BOOTSTRAP_TEST 1) + ENDIF(EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt") + SET(bootstrap "") + IF(CMAKE_RUN_LONG_TESTS AND NOT CMAKE_SKIP_BOOTSTRAP_TEST) + IF(UNIX) + SET(bootstrap ${CMake_SOURCE_DIR}/bootstrap) + ELSEIF(MSYS) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bootstrap.bat.in + ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.bat @ONLY) + SET(bootstrap ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.bat) + ENDIF() + ENDIF() + IF(bootstrap) + ADD_TEST(BootstrapTest ${CMAKE_CTEST_COMMAND} + --build-and-test + ${CMake_SOURCE_DIR} + ${CMake_BINARY_DIR}/Tests/BootstrapTest + --build-nocmake + --build-noclean + --build-makeprogram ${bootstrap} + --build-generator "${CMAKE_TEST_GENERATOR}" + --test-command + ${CMake_BINARY_DIR}/Tests/BootstrapTest/Bootstrap.cmk/cmake) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BootstrapTest") + # Make this test run early during parallel execution + SET_TESTS_PROPERTIES(BootstrapTest PROPERTIES COST 5000) + + # provide more time for the bootstrap test + GET_TEST_PROPERTY(BootstrapTest TIMEOUT PREVIOUS_TIMEOUT) + IF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + SET_TESTS_PROPERTIES ( BootstrapTest + PROPERTIES TIMEOUT 5400) + ENDIF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + ENDIF() + + IF(CMAKE_Fortran_COMPILER) + ADD_TEST(Fortran ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Fortran" + "${CMake_BINARY_DIR}/Tests/Fortran" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project testf + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --test-command testf) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") + + # FortranCInterface tests. + IF(UNIX) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY) + ADD_TEST(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P + ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags") + ELSE() + ADD_TEST(FortranC ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FortranC" + "${CMake_BINARY_DIR}/Tests/FortranC" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project FortranC + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --test-command CMakeFiles/FortranCInterface/FortranCInterface) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC") + ENDIF() + ENDIF() + + find_package(Java COMPONENTS Development QUIET) + IF(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE AND Java_JAR_EXECUTABLE AND NOT MINGW + AND NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Xcode") + GET_FILENAME_COMPONENT(JNIPATH ${JAVA_COMPILE} PATH) + FIND_FILE(JNI_H jni.h + "${JNIPATH}/../include" + "${JNIPATH}/../java/include") + IF(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink + FILE(READ "${JNI_H}" JNI_FILE) + IF("${JNI_FILE}" MATCHES "JDK1_2") + ADD_TEST(Java ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Java" + "${CMake_BINARY_DIR}/Tests/Java" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project hello + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/" + --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Java") + ENDIF("${JNI_FILE}" MATCHES "JDK1_2") + ENDIF() + ENDIF() + + # add some cross compiler tests, for now only with makefile based generators + IF(CMAKE_TEST_GENERATOR MATCHES "Makefiles" OR CMAKE_TEST_GENERATOR MATCHES "KDevelop") + + # if sdcc is found, build the SimpleCOnly project with sdcc + FIND_PROGRAM(SDCC_EXECUTABLE sdcc) + MARK_AS_ADVANCED(SDCC_EXECUTABLE) + IF(SDCC_EXECUTABLE) + ADD_TEST(SimpleCOnly_sdcc ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/SimpleCOnly" + "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project SimpleC + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-options + "-DCMAKE_SYSTEM_NAME=Generic" + "-DCMAKE_C_COMPILER=${SDCC_EXECUTABLE}") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc") + ENDIF(SDCC_EXECUTABLE) + + # If a Linux -> MinGW cross compiler is found then try it + FIND_PROGRAM(MINGW_CC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-gcc) + FIND_PROGRAM(MINGW_CXX_LINUX2WIN_EXECUTABLE i586-mingw32msvc-g++) + FIND_PROGRAM(MINGW_RC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-windres) + MARK_AS_ADVANCED(MINGW_CC_LINUX2WIN_EXECUTABLE MINGW_CXX_LINUX2WIN_EXECUTABLE MINGW_RC_LINUX2WIN_EXECUTABLE) + IF(MINGW_CC_LINUX2WIN_EXECUTABLE AND MINGW_CXX_LINUX2WIN_EXECUTABLE AND MINGW_RC_LINUX2WIN_EXECUTABLE) + ADD_TEST(Simple_Mingw_Linux2Win ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Simple" + "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project Simple + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-options + "-DCMAKE_SYSTEM_NAME=Windows" + "-DCMAKE_C_COMPILER=${MINGW_CC_LINUX2WIN_EXECUTABLE}" + "-DCMAKE_CXX_COMPILER=${MINGW_CXX_LINUX2WIN_EXECUTABLE}" + "-DCMAKE_RC_COMPILER=${MINGW_RC_LINUX2WIN_EXECUTABLE}" + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win") + ENDIF() + ENDIF(CMAKE_TEST_GENERATOR MATCHES "Makefiles" OR CMAKE_TEST_GENERATOR MATCHES "KDevelop") + + IF(UNIX) + STRING(COMPARE EQUAL "${CMAKE_INSTALL_PREFIX}" "${CMake_BINARY_DIR}/Tests/TestShellInstall/Prefix" + PREFIX_IS_FOR_TEST) + IF(PREFIX_IS_FOR_TEST) + CONFIGURE_FILE( + ${CMake_SOURCE_DIR}/Tests/TestInstall.sh.in + ${CMake_BINARY_DIR}/Tests/TestShellInstall/TestInstall.sh + @ONLY IMMEDIATE + ) + ADD_TEST(ShellInstall /bin/sh ${CMake_BINARY_DIR}/Tests/TestShellInstall/TestShellInstall.sh) + ENDIF(PREFIX_IS_FOR_TEST) + ENDIF(UNIX) + + IF(CMAKE_TEST_PROJECT_CSE_DIR) + SET(script "${CMAKE_TEST_PROJECT_CSE_DIR}/BuildProjectCSE.cmake") + IF(NOT EXISTS "${script}") + SET(script "${CMAKE_TEST_PROJECT_CSE_DIR}/cse_build.cmake") + ENDIF(NOT EXISTS "${script}") + IF(NOT EXISTS "${script}") + MESSAGE("warning: CMAKE_TEST_PROJECT_CSE_DIR set, but no build script found...") + ENDIF(NOT EXISTS "${script}") + + ADD_TEST(BuildCSE ${CMAKE_CTEST_COMMAND} -V -S "${script}") + SET_TESTS_PROPERTIES(BuildCSE PROPERTIES TIMEOUT 5400) + ENDIF(CMAKE_TEST_PROJECT_CSE_DIR) + + IF(CMAKE_TEST_PLPLOT_DIR) + ADD_TEST(plplot ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_PLPLOT_DIR}/../../EasyDashboardScripts/plplot.cmake ) + SET_TESTS_PROPERTIES ( plplot PROPERTIES TIMEOUT 5400) + ENDIF(CMAKE_TEST_PLPLOT_DIR) + + IF(CMAKE_TEST_CHICKEN_DIR) + ADD_TEST(Chicken ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_CHICKEN_DIR}/../../EasyDashboardScripts/Chicken.cmake ) + SET_TESTS_PROPERTIES ( Chicken PROPERTIES TIMEOUT 5400) + ENDIF(CMAKE_TEST_CHICKEN_DIR) + + IF(CMAKE_TEST_KDELIBS_ALPHA_1_DIR) + ADD_TEST(KDELibsAlpha1 ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_KDELIBS_ALPHA_1_DIR}/../../EasyDashboardScripts/kdelibs.cmake ) + SET_TESTS_PROPERTIES ( KDELibsAlpha1 PROPERTIES TIMEOUT 5400) + ENDIF(CMAKE_TEST_KDELIBS_ALPHA_1_DIR) + + # If this is not an in-source build, provide a target to wipe out + # all the test build directories. + IF(NOT EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt") + CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/test_clean.cmake.in + ${CMake_BINARY_DIR}/Tests/test_clean.cmake @ONLY) + ADD_CUSTOM_TARGET(test_clean + COMMAND ${CMAKE_COMMAND} -P ${CMake_BINARY_DIR}/Tests/test_clean.cmake + COMMENT "Removing test build directories." + ) + ENDIF(NOT EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt") + + ADD_TEST(CMakeWizardTest ${CMAKE_CMAKE_COMMAND} + -D build_dir:STRING=${CMAKE_CURRENT_BINARY_DIR}/CMakeWizardTest + -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() + + IF(TEST_CompileCommandOutput) + SET(CompileCommandOutput_EXTRA_OPTIONS + --build-options -DMAKE_SUPPORTS_SPACES=${MAKE_IS_GNU}) + ADD_TEST_MACRO(CompileCommandOutput + "${CMake_BINARY_DIR}/Tests/CMakeLib/runcompilecommands") + ENDIF() + + ADD_TEST(IncludeDirectories ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/IncludeDirectories" + "${CMake_BINARY_DIR}/Tests/IncludeDirectories" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project IncludeDirectories + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command IncludeDirectories) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories") + + IF(CMAKE_USE_KWSTYLE AND KWSTYLE_EXECUTABLE) + # The "make StyleCheck" command line as a test. If the test fails, look + # for lines like "Error #0 (624) Line length exceed 88 (max=79)" in the + # output to find where the style errors are... + ADD_TEST(KWStyle ${KWSTYLE_EXECUTABLE} + -xml ${CMake_BINARY_DIR}/CMake.kws.xml + -o ${CMake_SOURCE_DIR}/Utilities/KWStyle/CMakeOverwrite.txt + -v + -D ${CMake_BINARY_DIR}/CMakeKWSFiles.txt + ) + SET_TESTS_PROPERTIES(KWStyle PROPERTIES + WORKING_DIRECTORY ${CMake_BINARY_DIR}/Utilities/KWStyle) + ENDIF() +ENDIF(BUILD_TESTING) + +SUBDIRS(CMakeTests) diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt new file mode 100644 index 000000000..551cee3bc --- /dev/null +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -0,0 +1,84 @@ +cmake_minimum_required (VERSION 2.8) +project(AllFindModules) + +if (POLICY CMP0017) + cmake_policy(SET CMP0017 NEW) +endif () + +# Avoid ctest truncation of output +message(STATUS "CTEST_FULL_OUTPUT") + +file(GLOB FIND_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../Modules/Find*.cmake" ) + +macro(do_find MODULE_NAME) + message(STATUS " Checking Find${MODULE_NAME}") + find_package(${MODULE_NAME}) +endmacro(do_find) + +# It is only possible to use either Qt3 or Qt4 in one project. +# Since FindQt will complain if both are found we explicitly request Qt4 here +# and filter out FindQt3. FindKDE3 also depends on Qt3 and +# is therefore also blocked +set(DESIRED_QT_VERSION 4) +set(NO_QT4_MODULES "Qt3" "KDE3") + +# These modules are named Find*.cmake, but are nothing that works in +# find_package(). +set(NO_FIND_MODULES "PackageHandleStandardArgs" "PackageMessage") + +foreach(FIND_MODULE ${FIND_MODULES}) + string(REGEX REPLACE ".*/Find(.*)\\.cmake$" "\\1" MODULE_NAME "${FIND_MODULE}") + + list(FIND NO_QT4_MODULES ${MODULE_NAME} NO_QT4_INDEX) + list(FIND NO_FIND_MODULES ${MODULE_NAME} NO_FIND_INDEX) + if (NO_QT4_INDEX EQUAL -1 AND NO_FIND_INDEX EQUAL -1) + do_find(${MODULE_NAME}) + endif () + +endforeach(FIND_MODULE) + +# Qt4 is not present, so we can check Qt3 +if (NOT QT4_FOUND) + set(DESIRED_QT_VERSION 3) + foreach(FIND_MODULE ${NO_QT4_MODULES} "Qt") + do_find(${FIND_MODULE}) + endforeach(FIND_MODULE) +endif (NOT QT4_FOUND) + +macro(check_version_string MODULE_NAME VERSION_VAR) + if (${MODULE_NAME}_FOUND) + if (DEFINED ${VERSION_VAR}) + message(STATUS "${VERSION_VAR}='${${VERSION_VAR}}'") + if (NOT ${VERSION_VAR} MATCHES "^[0-9]") + message(SEND_ERROR "unexpected: ${VERSION_VAR} does not begin with a decimal digit") + endif() + if ("${${VERSION_VAR}}" STREQUAL "") + message(SEND_ERROR "unexpected: ${VERSION_VAR} is empty") + endif() + if (${VERSION_VAR} VERSION_EQUAL 0) + message(SEND_ERROR "unexpected: ${VERSION_VAR} is VERSION_EQUAL 0") + endif() + if (NOT ${VERSION_VAR} VERSION_GREATER 0) + message(SEND_ERROR "unexpected: ${VERSION_VAR} is NOT VERSION_GREATER 0") + endif() + else() + message(SEND_ERROR "${MODULE_NAME}_FOUND is set but version number variable ${VERSION_VAR} is NOT DEFINED") + endif() + endif () +endmacro(check_version_string) + +# If any of these modules reported that it was found a version number should have been +# reported. + +foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HSPELL + JASPER LIBLZMA LIBXML2 LIBXSLT PERL PKG_CONFIG PostgreSQL TIFF ZLIB) + check_version_string(${VTEST} ${VTEST}_VERSION_STRING) +endforeach(VTEST) + +foreach(VTEST BISON Boost CUDA DOXYGEN FLEX GIF GTK2 LibArchive OPENSCENEGRAPH + RUBY SWIG) + check_version_string(${VTEST} ${VTEST}_VERSION) +endforeach(VTEST) + +check_version_string(PYTHONINTERP PYTHON_VERSION_STRING) +check_version_string(SUBVERSION Subversion_VERSION_SVN) diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt new file mode 100644 index 000000000..a1551ca03 --- /dev/null +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -0,0 +1,30 @@ +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Test.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake @ONLY) + +macro(add_CMakeOnly_test test) + add_test(CMakeOnly.${test} ${CMAKE_CMAKE_COMMAND} + -DTEST=${test} + -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake + ) +endmacro() + +add_CMakeOnly_test(LinkInterfaceLoop) +set_property(TEST CMakeOnly.LinkInterfaceLoop PROPERTY TIMEOUT 90) + +add_CMakeOnly_test(CheckSymbolExists) + +add_CMakeOnly_test(CheckCXXSymbolExists) + +add_CMakeOnly_test(CheckCXXCompilerFlag) + +add_CMakeOnly_test(CheckLanguage) + +add_CMakeOnly_test(AllFindModules) + +add_CMakeOnly_test(TargetScope) + +add_test(CMakeOnly.ProjectInclude ${CMAKE_CMAKE_COMMAND} + -DTEST=ProjectInclude + -DCMAKE_ARGS=-DCMAKE_PROJECT_ProjectInclude_INCLUDE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectInclude/include.cmake + -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake + ) diff --git a/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt new file mode 100644 index 000000000..e205330b0 --- /dev/null +++ b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt @@ -0,0 +1,58 @@ +cmake_minimum_required(VERSION 2.8) +project(CheckCXXCompilerFlag) + +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +set(CMAKE_VERBOSE_MAKEFILE 1) + +macro(TEST_FAIL value msg) + if (${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +macro(TEST_PASS value msg) + if (NOT ${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +if(CMAKE_COMPILER_IS_GNUCXX) + exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) + string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") + # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the + # patch level, handle this here: + if(NOT _gcc_version) + string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}") + endif() +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES Clang) + exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _clang_version_info) + string (REGEX REPLACE ".*version ([0-9]\\.[0-9]).*" "\\1" _clang_version "${_clang_version_info}") +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES Intel) + exec_program(${CMAKE_CXX_COMPILER} ARGS -V OUTPUT_VARIABLE _intel_version_info) + string (REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" "\\1" _intel_version "${_intel_version_info}") +endif() + +message("Platform:\n WIN32: ${WIN32}\n UNIX: ${UNIX}\n APPLE: ${APPLE}\n MINGW: ${MINGW}\n CYGWIN: ${CYGWIN}\n" + " MSVC: ${MSVC}\n MSVC60: ${MSVC60}\n MSVC70: ${MSVC70}\n MSVC71: ${MSVC71}\n MSVC80: ${MSVC80}\n MSVC90: ${MSVC90}\n MSVC10: ${MSVC10}\n" + " GCC: ${_gcc_version}\n" + " Clang: ${_clang_version}\n" + " Intel: ${_intel_version}\n" +) + +include(CheckCXXCompilerFlag) + +check_cxx_compiler_flag(-fvisibility=hidden HAS_HIDDEN_VISIBILITY) + +message("HAS_HIDDEN_VISIBILITY: ${HAS_HIDDEN_VISIBILITY}\n\nCOMPILE OUTPUT:\n${OUTPUT}") + +if(CMAKE_COMPILER_IS_GNUCXX) + if(NOT WIN32) +# test_pass(HAS_HIDDEN_VISIBILITY "GCC should support hidden visibility, but does not.") + endif() +else() + message("Unhandled Platform") +endif() diff --git a/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt b/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt new file mode 100644 index 000000000..1c978c181 --- /dev/null +++ b/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt @@ -0,0 +1,62 @@ +# This test will verify if CheckCXXSymbolExists only report symbols available +# for linking that really are. You can find some documentation on this in +# bug 11333 where we found out that gcc would optimize out the actual +# reference to the symbol, so symbols that are in fact _not_ available in the +# given libraries (but seen in header) were reported as present. +# +# If you change this test do not forget to change the CheckSymbolExists +# test, too. + +PROJECT(CheckCXXSymbolExists CXX) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) + +SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/../CheckSymbolExists") + +INCLUDE(CheckCXXSymbolExists) + +foreach(_config_type Release RelWithDebInfo MinSizeRel Debug) + set(CMAKE_TRY_COMPILE_CONFIGURATION ${_config_type}) + unset(CSE_RESULT_${_config_type} CACHE) + MESSAGE(STATUS "Testing configuration ${_config_type}") + check_cxx_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_${_config_type}) + + IF (CSE_RESULT_${_config_type}) + MESSAGE(SEND_ERROR "CheckCXXSymbolExists reported a nonexistent symbol as existing in configuration ${_config_type}") + ENDIF (CSE_RESULT_${_config_type}) +endforeach() + +set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE}) +unset(CSE_RESULT_ERRNO_CERRNO CACHE) + +MESSAGE(STATUS "Checking <cerrno>") + +check_cxx_symbol_exists(errno "cerrno" CSE_RESULT_ERRNO_CERRNO) + +IF (NOT CSE_RESULT_ERRNO_CERRNO) + unset(CSE_RESULT_ERRNO_ERRNOH CACHE) + + MESSAGE(STATUS "Checking <errno.h>") + + check_cxx_symbol_exists(errno "errno.h" CSE_RESULT_ERRNO_ERRNOH) + + IF (NOT CSE_RESULT_ERRNO_ERRNOH) + MESSAGE(SEND_ERROR "CheckCXXSymbolExists did not find errno in <cerrno> and <errno.h>") + ELSE (NOT CSE_RESULT_ERRNO_ERRNOH) + MESSAGE(STATUS "errno found in <errno.h>") + ENDIF (NOT CSE_RESULT_ERRNO_ERRNOH) +ELSE (NOT CSE_RESULT_ERRNO_CERRNO) + MESSAGE(STATUS "errno found in <cerrno>") +ENDIF (NOT CSE_RESULT_ERRNO_CERRNO) + +IF (CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") + unset(CSE_RESULT_O3 CACHE) + MESSAGE(STATUS "Testing with optimization -O3") + + check_cxx_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_O3) + + IF (CSE_RESULT_O3) + MESSAGE(SEND_ERROR "CheckCXXSymbolExists reported a nonexistent symbol as existing with optimization -O3") + ENDIF (CSE_RESULT_O3) +ENDIF (CMAKE_COMPILER_IS_GNUCXX) diff --git a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt new file mode 100644 index 000000000..f5336dc03 --- /dev/null +++ b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required (VERSION 2.8) +project(CheckLanguage NONE) +include(CheckLanguage) + +set(langs ) +set(expect_C 1) +set(expect_CXX 1) +unset(expect_Fortran) +set(expect_NoSuchLanguage 0) +foreach(lang C CXX Fortran NoSuchLanguage) + check_language(${lang}) + if(NOT DEFINED CMAKE_${lang}_COMPILER) + message(FATAL_ERROR "check_language(${lang}) did not set result") + endif() + if(DEFINED expect_${lang}) + if(expect_${lang} AND NOT CMAKE_${lang}_COMPILER) + message(FATAL_ERROR "check_language(${lang}) should not fail!") + elseif(NOT expect_${lang} AND CMAKE_${lang}_COMPILER) + message(FATAL_ERROR "check_language(${lang}) should not succeed!") + endif() + endif() +endforeach() diff --git a/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt b/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt new file mode 100644 index 000000000..7c969d3be --- /dev/null +++ b/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt @@ -0,0 +1,51 @@ +# This test will verify if CheckSymbolExists only report symbols available +# for linking that really are. You can find some documentation on this in +# bug 11333 where we found out that gcc would optimize out the actual +# reference to the symbol, so symbols that are in fact _not_ available in the +# given libraries (but seen in header) were reported as present. +# +# If you change this test do not forget to change the CheckCXXSymbolExists +# test, too. + +PROJECT(CheckSymbolExists C) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) + +SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}") + +INCLUDE(CheckSymbolExists) + +foreach(_config_type Release RelWithDebInfo MinSizeRel Debug) + set(CMAKE_TRY_COMPILE_CONFIGURATION ${_config_type}) + unset(CSE_RESULT_${_config_type} CACHE) + MESSAGE(STATUS "Testing configuration ${_config_type}") + + check_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_${_config_type}) + + IF (CSE_RESULT_${_config_type}) + MESSAGE(SEND_ERROR "CheckSymbolExists reported a nonexistent symbol as existing in configuration ${_config_type}") + ENDIF (CSE_RESULT_${_config_type}) +endforeach() + +set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE}) +unset(CSE_RESULT_ERRNO CACHE) + +check_symbol_exists(errno "errno.h" CSE_RESULT_ERRNO) + +IF (NOT CSE_RESULT_ERRNO) + MESSAGE(SEND_ERROR "CheckSymbolExists did not find errno in <errno.h>") +ELSE (NOT CSE_RESULT_ERRNO) + MESSAGE(STATUS "errno found as expected") +ENDIF (NOT CSE_RESULT_ERRNO) + +IF (CMAKE_COMPILER_IS_GNUCC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") + unset(CSE_RESULT_O3 CACHE) + MESSAGE(STATUS "Testing with optimization -O3") + + check_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_O3) + + IF (CSE_RESULT_O3) + MESSAGE(SEND_ERROR "CheckSymbolExists reported a nonexistent symbol as existing with optimization -O3") + ENDIF (CSE_RESULT_O3) +ENDIF (CMAKE_COMPILER_IS_GNUCC) diff --git a/Tests/CMakeOnly/CheckSymbolExists/cm_cse.h b/Tests/CMakeOnly/CheckSymbolExists/cm_cse.h new file mode 100644 index 000000000..4f41c7696 --- /dev/null +++ b/Tests/CMakeOnly/CheckSymbolExists/cm_cse.h @@ -0,0 +1,6 @@ +#ifndef _CSE_DUMMY_H +#define _CSE_DUMMY_H + +int non_existent_function_for_symbol_test(); + +#endif diff --git a/Tests/CMakeOnly/LinkInterfaceLoop/CMakeLists.txt b/Tests/CMakeOnly/LinkInterfaceLoop/CMakeLists.txt new file mode 100644 index 000000000..56e449afd --- /dev/null +++ b/Tests/CMakeOnly/LinkInterfaceLoop/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required (VERSION 2.8) +project(LinkInterfaceLoop C) + +# Add a shared library that incorrectly names itself as a +# dependency, thus forming a cycle. +add_library(A SHARED IMPORTED) +set_target_properties(A PROPERTIES + IMPORTED_LINK_DEPENDENT_LIBRARIES A + IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/dirA/A" + ) + +# Add a shared library that incorrectly names itself in +# its link interface, thus forming a cycle. +add_library(B SHARED IMPORTED) +set_target_properties(B PROPERTIES + IMPORTED_LINK_INTERFACE_LIBRARIES B + IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/dirB/B" + ) + +# Add a shared library with an empty link interface +# that depends on two shared libraries. +add_library(C SHARED lib.c) +set_property(TARGET C PROPERTY LINK_INTERFACE_LIBRARIES "") +target_link_libraries(C B A) + +add_executable(main main.c) +target_link_libraries(main C) diff --git a/Tests/CMakeOnly/LinkInterfaceLoop/lib.c b/Tests/CMakeOnly/LinkInterfaceLoop/lib.c new file mode 100644 index 000000000..fede1d61f --- /dev/null +++ b/Tests/CMakeOnly/LinkInterfaceLoop/lib.c @@ -0,0 +1 @@ +int lib(void) { return 0; } diff --git a/Tests/CMakeOnly/LinkInterfaceLoop/main.c b/Tests/CMakeOnly/LinkInterfaceLoop/main.c new file mode 100644 index 000000000..78f2de106 --- /dev/null +++ b/Tests/CMakeOnly/LinkInterfaceLoop/main.c @@ -0,0 +1 @@ +int main(void) { return 0; } diff --git a/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt b/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt new file mode 100644 index 000000000..a9abb4ad7 --- /dev/null +++ b/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt @@ -0,0 +1,4 @@ +project(ProjectInclude) +if(NOT AUTO_INCLUDE) + message(FATAL_ERROR "include file not found") +endif() diff --git a/Tests/CMakeOnly/ProjectInclude/include.cmake b/Tests/CMakeOnly/ProjectInclude/include.cmake new file mode 100644 index 000000000..527ebe7d0 --- /dev/null +++ b/Tests/CMakeOnly/ProjectInclude/include.cmake @@ -0,0 +1 @@ +set(AUTO_INCLUDE TRUE) diff --git a/Tests/CMakeOnly/TargetScope/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/CMakeLists.txt new file mode 100644 index 000000000..fa5d8e234 --- /dev/null +++ b/Tests/CMakeOnly/TargetScope/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 2.8) +project(TargetScope NONE) + +add_subdirectory(Sub) + +if(TARGET SubLibLocal) + message(FATAL_ERROR "SubLibLocal visible in top directory") +endif() +if(NOT TARGET SubLibGlobal) + message(FATAL_ERROR "SubLibGlobal not visible in top directory") +endif() + +add_subdirectory(Sib) diff --git a/Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt new file mode 100644 index 000000000..7f6f4e8fd --- /dev/null +++ b/Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt @@ -0,0 +1,6 @@ +if(TARGET SubLibLocal) + message(FATAL_ERROR "SubLibLocal visible in sibling directory") +endif() +if(NOT TARGET SubLibGlobal) + message(FATAL_ERROR "SubLibGlobal not visible in sibling directory") +endif() diff --git a/Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt new file mode 100644 index 000000000..27318f585 --- /dev/null +++ b/Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(SubLibLocal UNKNOWN IMPORTED) +add_library(SubLibGlobal UNKNOWN IMPORTED GLOBAL) +add_subdirectory(Sub) +if(NOT TARGET SubLibLocal) + message(FATAL_ERROR "SubLibLocal not visible in own directory") +endif() +if(NOT TARGET SubLibGlobal) + message(FATAL_ERROR "SubLibGlobal not visible in own directory") +endif() diff --git a/Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt new file mode 100644 index 000000000..a351daadf --- /dev/null +++ b/Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt @@ -0,0 +1,6 @@ +if(NOT TARGET SubLibLocal) + message(FATAL_ERROR "SubLibLocal not visible in subdirectory") +endif() +if(NOT TARGET SubLibGlobal) + message(FATAL_ERROR "SubLibGlobal not visible in subdirectory") +endif() diff --git a/Tests/CMakeOnly/Test.cmake.in b/Tests/CMakeOnly/Test.cmake.in new file mode 100644 index 000000000..42af06891 --- /dev/null +++ b/Tests/CMakeOnly/Test.cmake.in @@ -0,0 +1,13 @@ +set(source_dir "@CMAKE_CURRENT_SOURCE_DIR@/${TEST}") +set(binary_dir "@CMAKE_CURRENT_BINARY_DIR@/${TEST}-build") +file(REMOVE_RECURSE "${binary_dir}") +file(MAKE_DIRECTORY "${binary_dir}") +execute_process( + COMMAND ${CMAKE_COMMAND} ${CMAKE_ARGS} + "${source_dir}" -G "@CMAKE_TEST_GENERATOR@" + WORKING_DIRECTORY "${binary_dir}" + RESULT_VARIABLE result + ) +if(result) + message(FATAL_ERROR "CMake failed to configure ${TEST}") +endif() diff --git a/Tests/CMakeTestAllGenerators/RunCMake.cmake b/Tests/CMakeTestAllGenerators/RunCMake.cmake new file mode 100644 index 000000000..6d27d3be1 --- /dev/null +++ b/Tests/CMakeTestAllGenerators/RunCMake.cmake @@ -0,0 +1,117 @@ +if(NOT DEFINED CMake_SOURCE_DIR) + message(FATAL_ERROR "CMake_SOURCE_DIR not defined") +endif() + +if(NOT DEFINED dir) + message(FATAL_ERROR "dir not defined") +endif() + +# Analyze 'cmake --help' output for list of available generators: +# +execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${dir}) +execute_process(COMMAND ${CMAKE_COMMAND} --help + RESULT_VARIABLE result + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + WORKING_DIRECTORY ${dir}) + +string(REPLACE ";" "\\;" stdout "${stdout}") +string(REPLACE "\n" "E;" stdout "${stdout}") + +set(collecting 0) +set(generators) +foreach(eline ${stdout}) + string(REGEX REPLACE "^(.*)E$" "\\1" line "${eline}") + if(collecting AND NOT line STREQUAL "") + if(line MATCHES "=") + string(REGEX REPLACE "^ (.+)= (.*)$" "\\1" gen "${line}") + if(gen MATCHES "[A-Za-z]") + string(REGEX REPLACE "^(.*[^ ]) +$" "\\1" gen "${gen}") + if(gen) + set(generators ${generators} ${gen}) + endif() + endif() + else() + if(line MATCHES "^ [A-Za-z0-9]") + string(REGEX REPLACE "^ (.+)$" "\\1" gen "${line}") + string(REGEX REPLACE "^(.*[^ ]) +$" "\\1" gen "${gen}") + if(gen) + set(generators ${generators} ${gen}) + endif() + endif() + endif() + endif() + if(line STREQUAL "The following generators are available on this platform:") + set(collecting 1) + endif() +endforeach() + +# Also call with one non-existent generator: +# +set(generators ${generators} "BOGUS_CMAKE_GENERATOR") + +# Call cmake with -G on each available generator. We do not care if this +# succeeds or not. We expect it *not* to succeed if the underlying packaging +# tools are not installed on the system... This test is here simply to add +# coverage for the various cmake generators, even/especially to test ones +# where the tools are not installed. +# +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") + +message(STATUS "CMake generators='${generators}'") + +# If we'll be testing any of the MinGW Makefiles generators, adjust the +# ENV{PATH} to make sure libgmp-10.dll can be loaded as needed. But only if +# the testing machine has a default MinGW install... (If you have a +# non-default install, append to the PATH before running the test...) +# +if(generators MATCHES "MinGW Makefiles") + if(EXISTS "C:/MinGW/bin/libgmp-10.dll") + string(TOLOWER "$ENV{PATH}" path) + if(NOT path MATCHES "/mingw/bin") + if(UNIX) + set(sep ":") + set(mingw_bin "/mingw/bin") + else() + set(sep ";") + set(mingw_bin "C:/MinGW/bin") + endif() + set(ENV{PATH} "$ENV{PATH}${sep}${mingw_bin}") + message(STATUS "info: appending '${sep}${mingw_bin}' to the PATH") + endif() + endif() +endif() + +# First setup a source tree to run CMake on. +# +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMake_SOURCE_DIR}/Tests/CTestTest/SmallAndFast + ${dir}/Source +) + +foreach(g ${generators}) + message(STATUS "cmake -G \"${g}\" ..") + + # Create a binary directory for each generator: + # + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory + ${dir}/Source/${g} + ) + + # Run cmake: + # + execute_process(COMMAND ${CMAKE_COMMAND} -G ${g} .. + RESULT_VARIABLE result + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + WORKING_DIRECTORY ${dir}/Source/${g} + ) + + message(STATUS "result='${result}'") + message(STATUS "stdout='${stdout}'") + message(STATUS "stderr='${stderr}'") + message(STATUS "") +endforeach() + +message(STATUS "CMake generators='${generators}'") +message(STATUS "CMAKE_COMMAND='${CMAKE_COMMAND}'") diff --git a/Tests/CMakeTestBadCommandLines/RunCMake.cmake b/Tests/CMakeTestBadCommandLines/RunCMake.cmake new file mode 100644 index 000000000..08549cc5e --- /dev/null +++ b/Tests/CMakeTestBadCommandLines/RunCMake.cmake @@ -0,0 +1,79 @@ +if(NOT DEFINED CMake_SOURCE_DIR) + message(FATAL_ERROR "CMake_SOURCE_DIR not defined") +endif() + +if(NOT DEFINED dir) + message(FATAL_ERROR "dir not defined") +endif() + +if(NOT DEFINED gen) + message(FATAL_ERROR "gen not defined") +endif() + +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") + +# First setup a source tree to run CMake on. +# +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMake_SOURCE_DIR}/Tests/CTestTest/SmallAndFast + ${dir}/Source +) + +execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory + ${dir}/Build + ) + +function(RunCMakeWithArgs) + message(STATUS "info: running cmake with ARGN='${ARGN}'") + + execute_process(COMMAND ${CMAKE_COMMAND} ${ARGN} + RESULT_VARIABLE result + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + WORKING_DIRECTORY ${dir}/Build + ) + + message(STATUS "result='${result}'") + message(STATUS "stdout='${stdout}'") + message(STATUS "stderr='${stderr}'") + message(STATUS "") +endfunction() + +# Run cmake once with no errors to get a good build tree: +# +RunCMakeWithArgs(-G ${gen} ../Source) + +# Run cmake with args that produce some sort of problem to cover the error +# cases in cmake.cxx... +# +# (These are not good examples of cmake command lines. Do not copy and +# paste them elsewhere and expect them to work... See the cmake +# documentation or other real examples of usage instead.) +# +RunCMakeWithArgs() +RunCMakeWithArgs(-C) +RunCMakeWithArgs(-C nosuchcachefile.txt) +RunCMakeWithArgs(--check-stamp-file nostampfile) +RunCMakeWithArgs(--check-stamp-list nostamplist) +RunCMakeWithArgs(nosuchsubdir/CMakeCache.txt) +RunCMakeWithArgs(nosuchsubdir/CMakeLists.txt) +RunCMakeWithArgs(-D) +RunCMakeWithArgs(--debug-output .) +RunCMakeWithArgs(--debug-trycompile .) +RunCMakeWithArgs(-E) +RunCMakeWithArgs(-E create_symlink) +RunCMakeWithArgs(-E echo_append) +RunCMakeWithArgs(-E rename) +RunCMakeWithArgs(-E touch_nocreate) +RunCMakeWithArgs(-G) +RunCMakeWithArgs(--graphviz= ../Source) +RunCMakeWithArgs(--graphviz=g.dot .) +RunCMakeWithArgs(-P) +RunCMakeWithArgs(-P nosuchscriptfile.cmake) +RunCMakeWithArgs(--trace .) +RunCMakeWithArgs(-U) +RunCMakeWithArgs(-U nosuchvariable .) +RunCMakeWithArgs(-V) +RunCMakeWithArgs(-V .) +RunCMakeWithArgs(-Wno-dev .) +RunCMakeWithArgs(-Wdev .) diff --git a/Tests/CMakeTestMultipleConfigures/RunCMake.cmake b/Tests/CMakeTestMultipleConfigures/RunCMake.cmake new file mode 100644 index 000000000..19391d7f1 --- /dev/null +++ b/Tests/CMakeTestMultipleConfigures/RunCMake.cmake @@ -0,0 +1,165 @@ +if(NOT DEFINED CMake_SOURCE_DIR) + message(FATAL_ERROR "CMake_SOURCE_DIR not defined") +endif() + +if(NOT DEFINED dir) + message(FATAL_ERROR "dir not defined") +endif() + +if(NOT DEFINED gen) + message(FATAL_ERROR "gen not defined") +endif() + +# Call cmake once to get a baseline/reference output build tree: "Build". +# Then call cmake N more times, each time making a copy of the entire +# build tree after cmake is done configuring/generating. At the end, +# analyze the diffs in the generated build trees. Expect no diffs. +# +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") + +set(N 7) + +# First setup source and binary trees: +# +execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory + ${dir}/Source +) + +execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory + ${dir}/Build +) + +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMake_SOURCE_DIR}/Tests/CTestTest/SmallAndFast + ${dir}/Source +) + +execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory + ${dir}/Build +) + +# Patch SmallAndFast to build a .cxx executable too: +# +execute_process(COMMAND ${CMAKE_COMMAND} -E copy + ${dir}/Source/echoargs.c + ${dir}/Source/echoargs.cxx +) +file(APPEND "${dir}/Source/CMakeLists.txt" "\nadd_executable(echoargsCXX echoargs.cxx)\n") + +# Loop N times, saving a copy of the configured/generated build tree each time: +# +foreach(i RANGE 1 ${N}) + # Equivalent sequence of shell commands: + # + message(STATUS "${i}: cd Build && cmake -G \"${gen}\" ../Source && cd .. && cp -r Build b${i}") + + # Run cmake: + # + execute_process(COMMAND ${CMAKE_COMMAND} -G ${gen} ../Source + RESULT_VARIABLE result + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + WORKING_DIRECTORY ${dir}/Build + ) + + message(STATUS "result='${result}'") + message(STATUS "stdout='${stdout}'") + message(STATUS "stderr='${stderr}'") + message(STATUS "") + + # Save this iteration of the Build directory: + # + execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory + ${dir}/b${i} + ) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory + ${dir}/Build + ${dir}/b${i} + RESULT_VARIABLE result + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + ) + + message(STATUS "result='${result}'") + message(STATUS "stdout='${stdout}'") + message(STATUS "stderr='${stderr}'") + message(STATUS "") +endforeach() + + +# Function to analyze diffs between two directories. +# Set DIFF_EXECUTABLE before calling if 'diff' is available. +# +function(analyze_directory_diffs d1 d2 diff_count_var) + set(diffs 0) + + message(STATUS "Analyzing directory diffs between:") + message(STATUS " d1='${d1}'") + message(STATUS " d2='${d2}'") + + if(NOT "${d1}" STREQUAL "" AND NOT "${d2}" STREQUAL "") + message(STATUS "info: analyzing directories") + + file(GLOB_RECURSE files1 RELATIVE "${d1}" "${d1}/*") + file(GLOB_RECURSE files2 RELATIVE "${d2}" "${d2}/*") + + if("${files1}" STREQUAL "${files2}") + message(STATUS "info: file lists the same") + #message(STATUS " files='${files1}'") + + foreach(f ${files1}) + execute_process(COMMAND ${CMAKE_COMMAND} -E compare_files + ${d1}/${f} + ${d2}/${f} + RESULT_VARIABLE result + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + ) + if(result STREQUAL 0) + #message(STATUS "info: file '${f}' the same") + else() + math(EXPR diffs "${diffs} + 1") + message(STATUS "warning: file '${f}' differs from d1 to d2") + file(READ "${d1}/${f}" f1contents) + message(STATUS "contents of file '${d1}/${f}' +[===[${f1contents}]===]") + file(READ "${d2}/${f}" f2contents) + message(STATUS "contents of file '${d2}/${f}' +[===[${f2contents}]===]") + if(DIFF_EXECUTABLE) + message(STATUS "diff of files '${d1}/${f}' '${d2}/${f}'") + message(STATUS "[====[") + execute_process(COMMAND ${DIFF_EXECUTABLE} "${d1}/${f}" "${d2}/${f}") + message(STATUS "]====]") + endif() + endif() + endforeach() + else() + math(EXPR diffs "${diffs} + 1") + message(STATUS "warning: file *lists* differ - some files exist in d1/not-d2 or not-d1/d2...") + message(STATUS " files1='${files1}'") + message(STATUS " files2='${files2}'") + endif() + endif() + + set(${diff_count_var} ${diffs} PARENT_SCOPE) +endfunction(analyze_directory_diffs) + + +# Analyze diffs between b1:b2, b2:b3, b3:b4, b4:b5 ... bN-1:bN. +# Expect no diffs. +# +find_program(DIFF_EXECUTABLE diff) +set(total_diffs 0) + +foreach(i RANGE 2 ${N}) + math(EXPR prev "${i} - 1") + set(count 0) + analyze_directory_diffs(${dir}/b${prev} ${dir}/b${i} count) + message(STATUS "diff count='${count}'") + message(STATUS "") + math(EXPR total_diffs "${total_diffs} + ${count}") +endforeach() + +message(STATUS "CMAKE_COMMAND='${CMAKE_COMMAND}'") +message(STATUS "total_diffs='${total_diffs}'") 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 */ diff --git a/Tests/CMakeWizardTest.cmake b/Tests/CMakeWizardTest.cmake new file mode 100644 index 000000000..bcae8afeb --- /dev/null +++ b/Tests/CMakeWizardTest.cmake @@ -0,0 +1,52 @@ +message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") + +message(STATUS "build_dir='${build_dir}'") + +message(STATUS "source_dir='${source_dir}'") + + +execute_process(COMMAND ${CMAKE_COMMAND} -E + remove_directory ${build_dir} + TIMEOUT 5) + +execute_process(COMMAND ${CMAKE_COMMAND} -E + make_directory ${build_dir} + TIMEOUT 5) + +execute_process(COMMAND ${CMAKE_COMMAND} -E + copy_directory ${source_dir} ${build_dir}/src + TIMEOUT 5) + +execute_process(COMMAND ${CMAKE_COMMAND} -E + make_directory ${build_dir}/build + TIMEOUT 5) + +# This is enough to answer 32 questions with "the default answer is ok"... +# +file(WRITE ${build_dir}/input.txt + "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n") + + +message(STATUS "running wizard mode (cmake -i)...") + +execute_process(COMMAND ${CMAKE_COMMAND} -i ../src + INPUT_FILE ${build_dir}/input.txt + WORKING_DIRECTORY ${build_dir}/build + TIMEOUT 5 + ) + + +message(STATUS "building...") + +execute_process(COMMAND ${CMAKE_COMMAND} --build . + WORKING_DIRECTORY ${build_dir}/build + TIMEOUT 5 + ) + + +message(STATUS "testing...") + +execute_process(COMMAND ${CMAKE_CTEST_COMMAND} + WORKING_DIRECTORY ${build_dir}/build + TIMEOUT 5 + ) diff --git a/Tests/COnly/CMakeLists.txt b/Tests/COnly/CMakeLists.txt new file mode 100644 index 000000000..5ef0f1eea --- /dev/null +++ b/Tests/COnly/CMakeLists.txt @@ -0,0 +1,23 @@ +# a simple C only test case +cmake_minimum_required (VERSION 2.6) +project (COnly C) + +set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") +add_library(testc1 STATIC libc1.c) +add_library(testc2 SHARED libc2.c) +add_executable (COnly conly.c foo.c foo.h) +target_link_libraries(COnly testc1 testc2) +if(MSVC_VERSION) + set_target_properties(COnly PROPERTIES + LINK_FLAGS " /NODEFAULTLIB:\"libcdg.lib\" /NODEFAULTLIB:\"libcmtg.lib\" /NODEFAULTLIB:\"foomsvcrt.lib\" /NODEFAULTLIB:\"libbar.lib\" /NODEFAULTLIB:\"libfooba.lib\"") +endif(MSVC_VERSION) +string(ASCII 35 32 67 77 97 107 101 ASCII_STRING) +message(STATUS "String: ${ASCII_STRING}") +get_source_file_property(LANG conly.c LANGUAGE) +if("${LANG}" STREQUAL "C") + message("Language is C") +else("${LANG}" STREQUAL "C") + message(FATAL_ERROR "Bad language for file conly.c") +endif("${LANG}" STREQUAL "C") + +add_library(testCModule MODULE testCModule.c) diff --git a/Tests/COnly/conly.c b/Tests/COnly/conly.c new file mode 100644 index 000000000..7214fe1bc --- /dev/null +++ b/Tests/COnly/conly.c @@ -0,0 +1,23 @@ +#include "foo.h" + +#include "libc1.h" +#include "libc2.h" + +#include <stdio.h> + +int main () +{ + int class = 0; + if ( LibC1Func() != 2.0 ) + { + printf("Problem with libc1\n"); + return 1; + } + if ( LibC2Func() != 1.0 ) + { + printf("Problem with libc2\n"); + return 1; + } + printf("Foo: %s %d\n", foo, class); + return 0; +} diff --git a/Tests/COnly/foo.c b/Tests/COnly/foo.c new file mode 100644 index 000000000..e4faf38a3 --- /dev/null +++ b/Tests/COnly/foo.c @@ -0,0 +1 @@ +char* foo = "Foo"; diff --git a/Tests/COnly/foo.h b/Tests/COnly/foo.h new file mode 100644 index 000000000..ad4a9af0f --- /dev/null +++ b/Tests/COnly/foo.h @@ -0,0 +1 @@ +extern char* foo; diff --git a/Tests/COnly/libc1.c b/Tests/COnly/libc1.c new file mode 100644 index 000000000..b01e1e1b5 --- /dev/null +++ b/Tests/COnly/libc1.c @@ -0,0 +1,4 @@ +float LibC1Func() +{ + return 2.0; +} diff --git a/Tests/COnly/libc1.h b/Tests/COnly/libc1.h new file mode 100644 index 000000000..84c94a9cb --- /dev/null +++ b/Tests/COnly/libc1.h @@ -0,0 +1 @@ +extern float LibC1Func(); diff --git a/Tests/COnly/libc2.c b/Tests/COnly/libc2.c new file mode 100644 index 000000000..0fd895664 --- /dev/null +++ b/Tests/COnly/libc2.c @@ -0,0 +1,6 @@ +#include "libc2.h" + +float LibC2Func() +{ + return 1.0; +} diff --git a/Tests/COnly/libc2.h b/Tests/COnly/libc2.h new file mode 100644 index 000000000..a99d8984e --- /dev/null +++ b/Tests/COnly/libc2.h @@ -0,0 +1,11 @@ +#ifdef _WIN32 +# ifdef testc2_EXPORTS +# define CM_TEST_LIB_EXPORT __declspec( dllexport ) +# else +# define CM_TEST_LIB_EXPORT __declspec( dllimport ) +# endif +#else +# define CM_TEST_LIB_EXPORT +#endif + +CM_TEST_LIB_EXPORT float LibC2Func(); diff --git a/Tests/COnly/testCModule.c b/Tests/COnly/testCModule.c new file mode 100644 index 000000000..1a89292b3 --- /dev/null +++ b/Tests/COnly/testCModule.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +# define TEST_EXPORT __declspec(dllexport) +#else +# define TEST_EXPORT +#endif +TEST_EXPORT int testCModule(void) { return 0; } diff --git a/Tests/CPackComponents/CMakeLists.txt b/Tests/CPackComponents/CMakeLists.txt new file mode 100644 index 000000000..58f5bdffe --- /dev/null +++ b/Tests/CPackComponents/CMakeLists.txt @@ -0,0 +1,128 @@ +# CPack Example: User-selectable Installation Components +# +# In this example, we have a simple library (mylib) with an example +# application (mylibapp). We create a binary installer that allows +# users to select which pieces will be installed: the example +# application, the library binaries, and/or the header file. +cmake_minimum_required(VERSION 2.6) +project(CPackComponents) + +# Create the mylib library +add_library(mylib mylib.cpp) + +# Create the mylibapp application +add_executable(mylibapp mylibapp.cpp) +target_link_libraries(mylibapp mylib) + +# On Linux, enable using an absolute install path to verify that +# CMAKE_INSTALL_PREFIX and CPACK_SET_DESTDIR interact properly. +# +# But only use absolute paths if not targeting an NSIS installer +# as indicated by CPACK_BINARY_NSIS. (If we allow this, the test +# fails on Linux machines with makensis installed when we are not +# cross-compiling...) +# +if(UNIX AND NOT APPLE) + if(NOT CPACK_BINARY_NSIS) + set(mylib_install_to_absolute_path ON) + endif() +endif() + +if(mylib_install_to_absolute_path) + set(CMAKE_INSTALL_PREFIX "/opt/mylib") + set(CPACK_SET_DESTDIR ON) +endif() + +# Create installation targets. Note that we put each kind of file +# into a different component via COMPONENT. These components will +# be used to create the installation components. +install(TARGETS mylib + ARCHIVE + DESTINATION lib + COMPONENT libraries) +install(TARGETS mylibapp + RUNTIME + DESTINATION bin + COMPONENT applications) +install(FILES mylib.h + DESTINATION include + COMPONENT headers) +install(FILES "Issue 7470.html" + DESTINATION docs + COMPONENT documentation) + +if(mylib_install_to_absolute_path) + install(FILES mylib.cpp + DESTINATION /opt/mylib-source + COMPONENT source) +endif() + +# CPack boilerplate for this project +set(CPACK_PACKAGE_NAME "MyLib") +set(CPACK_PACKAGE_VENDOR "CMake.org") +set(CPACK_PACKAGE_CONTACT "somebody@cmake.org") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyLib - CPack Component Installation Example") +set(CPACK_PACKAGE_VERSION "1.0.0") +set(CPACK_PACKAGE_VERSION_MAJOR "1") +set(CPACK_PACKAGE_VERSION_MINOR "0") +set(CPACK_PACKAGE_VERSION_PATCH "0") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example") + +# Settings used when building NSIS installers +set(CPACK_NSIS_MENU_LINKS + "ftp://ftpserver" "Test Ftp Link" + "ftps://ftpsserver" "Test Ftps Link" + "http://www.cmake.org" "CMake Web Site" + "https://github.com/" "Test Https Link" + "mailto:kitware@kitware.com" "Test MailTo Link" + "news://newsserver" "Test News Link" + ) + +# Suggested default root for end users of the installer: +set(CPACK_NSIS_INSTALL_ROOT "C:\\Program Files\\CMake Tests Install Root") + +# Include CPack to introduce the appropriate targets +include(CPack) + +# Installation types +cpack_add_install_type(Full + DISPLAY_NAME "Everything") +cpack_add_install_type(Developer) + +# Component groups +cpack_add_component_group(Runtime) +cpack_add_component_group(Development + EXPANDED + DESCRIPTION "All of the tools you'll ever need to develop software") + +# Components +cpack_add_component(applications + DISPLAY_NAME "MyLib Application" + DESCRIPTION "An extremely useful application that makes use of MyLib" + GROUP Runtime + INSTALL_TYPES Full) +cpack_add_component(documentation + DISPLAY_NAME "MyLib Documentation" + DESCRIPTION "The extensive suite of MyLib Application documentation files" + GROUP Runtime + INSTALL_TYPES Full) +cpack_add_component(libraries + DISPLAY_NAME "Libraries" + DESCRIPTION "Static libraries used to build programs with MyLib" + GROUP Development + INSTALL_TYPES Developer Full) +cpack_add_component(headers + DISPLAY_NAME "C++ Headers" + DESCRIPTION "C/C++ header files for use with MyLib" + GROUP Development + DEPENDS libraries + INSTALL_TYPES Developer Full) + +if(mylib_install_to_absolute_path) + cpack_add_component(source + DISPLAY_NAME "C++ Source Files" + DESCRIPTION "C/C++ source files to build MyLib" + GROUP Development + DEPENDS libraries + INSTALL_TYPES Developer Full) +endif() diff --git a/Tests/CPackComponents/Issue 7470.html b/Tests/CPackComponents/Issue 7470.html new file mode 100644 index 000000000..12df2c87d --- /dev/null +++ b/Tests/CPackComponents/Issue 7470.html @@ -0,0 +1,9 @@ +<html> +<body> +The install rule for this file demonstrates the problem described in<br/> +CMake issue #7470:<br/> +<br/> +<a href="http://public.kitware.com/Bug/view.php?id=7470"> +http://public.kitware.com/Bug/view.php?id=7470</a><br/> +</body> +</html> diff --git a/Tests/CPackComponents/VerifyResult.cmake b/Tests/CPackComponents/VerifyResult.cmake new file mode 100644 index 000000000..850ec0022 --- /dev/null +++ b/Tests/CPackComponents/VerifyResult.cmake @@ -0,0 +1,48 @@ +message(STATUS "=============================================================================") +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +message(STATUS "") + +if(NOT CPackComponents_BINARY_DIR) + message(FATAL_ERROR "CPackComponents_BINARY_DIR not set") +endif(NOT CPackComponents_BINARY_DIR) + +set(expected_file_mask "") + +if(WIN32) + # Only expect the *.exe installer if it looks like NSIS is + # installed on this machine: + # + find_program(NSIS_MAKENSIS_EXECUTABLE NAMES makensis + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS] + DOC "makensis.exe location" + ) + if(NSIS_MAKENSIS_EXECUTABLE) + set(expected_file_mask "${CPackComponents_BINARY_DIR}/MyLib-*.exe") + endif(NSIS_MAKENSIS_EXECUTABLE) +endif(WIN32) + +if(APPLE) + # Always expect the *.dmg installer - PackageMaker should always + # be installed on a development Mac: + # + set(expected_file_mask "${CPackComponents_BINARY_DIR}/MyLib-*.dmg") +endif(APPLE) + +if(expected_file_mask) + set(expected_count 1) + file(GLOB expected_file "${expected_file_mask}") + + message(STATUS "expected_count='${expected_count}'") + message(STATUS "expected_file='${expected_file}'") + message(STATUS "expected_file_mask='${expected_file_mask}'") + + if(NOT expected_file) + message(FATAL_ERROR "error: expected_file does not exist: CPackComponents test fails.") + endif(NOT expected_file) + + list(LENGTH expected_file actual_count) + message(STATUS "actual_count='${actual_count}'") + if(NOT actual_count EQUAL expected_count) + message(FATAL_ERROR "error: expected_count does not match actual_count: CPackComponents test fails.") + endif(NOT actual_count EQUAL expected_count) +endif(expected_file_mask) diff --git a/Tests/CPackComponents/mylib.cpp b/Tests/CPackComponents/mylib.cpp new file mode 100644 index 000000000..8ddac198c --- /dev/null +++ b/Tests/CPackComponents/mylib.cpp @@ -0,0 +1,7 @@ +#include "mylib.h" +#include "stdio.h" + +void mylib_function() +{ + printf("This is mylib"); +} diff --git a/Tests/CPackComponents/mylib.h b/Tests/CPackComponents/mylib.h new file mode 100644 index 000000000..5d0a822db --- /dev/null +++ b/Tests/CPackComponents/mylib.h @@ -0,0 +1 @@ +void mylib_function(); diff --git a/Tests/CPackComponents/mylibapp.cpp b/Tests/CPackComponents/mylibapp.cpp new file mode 100644 index 000000000..a438ac77f --- /dev/null +++ b/Tests/CPackComponents/mylibapp.cpp @@ -0,0 +1,6 @@ +#include "mylib.h" + +int main() +{ + mylib_function(); +} diff --git a/Tests/CPackComponentsForAll/CMakeLists.txt b/Tests/CPackComponentsForAll/CMakeLists.txt new file mode 100644 index 000000000..5449d09dc --- /dev/null +++ b/Tests/CPackComponentsForAll/CMakeLists.txt @@ -0,0 +1,123 @@ +# CPack Example: User-selectable Installation Components +# +# In this example, we have a simple library (mylib) with an example +# application (mylibapp). We create a binary installer (a CPack Generator) +# which supports CPack components. +# +# Depending on the CPack generator and on some CPACK_xxx var values +# the generator may produce a single (NSIS, PackageMaker) +# or several package files (Archive Generators, RPM, DEB) +cmake_minimum_required(VERSION 2.8.3.20101130 FATAL_ERROR) +project(CPackComponentsForAll) + +# Use GNUInstallDirs in order to enforce lib64 if needed +include(GNUInstallDirs) + +# Create the mylib library +add_library(mylib mylib.cpp) + +# Create the mylibapp application +add_executable(mylibapp mylibapp.cpp) +target_link_libraries(mylibapp mylib) + +# Duplicate of mylibapp application +# which won't be put in any component (?mistake?) +add_executable(mylibapp2 mylibapp.cpp) +target_link_libraries(mylibapp2 mylib) + +# Create installation targets. Note that we put each kind of file +# into a different component via COMPONENT. These components will +# be used to create the installation components. +install(TARGETS mylib + ARCHIVE + DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT libraries) +install(TARGETS mylibapp + RUNTIME + DESTINATION bin + COMPONENT applications) + +# This application does not belong to any component +# thus (as of cmake 2.8.2) it will be left "uninstalled" +# by a component-aware installer unless a +# CPACK_MONOLITHIC_INSTALL=1 is set (at cmake time). +install(TARGETS mylibapp2 + RUNTIME + DESTINATION bin) + +install(FILES mylib.h + DESTINATION include + COMPONENT headers) + +# CPack boilerplate for this project +set(CPACK_PACKAGE_NAME "MyLib") +set(CPACK_PACKAGE_CONTACT "None") +set(CPACK_PACKAGE_VENDOR "CMake.org") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyLib - CPack Component Installation Example") +set(CPACK_PACKAGE_VERSION "1.0.2") +set(CPACK_PACKAGE_VERSION_MAJOR "1") +set(CPACK_PACKAGE_VERSION_MINOR "0") +set(CPACK_PACKAGE_VERSION_PATCH "2") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example") + +# Tell CPack all of the components to install. The "ALL" +# refers to the fact that this is the set of components that +# will be included when CPack is instructed to put everything +# into the binary installer (the default behavior). +set(CPACK_COMPONENTS_ALL applications libraries headers Unspecified) + +# Set the displayed names for each of the components to install. +# These will be displayed in the list of components inside the installer. +set(CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "MyLib Application") +set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") +set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers") + +# Provide descriptions for each of the components to install. +# When the user hovers the mouse over the name of a component, +# the description will be shown in the "Description" box in the +# installer. If no descriptions are provided, the "Description" +# box will be removed. +set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION + "An extremely useful application that makes use of MyLib") +set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION + "Static libraries used to build programs with MyLib") +set(CPACK_COMPONENT_HEADERS_DESCRIPTION + "C/C++ header files for use with MyLib") + +# Put the components into two different groups: "Runtime" and "Development" +set(CPACK_COMPONENT_APPLICATIONS_GROUP "Runtime") +set(CPACK_COMPONENT_LIBRARIES_GROUP "Development") +set(CPACK_COMPONENT_HEADERS_GROUP "Development") + +# Expand the "Development" group by default, since we have so few components. +# Also, provide this group with a description. +set(CPACK_COMPONENT_GROUP_DEVELOPMENT_EXPANDED ON) +set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION + "All of the tools you'll ever need to develop software") + +# It doesn't make sense to install the headers without the libraries +# (because you could never use the headers!), so make the headers component +# depend on the libraries component. +set(CPACK_COMPONENT_HEADERS_DEPENDS libraries) + +# Create two installation types with pre-selected components. +# The "Developer" installation has just the library and headers, +# while the "Full" installation has everything. +set(CPACK_ALL_INSTALL_TYPES Full Developer) +set(CPACK_INSTALL_TYPE_FULL_DISPLAY_NAME "Everything") +set(CPACK_COMPONENT_LIBRARIES_INSTALL_TYPES Developer Full) +set(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full) +set(CPACK_COMPONENT_APPLICATIONS_INSTALL_TYPES Full) + +# We may use the CPack specific config file in order +# to tailor CPack behavior on a CPack generator specific way +# (Behavior would be different for RPM or TGZ or DEB ...) +if (NOT ("${CPackComponentWay}" STREQUAL "default")) + # Setup project specific CPack-time CPack Config file. + configure_file(${CPackComponentsForAll_SOURCE_DIR}/MyLibCPackConfig-${CPackComponentWay}.cmake.in + ${CPackComponentsForAll_BINARY_DIR}/MyLibCPackConfig-${CPackComponentWay}.cmake + @ONLY) + set(CPACK_PROJECT_CONFIG_FILE ${CPackComponentsForAll_BINARY_DIR}/MyLibCPackConfig-${CPackComponentWay}.cmake) +endif (NOT ("${CPackComponentWay}" STREQUAL "default")) +# Include CPack to introduce the appropriate targets +include(CPack)
\ No newline at end of file diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in new file mode 100644 index 000000000..1d203c8d8 --- /dev/null +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in @@ -0,0 +1,22 @@ +# +# Activate component packaging +# +if(CPACK_GENERATOR MATCHES "ZIP") + set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") +endif(CPACK_GENERATOR MATCHES "ZIP") + +if(CPACK_GENERATOR MATCHES "RPM") + set(CPACK_RPM_COMPONENT_INSTALL "ON") +endif(CPACK_GENERATOR MATCHES "RPM") + +if(CPACK_GENERATOR MATCHES "DEB") + set(CPACK_DEB_COMPONENT_INSTALL "ON") +endif(CPACK_GENERATOR MATCHES "DEB") + +# +# Choose grouping way +# +#set(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE 1) +#set(CPACK_COMPONENTS_GROUPING) +#set(CPACK_COMPONENTS_IGNORE_GROUPS 1) +set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1) diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in new file mode 100644 index 000000000..9444a1473 --- /dev/null +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in @@ -0,0 +1,23 @@ +# +# Activate component packaging +# +if(CPACK_GENERATOR MATCHES "ZIP") + set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") +endif(CPACK_GENERATOR MATCHES "ZIP") + +if(CPACK_GENERATOR MATCHES "RPM") + set(CPACK_RPM_COMPONENT_INSTALL "ON") + set(CPACK_RPM_applications_PACKAGE_REQUIRES "mylib-libraries") +endif(CPACK_GENERATOR MATCHES "RPM") + +if(CPACK_GENERATOR MATCHES "DEB") + set(CPACK_DEB_COMPONENT_INSTALL "ON") +endif(CPACK_GENERATOR MATCHES "DEB") + +# +# Choose grouping way +# +#set(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE) +#set(CPACK_COMPONENTS_GROUPING) +set(CPACK_COMPONENTS_IGNORE_GROUPS 1) +#set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
\ No newline at end of file diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in new file mode 100644 index 000000000..2d251b363 --- /dev/null +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in @@ -0,0 +1,27 @@ +# +# Activate component packaging +# +if(CPACK_GENERATOR MATCHES "ZIP") + set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") +endif(CPACK_GENERATOR MATCHES "ZIP") + +if(CPACK_GENERATOR MATCHES "RPM") + set(CPACK_RPM_COMPONENT_INSTALL "ON") + set(CPACK_RPM_Development_PACKAGE_REQUIRES "mylib-Runtime") +endif(CPACK_GENERATOR MATCHES "RPM") + +if(CPACK_GENERATOR MATCHES "DEB") + set(CPACK_DEB_COMPONENT_INSTALL "ON") +endif(CPACK_GENERATOR MATCHES "DEB") + +if(CPACK_GENERATOR MATCHES "DragNDrop") + set(CPACK_COMPONENTS_GROUPING "ONE_PER_GROUP") +endif(CPACK_GENERATOR MATCHES "DragNDrop") + +# +# Choose grouping way +# +#set(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE) +#set(CPACK_COMPONENTS_GROUPING) +#set(CPACK_COMPONENTS_IGNORE_GROUPS) +#set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE) diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake new file mode 100644 index 000000000..e2d343d9f --- /dev/null +++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake @@ -0,0 +1,126 @@ +message(STATUS "=============================================================================") +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +message(STATUS "") + +if(NOT CPackComponentsForAll_BINARY_DIR) + message(FATAL_ERROR "CPackComponentsForAll_BINARY_DIR not set") +endif(NOT CPackComponentsForAll_BINARY_DIR) + +if(NOT CPackGen) + message(FATAL_ERROR "CPackGen not set") +endif(NOT CPackGen) +get_filename_component(CPACK_LOCATION ${CMAKE_COMMAND} PATH) +set(CPackCommand "${CPACK_LOCATION}/cpack") +message("cpack = ${CPackCommand}") +if(NOT CPackCommand) + message(FATAL_ERROR "CPackCommand not set") +endif(NOT CPackCommand) + +if(NOT CPackComponentWay) + message(FATAL_ERROR "CPackComponentWay not set") +endif(NOT CPackComponentWay) + +set(expected_file_mask "") +# The usual default behavior is to expect a single file +# Then some specific generators (Archive, RPM, ...) +# May produce several numbers of files depending on +# CPACK_COMPONENT_xxx values +set(expected_count 1) +set(config_type $ENV{CMAKE_CONFIG_TYPE}) +set(config_args ) +if(config_type) + set(config_args -C ${config_type}) +endif(config_type) +set(config_verbose ) + +if(CPackGen MATCHES "ZIP") + set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip") + if (${CPackComponentWay} STREQUAL "default") + set(expected_count 1) + elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + set(expected_count 3) + elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + set(expected_count 4) + elseif (${CPackComponentWay} STREQUAL "AllInOne") + set(expected_count 1) + endif () +elseif (CPackGen MATCHES "RPM") + set(config_verbose -D "CPACK_RPM_PACKAGE_DEBUG=1") + set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.rpm") + if (${CPackComponentWay} STREQUAL "default") + set(expected_count 1) + elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + set(expected_count 3) + elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + set(expected_count 4) + elseif (${CPackComponentWay} STREQUAL "AllInOne") + set(expected_count 1) + endif () +elseif (CPackGen MATCHES "DEB") + set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.deb") + if (${CPackComponentWay} STREQUAL "default") + set(expected_count 1) + elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + set(expected_count 3) + elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + set(expected_count 4) + elseif (${CPackComponentWay} STREQUAL "AllInOne") + set(expected_count 1) + endif () +endif() + +if(CPackGen MATCHES "DragNDrop") + set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.dmg") + if (${CPackComponentWay} STREQUAL "default") + set(expected_count 1) + elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + set(expected_count 3) + elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + set(expected_count 4) + elseif (${CPackComponentWay} STREQUAL "AllInOne") + set(expected_count 1) + endif () +endif(CPackGen MATCHES "DragNDrop") + +# clean-up previously CPack generated files +if(expected_file_mask) + file(GLOB expected_file "${expected_file_mask}") + if (expected_file) + file(REMOVE ${expected_file}) + endif(expected_file) +endif(expected_file_mask) + +message("config_args = ${config_args}") +message("config_verbose = ${config_verbose}") +execute_process(COMMAND ${CPackCommand} ${config_verbose} -G ${CPackGen} ${config_args} + RESULT_VARIABLE CPack_result + OUTPUT_VARIABLE CPack_output + ERROR_VARIABLE CPack_error + WORKING_DIRECTORY ${CPackComponentsForAll_BINARY_DIR}) + +if (CPack_result) + message(FATAL_ERROR "error: CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}") +else (CPack_result) + message(STATUS "CPack_output=${CPack_output}") +endif(CPack_result) + +# Now verify if the number of expected file is OK +# - using expected_file_mask and +# - expected_count +if(expected_file_mask) + file(GLOB expected_file "${expected_file_mask}") + + message(STATUS "expected_count='${expected_count}'") + message(STATUS "expected_file='${expected_file}'") + message(STATUS "expected_file_mask='${expected_file_mask}'") + + if(NOT expected_file) + message(FATAL_ERROR "error: expected_file=${expected_file} does not exist: CPackComponentsForAll test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}") + endif(NOT expected_file) + + list(LENGTH expected_file actual_count) + message(STATUS "actual_count='${actual_count}'") + if(NOT actual_count EQUAL expected_count) + message(FATAL_ERROR "error: expected_count=${expected_count} does not match actual_count=${actual_count}: CPackComponents test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error})") + endif(NOT actual_count EQUAL expected_count) +endif(expected_file_mask) diff --git a/Tests/CPackComponentsForAll/mylib.cpp b/Tests/CPackComponentsForAll/mylib.cpp new file mode 100644 index 000000000..8ddac198c --- /dev/null +++ b/Tests/CPackComponentsForAll/mylib.cpp @@ -0,0 +1,7 @@ +#include "mylib.h" +#include "stdio.h" + +void mylib_function() +{ + printf("This is mylib"); +} diff --git a/Tests/CPackComponentsForAll/mylib.h b/Tests/CPackComponentsForAll/mylib.h new file mode 100644 index 000000000..5d0a822db --- /dev/null +++ b/Tests/CPackComponentsForAll/mylib.h @@ -0,0 +1 @@ +void mylib_function(); diff --git a/Tests/CPackComponentsForAll/mylibapp.cpp b/Tests/CPackComponentsForAll/mylibapp.cpp new file mode 100644 index 000000000..a438ac77f --- /dev/null +++ b/Tests/CPackComponentsForAll/mylibapp.cpp @@ -0,0 +1,6 @@ +#include "mylib.h" + +int main() +{ + mylib_function(); +} diff --git a/Tests/CPackTestAllGenerators/CMakeLists.txt b/Tests/CPackTestAllGenerators/CMakeLists.txt new file mode 100644 index 000000000..5eeb7e90b --- /dev/null +++ b/Tests/CPackTestAllGenerators/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8) +project(CPackTestAllGenerators) +add_subdirectory(../CTestTest/SmallAndFast SmallAndFast) +install(FILES RunCPack.cmake DESTINATION .) +include(CPack) diff --git a/Tests/CPackTestAllGenerators/RunCPack.cmake b/Tests/CPackTestAllGenerators/RunCPack.cmake new file mode 100644 index 000000000..e0c241ec4 --- /dev/null +++ b/Tests/CPackTestAllGenerators/RunCPack.cmake @@ -0,0 +1,55 @@ +if(NOT DEFINED cpack) + message(FATAL_ERROR "cpack not defined") +endif() + +if(NOT DEFINED dir) + message(FATAL_ERROR "dir not defined") +endif() + +# Analyze 'cpack --help' output for list of available generators: +# +execute_process(COMMAND ${cpack} --help + RESULT_VARIABLE result + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + WORKING_DIRECTORY ${dir}) + +string(REPLACE ";" "\\;" stdout "${stdout}") +string(REPLACE "\n" "E;" stdout "${stdout}") + +set(collecting 0) +set(generators) +foreach(eline ${stdout}) + string(REGEX REPLACE "^(.*)E$" "\\1" line "${eline}") + if(collecting AND NOT line STREQUAL "") + string(REGEX REPLACE "^ ([^ ]+) += (.*)$" "\\1" gen "${line}") + string(REGEX REPLACE "^ ([^ ]+) += (.*)$" "\\2" doc "${line}") + set(generators ${generators} ${gen}) + endif() + if(line STREQUAL "Generators") + set(collecting 1) + endif() +endforeach() + +# Call cpack with -G on each available generator. We do not care if this +# succeeds or not. We expect it *not* to succeed if the underlying packaging +# tools are not installed on the system... This test is here simply to add +# coverage for the various cpack generators, even/especially to test ones +# where the tools are not installed. +# +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") + +message(STATUS "CPack generators='${generators}'") + +foreach(g ${generators}) + message(STATUS "Calling cpack -G ${g}...") + execute_process(COMMAND ${cpack} -G ${g} + RESULT_VARIABLE result + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + WORKING_DIRECTORY ${dir}) + message(STATUS "result='${result}'") + message(STATUS "stdout='${stdout}'") + message(STATUS "stderr='${stderr}'") + message(STATUS "") +endforeach() diff --git a/Tests/CTestConfig/CMakeLists.txt b/Tests/CTestConfig/CMakeLists.txt new file mode 100644 index 000000000..f46d89a55 --- /dev/null +++ b/Tests/CTestConfig/CMakeLists.txt @@ -0,0 +1,47 @@ +cmake_minimum_required(VERSION 2.8) +project(CTestConfig) + +include(CTest) + + +# We expect this configure to occur through a 'ctest -D Experimental' or a +# 'ctest -S script.cmake' call. +# +# In either case, we expect CMAKE_BUILD_TYPE to be defined for single-configuration +# build trees and not defined for multi-configuration build trees. +# +if(CMAKE_CONFIGURATION_TYPES) + # multi-configuration: expect not defined, error if defined + if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "") + message(FATAL_ERROR "CMAKE_CONFIGURATION_TYPES='${CMAKE_CONFIGURATION_TYPES}' CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}' is defined and non-empty (but should not be for a multi-configuration generator)") + endif() +else() + # single-configuration: expect defined, error if not defined + if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "") + message(FATAL_ERROR "CMAKE_BUILD_TYPE is not defined or is empty (but should be defined and non-empty for a single-configuration generator)") + endif() +endif() + + +if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "") + add_definitions(-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}") +endif() + +add_executable(ctc CTestConfig.cxx) + + +foreach(cfg ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE}) + add_test(NAME ctc-${cfg} CONFIGURATIONS ${cfg} COMMAND ctc --config $<CONFIGURATION>) + + if(CMAKE_CONFIGURATION_TYPES) + set_property(TEST ctc-${cfg} + PROPERTY PASS_REGULAR_EXPRESSION "CMAKE_INTDIR is ${cfg}") + set_property(TEST ctc-${cfg} + PROPERTY FAIL_REGULAR_EXPRESSION "CMAKE_BUILD_TYPE is") + else() + set_property(TEST ctc-${cfg} + PROPERTY PASS_REGULAR_EXPRESSION "CMAKE_BUILD_TYPE is ${cfg}") + set_property(TEST ctc-${cfg} + PROPERTY FAIL_REGULAR_EXPRESSION "CMAKE_INTDIR is") + endif() +endforeach() diff --git a/Tests/CTestConfig/CTestConfig.cxx b/Tests/CTestConfig/CTestConfig.cxx new file mode 100644 index 000000000..49c53241a --- /dev/null +++ b/Tests/CTestConfig/CTestConfig.cxx @@ -0,0 +1,20 @@ +#include <stdio.h> + +int main(int argc, const char* argv[]) +{ + int i = 0; + for (; i<argc; ++i) + { + fprintf(stdout, "%s\n", argv[i]); + } + +#ifdef CMAKE_BUILD_TYPE + fprintf(stdout, "CMAKE_BUILD_TYPE is %s\n", CMAKE_BUILD_TYPE); +#endif + +#ifdef CMAKE_INTDIR + fprintf(stdout, "CMAKE_INTDIR is %s\n", CMAKE_INTDIR); +#endif + + return 0; +} diff --git a/Tests/CTestConfig/ScriptWithArgs.cmake b/Tests/CTestConfig/ScriptWithArgs.cmake new file mode 100644 index 000000000..79896a7fc --- /dev/null +++ b/Tests/CTestConfig/ScriptWithArgs.cmake @@ -0,0 +1,16 @@ +set(CTEST_RUN_CURRENT_SCRIPT 0) + +macro(check_arg name expected_value) + message("${name}='${${name}}'") + if(NOT "${${name}}" STREQUAL "${expected_value}") + message(FATAL_ERROR "unexpected ${name} value '${${name}}', expected '${expected_value}'") + endif() +endmacro() + +check_arg(arg1 "this") +check_arg(arg2 "that") +check_arg(arg3 "the other") +check_arg(arg4 "this is the fourth") +check_arg(arg5 "the_fifth") +check_arg(arg6 "value-with-type") +check_arg(arg7 "") diff --git a/Tests/CTestConfig/dashboard.cmake.in b/Tests/CTestConfig/dashboard.cmake.in new file mode 100644 index 000000000..c7ac21023 --- /dev/null +++ b/Tests/CTestConfig/dashboard.cmake.in @@ -0,0 +1,43 @@ +set(CMAKE_CONFIGURATION_TYPES "@CMAKE_CONFIGURATION_TYPES@") +set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig") +set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-dashboard") + +file(MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}") + +get_filename_component(dir "${CMAKE_COMMAND}" PATH) +set(CMAKE_CTEST_COMMAND "${dir}/ctest") + +message("CMAKE_COMMAND='${CMAKE_COMMAND}'") +message("CMAKE_CTEST_COMMAND='${CMAKE_CTEST_COMMAND}'") + +set(arg "") +if(NOT CMAKE_CONFIGURATION_TYPES) + set(arg "-DCMAKE_BUILD_TYPE:STRING=@cfg@") +endif() + +message("cmake initial configure") +execute_process(COMMAND ${CMAKE_COMMAND} + ${arg} -G "@CMAKE_TEST_GENERATOR@" ${CTEST_SOURCE_DIRECTORY} + WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} + RESULT_VARIABLE rv) +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "error calling cmake: rv='${rv}'") +endif() + + +function(call_ctest arg) + message("call_ctest ${arg}") + execute_process(COMMAND ${CMAKE_CTEST_COMMAND} + -C "@cfg@" -D ${arg} -VV + WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} + RESULT_VARIABLE rv) + if(NOT rv STREQUAL 0) + message(FATAL_ERROR "error calling ctest: rv='${rv}'") + endif() +endfunction() + + +call_ctest(ExperimentalStart) +call_ctest(ExperimentalConfigure) +call_ctest(ExperimentalBuild) +call_ctest(ExperimentalTest) diff --git a/Tests/CTestConfig/script.cmake.in b/Tests/CTestConfig/script.cmake.in new file mode 100644 index 000000000..5ceb7c325 --- /dev/null +++ b/Tests/CTestConfig/script.cmake.in @@ -0,0 +1,21 @@ +set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_PROJECT_NAME "CTestConfig") +set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig") +set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-script") + +ctest_start(Experimental) + +ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE rv) +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "*** error in ctest_configure ***") +endif() + +ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE rv) +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "*** error in ctest_build ***") +endif() + +ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE rv) +if(NOT rv STREQUAL 0) + message(FATAL_ERROR "*** error in ctest_test ***") +endif() diff --git a/Tests/CTestScriptMode/CTestTestScriptMode.cmake.in b/Tests/CTestScriptMode/CTestTestScriptMode.cmake.in new file mode 100644 index 000000000..0c4394faa --- /dev/null +++ b/Tests/CTestScriptMode/CTestTestScriptMode.cmake.in @@ -0,0 +1,14 @@ +# This script will be executed with ctest -S + +# Check that the system name is determined correctly: +set(CMAKE_CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@") + +if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "${CMAKE_CMAKE_SYSTEM_NAME}") + message(FATAL_ERROR "Error: CMAKE_SYSTEM_NAME is \"${CMAKE_SYSTEM_NAME}\", but should be \"@CMAKE_SYSTEM_NAME@\"") +endif(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "${CMAKE_CMAKE_SYSTEM_NAME}") + +# this seems to be necessary, otherwise ctest complains that these +# variables are not set: +set(CTEST_COMMAND "\"@CMAKE_CTEST_COMMAND@\"") +set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestScriptMode/") +set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestScriptMode/") diff --git a/Tests/CTestTest/SmallAndFast/CMakeLists.txt b/Tests/CTestTest/SmallAndFast/CMakeLists.txt new file mode 100644 index 000000000..85cb30cef --- /dev/null +++ b/Tests/CTestTest/SmallAndFast/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 2.8) +project(SmallAndFast) + +include(CTest) + +add_executable(echoargs echoargs.c) +set_property(SOURCE echoargs.c APPEND PROPERTY LABELS SourceLabel Everything) +set_property(TARGET echoargs APPEND PROPERTY LABELS TargetLabel Everything) + +add_test(test0 echoargs) +set_property(TEST test0 APPEND PROPERTY LABELS TestLabel 0ArgTest Everything) + +add_test(test1 echoargs 1) +set_property(TEST test1 APPEND PROPERTY LABELS TestLabel 1ArgTest Everything) + +add_test(test2 echoargs 1 2) +set_property(TEST test2 APPEND PROPERTY LABELS TestLabel 2ArgTest Everything) + +if(SAF_INTENTIONAL_COMPILE_ERROR) + add_executable(ice intentional_compile_error.cxx) +endif() + +if(SAF_INTENTIONAL_COMPILE_WARNING) + add_executable(icw intentional_compile_warning.cxx) +endif() diff --git a/Tests/CTestTest/SmallAndFast/echoargs.c b/Tests/CTestTest/SmallAndFast/echoargs.c new file mode 100644 index 000000000..6e17464f7 --- /dev/null +++ b/Tests/CTestTest/SmallAndFast/echoargs.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +int main(int argc, const char* argv[]) +{ + int i = 0; + for (; i<argc; ++i) + { + fprintf(stdout, "%s\n", argv[i]); + } + return 0; +} diff --git a/Tests/CTestTest/SmallAndFast/intentional_compile_error.cxx b/Tests/CTestTest/SmallAndFast/intentional_compile_error.cxx new file mode 100644 index 000000000..a8930cf72 --- /dev/null +++ b/Tests/CTestTest/SmallAndFast/intentional_compile_error.cxx @@ -0,0 +1 @@ +garbage - obviously this should not compile as is diff --git a/Tests/CTestTest/SmallAndFast/intentional_compile_warning.cxx b/Tests/CTestTest/SmallAndFast/intentional_compile_warning.cxx new file mode 100644 index 000000000..8ea5e404f --- /dev/null +++ b/Tests/CTestTest/SmallAndFast/intentional_compile_warning.cxx @@ -0,0 +1,11 @@ +#include <stdio.h> + +int main(int argc, const char* argv[]) +{ + unsigned int i = 0; // "i<argc" should produce a "signed/unsigned comparison" warning + for (; i<argc; ++i) + { + fprintf(stdout, "%s\n", argv[i]); + } + return 0; +} diff --git a/Tests/CTestTest/test.cmake.in b/Tests/CTestTest/test.cmake.in new file mode 100644 index 000000000..eac5eab20 --- /dev/null +++ b/Tests/CTestTest/test.cmake.in @@ -0,0 +1,68 @@ +# please see common.cmake for more documentation +################################################################### +# The values in this section must always be provided +################################################################### + +# this is the cvs module name that should be checked out +SET (CTEST_MODULE_NAME SmallAndFast) + +# these are the the name of the source and binary directory on disk. +# They will be appended to DASHBOARD_ROOT +SET (CTEST_SOURCE_NAME SmallAndFast) +SET (CTEST_BINARY_NAME SmallAndFastBuild) + +# which ctest command to use for running the dashboard +SET (CTEST_COMMAND + "\"${CTEST_EXECUTABLE_NAME}\" --version" + "\"${CTEST_EXECUTABLE_NAME}\" -D Experimental -A \"${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}\"" + ) + +# what cmake command to use for configuring this dashboard +GET_FILENAME_COMPONENT(CTEST_EXECUTABLE_PATH "${CTEST_EXECUTABLE_NAME}" PATH) +SET(CTEST_CMAKE_COMMAND "\"${CTEST_EXECUTABLE_PATH}/cmake\"") + +MESSAGE("CTest executable: ${CTEST_EXECUTABLE_NAME}") +MESSAGE("CMake executable: ${CTEST_CMAKE_COMMAND}") + +CTEST_SLEEP(1) +CTEST_SLEEP(1 1 1) + +#################################################################### +# The values in this section are optional you can either +# have them or leave them commented out +#################################################################### + +# should ctest wipe the binary tree before running +SET (CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE) + +# this is the initial cache to use for the binary tree, be careful to escape +# any quotes inside of this string if you use it +SET (CTEST_INITIAL_CACHE " +SITE:STRING=@SITE@ +BUILDNAME:STRING=SmallAndFast-@BUILDNAME@ +CMAKE_GENERATOR:INTERNAL=@CMAKE_GENERATOR@ +CMAKE_CXX_FLAGS:STRING=@CMAKE_CXX_FLAGS@ +CMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@ +CMAKE_C_COMPILER:STRING=@CMAKE_C_COMPILER@ +CMAKE_CXX_COMPILER:STRING=@CMAKE_CXX_COMPILER@ +CMAKE_C_COMPILER_ARG1:STRING=@CMAKE_C_COMPILER_ARG1@ +CMAKE_CXX_COMPILER_ARG1:STRING=@CMAKE_CXX_COMPILER_ARG1@ +DART_ROOT:PATH= +MEMORYCHECK_COMMAND:STRING=@MEMORYCHECK_COMMAND@ +MEMORYCHECK_SUPPRESSIONS_FILE:FILEPATH=@MEMORYCHECK_SUPPRESSIONS_FILE@ +MEMORYCHECK_COMMAND_OPTIONS:STRING=@MEMORYCHECK_COMMAND_OPTIONS@ +COVERAGE_COMMAND:FILEPATH=@COVERAGE_COMMAND@ +") + +# if you do not want to use the default location for a +# dashboard then set this variable to the directory +# the dashboard should be in +SET (CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@/Tests/CTestTest") + + +# set any extra envionment varibles here +SET (CTEST_ENVIRONMENT +) + +SET (CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTest/SmallAndFast") +SET (CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTest/${CTEST_BINARY_NAME}") diff --git a/Tests/CTestTest2/test.cmake.in b/Tests/CTestTest2/test.cmake.in new file mode 100644 index 000000000..b58b6397e --- /dev/null +++ b/Tests/CTestTest2/test.cmake.in @@ -0,0 +1,60 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "KWSys-@BUILDNAME@-CTest2") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Source/kwsys") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTest2/kwsysBin") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") +SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") +SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +# By default, CTESTTEST2_USE_PURIFY is not defined. If you want to run purify +# on CTestTest2, set CTESTTEST2_USE_PURIFY to ON in CMake's cache. +SET(CTESTTEST2_USE_PURIFY @CTESTTEST2_USE_PURIFY@) +IF("${CTEST_MEMORYCHECK_COMMAND}" MATCHES purify AND NOT CTESTTEST2_USE_PURIFY) + SET(CTEST_MEMORYCHECK_COMMAND) +ENDIF() + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " +CMAKE_CXX_FLAGS:STRING=@CMAKE_CXX_FLAGS@ +CMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@ +CMAKE_C_COMPILER:STRING=@CMAKE_C_COMPILER@ +CMAKE_CXX_COMPILER:STRING=@CMAKE_CXX_COMPILER@ +CMAKE_C_COMPILER_ARG1:STRING=@CMAKE_C_COMPILER_ARG1@ +CMAKE_CXX_COMPILER_ARG1:STRING=@CMAKE_CXX_COMPILER_ARG1@ + +# This one is needed for testing advanced ctest features +CTEST_TEST_KWSYS:BOOL=ON +") + +CTEST_START(Experimental) +#CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res START 1 END 5 STRIDE 2) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res START 7 STRIDE 2 SUBMIT_INDEX 1) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res START 2 END 4 STRIDE 2 SUBMIT_INDEX 2) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res START 6 STRIDE 2 SUBMIT_INDEX 3) +CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res STRIDE 1.5) +CTEST_COVERAGE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) + +set(CTEST_DROP_METHOD "@protocol@") +set(CTEST_DROP_SITE "@server@") +set(CTEST_DROP_LOCATION "@path@/submit.php?project=PublicDashboard") + +CTEST_SUBMIT(RETURN_VALUE res) + +# Test submission of a subset of parts. +SET(CTEST_EXTRA_SUBMIT_FILES ${CTEST_NOTES_FILES}) +CTEST_SUBMIT(RETURN_VALUE res PARTS ExtraFiles) +SET(CTEST_EXTRA_SUBMIT_FILES) diff --git a/Tests/CTestTestBadExe/CMakeLists.txt b/Tests/CTestTestBadExe/CMakeLists.txt new file mode 100644 index 000000000..8a925b62f --- /dev/null +++ b/Tests/CTestTestBadExe/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CTestTestBadExe) +INCLUDE(CTest) + +CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/notAnExe.txt" "${CMAKE_CURRENT_BINARY_DIR}/notAnExe.txt" COPYONLY) + +ADD_TEST (TestBadExe "${CMAKE_CURRENT_BINARY_DIR}/notAnExe.txt") diff --git a/Tests/CTestTestBadExe/CTestConfig.cmake b/Tests/CTestTestBadExe/CTestConfig.cmake new file mode 100644 index 000000000..1d46ea3e7 --- /dev/null +++ b/Tests/CTestTestBadExe/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestBadExe") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestBadExe/notAnExe.txt b/Tests/CTestTestBadExe/notAnExe.txt new file mode 100644 index 000000000..f2a0aa4a3 --- /dev/null +++ b/Tests/CTestTestBadExe/notAnExe.txt @@ -0,0 +1 @@ +This is not an executable file. diff --git a/Tests/CTestTestBadExe/test.cmake.in b/Tests/CTestTestBadExe/test.cmake.in new file mode 100644 index 000000000..5d22d3587 --- /dev/null +++ b/Tests/CTestTestBadExe/test.cmake.in @@ -0,0 +1,21 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-BadExe") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestBadExe") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestBadExe") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestChecksum/test.cmake.in b/Tests/CTestTestChecksum/test.cmake.in new file mode 100644 index 000000000..84135446f --- /dev/null +++ b/Tests/CTestTestChecksum/test.cmake.in @@ -0,0 +1,25 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Checksum") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestParallel") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParallel") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 4) + +SET(CTEST_DROP_METHOD "@protocol@") +SET(CTEST_DROP_SITE "@server@") +SET(CTEST_DROP_LOCATION "@path@/submit.php?project=PublicDashboard") + +CTEST_SUBMIT(RETRY_DELAY 3 RETRY_COUNT 2 INTERNAL_TEST_CHECKSUM RETURN_VALUE res) diff --git a/Tests/CTestTestConfigFileInBuildDir/CMakeLists.txt b/Tests/CTestTestConfigFileInBuildDir/CMakeLists.txt new file mode 100644 index 000000000..3c53e6623 --- /dev/null +++ b/Tests/CTestTestConfigFileInBuildDir/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(CTestTestConfigFileInBuildDir) +include(CTest) diff --git a/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake b/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake new file mode 100644 index 000000000..d2c28f98c --- /dev/null +++ b/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "CTestTestConfigFileInBuildDir") +set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in new file mode 100644 index 000000000..498cab280 --- /dev/null +++ b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in @@ -0,0 +1,17 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ConfigFileInBuildDir1") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir1") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in new file mode 100644 index 000000000..d359f2d36 --- /dev/null +++ b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in @@ -0,0 +1,17 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ConfigFileInBuildDir2") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir2") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestCostSerial/CMakeLists.txt b/Tests/CTestTestCostSerial/CMakeLists.txt new file mode 100644 index 000000000..a9a5c2594 --- /dev/null +++ b/Tests/CTestTestCostSerial/CMakeLists.txt @@ -0,0 +1,13 @@ +CMAKE_MINIMUM_REQUIRED (VERSION 2.6) +PROJECT (CTestTestCostSerial) +INCLUDE (CTest) + +ADD_EXECUTABLE (Sleep sleep.c) + +FOREACH (index RANGE 1 3) + ADD_TEST (TestSleep${index} Sleep) +ENDFOREACH (index RANGE 1 3) + +SET_TESTS_PROPERTIES(TestSleep1 PROPERTIES COST -500) +SET_TESTS_PROPERTIES(TestSleep2 PROPERTIES COST 12) +SET_TESTS_PROPERTIES(TestSleep3 PROPERTIES COST 0) diff --git a/Tests/CTestTestCostSerial/CTestConfig.cmake b/Tests/CTestTestCostSerial/CTestConfig.cmake new file mode 100644 index 000000000..05c20eb4b --- /dev/null +++ b/Tests/CTestTestCostSerial/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "CTestTestCostSerial") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestCostSerial/sleep.c b/Tests/CTestTestCostSerial/sleep.c new file mode 100644 index 000000000..cb9f87ab2 --- /dev/null +++ b/Tests/CTestTestCostSerial/sleep.c @@ -0,0 +1,16 @@ +#if defined(_WIN32) +# include <windows.h> +#else +# include <unistd.h> +#endif + +/* sleeps for 1 second */ +int main(int argc, char** argv) +{ +#if defined(_WIN32) + Sleep(1000); +#else + sleep(1); +#endif + return 0; +} diff --git a/Tests/CTestTestCostSerial/test.cmake.in b/Tests/CTestTestCostSerial/test.cmake.in new file mode 100644 index 000000000..ca216e3fc --- /dev/null +++ b/Tests/CTestTestCostSerial/test.cmake.in @@ -0,0 +1,28 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-CostSerial") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCostSerial") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCostSerial") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +# Remove old cost data file if it exists +IF(EXISTS "${CTEST_BINARY_DIRECTORY}/Testing/Temporary/CTestCostData.txt") + FILE(REMOVE "${CTEST_BINARY_DIRECTORY}/Testing/Temporary/CTestCostData.txt") +ENDIF(EXISTS "${CTEST_BINARY_DIRECTORY}/Testing/Temporary/CTestCostData.txt") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +# Run test set a second time to make sure they run in same specified order +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestCrash/CMakeLists.txt b/Tests/CTestTestCrash/CMakeLists.txt new file mode 100644 index 000000000..0ac6ba03c --- /dev/null +++ b/Tests/CTestTestCrash/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CTestTestCrash) +INCLUDE(CTest) + +ADD_EXECUTABLE (Crash crash.cxx) + +ADD_TEST (TestCrash Crash) diff --git a/Tests/CTestTestCrash/CTestConfig.cmake b/Tests/CTestTestCrash/CTestConfig.cmake new file mode 100644 index 000000000..e1c5b1b6f --- /dev/null +++ b/Tests/CTestTestCrash/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestCrash") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestCrash/crash.cxx b/Tests/CTestTestCrash/crash.cxx new file mode 100644 index 000000000..bc9e096e4 --- /dev/null +++ b/Tests/CTestTestCrash/crash.cxx @@ -0,0 +1,6 @@ +//causes a segfault +int main() +{ + int* ptr = 0; + *ptr = 1; +} diff --git a/Tests/CTestTestCrash/test.cmake.in b/Tests/CTestTestCrash/test.cmake.in new file mode 100644 index 000000000..5cec594cd --- /dev/null +++ b/Tests/CTestTestCrash/test.cmake.in @@ -0,0 +1,22 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Crash") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCrash") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCrash") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +#CTEST_SUBMIT() diff --git a/Tests/CTestTestCycle/CMakeLists.txt b/Tests/CTestTestCycle/CMakeLists.txt new file mode 100644 index 000000000..6ba6b8c95 --- /dev/null +++ b/Tests/CTestTestCycle/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 2.6) +project(CTestTestCycle) +include(CTest) + +add_executable (simple simple.cxx) +add_test (one simple) +add_test (two simple) +add_test (three simple) + +# Add cyclical test dependency +set_tests_properties(one PROPERTIES DEPENDS "two") +set_tests_properties(two PROPERTIES DEPENDS "three") +set_tests_properties(three PROPERTIES DEPENDS "one") diff --git a/Tests/CTestTestCycle/CTestConfig.cmake b/Tests/CTestTestCycle/CTestConfig.cmake new file mode 100644 index 000000000..43e99863a --- /dev/null +++ b/Tests/CTestTestCycle/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestCycle") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestCycle/simple.cxx b/Tests/CTestTestCycle/simple.cxx new file mode 100644 index 000000000..766b7751b --- /dev/null +++ b/Tests/CTestTestCycle/simple.cxx @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/CTestTestCycle/test.cmake.in b/Tests/CTestTestCycle/test.cmake.in new file mode 100644 index 000000000..201f6044e --- /dev/null +++ b/Tests/CTestTestCycle/test.cmake.in @@ -0,0 +1,19 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Cycle") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCycle") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCycle") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestDepends/CMakeLists.txt b/Tests/CTestTestDepends/CMakeLists.txt new file mode 100644 index 000000000..26367a658 --- /dev/null +++ b/Tests/CTestTestDepends/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required (VERSION 2.6) +project(CTestTestDepends) +include(CTest) + +add_executable (simple simple.cxx) +add_test (one simple) +add_test (two simple) +add_test (three simple) + +# Add redundant (but not cyclical) dependencies +set_tests_properties(two PROPERTIES DEPENDS "one") +set_tests_properties(three PROPERTIES DEPENDS "one;two") diff --git a/Tests/CTestTestDepends/CTestConfig.cmake b/Tests/CTestTestDepends/CTestConfig.cmake new file mode 100644 index 000000000..e3af7dd8d --- /dev/null +++ b/Tests/CTestTestDepends/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestDepends") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestDepends/simple.cxx b/Tests/CTestTestDepends/simple.cxx new file mode 100644 index 000000000..766b7751b --- /dev/null +++ b/Tests/CTestTestDepends/simple.cxx @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/CTestTestDepends/test.cmake.in b/Tests/CTestTestDepends/test.cmake.in new file mode 100644 index 000000000..36a1ebf87 --- /dev/null +++ b/Tests/CTestTestDepends/test.cmake.in @@ -0,0 +1,19 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Depends") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestDepends") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestDepends") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestFailedSubmits/test.cmake.in b/Tests/CTestTestFailedSubmits/test.cmake.in new file mode 100644 index 000000000..b0e16322d --- /dev/null +++ b/Tests/CTestTestFailedSubmits/test.cmake.in @@ -0,0 +1,47 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +# CTestConfig.cmake settings: +set(CTEST_PROJECT_NAME "SmallAndFast") + +# Intentionally leave out other upload-related CTestConfig.cmake settings +# so that the ctest_submit call below fails with an error message... +# +set(CTEST_DROP_METHOD "@drop_method@") + +# Settings: +SET(CTEST_USE_LAUNCHERS 1) + +# Emit these compiler warnings: +set(ENV{CXXFLAGS} "$ENV{CXXFLAGS} -Wall") + +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTestLaunchers-@drop_method@") + +SET(CTEST_SOURCE_DIRECTORY "@source@") +SET(CTEST_BINARY_DIRECTORY "@build@") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) + +# explicitly do not use CTEST_UPDATE - avoid network activity + +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" + OPTIONS "-DCTEST_USE_LAUNCHERS:BOOL=${CTEST_USE_LAUNCHERS};-DSAF_INTENTIONAL_COMPILE_ERROR:BOOL=ON;-DSAF_INTENTIONAL_COMPILE_WARNING:BOOL=ON" + RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_COVERAGE(BUILD "${CTEST_BINARY_DIRECTORY}" @ctest_coverage_labels_args@ RETURN_VALUE res) + +# ok to call ctest_submit - still avoids network activity because there is +# not a valid drop location given above... +CTEST_SUBMIT(RETURN_VALUE res) + +# Add coverage for the new APPEND arg to ctest_start: +# +CTEST_START(Experimental APPEND) diff --git a/Tests/CTestTestFailure/CMakeLists.txt b/Tests/CTestTestFailure/CMakeLists.txt new file mode 100644 index 000000000..690fbfc5c --- /dev/null +++ b/Tests/CTestTestFailure/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CTestTestFailure) +INCLUDE(CTest) + +ADD_EXECUTABLE (NoBuild badCode.cxx) +TARGET_LINK_LIBRARIES (NoBuild ${EXTRA_LIBS}) + +ADD_TEST (TestNoExe NoBuild) diff --git a/Tests/CTestTestFailure/CTestConfig.cmake b/Tests/CTestTestFailure/CTestConfig.cmake new file mode 100644 index 000000000..fd8d97acf --- /dev/null +++ b/Tests/CTestTestFailure/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestFailure") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestFailure/badCode.cxx b/Tests/CTestTestFailure/badCode.cxx new file mode 100644 index 000000000..b410f0a13 --- /dev/null +++ b/Tests/CTestTestFailure/badCode.cxx @@ -0,0 +1,4 @@ +int main() +{ +this code will not compile +} diff --git a/Tests/CTestTestFailure/testNoBuild.cmake.in b/Tests/CTestTestFailure/testNoBuild.cmake.in new file mode 100644 index 000000000..7bc921a31 --- /dev/null +++ b/Tests/CTestTestFailure/testNoBuild.cmake.in @@ -0,0 +1,21 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoBuild") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +#CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestFailure/testNoExe.cmake.in b/Tests/CTestTestFailure/testNoExe.cmake.in new file mode 100644 index 000000000..59c18d752 --- /dev/null +++ b/Tests/CTestTestFailure/testNoExe.cmake.in @@ -0,0 +1,19 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoExe") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestParallel/CMakeLists.txt b/Tests/CTestTestParallel/CMakeLists.txt new file mode 100644 index 000000000..fc53f6874 --- /dev/null +++ b/Tests/CTestTestParallel/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CTestTestParallel) +INCLUDE(CTest) + +ADD_EXECUTABLE (LockFile lockFile.c) + +ADD_TEST (TestRunSerial1 LockFile) +ADD_TEST (TestRunSerial2 LockFile) +SET_TESTS_PROPERTIES(TestRunSerial1 TestRunSerial2 PROPERTIES RUN_SERIAL true) + +ADD_TEST (TestProcessorsGreaterThanMPL1 LockFile) +ADD_TEST (TestProcessorsGreaterThanMPL2 LockFile) +SET_TESTS_PROPERTIES(TestProcessorsGreaterThanMPL1 PROPERTIES PROCESSORS 10) +SET_TESTS_PROPERTIES(TestProcessorsGreaterThanMPL1 PROPERTIES DEPENDS + TestProcessorsGreaterThanMPL2) diff --git a/Tests/CTestTestParallel/CTestConfig.cmake b/Tests/CTestTestParallel/CTestConfig.cmake new file mode 100644 index 000000000..c3c503881 --- /dev/null +++ b/Tests/CTestTestParallel/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "CTestTestParallel") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestParallel/lockFile.c b/Tests/CTestTestParallel/lockFile.c new file mode 100644 index 000000000..6a6a889cc --- /dev/null +++ b/Tests/CTestTestParallel/lockFile.c @@ -0,0 +1,20 @@ +#include <stdio.h> + +/*if run serially, works fine. + If run in parallel, someone will attempt to delete + a locked file, which will fail */ +int main(void) +{ + FILE* file; + int i; + const char* fname = "lockedFile.txt"; + file = fopen(fname, "w"); + + for(i = 0; i < 10000; i++) + { + fprintf(file, "%s", "x"); + fflush(file); + } + fclose(file); + return remove(fname); +} diff --git a/Tests/CTestTestParallel/test.cmake.in b/Tests/CTestTestParallel/test.cmake.in new file mode 100644 index 000000000..83845dee4 --- /dev/null +++ b/Tests/CTestTestParallel/test.cmake.in @@ -0,0 +1,21 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Parallel") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestParallel") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParallel") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 4) diff --git a/Tests/CTestTestResourceLock/CMakeLists.txt b/Tests/CTestTestResourceLock/CMakeLists.txt new file mode 100644 index 000000000..1041ef149 --- /dev/null +++ b/Tests/CTestTestResourceLock/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CTestTestResourceLock) +INCLUDE(CTest) + +ADD_EXECUTABLE (LockFile lockFile.c) + +ADD_TEST (TestLockedFile1.1 LockFile locked1.txt) +ADD_TEST (TestLockedFile1.2 LockFile locked1.txt) +SET_TESTS_PROPERTIES(TestLockedFile1.1 TestLockedFile1.2 PROPERTIES RESOURCE_LOCK "locked1.txt") + +ADD_TEST (TestLockedFile2.1 LockFile locked2.txt) +ADD_TEST (TestLockedFile2.2 LockFile locked2.txt) +SET_TESTS_PROPERTIES(TestLockedFile2.1 TestLockedFile2.2 PROPERTIES RESOURCE_LOCK "locked2.txt") diff --git a/Tests/CTestTestResourceLock/CTestConfig.cmake b/Tests/CTestTestResourceLock/CTestConfig.cmake new file mode 100644 index 000000000..5fb560b87 --- /dev/null +++ b/Tests/CTestTestResourceLock/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "CTestTestResourceLock") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestResourceLock/lockFile.c b/Tests/CTestTestResourceLock/lockFile.c new file mode 100644 index 000000000..a6a4dc0f4 --- /dev/null +++ b/Tests/CTestTestResourceLock/lockFile.c @@ -0,0 +1,31 @@ +#include <stdio.h> + +/* Disable deprecation warning for fopen */ +#pragma warning(disable: 4996) + +/*if run serially, works fine. + If run in parallel, someone will attempt to delete + a locked file, which will fail */ +int main(int argc, char** argv) +{ + FILE* file; + int i; + const char* fname; + if(argc >= 2) + { + fname = argv[1]; + } + else + { + fname = "lockedFile.txt"; + } + file = fopen(fname, "w"); + + for(i = 0; i < 10000; i++) + { + fprintf(file, "%s", "x"); + fflush(file); + } + fclose(file); + return remove(fname); +} diff --git a/Tests/CTestTestResourceLock/test.cmake.in b/Tests/CTestTestResourceLock/test.cmake.in new file mode 100644 index 000000000..98c5901c4 --- /dev/null +++ b/Tests/CTestTestResourceLock/test.cmake.in @@ -0,0 +1,19 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ResourceLock") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestResourceLock") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestResourceLock") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 4) diff --git a/Tests/CTestTestRunScript/hello.cmake.in b/Tests/CTestTestRunScript/hello.cmake.in new file mode 100644 index 000000000..140df1e02 --- /dev/null +++ b/Tests/CTestTestRunScript/hello.cmake.in @@ -0,0 +1,2 @@ +SET(CTEST_RUN_CURRENT_SCRIPT 0) +MESSAGE("hello world") diff --git a/Tests/CTestTestRunScript/test.cmake.in b/Tests/CTestTestRunScript/test.cmake.in new file mode 100644 index 000000000..8301a56d3 --- /dev/null +++ b/Tests/CTestTestRunScript/test.cmake.in @@ -0,0 +1,2 @@ +SET(CTEST_RUN_CURRENT_SCRIPT 0) +CTEST_RUN_SCRIPT("CTestTestRunScript/hello.cmake" RETURN_VALUE res RETURN_VALUE) diff --git a/Tests/CTestTestScheduler/CMakeLists.txt b/Tests/CTestTestScheduler/CMakeLists.txt new file mode 100644 index 000000000..882988fd4 --- /dev/null +++ b/Tests/CTestTestScheduler/CMakeLists.txt @@ -0,0 +1,9 @@ +CMAKE_MINIMUM_REQUIRED (VERSION 2.6) +PROJECT (CTestTestScheduler) +INCLUDE (CTest) + +ADD_EXECUTABLE (Sleep sleep.c) + +FOREACH (time RANGE 1 4) + ADD_TEST (TestSleep${time} Sleep ${time}) +ENDFOREACH (time RANGE 1 4) diff --git a/Tests/CTestTestScheduler/CTestConfig.cmake b/Tests/CTestTestScheduler/CTestConfig.cmake new file mode 100644 index 000000000..7da8f6f53 --- /dev/null +++ b/Tests/CTestTestScheduler/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "CTestTestScheduler") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestScheduler/sleep.c b/Tests/CTestTestScheduler/sleep.c new file mode 100644 index 000000000..9631a68dc --- /dev/null +++ b/Tests/CTestTestScheduler/sleep.c @@ -0,0 +1,21 @@ +#if defined(_WIN32) +# include <windows.h> +#else +# include <unistd.h> +#endif + +/* sleeps for 4n seconds, where n is the argument to the program */ +int main(int argc, char** argv) +{ + int time; + if(argc > 1) + { + time = 4 * atoi(argv[1]); + } +#if defined(_WIN32) + Sleep(time * 1000); +#else + sleep(time); +#endif + return 0; +} diff --git a/Tests/CTestTestScheduler/test.cmake.in b/Tests/CTestTestScheduler/test.cmake.in new file mode 100644 index 000000000..505bd7c5b --- /dev/null +++ b/Tests/CTestTestScheduler/test.cmake.in @@ -0,0 +1,28 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Scheduler") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestScheduler") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestScheduler") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +# Remove old cost data file if it exists +IF(EXISTS "${CTEST_BINARY_DIRECTORY}/Testing/Temporary/CTestCostData.txt") + FILE(REMOVE "${CTEST_BINARY_DIRECTORY}/Testing/Temporary/CTestCostData.txt") +ENDIF(EXISTS "${CTEST_BINARY_DIRECTORY}/Testing/Temporary/CTestCostData.txt") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 5) +# Run test set a second time to make sure they run in reverse order +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 5) diff --git a/Tests/CTestTestStopTime/CMakeLists.txt b/Tests/CTestTestStopTime/CMakeLists.txt new file mode 100644 index 000000000..5fe30d352 --- /dev/null +++ b/Tests/CTestTestStopTime/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CTestTestStopTime) +INCLUDE(CTest) + +ADD_EXECUTABLE (Sleep sleep.c) + +ADD_TEST (TestSleep Sleep 30) +ADD_TEST (ShouldNotRun Sleep 30) + +SET_TESTS_PROPERTIES(ShouldNotRun PROPERTIES DEPENDS TestSleep) +SET_TESTS_PROPERTIES(ShouldNotRun PROPERTIES WILL_FAIL ON) diff --git a/Tests/CTestTestStopTime/CTestConfig.cmake b/Tests/CTestTestStopTime/CTestConfig.cmake new file mode 100644 index 000000000..129db4dea --- /dev/null +++ b/Tests/CTestTestStopTime/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestStopTime") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestStopTime/GetDate.cmake b/Tests/CTestTestStopTime/GetDate.cmake new file mode 100644 index 000000000..b79330691 --- /dev/null +++ b/Tests/CTestTestStopTime/GetDate.cmake @@ -0,0 +1,233 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.2) + +MACRO(GET_DATE) + # + # All macro arguments are optional. + # If there's an ARGV0, use it as GD_PREFIX. Default = 'GD_' + # If there's an ARGV1, use it as ${GD_PREFIX}VERBOSE. Default = '0' + # + # If the date can be retrieved and parsed successfully, this macro + # will set the following CMake variables: + # + # GD_PREFIX + # ${GD_PREFIX}PREFIX (if '${GD_PREFIX}' is not 'GD_'...!) + # ${GD_PREFIX}VERBOSE + # + # ${GD_PREFIX}CMD + # ${GD_PREFIX}ARGS + # ${GD_PREFIX}OV + # ${GD_PREFIX}RV + # + # ${GD_PREFIX}REGEX + # ${GD_PREFIX}YEAR + # ${GD_PREFIX}MONTH + # ${GD_PREFIX}DAY + # ${GD_PREFIX}HOUR + # ${GD_PREFIX}MINUTE + # ${GD_PREFIX}SECOND + # ${GD_PREFIX}FRACTIONAL_SECOND + # ${GD_PREFIX}DAY_OF_WEEK + # + # Caller can then use these variables to construct names based on + # date and time stamps... + # + + # If there's an ARGV0, use it as GD_PREFIX: + # + SET(GD_PREFIX "GD_") + IF(NOT "${ARGV0}" STREQUAL "") + SET(GD_PREFIX "${ARGV0}") + ENDIF(NOT "${ARGV0}" STREQUAL "") + IF(NOT "${GD_PREFIX}" STREQUAL "GD_") + SET(${GD_PREFIX}PREFIX "${GD_PREFIX}") + ENDIF(NOT "${GD_PREFIX}" STREQUAL "GD_") + + # If there's an ARGV1, use it as ${GD_PREFIX}VERBOSE: + # + SET(${GD_PREFIX}VERBOSE "0") + IF(NOT "${ARGV1}" STREQUAL "") + SET(${GD_PREFIX}VERBOSE "${ARGV1}") + ENDIF(NOT "${ARGV1}" STREQUAL "") + + # Retrieve the current date and time in the format: + # + # Thu 01/12/2006 8:55:12.01 + # dow mm/dd/YYYY HH:MM:SS.ssssss + # + # Use "echo %DATE% %TIME%" on Windows. + # Otherwise, try "date" as implemented on most Unix flavors. + # + IF(WIN32) + # + # Use "cmd" shell with %DATE% and %TIME% support... + # May need adjustment in different locales or for custom date/time formats + # set in the Windows Control Panel. + # + SET(${GD_PREFIX}CMD "cmd") + SET(${GD_PREFIX}ARGS "/c echo %DATE% %TIME%") + ELSE(WIN32) + # + # Match the format returned by default in US English Windows: + # + SET(${GD_PREFIX}CMD "date") + SET(${GD_PREFIX}ARGS "\"+%a %m/%d/%Y %H:%M:%S.00\"") + ENDIF(WIN32) + + EXEC_PROGRAM("${${GD_PREFIX}CMD}" "." ARGS "${${GD_PREFIX}ARGS}" + OUTPUT_VARIABLE ${GD_PREFIX}OV RETURN_VALUE ${GD_PREFIX}RV + ) + + IF(${GD_PREFIX}VERBOSE) + MESSAGE(STATUS "") + MESSAGE(STATUS "<GET_DATE>") + MESSAGE(STATUS "") + MESSAGE(STATUS "GD_PREFIX='${GD_PREFIX}'") + IF(NOT "${GD_PREFIX}" STREQUAL "GD_") + MESSAGE(STATUS "${GD_PREFIX}PREFIX='${${GD_PREFIX}PREFIX}'") + ENDIF(NOT "${GD_PREFIX}" STREQUAL "GD_") + MESSAGE(STATUS "${GD_PREFIX}VERBOSE='${${GD_PREFIX}VERBOSE}'") + MESSAGE(STATUS "") + MESSAGE(STATUS "${GD_PREFIX}CMD='${${GD_PREFIX}CMD}'") + MESSAGE(STATUS "${GD_PREFIX}ARGS='${${GD_PREFIX}ARGS}'") + MESSAGE(STATUS "${GD_PREFIX}OV='${${GD_PREFIX}OV}'") + MESSAGE(STATUS "${GD_PREFIX}RV='${${GD_PREFIX}RV}'") + MESSAGE(STATUS "") + ENDIF(${GD_PREFIX}VERBOSE) + + IF("${${GD_PREFIX}RV}" STREQUAL "0") + # + # Extract eight individual components by matching a regex with paren groupings. + # Use the replace functionality and \\1 thru \\8 to extract components. + # + SET(${GD_PREFIX}REGEX "([^ ]+) +([^/]+)/([^/]+)/([^ ]+) +([^:]+):([^:]+):([^\\.]+)\\.(.*)") + + STRING(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\1" ${GD_PREFIX}DAY_OF_WEEK "${${GD_PREFIX}OV}") + STRING(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\2" ${GD_PREFIX}MONTH "${${GD_PREFIX}OV}") + STRING(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\3" ${GD_PREFIX}DAY "${${GD_PREFIX}OV}") + STRING(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\4" ${GD_PREFIX}YEAR "${${GD_PREFIX}OV}") + STRING(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\5" ${GD_PREFIX}HOUR "${${GD_PREFIX}OV}") + STRING(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\6" ${GD_PREFIX}MINUTE "${${GD_PREFIX}OV}") + STRING(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\7" ${GD_PREFIX}SECOND "${${GD_PREFIX}OV}") + STRING(REGEX REPLACE "${${GD_PREFIX}REGEX}" "\\8" ${GD_PREFIX}FRACTIONAL_SECOND "${${GD_PREFIX}OV}") + + # + # Verify that extracted components don't have anything obviously + # wrong with them... Emit warnings if something looks suspicious... + # + + # Expecting a four digit year: + # + IF(NOT "${${GD_PREFIX}YEAR}" MATCHES "^[0-9][0-9][0-9][0-9]$") + MESSAGE(STATUS "WARNING: Extracted ${GD_PREFIX}YEAR='${${GD_PREFIX}YEAR}' is not a four digit number...") + ENDIF(NOT "${${GD_PREFIX}YEAR}" MATCHES "^[0-9][0-9][0-9][0-9]$") + + # Expecting month to be <= 12: + # + IF(${${GD_PREFIX}MONTH} GREATER 12) + MESSAGE(STATUS "WARNING: Extracted ${GD_PREFIX}MONTH='${${GD_PREFIX}MONTH}' is greater than 12!") + ENDIF(${${GD_PREFIX}MONTH} GREATER 12) + + # Expecting day to be <= 31: + # + IF(${${GD_PREFIX}DAY} GREATER 31) + MESSAGE(STATUS "WARNING: Extracted ${GD_PREFIX}DAY='${${GD_PREFIX}DAY}' is greater than 31!") + ENDIF(${${GD_PREFIX}DAY} GREATER 31) + + # Expecting hour to be <= 23: + # + IF(${${GD_PREFIX}HOUR} GREATER 23) + MESSAGE(STATUS "WARNING: Extracted ${GD_PREFIX}HOUR='${${GD_PREFIX}HOUR}' is greater than 23!") + ENDIF(${${GD_PREFIX}HOUR} GREATER 23) + + # Expecting minute to be <= 59: + # + IF(${${GD_PREFIX}MINUTE} GREATER 59) + MESSAGE(STATUS "WARNING: Extracted ${GD_PREFIX}MINUTE='${${GD_PREFIX}MINUTE}' is greater than 59!") + ENDIF(${${GD_PREFIX}MINUTE} GREATER 59) + + # Expecting second to be <= 59: + # + IF(${${GD_PREFIX}SECOND} GREATER 59) + MESSAGE(STATUS "WARNING: Extracted ${GD_PREFIX}SECOND='${${GD_PREFIX}SECOND}' is greater than 59!") + ENDIF(${${GD_PREFIX}SECOND} GREATER 59) + + # If individual components are single digit, + # prepend a leading zero: + # + IF("${${GD_PREFIX}YEAR}" MATCHES "^[0-9]$") + SET(${GD_PREFIX}YEAR "0${${GD_PREFIX}YEAR}") + ENDIF("${${GD_PREFIX}YEAR}" MATCHES "^[0-9]$") + IF("${${GD_PREFIX}MONTH}" MATCHES "^[0-9]$") + SET(${GD_PREFIX}MONTH "0${${GD_PREFIX}MONTH}") + ENDIF("${${GD_PREFIX}MONTH}" MATCHES "^[0-9]$") + IF("${${GD_PREFIX}DAY}" MATCHES "^[0-9]$") + SET(${GD_PREFIX}DAY "0${${GD_PREFIX}DAY}") + ENDIF("${${GD_PREFIX}DAY}" MATCHES "^[0-9]$") + IF("${${GD_PREFIX}HOUR}" MATCHES "^[0-9]$") + SET(${GD_PREFIX}HOUR "0${${GD_PREFIX}HOUR}") + ENDIF("${${GD_PREFIX}HOUR}" MATCHES "^[0-9]$") + IF("${${GD_PREFIX}MINUTE}" MATCHES "^[0-9]$") + SET(${GD_PREFIX}MINUTE "0${${GD_PREFIX}MINUTE}") + ENDIF("${${GD_PREFIX}MINUTE}" MATCHES "^[0-9]$") + IF("${${GD_PREFIX}SECOND}" MATCHES "^[0-9]$") + SET(${GD_PREFIX}SECOND "0${${GD_PREFIX}SECOND}") + ENDIF("${${GD_PREFIX}SECOND}" MATCHES "^[0-9]$") + + IF(${GD_PREFIX}VERBOSE) + MESSAGE(STATUS "${GD_PREFIX}REGEX='${${GD_PREFIX}REGEX}'") + MESSAGE(STATUS "${GD_PREFIX}YEAR='${${GD_PREFIX}YEAR}'") + MESSAGE(STATUS "${GD_PREFIX}MONTH='${${GD_PREFIX}MONTH}'") + MESSAGE(STATUS "${GD_PREFIX}DAY='${${GD_PREFIX}DAY}'") + MESSAGE(STATUS "${GD_PREFIX}HOUR='${${GD_PREFIX}HOUR}'") + MESSAGE(STATUS "${GD_PREFIX}MINUTE='${${GD_PREFIX}MINUTE}'") + MESSAGE(STATUS "${GD_PREFIX}SECOND='${${GD_PREFIX}SECOND}'") + MESSAGE(STATUS "${GD_PREFIX}FRACTIONAL_SECOND='${${GD_PREFIX}FRACTIONAL_SECOND}'") + MESSAGE(STATUS "${GD_PREFIX}DAY_OF_WEEK='${${GD_PREFIX}DAY_OF_WEEK}'") + MESSAGE(STATUS "") + MESSAGE(STATUS "Counters that change...") + MESSAGE(STATUS "") + MESSAGE(STATUS "...very very quickly : ${${GD_PREFIX}YEAR}${${GD_PREFIX}MONTH}${${GD_PREFIX}DAY}${${GD_PREFIX}HOUR}${${GD_PREFIX}MINUTE}${${GD_PREFIX}SECOND}${${GD_PREFIX}FRACTIONAL_SECOND}") + MESSAGE(STATUS " every second : ${${GD_PREFIX}YEAR}${${GD_PREFIX}MONTH}${${GD_PREFIX}DAY}${${GD_PREFIX}HOUR}${${GD_PREFIX}MINUTE}${${GD_PREFIX}SECOND}") + MESSAGE(STATUS " daily : ${${GD_PREFIX}YEAR}${${GD_PREFIX}MONTH}${${GD_PREFIX}DAY}") + MESSAGE(STATUS " monthly : ${${GD_PREFIX}YEAR}${${GD_PREFIX}MONTH}") + MESSAGE(STATUS " annually : ${${GD_PREFIX}YEAR}") + MESSAGE(STATUS "") + ENDIF(${GD_PREFIX}VERBOSE) + ELSE("${${GD_PREFIX}RV}" STREQUAL "0") + MESSAGE(SEND_ERROR "ERROR: MACRO(GET_DATE) failed. ${GD_PREFIX}CMD='${${GD_PREFIX}CMD}' ${GD_PREFIX}ARGS='${${GD_PREFIX}ARGS}' ${GD_PREFIX}OV='${${GD_PREFIX}OV}' ${GD_PREFIX}RV='${${GD_PREFIX}RV}'") + ENDIF("${${GD_PREFIX}RV}" STREQUAL "0") + + IF(${GD_PREFIX}VERBOSE) + MESSAGE(STATUS "</GET_DATE>") + MESSAGE(STATUS "") + ENDIF(${GD_PREFIX}VERBOSE) +ENDMACRO(GET_DATE) + +MACRO(ADD_SECONDS sec) + set(new_min ${${GD_PREFIX}MINUTE}) + set(new_hr ${${GD_PREFIX}HOUR}) + math(EXPR new_sec "${sec} + ${${GD_PREFIX}SECOND}") + while(${new_sec} GREATER 60 OR ${new_sec} EQUAL 60) + math(EXPR new_sec "${new_sec} - 60") + math(EXPR new_min "${${GD_PREFIX}MINUTE} + 1") + endwhile() + while(${new_min} GREATER 60 OR ${new_min} EQUAL 60) + math(EXPR new_min "${new_min} - 60") + math(EXPR new_hr "${${GD_PREFIX}HOUR} + 1") + endwhile() + math(EXPR new_hr "${new_hr} % 24") + + # Pad the H, M, S if needed + string(LENGTH ${new_sec} sec_len) + string(LENGTH ${new_min} min_len) + string(LENGTH ${new_hr} hr_len) + if(${sec_len} EQUAL 1) + set(new_sec "0${new_sec}") + endif() + if(${min_len} EQUAL 1) + set(new_min "0${new_min}") + endif() + if(${hr_len} EQUAL 1) + set(new_hr "0${new_hr}") + endif() +ENDMACRO(ADD_SECONDS) diff --git a/Tests/CTestTestStopTime/sleep.c b/Tests/CTestTestStopTime/sleep.c new file mode 100644 index 000000000..b5896474b --- /dev/null +++ b/Tests/CTestTestStopTime/sleep.c @@ -0,0 +1,21 @@ +#if defined(_WIN32) +# include <windows.h> +#else +# include <unistd.h> +#endif + +/* sleeps for n seconds, where n is the argument to the program */ +int main(int argc, char** argv) +{ + int time; + if(argc > 1) + { + time = atoi(argv[1]); + } +#if defined(_WIN32) + Sleep(time * 1000); +#else + sleep(time); +#endif + return 0; +} diff --git a/Tests/CTestTestStopTime/test.cmake.in b/Tests/CTestTestStopTime/test.cmake.in new file mode 100644 index 000000000..2d03686e6 --- /dev/null +++ b/Tests/CTestTestStopTime/test.cmake.in @@ -0,0 +1,31 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-StopTime") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestStopTime") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestStopTime") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +INCLUDE("${CTEST_BINARY_DIRECTORY}/GetDate.cmake") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) + +GET_DATE() +message("curr time: ${${GD_PREFIX}HOUR}:${${GD_PREFIX}MINUTE}:${${GD_PREFIX}SECOND}") +ADD_SECONDS(15) +message("stop time: ${new_hr}:${new_min}:${new_sec}") + +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res STOP_TIME "${new_hr}:${new_min}:${new_sec}") + +#CTEST_SUBMIT() diff --git a/Tests/CTestTestSubdir/CMakeLists.txt b/Tests/CTestTestSubdir/CMakeLists.txt new file mode 100644 index 000000000..5400ee8c5 --- /dev/null +++ b/Tests/CTestTestSubdir/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CTestTestSubdir) +INCLUDE(CTest) + +ADD_SUBDIRECTORY(subdir) +SUBDIRS(subdir2) +SUBDIRS("${CTestTestSubdir_SOURCE_DIR}/subdir3") diff --git a/Tests/CTestTestSubdir/CTestConfig.cmake b/Tests/CTestTestSubdir/CTestConfig.cmake new file mode 100644 index 000000000..4b848aa26 --- /dev/null +++ b/Tests/CTestTestSubdir/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "CTestTestSubdir") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestSubdir/subdir/CMakeLists.txt b/Tests/CTestTestSubdir/subdir/CMakeLists.txt new file mode 100644 index 000000000..b40d316d6 --- /dev/null +++ b/Tests/CTestTestSubdir/subdir/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_EXECUTABLE (main main.c) +ADD_TEST (TestMain1 main) diff --git a/Tests/CTestTestSubdir/subdir/main.c b/Tests/CTestTestSubdir/subdir/main.c new file mode 100644 index 000000000..8488f4e58 --- /dev/null +++ b/Tests/CTestTestSubdir/subdir/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/CTestTestSubdir/subdir2/CMakeLists.txt b/Tests/CTestTestSubdir/subdir2/CMakeLists.txt new file mode 100644 index 000000000..23f8e07c2 --- /dev/null +++ b/Tests/CTestTestSubdir/subdir2/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_EXECUTABLE (main2 main.c) +ADD_TEST (TestMain2 main2) diff --git a/Tests/CTestTestSubdir/subdir2/main.c b/Tests/CTestTestSubdir/subdir2/main.c new file mode 100644 index 000000000..8488f4e58 --- /dev/null +++ b/Tests/CTestTestSubdir/subdir2/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/CTestTestSubdir/subdir3/CMakeLists.txt b/Tests/CTestTestSubdir/subdir3/CMakeLists.txt new file mode 100644 index 000000000..9a44b12b8 --- /dev/null +++ b/Tests/CTestTestSubdir/subdir3/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_EXECUTABLE (main3 main.c) +ADD_TEST (TestMain3 main3) diff --git a/Tests/CTestTestSubdir/subdir3/main.c b/Tests/CTestTestSubdir/subdir3/main.c new file mode 100644 index 000000000..8488f4e58 --- /dev/null +++ b/Tests/CTestTestSubdir/subdir3/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/CTestTestSubdir/test.cmake.in b/Tests/CTestTestSubdir/test.cmake.in new file mode 100644 index 000000000..f240473ee --- /dev/null +++ b/Tests/CTestTestSubdir/test.cmake.in @@ -0,0 +1,21 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Subdir") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestSubdir") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestSubdir") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestTimeout/CMakeLists.txt b/Tests/CTestTestTimeout/CMakeLists.txt new file mode 100644 index 000000000..0fd1cebb3 --- /dev/null +++ b/Tests/CTestTestTimeout/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required (VERSION 2.8) +PROJECT(CTestTestTimeout) +INCLUDE(CTest) + +IF(NOT TIMEOUT) + IF(CYGWIN) + SET(TIMEOUT 4) # Cygwin CMake sometimes takes > 1 second to load! + ELSE() + SET(TIMEOUT 1) + ENDIF() +ENDIF() + +ADD_DEFINITIONS(-DTIMEOUT=${TIMEOUT}) +ADD_EXECUTABLE (Timeout timeout.c) + +ADD_TEST(NAME TestTimeout + COMMAND ${CMAKE_COMMAND} -D Timeout=$<TARGET_FILE:Timeout> + -D Log=${CMAKE_CURRENT_BINARY_DIR}/timeout.log + -P ${CMAKE_CURRENT_SOURCE_DIR}/timeout.cmake + ) +SET_TESTS_PROPERTIES(TestTimeout PROPERTIES TIMEOUT ${TIMEOUT}) + +ADD_TEST(NAME CheckChild + COMMAND ${CMAKE_COMMAND} -D Timeout=$<TARGET_FILE:Timeout> + -D Log=${CMAKE_CURRENT_BINARY_DIR}/timeout.log + -P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake + ) +SET_TESTS_PROPERTIES(CheckChild PROPERTIES DEPENDS TestTimeout) diff --git a/Tests/CTestTestTimeout/CTestConfig.cmake b/Tests/CTestTestTimeout/CTestConfig.cmake new file mode 100644 index 000000000..76d62ad27 --- /dev/null +++ b/Tests/CTestTestTimeout/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "CTestTestTimeout") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestTimeout/check.cmake b/Tests/CTestTestTimeout/check.cmake new file mode 100644 index 000000000..b16f2aab9 --- /dev/null +++ b/Tests/CTestTestTimeout/check.cmake @@ -0,0 +1,9 @@ +# Block just as long as timeout.cmake would if it were not killed. +execute_process(COMMAND ${Timeout}) + +# Verify that the log is empty, which indicates that the grandchild +# was killed before it finished sleeping. +file(READ "${Log}" LOG) +if(NOT "${LOG}" STREQUAL "") + message(FATAL_ERROR "${LOG}") +endif() diff --git a/Tests/CTestTestTimeout/test.cmake.in b/Tests/CTestTestTimeout/test.cmake.in new file mode 100644 index 000000000..8a8dc24e5 --- /dev/null +++ b/Tests/CTestTestTimeout/test.cmake.in @@ -0,0 +1,25 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Timeout") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestTimeout") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestTimeout") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +#CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) + +FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " +TIMEOUT:STRING=@CTestTestTimeout_TIME@ +") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestTimeout/timeout.c b/Tests/CTestTestTimeout/timeout.c new file mode 100644 index 000000000..370ab22ed --- /dev/null +++ b/Tests/CTestTestTimeout/timeout.c @@ -0,0 +1,18 @@ +#if defined(_WIN32) +# include <windows.h> +#else +# include <unistd.h> +#endif + +#include <stdio.h> + +int main(void) +{ +#if defined(_WIN32) + Sleep((TIMEOUT+4)*1000); +#else + sleep((TIMEOUT+4)); +#endif + printf("timeout process finished sleeping!\n"); + return -1; +} diff --git a/Tests/CTestTestTimeout/timeout.cmake b/Tests/CTestTestTimeout/timeout.cmake new file mode 100644 index 000000000..198cc9713 --- /dev/null +++ b/Tests/CTestTestTimeout/timeout.cmake @@ -0,0 +1,6 @@ +# Remove the log file. +file(REMOVE ${Log}) + +# Run a child that sleeps longer than the timout of this test. +# Log its output so check.cmake can verify it dies. +execute_process(COMMAND ${Timeout} OUTPUT_FILE ${Log}) diff --git a/Tests/CTestTestUpload/CMakeLists.txt b/Tests/CTestTestUpload/CMakeLists.txt new file mode 100644 index 000000000..bc164b10c --- /dev/null +++ b/Tests/CTestTestUpload/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CTestTestUpload) + +add_executable (Sleep sleep.c) diff --git a/Tests/CTestTestUpload/CTestConfig.cmake b/Tests/CTestTestUpload/CTestConfig.cmake new file mode 100644 index 000000000..89c5b9474 --- /dev/null +++ b/Tests/CTestTestUpload/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestUpload") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set (CTEST_DROP_METHOD "http") +set (CTEST_DROP_SITE "www.cdash.org") +set (CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set (CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestUpload/sleep.c b/Tests/CTestTestUpload/sleep.c new file mode 100644 index 000000000..b5896474b --- /dev/null +++ b/Tests/CTestTestUpload/sleep.c @@ -0,0 +1,21 @@ +#if defined(_WIN32) +# include <windows.h> +#else +# include <unistd.h> +#endif + +/* sleeps for n seconds, where n is the argument to the program */ +int main(int argc, char** argv) +{ + int time; + if(argc > 1) + { + time = atoi(argv[1]); + } +#if defined(_WIN32) + Sleep(time * 1000); +#else + sleep(time); +#endif + return 0; +} diff --git a/Tests/CTestTestUpload/test.cmake.in b/Tests/CTestTestUpload/test.cmake.in new file mode 100644 index 000000000..acfa233bc --- /dev/null +++ b/Tests/CTestTestUpload/test.cmake.in @@ -0,0 +1,17 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Upload") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestUpload") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestUpload") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_UPLOAD(FILES "${CTEST_SOURCE_DIRECTORY}/sleep.c" "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt") +CTEST_SUBMIT() diff --git a/Tests/CTestTestZeroTimeout/CMakeLists.txt b/Tests/CTestTestZeroTimeout/CMakeLists.txt new file mode 100644 index 000000000..8a5246db1 --- /dev/null +++ b/Tests/CTestTestZeroTimeout/CMakeLists.txt @@ -0,0 +1,8 @@ +CMAKE_MINIMUM_REQUIRED (VERSION 2.6) +PROJECT (CTestTestZeroTimeout) +INCLUDE (CTest) + +ADD_EXECUTABLE (Sleep sleep.c) + +ADD_TEST (TestExplicitZeroTimeout Sleep) +SET_TESTS_PROPERTIES(TestExplicitZeroTimeout PROPERTIES TIMEOUT 0) diff --git a/Tests/CTestTestZeroTimeout/CTestConfig.cmake b/Tests/CTestTestZeroTimeout/CTestConfig.cmake new file mode 100644 index 000000000..f8e06093d --- /dev/null +++ b/Tests/CTestTestZeroTimeout/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "CTestTestZeroTimeout") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestZeroTimeout/sleep.c b/Tests/CTestTestZeroTimeout/sleep.c new file mode 100644 index 000000000..d40d59d97 --- /dev/null +++ b/Tests/CTestTestZeroTimeout/sleep.c @@ -0,0 +1,16 @@ +#if defined(_WIN32) +# include <windows.h> +#else +# include <unistd.h> +#endif + +/* sleeps for 5 seconds */ +int main(int argc, char** argv) +{ +#if defined(_WIN32) + Sleep(5000); +#else + sleep(5); +#endif + return 0; +} diff --git a/Tests/CTestTestZeroTimeout/test.cmake.in b/Tests/CTestTestZeroTimeout/test.cmake.in new file mode 100644 index 000000000..56bae9d17 --- /dev/null +++ b/Tests/CTestTestZeroTimeout/test.cmake.in @@ -0,0 +1,20 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ZeroTimeout") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestZeroTimeout") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestZeroTimeout") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") +SET(CTEST_TEST_TIMEOUT 2) + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestUpdateBZR.cmake.in b/Tests/CTestUpdateBZR.cmake.in new file mode 100644 index 000000000..c654f477a --- /dev/null +++ b/Tests/CTestUpdateBZR.cmake.in @@ -0,0 +1,153 @@ +# This script drives creation of a bzr repository and checks +# that CTest can update from it. + +#----------------------------------------------------------------------------- +# Test in a directory next to this script. +get_filename_component(TOP "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(TOP "${TOP}/@CTestUpdateBZR_DIR@") + +# Include code common to all update tests. +include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake") + +#----------------------------------------------------------------------------- +# Report bzr tools in use. +message("Using BZR tools:") +set(BZR "@BZR_EXECUTABLE@") +message(" bzr = ${BZR}") + +#----------------------------------------------------------------------------- +# Initialize the testing directory. +message("Creating test directory...") +init_testing() + +#----------------------------------------------------------------------------- +# Create the repository. +message("Creating repository...") +file(MAKE_DIRECTORY ${TOP}/repo.bzr) +run_child( + WORKING_DIRECTORY ${TOP}/repo.bzr + COMMAND ${BZR} init + ) +set(REPO file://${TOP}/repo.bzr) + +#----------------------------------------------------------------------------- +# Import initial content into the repository. +message("Importing content...") +create_content(import) + +# Import the content into the repository. +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${BZR} init + ) +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${BZR} whoami --branch "Test Author <testauthor@cmake.org>" + ) + +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${BZR} add . + ) +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${BZR} commit -m "Initial content" + ) +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${BZR} push --create-prefix "${REPO}" + ) + +#----------------------------------------------------------------------------- +# Create a working tree. +message("Checking out revision 1...") +run_child( + WORKING_DIRECTORY ${TOP} + COMMAND ${BZR} branch "${REPO}" user-source + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${BZR} whoami --branch "Test Author <testauthor@cmake.org>" + ) + +#----------------------------------------------------------------------------- +# Make changes in the working tree. +message("Changing content...") +update_content(user-source files_added files_removed dirs_added) +if(dirs_added) + run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${BZR} add ${dirs_added} + ) +endif(dirs_added) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${BZR} add ${files_added} + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${BZR} rm ${files_removed} + ) + +#----------------------------------------------------------------------------- +# Commit the changes to the repository. +message("Committing revision 2...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${BZR} commit -m "Changed content" + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${BZR} push "${REPO}" + ) + +#----------------------------------------------------------------------------- +# Make changes in the working tree. +message("Changing content again...") +change_content(user-source) + +#----------------------------------------------------------------------------- +# Commit the changes to the repository. +message("Committing revision 3...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${BZR} commit -m "Changed content again" + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${BZR} push "${REPO}" + ) + +#----------------------------------------------------------------------------- +# Go back to before the changes so we can test updating. +message("Backing up to revision 1...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${BZR} pull --overwrite -r1 + ) + +# Create a modified file. +modify_content(user-source) + +#----------------------------------------------------------------------------- +# Test updating the user work directory with the command-line interface. +message("Running CTest Dashboard Command Line...") + +# Create the user build tree. +create_build_tree(user-source user-binary) +file(APPEND ${TOP}/user-binary/CTestConfiguration.ini + "# BZR command configuration +UpdateCommand: ${BZR} +") + +# Run the dashboard command line interface. +run_dashboard_command_line(user-binary) + +#----------------------------------------------------------------------------- +# Test initial checkout and update with a dashboard script. +message("Running CTest Dashboard Script...") + +create_dashboard_script(dash-binary + "# bzr command configuration +set(CTEST_BZR_COMMAND \"${BZR}\") +set(CTEST_CHECKOUT_COMMAND + \"\\\"\${CTEST_BZR_COMMAND}\\\" branch -r1 \\\"${REPO}\\\" dash-source\") +") + +# Run the dashboard script with CTest. +run_dashboard_script(dash-binary) diff --git a/Tests/CTestUpdateCVS.cmake.in b/Tests/CTestUpdateCVS.cmake.in new file mode 100644 index 000000000..f7f5db65d --- /dev/null +++ b/Tests/CTestUpdateCVS.cmake.in @@ -0,0 +1,172 @@ +# This script drives creation of a CVS repository and checks +# that CTest can update from it. + +#----------------------------------------------------------------------------- +# Test in a directory next to this script. +get_filename_component(TOP "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(TOP "${TOP}/@CTestUpdateCVS_DIR@") +set(UPDATE_NOT_GLOBAL 1) +set(UPDATE_MAYBE Updated{CTestConfig.cmake}) + +# Include code common to all update tests. +include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake") + +#----------------------------------------------------------------------------- +# Report CVS tools in use. +message("Using CVS tools:") +set(CVS "@CVS_EXECUTABLE@") +message(" cvs = ${CVS}") + +set(REPO ${TOP}/repo) + +# The MSYS cvs tool interprets "c:/" as a "machine:" name for SSH. +# Detect the MSYS cvs and convert the repo path to an MSYS path. +if(WIN32) + if(EXISTS "${CVS}") + file(STRINGS "${CVS}" cvs_is_msys LIMIT_COUNT 1 REGEX "[Mm][Ss][Yy][Ss]") + if(cvs_is_msys) + message(" '${CVS}' is from MSYS (contains '${cvs_is_msys}')") + string(REGEX REPLACE "^([A-Za-z]):" "/\\1" REPO "${REPO}") + endif() + endif() +endif() + +set(CVSCMD ${CVS} -d${REPO}) + +# CVSNT requires an extra option to 'cvs init'. +set(CVS_INIT_OPT) +execute_process( + COMMAND ${CVS} --version + RESULT_VARIABLE RESULT + OUTPUT_VARIABLE OUTPUT + ERROR_VARIABLE OUTPUT + ) +if("${RESULT}" STREQUAL "0" AND "${OUTPUT}" MATCHES "\\(CVSNT\\)") + set(CVS_INIT_OPT -n) + message(" cvs init needs -n") +endif() + +#----------------------------------------------------------------------------- +# Initialize the testing directory. +message("Creating test directory...") +init_testing() + +#----------------------------------------------------------------------------- +# Create the repository. +message("Creating repository...") +file(MAKE_DIRECTORY ${TOP}/repo) +run_child( + COMMAND ${CVSCMD} init ${CVS_INIT_OPT} + ) + +#----------------------------------------------------------------------------- +# Import initial content into the repository. +message("Importing content...") +create_content(import) + +# Import the content into the repository. +run_child( + WORKING_DIRECTORY ${TOP}/import + COMMAND ${CVSCMD} import -m "Initial content" Project vendor-tag release-tag + ) + +#----------------------------------------------------------------------------- +# Create a working tree. +message("Checking out revision 1...") +run_child( + WORKING_DIRECTORY ${TOP} + COMMAND ${CVSCMD} co -d user-source Project + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${CVSCMD} tag Revision1 + ) + +#----------------------------------------------------------------------------- +# Make changes in the working tree. +message("Changing content...") +update_content(user-source files_added files_removed dirs_added) +if(dirs_added) + run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${CVSCMD} add ${dirs_added} + ) +endif(dirs_added) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${CVSCMD} add ${files_added} + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${CVSCMD} rm ${files_removed} + ) + +#----------------------------------------------------------------------------- +# Commit the changes to the repository. +message("Committing revision 2...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${CVSCMD} commit -m "Changed content" + ) + +#----------------------------------------------------------------------------- +# Make changes in the working tree. +message("Changing content again...") +change_content(user-source) + +#----------------------------------------------------------------------------- +# Commit the changes to the repository. +message("Committing revision 3...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${CVSCMD} commit -m "Changed content again" + ) + +#----------------------------------------------------------------------------- +# Go back to before the changes so we can test updating. +message("Backing up to revision 1...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${CVSCMD} up -rRevision1 + ) + +# Delay 1 second so the modification produces a newer time stamp. +find_program(SLEEP sleep) +if(SLEEP) + message("Delaying...") + execute_process(COMMAND ${SLEEP} 1) +endif() + +# Create a modified file. +message("Modifying locally...") +modify_content(user-source) + +#----------------------------------------------------------------------------- +# Test updating the user work directory with the command-line interface. +message("Running CTest Dashboard Command Line...") + +# Create the user build tree. +create_build_tree(user-source user-binary) +file(APPEND ${TOP}/user-binary/CTestConfiguration.ini + "# CVS command configuration +CVSCommand: ${CVS} +CVSUpdateOptions: -dAP +") + +# Run the dashboard command line interface. +run_dashboard_command_line(user-binary) + +#----------------------------------------------------------------------------- +# Test initial checkout and update with a dashboard script. +message("Running CTest Dashboard Script...") + +create_dashboard_script(dash-binary + "# CVS command configuration +set(CTEST_CVS_COMMAND \"${CVS}\") +set(CTEST_CVS_UPDATE_OPTIONS -dAP) +set(CTEST_CHECKOUT_COMMAND + \"\\\"\${CTEST_CVS_COMMAND}\\\" -d \\\"${REPO}\\\" co -rRevision1 -d dash-source Project\") +") + +# Run the dashboard script with CTest. +run_dashboard_script(dash-binary) diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake new file mode 100644 index 000000000..335d09e7e --- /dev/null +++ b/Tests/CTestUpdateCommon.cmake @@ -0,0 +1,234 @@ +#----------------------------------------------------------------------------- +# Function to run a child process and report output only on error. +function(run_child) + execute_process(${ARGN} + RESULT_VARIABLE FAILED + OUTPUT_VARIABLE OUTPUT + ERROR_VARIABLE OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_STRIP_TRAILING_WHITESPACE + ) + if(FAILED) + string(REGEX REPLACE "\n" "\n " OUTPUT "${OUTPUT}") + message(FATAL_ERROR "Child failed (${FAILED}), output is\n ${OUTPUT}\n" + "Command = [${ARGN}]\n") + endif(FAILED) +endfunction(run_child) + +#----------------------------------------------------------------------------- +# Function to find the Update.xml file and check for expected entries. +function(check_updates build) + # Find the Update.xml file for the given build tree + set(PATTERN ${TOP}/${build}/Testing/*/Update.xml) + file(GLOB UPDATE_XML_FILE RELATIVE ${TOP} ${PATTERN}) + string(REGEX REPLACE "//Update.xml$" "/Update.xml" + UPDATE_XML_FILE "${UPDATE_XML_FILE}" + ) + if(NOT UPDATE_XML_FILE) + message(FATAL_ERROR "Cannot find Update.xml with pattern\n ${PATTERN}") + endif(NOT UPDATE_XML_FILE) + message(" found ${UPDATE_XML_FILE}") + + set(max_update_xml_size 16384) + + # Read entries from the Update.xml file + set(types "Updated|Modified|Conflicting") + file(STRINGS ${TOP}/${UPDATE_XML_FILE} UPDATE_XML_ENTRIES + REGEX "<(${types}|FullName)>" + LIMIT_INPUT ${max_update_xml_size} + ) + string(REGEX REPLACE + "[ \t]*<(${types})>[ \t]*;[ \t]*<FullName>([^<]*)</FullName>" + "\\1{\\2}" UPDATE_XML_ENTRIES "${UPDATE_XML_ENTRIES}") + + # Compare expected and actual entries + set(EXTRA "${UPDATE_XML_ENTRIES}") + list(REMOVE_ITEM EXTRA ${ARGN} ${UPDATE_EXTRA} ${UPDATE_MAYBE}) + set(MISSING "${ARGN}" ${UPDATE_EXTRA}) + list(REMOVE_ITEM MISSING ${UPDATE_XML_ENTRIES}) + + if(NOT UPDATE_NOT_GLOBAL) + set(rev_elements Revision PriorRevision ${UPDATE_GLOBAL_ELEMENTS}) + string(REPLACE ";" "|" rev_regex "${rev_elements}") + set(rev_regex "^\t<(${rev_regex})>[^<\n]+</(${rev_regex})>$") + file(STRINGS ${TOP}/${UPDATE_XML_FILE} UPDATE_XML_REVISIONS + REGEX "${rev_regex}" + LIMIT_INPUT ${max_update_xml_size} + ) + foreach(r IN LISTS UPDATE_XML_REVISIONS) + string(REGEX REPLACE "${rev_regex}" "\\1" element "${r}") + set(element_${element} 1) + endforeach() + foreach(element ${rev_elements}) + if(NOT element_${element}) + list(APPEND MISSING "global <${element}> element") + endif() + endforeach() + endif() + + # Report the result + set(MSG "") + if(MISSING) + # List the missing entries + set(MSG "${MSG}Update.xml is missing expected entries:\n") + foreach(f ${MISSING}) + set(MSG "${MSG} ${f}\n") + endforeach(f) + else(MISSING) + # Success + message(" no entries missing from Update.xml") + endif(MISSING) + + # Report the result + if(EXTRA) + # List the extra entries + set(MSG "${MSG}Update.xml has extra unexpected entries:\n") + foreach(f ${EXTRA}) + set(MSG "${MSG} ${f}\n") + endforeach(f) + else(EXTRA) + # Success + message(" no extra entries in Update.xml") + endif(EXTRA) + + if(MSG) + # Provide the log file + file(GLOB UPDATE_LOG_FILE + ${TOP}/${build}/Testing/Temporary/LastUpdate*.log) + if(UPDATE_LOG_FILE) + file(READ ${UPDATE_LOG_FILE} UPDATE_LOG LIMIT ${max_update_xml_size}) + string(REGEX REPLACE "\n" "\n " UPDATE_LOG "${UPDATE_LOG}") + set(MSG "${MSG}Update log:\n ${UPDATE_LOG}") + else(UPDATE_LOG_FILE) + set(MSG "${MSG}No update log found!") + endif(UPDATE_LOG_FILE) + + # Display the error message + message(FATAL_ERROR "${MSG}") + endif(MSG) +endfunction(check_updates) + +#----------------------------------------------------------------------------- +# Function to create initial content. +function(create_content dir) + file(MAKE_DIRECTORY ${TOP}/${dir}) + + # An example CTest project configuration file. + file(WRITE ${TOP}/${dir}/CTestConfig.cmake + "# CTest Configuration File +set(CTEST_PROJECT_NAME TestProject) +set(CTEST_NIGHTLY_START_TIME \"21:00:00 EDT\") +") + + # Some other files. + file(WRITE ${TOP}/${dir}/foo.txt "foo\n") + file(WRITE ${TOP}/${dir}/bar.txt "bar\n") +endfunction(create_content) + +#----------------------------------------------------------------------------- +# Function to update content. +function(update_content dir added_var removed_var dirs_var) + file(APPEND ${TOP}/${dir}/foo.txt "foo line 2\n") + file(WRITE ${TOP}/${dir}/zot.txt "zot\n") + file(REMOVE ${TOP}/${dir}/bar.txt) + file(MAKE_DIRECTORY ${TOP}/${dir}/subdir) + file(WRITE ${TOP}/${dir}/subdir/foo.txt "foo\n") + file(WRITE ${TOP}/${dir}/subdir/bar.txt "bar\n") + set(${dirs_var} subdir PARENT_SCOPE) + set(${added_var} zot.txt subdir/foo.txt subdir/bar.txt PARENT_SCOPE) + set(${removed_var} bar.txt PARENT_SCOPE) +endfunction(update_content) + +#----------------------------------------------------------------------------- +# Function to change existing files +function(change_content dir) + file(APPEND ${TOP}/${dir}/foo.txt "foo line 3\n") + file(APPEND ${TOP}/${dir}/subdir/foo.txt "foo line 2\n") +endfunction(change_content) + +#----------------------------------------------------------------------------- +# Function to create local modifications before update +function(modify_content dir) + file(APPEND ${TOP}/${dir}/CTestConfig.cmake "# local modification\n") +endfunction(modify_content) + +#----------------------------------------------------------------------------- +# Function to write CTestConfiguration.ini content. +function(create_build_tree src_dir bin_dir) + file(MAKE_DIRECTORY ${TOP}/${bin_dir}) + file(WRITE ${TOP}/${bin_dir}/CTestConfiguration.ini + "# CTest Configuration File +SourceDirectory: ${TOP}/${src_dir} +BuildDirectory: ${TOP}/${bin_dir} +Site: test.site +BuildName: user-test +") +endfunction(create_build_tree) + +#----------------------------------------------------------------------------- +# Function to write the dashboard test script. +function(create_dashboard_script bin_dir custom_text) + # Write the dashboard script. + file(WRITE ${TOP}/${bin_dir}.cmake + "# CTest Dashboard Script +set(CTEST_DASHBOARD_ROOT \"${TOP}\") +set(CTEST_SITE test.site) +set(CTEST_BUILD_NAME dash-test) +set(CTEST_SOURCE_DIRECTORY \${CTEST_DASHBOARD_ROOT}/dash-source) +set(CTEST_BINARY_DIRECTORY \${CTEST_DASHBOARD_ROOT}/${bin_dir}) +${custom_text} +# Start a dashboard and run the update step +ctest_start(Experimental) +ctest_update(SOURCE \${CTEST_SOURCE_DIRECTORY}) +") +endfunction(create_dashboard_script) + +#----------------------------------------------------------------------------- +# Function to run the dashboard through the command line +function(run_dashboard_command_line bin_dir) + run_child( + WORKING_DIRECTORY ${TOP}/${bin_dir} + COMMAND ${CMAKE_CTEST_COMMAND} -M Experimental -T Start -T Update + ) + + # Verify the updates reported by CTest. + list(APPEND UPDATE_MAYBE Updated{subdir}) + set(_modified Modified{CTestConfig.cmake}) + if(UPDATE_NO_MODIFIED) + set(_modified "") + endif() + check_updates(${bin_dir} + Updated{foo.txt} + Updated{bar.txt} + Updated{zot.txt} + Updated{subdir/foo.txt} + Updated{subdir/bar.txt} + ${_modified} + ) +endfunction(run_dashboard_command_line) + +#----------------------------------------------------------------------------- +# Function to run the dashboard through a script +function(run_dashboard_script bin_dir) + run_child( + WORKING_DIRECTORY ${TOP} + COMMAND ${CMAKE_CTEST_COMMAND} -S ${bin_dir}.cmake -V + ) + + # Verify the updates reported by CTest. + list(APPEND UPDATE_MAYBE Updated{subdir}) + check_updates(${bin_dir} + Updated{foo.txt} + Updated{bar.txt} + Updated{zot.txt} + Updated{subdir/foo.txt} + Updated{subdir/bar.txt} + ) +endfunction(run_dashboard_script) + +#----------------------------------------------------------------------------- +# Function to initialize the testing directory. +function(init_testing) + file(REMOVE_RECURSE ${TOP}) + file(MAKE_DIRECTORY ${TOP}) +endfunction(init_testing) diff --git a/Tests/CTestUpdateGIT.cmake.in b/Tests/CTestUpdateGIT.cmake.in new file mode 100644 index 000000000..eb9f987c6 --- /dev/null +++ b/Tests/CTestUpdateGIT.cmake.in @@ -0,0 +1,317 @@ +# This script drives creation of a git repository and checks +# that CTest can update from it. + +#----------------------------------------------------------------------------- +# Test in a directory next to this script. +get_filename_component(TOP "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(TOP "${TOP}/@CTestUpdateGIT_DIR@") +set(UPDATE_EXTRA Updated{module}) + +# Include code common to all update tests. +include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake") + +#----------------------------------------------------------------------------- +# Report git tools in use. +message("Using GIT tools:") +set(GIT "@GIT_EXECUTABLE@") +message(" git = ${GIT}") + +set(AUTHOR_CONFIG "[user] +\tname = Test Author +\temail = testauthor@cmake.org +") + +#----------------------------------------------------------------------------- +# Initialize the testing directory. +message("Creating test directory...") +init_testing() + +if(UNIX) + set(src "@CMAKE_CURRENT_SOURCE_DIR@") + configure_file(${src}/CTestUpdateGIT.sh.in ${TOP}/git.sh @ONLY) + set(GIT ${TOP}/git.sh) +endif() + +#----------------------------------------------------------------------------- +# Create the repository. +message("Creating repository...") +file(MAKE_DIRECTORY ${TOP}/repo.git) +run_child( + WORKING_DIRECTORY ${TOP}/repo.git + COMMAND ${GIT} --bare init + ) +file(REMOVE_RECURSE ${TOP}/repo.git/hooks) +set(REPO file://${TOP}/repo.git) + +# Create submodule repository. +message("Creating submodule...") +file(MAKE_DIRECTORY ${TOP}/module.git) +run_child( + WORKING_DIRECTORY ${TOP}/module.git + COMMAND ${GIT} --bare init + ) +file(REMOVE_RECURSE ${TOP}/module.git/hooks) +set(MOD_REPO file://${TOP}/module.git) +create_content(module) +run_child(WORKING_DIRECTORY ${TOP}/module + COMMAND ${GIT} init + ) +file(REMOVE_RECURSE ${TOP}/module/.git/hooks) +file(APPEND ${TOP}/module/.git/config " +[remote \"origin\"] +\turl = ${MOD_REPO} +\tfetch = +refs/heads/*:refs/remotes/origin/* +${AUTHOR_CONFIG}") +run_child(WORKING_DIRECTORY ${TOP}/module + COMMAND ${GIT} add . + ) +run_child(WORKING_DIRECTORY ${TOP}/module + COMMAND ${GIT} commit -m "Initial content" + ) +run_child(WORKING_DIRECTORY ${TOP}/module + COMMAND ${GIT} push origin master:refs/heads/master + ) + +#----------------------------------------------------------------------------- +# Import initial content into the repository. +message("Importing content...") +create_content(import) + +# Import the content into the repository. +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${GIT} init + ) +file(REMOVE_RECURSE ${TOP}/import/.git/hooks) +file(APPEND ${TOP}/import/.git/config " +[remote \"origin\"] +\turl = ${REPO} +\tfetch = +refs/heads/*:refs/remotes/origin/* +${AUTHOR_CONFIG}") +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${GIT} add . + ) +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${GIT} config core.safecrlf false + ) +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${GIT} submodule add ${MOD_REPO} module + ) +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${GIT} commit -m "Initial content" + ) +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${GIT} push origin master:refs/heads/master + ) + +#----------------------------------------------------------------------------- +# Modify the submodule. +change_content(module) +run_child(WORKING_DIRECTORY ${TOP}/module + COMMAND ${GIT} add -u + ) +run_child(WORKING_DIRECTORY ${TOP}/module + COMMAND ${GIT} commit -m "Changed content" + ) +run_child(WORKING_DIRECTORY ${TOP}/module + COMMAND ${GIT} push origin master:refs/heads/master + ) + +#----------------------------------------------------------------------------- +# Create a working tree. +message("Checking out revision 1...") +run_child( + WORKING_DIRECTORY ${TOP} + COMMAND ${GIT} clone ${REPO} user-source + ) +file(REMOVE_RECURSE ${TOP}/user-source/.git/hooks) +file(APPEND ${TOP}/user-source/.git/config "${AUTHOR_CONFIG}") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} submodule init + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} submodule update + ) + +# Save the first revision name. +execute_process( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} rev-parse HEAD + OUTPUT_VARIABLE revision1 + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + +#----------------------------------------------------------------------------- +# Create an empty commit. +message("Creating empty commit...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} commit --allow-empty -m "Empty commit" + ) + +#----------------------------------------------------------------------------- +# Make changes in the working tree. +message("Changing content...") +update_content(user-source files_added files_removed dirs_added) +if(dirs_added) + run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} add ${dirs_added} + ) +endif(dirs_added) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} add ${files_added} + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} rm ${files_removed} + ) +run_child(WORKING_DIRECTORY ${TOP}/user-source/module + COMMAND ${GIT} checkout master + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} add -u + ) + +#----------------------------------------------------------------------------- +# Commit the changes to the repository. +message("Committing revision 2...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} commit -m "Changed content" + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} push origin + ) + +#----------------------------------------------------------------------------- +# Make changes in the working tree. +message("Changing content again...") +change_content(user-source) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} add -u + ) + +#----------------------------------------------------------------------------- +# Commit the changes to the repository. +message("Committing revision 3...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} commit -m "Changed content again" + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} push origin + ) + +#----------------------------------------------------------------------------- +# Go back to before the changes so we can test updating. +macro(rewind_source src_dir) + message("Backing up to revision 1...") + run_child( + WORKING_DIRECTORY ${TOP}/${src_dir} + COMMAND ${GIT} reset --hard ${revision1} + ) + run_child( + WORKING_DIRECTORY ${TOP}/${src_dir} + COMMAND ${GIT} submodule update + ) +endmacro(rewind_source) +rewind_source(user-source) + +# Make sure pull does not try to rebase (which does not work with +# modified files) even if ~/.gitconfig sets "branch.master.rebase". +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${GIT} config branch.master.rebase false + ) + +# Create a modified file. +modify_content(user-source) + +#----------------------------------------------------------------------------- +# Test updating the user work directory with the command-line interface. +message("Running CTest Dashboard Command Line...") + +# Create the user build tree. +create_build_tree(user-source user-binary) +file(APPEND ${TOP}/user-binary/CTestConfiguration.ini + "# GIT command configuration +UpdateCommand: ${GIT} +") + +# Run the dashboard command line interface. +set(UPDATE_NO_MODIFIED 1) +run_dashboard_command_line(user-binary) +set(UPDATE_NO_MODIFIED 0) + +rewind_source(user-source) +modify_content(user-source) + +message("Running CTest Dashboard Command Line (custom update)...") + +# Create the user build tree. +create_build_tree(user-source user-binary-custom) +file(APPEND ${TOP}/user-binary-custom/CTestConfiguration.ini + "# GIT command configuration +UpdateCommand: ${GIT} +GITUpdateCustom: ${GIT};pull;origin;master +") + +# Run the dashboard command line interface. +run_dashboard_command_line(user-binary-custom) + +#----------------------------------------------------------------------------- +# Test initial checkout and update with a dashboard script. +message("Running CTest Dashboard Script...") + +create_dashboard_script(dash-binary + "# git command configuration +set(CTEST_GIT_COMMAND \"${GIT}\") +set(CTEST_GIT_UPDATE_OPTIONS) +execute_process( + WORKING_DIRECTORY \"${TOP}\" + COMMAND \"${GIT}\" clone \"${REPO}\" dash-source + ) + +# Test .git file. +file(RENAME \"${TOP}/dash-source/.git\" \"${TOP}/dash-source/repo.git\") +file(WRITE \"${TOP}/dash-source/.git\" \"gitdir: repo.git\n\") + +execute_process( + WORKING_DIRECTORY \"${TOP}/dash-source\" + COMMAND \"${GIT}\" reset --hard ${revision1} + ) +execute_process( + WORKING_DIRECTORY \"${TOP}/dash-source\" + COMMAND \"${GIT}\" submodule init + ) +execute_process( + WORKING_DIRECTORY \"${TOP}/dash-source\" + COMMAND \"${GIT}\" submodule update + ) +") + +# Run the dashboard script with CTest. +run_dashboard_script(dash-binary) + +rewind_source(dash-source) + +#----------------------------------------------------------------------------- +# Test custom update with a dashboard script. +message("Running CTest Dashboard Script (custom update)...") + +create_dashboard_script(dash-binary-custom + "# git command configuration +set(CTEST_GIT_COMMAND \"${GIT}\") +set(CTEST_GIT_UPDATE_OPTIONS) +set(CTEST_GIT_UPDATE_CUSTOM \${CTEST_GIT_COMMAND} pull origin master) +") + +# Run the dashboard script with CTest. +run_dashboard_script(dash-binary-custom) diff --git a/Tests/CTestUpdateGIT.sh.in b/Tests/CTestUpdateGIT.sh.in new file mode 100755 index 000000000..e7586d6bf --- /dev/null +++ b/Tests/CTestUpdateGIT.sh.in @@ -0,0 +1,6 @@ +#!/bin/sh +if test "x$1" = "xpull" -o "x$1" = "xreset"; then + "@GIT@" "$@" && sleep 1 && touch foo.txt +else + exec "@GIT@" "$@" +fi diff --git a/Tests/CTestUpdateHG.cmake.in b/Tests/CTestUpdateHG.cmake.in new file mode 100644 index 000000000..640d2c6f3 --- /dev/null +++ b/Tests/CTestUpdateHG.cmake.in @@ -0,0 +1,166 @@ +# This script drives creation of a Mercurial repository and checks +# that CTest can update from it. + +#----------------------------------------------------------------------------- +# Test in a directory next to this script. +get_filename_component(TOP "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(TOP "${TOP}/@CTestUpdateHG_DIR@") + +# Include code common to all update tests. +include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake") + +#----------------------------------------------------------------------------- +# Report hg tools in use. +message("Using HG tools:") +set(HG "@HG_EXECUTABLE@") +message(" hg = ${HG}") + +#----------------------------------------------------------------------------- +# Initialize the testing directory. +message("Creating test directory...") +init_testing() + +#----------------------------------------------------------------------------- +# Create the repository. +message("Creating repository...") +file(MAKE_DIRECTORY ${TOP}/repo.hg) +run_child( + WORKING_DIRECTORY ${TOP}/repo.hg + COMMAND ${HG} init + ) +if(NOT "${TOP}" MATCHES "^/") + set(slash /) +endif() +set(REPO file://${slash}${TOP}/repo.hg) + +#----------------------------------------------------------------------------- +# Import initial content into the repository. +message("Importing content...") +create_content(import) + +# Import the content into the repository. +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${HG} init + ) +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${HG} add . + ) +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${HG} commit -m "Initial content" + -u "Test Author <testauthor@cmake.org>" + ) +run_child(WORKING_DIRECTORY ${TOP}/import + COMMAND ${HG} push "${REPO}" + ) + +#----------------------------------------------------------------------------- +# Create a working tree. +message("Checking out first revision...") +run_child( + WORKING_DIRECTORY ${TOP} + COMMAND ${HG} clone ${REPO} user-source + ) + +#----------------------------------------------------------------------------- +# Make changes in the working tree. +message("Changing content...") +update_content(user-source files_added files_removed dirs_added) +if(dirs_added) + run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${HG} add ${dirs_added} + ) +endif(dirs_added) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${HG} add ${files_added} + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${HG} rm ${files_removed} + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${HG} add + ) + +#----------------------------------------------------------------------------- +# Commit the changes to the repository. +message("Committing revision 2...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${HG} commit -m "Changed content" + -u "Test Author <testauthor@cmake.org>" + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${HG} push + ) + +#----------------------------------------------------------------------------- +# Make changes in the working tree. +message("Changing content again...") +change_content(user-source) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${HG} add + ) + +#----------------------------------------------------------------------------- +# Commit the changes to the repository. +message("Committing revision 3...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${HG} commit -m "Changed content again" + -u "Test Author <testauthor@cmake.org>" + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${HG} push + ) + +#----------------------------------------------------------------------------- +# Go back to before the changes so we can test updating. +message("Backing up to first revision...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${HG} update -C -r 0 + ) + +# Create a modified file. +modify_content(user-source) + +#----------------------------------------------------------------------------- +# Test updating the user work directory with the command-line interface. +message("Running CTest Dashboard Command Line...") + +# Create the user build tree. +create_build_tree(user-source user-binary) +file(APPEND ${TOP}/user-binary/CTestConfiguration.ini + "# HG command configuration +UpdateCommand: ${HG} +") + +# Run the dashboard command line interface. +run_dashboard_command_line(user-binary) + +#----------------------------------------------------------------------------- +# Test initial checkout and update with a dashboard script. +message("Running CTest Dashboard Script...") + +create_dashboard_script(dash-binary + "# hg command configuration +set(CTEST_HG_COMMAND \"${HG}\") +set(CTEST_HG_UPDATE_OPTIONS) +execute_process( + WORKING_DIRECTORY \"${TOP}\" + COMMAND \"${HG}\" clone \"${REPO}\" dash-source + ) +execute_process( + WORKING_DIRECTORY \"${TOP}/dash-source\" + COMMAND \"${HG}\" update -C -r 0 + ) +") + +# Run the dashboard script with CTest. +run_dashboard_script(dash-binary) diff --git a/Tests/CTestUpdateSVN.cmake.in b/Tests/CTestUpdateSVN.cmake.in new file mode 100644 index 000000000..15b833b10 --- /dev/null +++ b/Tests/CTestUpdateSVN.cmake.in @@ -0,0 +1,149 @@ +# This script drives creation of a Subversion repository and checks +# that CTest can update from it. + +#----------------------------------------------------------------------------- +# Test in a directory next to this script. +get_filename_component(TOP "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(TOP "${TOP}/@CTestUpdateSVN_DIR@") +set(UPDATE_GLOBAL_ELEMENTS SVNPath) + +# Include code common to all update tests. +include("@CMAKE_CURRENT_SOURCE_DIR@/CTestUpdateCommon.cmake") + +#----------------------------------------------------------------------------- +# Report subversion tools in use. +message("Using subversion tools:") +set(SVN "@Subversion_SVN_EXECUTABLE@") +set(SVNADMIN "@Subversion_SVNADMIN_EXECUTABLE@") +message(" svn = ${SVN}") +message(" svnadmin = ${SVNADMIN}") + +# Isolate svn test operations from the user configuration. +file(MAKE_DIRECTORY ${TOP}/config) +set(SVNCMD ${SVN} --config-dir ${TOP}/config) +set(SVNUSER --username "test author" --non-interactive) + +# Configure for this svn version. +execute_process( + COMMAND ${SVN} help add OUTPUT_VARIABLE help_add ERROR_VARIABLE help_add + ) +if("${help_add}" MATCHES "--depth") + set(depth_empty "--depth=empty") +else() + set(depth_empty "") +endif() + +#----------------------------------------------------------------------------- +# Initialize the testing directory. +message("Creating test directory...") +init_testing() + +#----------------------------------------------------------------------------- +# Create the repository. +message("Creating repository...") +run_child( + COMMAND ${SVNADMIN} create --config-dir ${TOP}/config ${TOP}/repo + ) +set(REPO file:///${TOP}/repo/trunk) + +#----------------------------------------------------------------------------- +# Import initial content into the repository. +message("Importing content...") +create_content(import) + +# Import the content into the repository. +run_child( + WORKING_DIRECTORY ${TOP}/import + COMMAND ${SVNCMD} import ${SVNUSER} -m "Initial content" . "${REPO}" + ) + +#----------------------------------------------------------------------------- +# Create a working tree. +message("Checking out revision 1...") +run_child( + WORKING_DIRECTORY ${TOP} + COMMAND ${SVNCMD} co ${SVNUSER} ${REPO} user-source + ) + +#----------------------------------------------------------------------------- +# Make changes in the working tree. +message("Changing content...") +update_content(user-source files_added files_removed dirs_added) +if(dirs_added) + run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${SVNCMD} add ${depth_empty} ${dirs_added} + ) +endif(dirs_added) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${SVNCMD} add ${files_added} + ) +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${SVNCMD} rm ${files_removed} + ) + +#----------------------------------------------------------------------------- +# Commit the changes to the repository. +message("Committing revision 2...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${SVNCMD} commit -m "Changed content" + ) + +#----------------------------------------------------------------------------- +# Make changes in the working tree. +message("Changing content again...") +change_content(user-source) + +#----------------------------------------------------------------------------- +# Commit the changes to the repository. +message("Committing revision 3...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${SVNCMD} commit -m "Changed content again" + ) + +#----------------------------------------------------------------------------- +# Go back to before the changes so we can test updating. +message("Backing up to revision 1...") +run_child( + WORKING_DIRECTORY ${TOP}/user-source + COMMAND ${SVNCMD} up -r1 + ) + +# Create a modified file. +message("Modifying locally...") +modify_content(user-source) + +#----------------------------------------------------------------------------- +# Test updating the user work directory with the command-line interface. +message("Running CTest Dashboard Command Line...") + +# Create the user build tree. +create_build_tree(user-source user-binary) +file(APPEND ${TOP}/user-binary/CTestConfiguration.ini + "# SVN command configuration +SVNCommand: ${SVN} +SVNUpdateOptions: --config-dir \"${TOP}/config\" +") + +# Run the dashboard command line interface. +run_dashboard_command_line(user-binary) + +#----------------------------------------------------------------------------- +# Test initial checkout and update with a dashboard script. +message("Running CTest Dashboard Script...") + +create_dashboard_script(dash-binary + "# Subversion command configuration +set(CTEST_SVN_COMMAND \"${SVN}\") +set(CTEST_SVN_UPDATE_OPTIONS + \"--config-dir \\\"\${CTEST_DASHBOARD_ROOT}/config\\\"\") +set(CTEST_CHECKOUT_COMMAND + \"\\\"\${CTEST_SVN_COMMAND}\\\" co -r1 \\\"${REPO}\\\" dash-source\") +") + +# Run the dashboard script with CTest. +run_dashboard_script(dash-binary) diff --git a/Tests/CheckCompilerRelatedVariables/CMakeLists.txt b/Tests/CheckCompilerRelatedVariables/CMakeLists.txt new file mode 100644 index 000000000..8b279a5c4 --- /dev/null +++ b/Tests/CheckCompilerRelatedVariables/CMakeLists.txt @@ -0,0 +1,90 @@ +cmake_minimum_required(VERSION 2.8) +project(CheckCompilerRelatedVariables) + + +function(echo_var var) + if(DEFINED ${var}) + message("${var}='${${var}}' is defined") + else() + message("${var}='${${var}}' is NOT defined") + endif() +endfunction() + + +# +# Check that the correct number of MSVC** variables are defined... +# +set(msvc_total 0) + +if(DEFINED MSVC60) + math(EXPR msvc_total "${msvc_total} + 1") +endif() +if(DEFINED MSVC70) + math(EXPR msvc_total "${msvc_total} + 1") +endif() +if(DEFINED MSVC71) + math(EXPR msvc_total "${msvc_total} + 1") +endif() +if(DEFINED MSVC80) + math(EXPR msvc_total "${msvc_total} + 1") +endif() +if(DEFINED MSVC90) + math(EXPR msvc_total "${msvc_total} + 1") +endif() +if(DEFINED MSVC10) + math(EXPR msvc_total "${msvc_total} + 1") +endif() +if(DEFINED MSVC11) + math(EXPR msvc_total "${msvc_total} + 1") +endif() + +echo_var(MSVC) +echo_var(MSVC60) +echo_var(MSVC70) +echo_var(MSVC71) +echo_var(MSVC80) +echo_var(MSVC90) +echo_var(MSVC10) +echo_var(MSVC11) + +if(MSVC) + # + # MSVC is set in cl.cmake when cl is the compiler... + # + # Exactly one of the numbered variables should also be set + # indicating which version of the cl compiler / Visual Studio + # is in use... + # + if(msvc_total EQUAL 1) + message("test passes: exactly one MSVC** variable is defined...") + else() + message(FATAL_ERROR "error: ${msvc_total} MSVC** variables are defined -- exactly 1 expected") + endif() +else() + # + # The compiler is something other than cl... None of the MSVC** variables + # should be defined... + # + if(msvc_total EQUAL 0) + message("test passes: no MSVC** variables are defined on non-MSVC build...") + else() + message(FATAL_ERROR "error: ${msvc_total} MSVC** variables are defined -- exactly 0 expected") + endif() +endif() + + +# +# This is a no-op executable... If this test is going to fail, it fails during +# the configure step while cmake is configuring this CMakeLists.txt file... +# + +file(WRITE + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + "int main() { return 0; } +" + ) + +add_executable( + CheckCompilerRelatedVariables + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + ) diff --git a/Tests/CheckFortran.cmake b/Tests/CheckFortran.cmake new file mode 100644 index 000000000..ebbb426ce --- /dev/null +++ b/Tests/CheckFortran.cmake @@ -0,0 +1,50 @@ + +#============================================================================= +# Copyright 2009 Kitware, Inc. +# +# 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.) + +if(NOT DEFINED CMAKE_Fortran_COMPILER) + set(_desc "Looking for a Fortran compiler") + message(STATUS ${_desc}) + file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran/CMakeLists.txt" + "cmake_minimum_required(VERSION 2.4) +project(CheckFortran Fortran) +file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" + \"set(CMAKE_Fortran_COMPILER \\\"\${CMAKE_Fortran_COMPILER}\\\")\\n\" + \"set(CMAKE_Fortran_FLAGS \\\"\${CMAKE_Fortran_FLAGS}\\\")\\n\" + ) +") + execute_process( + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran + COMMAND ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR} + OUTPUT_VARIABLE output + ERROR_VARIABLE output + RESULT_VARIABLE result + ) + include(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran/result.cmake OPTIONAL) + if(CMAKE_Fortran_COMPILER AND "${result}" STREQUAL "0") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "${_desc} passed with the following output:\n" + "${output}\n") + else() + set(CMAKE_Fortran_COMPILER NOTFOUND) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "${_desc} failed with the following output:\n" + "${output}\n") + endif() + message(STATUS "${_desc} - ${CMAKE_Fortran_COMPILER}") + set(CMAKE_Fortran_COMPILER "${CMAKE_Fortran_COMPILER}" CACHE FILEPATH "Fortran compiler") + mark_as_advanced(CMAKE_Fortran_COMPILER) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" CACHE STRING "Fortran flags") + mark_as_advanced(CMAKE_Fortran_FLAGS) +endif() diff --git a/Tests/CommandLineTest/CMakeLists.txt b/Tests/CommandLineTest/CMakeLists.txt new file mode 100644 index 000000000..0493a0c4b --- /dev/null +++ b/Tests/CommandLineTest/CMakeLists.txt @@ -0,0 +1,79 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CommandLineTest) + +GET_FILENAME_COMPONENT(CMAKE_BIN_DIR ${CMAKE_COMMAND} PATH) +MACRO(EXEC_CMAKE_COMMAND CMAKE_ARGS) + EXEC_PROGRAM("${CMAKE_COMMAND}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET) + IF(${RET}) + MESSAGE(SEND_ERROR "CMake command failed with arguments \"${CMAKE_ARGS}\"") + ENDIF(${RET}) +ENDMACRO(EXEC_CMAKE_COMMAND) + +EXEC_CMAKE_COMMAND("-E chdir \"${CMAKE_CURRENT_SOURCE_DIR}\" \"${CMAKE_COMMAND}\" -E echo \"Hello World\"") +EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -L ${CommandLineTest_SOURCE_DIR}\"") +EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LA ${CommandLineTest_SOURCE_DIR}\"") +EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LH ${CommandLineTest_SOURCE_DIR}\"") +EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LAH ${CommandLineTest_SOURCE_DIR}\"") +EXEC_CMAKE_COMMAND("--help") +EXEC_CMAKE_COMMAND("--help-command-list") +EXEC_CMAKE_COMMAND("--help add_executable") +EXEC_CMAKE_COMMAND("--help-command add_executable") +EXEC_CMAKE_COMMAND("--help-full \"${CMAKE_CURRENT_BINARY_DIR}/cmake.txt\"") +EXEC_CMAKE_COMMAND("--help-man \"${CMAKE_CURRENT_BINARY_DIR}/cmake.man\"") +EXEC_CMAKE_COMMAND("--help-html \"${CMAKE_CURRENT_BINARY_DIR}/cmake.html\"") +EXEC_CMAKE_COMMAND("--copyright \"${CMAKE_CURRENT_BINARY_DIR}/Copyright.txt\"") +EXEC_CMAKE_COMMAND("--version \"${CMAKE_CURRENT_BINARY_DIR}/version.txt\"") + +ADD_EXECUTABLE(CommandLineTest CommandLineTest.cxx) + +GET_FILENAME_COMPONENT(CMAKE_COMMAND_PATH "${CMAKE_COMMAND}" PATH) +SET(CTEST_COMMAND "${CMAKE_COMMAND_PATH}/ctest") +MACRO(EXEC_CTEST_COMMAND CMAKE_ARGS) + EXEC_PROGRAM("${CTEST_COMMAND}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET) + IF(${RET}) + MESSAGE(SEND_ERROR "CTest command failed with arguments \"${CMAKE_ARGS}\"") + ENDIF(${RET}) +ENDMACRO(EXEC_CTEST_COMMAND) +MACRO(EXEC_CTEST_COMMAND_WITH_DIR DIR CMAKE_ARGS) + EXEC_PROGRAM("${CTEST_COMMAND}" "${DIR}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET) + IF(${RET}) + MESSAGE(SEND_ERROR "CTest command failed with arguments \"${CMAKE_ARGS}\"") + ENDIF(${RET}) +ENDMACRO(EXEC_CTEST_COMMAND_WITH_DIR) + +EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N") +EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-R complex -N") +EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-E Simple -N") +EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-E Simple -N") +EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N -I -10") +EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N -I 10-") +EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N -I 3,4") +EXEC_CTEST_COMMAND("--help") +EXEC_CTEST_COMMAND("--copyright") +EXEC_CTEST_COMMAND("--help-full \"${CMAKE_CURRENT_BINARY_DIR}/ctest.txt\"") +EXEC_CTEST_COMMAND("--help-man \"${CMAKE_CURRENT_BINARY_DIR}/ctest.man\"") +EXEC_CTEST_COMMAND("--help-html \"${CMAKE_CURRENT_BINARY_DIR}/ctest.html\"") +EXEC_CTEST_COMMAND("--version") + +IF(THIS_SHOULD_BE_SET) + MESSAGE(STATUS "***************************") + MESSAGE(STATUS "PreLoad.cmake works fine.") + MESSAGE(STATUS "***************************") +ELSE(THIS_SHOULD_BE_SET) + MESSAGE("***************************") + MESSAGE(FATAL_ERROR "PreLoad.cmake does not work.") +ENDIF(THIS_SHOULD_BE_SET) + +IF(DEFINED ENV{TEST_ENVIRONMENT_VARIABLE_NOTSET}) + MESSAGE(SEND_ERROR "Environment variable definition test broken!") +ENDIF(DEFINED ENV{TEST_ENVIRONMENT_VARIABLE_NOTSET}) + +SET(ENV{TEST_ENVIRONMENT_VARIABLE} "Environment variable set") +IF("$ENV{TEST_ENVIRONMENT_VARIABLE}" STREQUAL "Environment variable set") + MESSAGE(STATUS "Environment variable set to: $ENV{TEST_ENVIRONMENT_VARIABLE}") + IF(NOT DEFINED ENV{TEST_ENVIRONMENT_VARIABLE}) + MESSAGE(SEND_ERROR "Environment variable definition test failed!") + ENDIF(NOT DEFINED ENV{TEST_ENVIRONMENT_VARIABLE}) +ELSE("$ENV{TEST_ENVIRONMENT_VARIABLE}" STREQUAL "Environment variable set") + MESSAGE(SEND_ERROR "Environment variable setting is broken") +ENDIF("$ENV{TEST_ENVIRONMENT_VARIABLE}" STREQUAL "Environment variable set") diff --git a/Tests/CommandLineTest/CommandLineTest.cxx b/Tests/CommandLineTest/CommandLineTest.cxx new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/CommandLineTest/CommandLineTest.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/CommandLineTest/PreLoad.cmake b/Tests/CommandLineTest/PreLoad.cmake new file mode 100644 index 000000000..87284aff0 --- /dev/null +++ b/Tests/CommandLineTest/PreLoad.cmake @@ -0,0 +1 @@ +SET(THIS_SHOULD_BE_SET ON CACHE BOOL "Some variable") diff --git a/Tests/CompileCommandOutput/CMakeLists.txt b/Tests/CompileCommandOutput/CMakeLists.txt new file mode 100644 index 000000000..bd8e305c2 --- /dev/null +++ b/Tests/CompileCommandOutput/CMakeLists.txt @@ -0,0 +1,16 @@ +# a simple C only test case +cmake_minimum_required (VERSION 2.6) +project (CompileCommandOutput CXX) + +SET(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") +IF(MAKE_SUPPORTS_SPACES) + SET(test1_srcs "file with spaces.cxx") +ELSE() + SET(test1_srcs "file_with_underscores.cxx") +ENDIF() +ADD_LIBRARY(test1 STATIC ${test1_srcs}) +ADD_LIBRARY(test2 SHARED "../CompileCommandOutput/relative.cxx") +INCLUDE_DIRECTORIES(${CompileCommandOutput_SOURCE_DIR}/../../Source) +ADD_EXECUTABLE(CompileCommandOutput compile_command_output.cxx) +TARGET_LINK_LIBRARIES(CompileCommandOutput test1 test2) diff --git a/Tests/CompileCommandOutput/compile_command_output.cxx b/Tests/CompileCommandOutput/compile_command_output.cxx new file mode 100644 index 000000000..145a06426 --- /dev/null +++ b/Tests/CompileCommandOutput/compile_command_output.cxx @@ -0,0 +1,9 @@ +#include "file_with_underscores.h" +#include "relative.h" + +int main (int argc, char** argv) +{ + file_with_underscores(); + relative(); + return 0; +} diff --git a/Tests/CompileCommandOutput/file with spaces.cxx b/Tests/CompileCommandOutput/file with spaces.cxx new file mode 100644 index 000000000..554e176e4 --- /dev/null +++ b/Tests/CompileCommandOutput/file with spaces.cxx @@ -0,0 +1 @@ +#include "file_with_underscores.cxx" diff --git a/Tests/CompileCommandOutput/file_with_underscores.cxx b/Tests/CompileCommandOutput/file_with_underscores.cxx new file mode 100644 index 000000000..4f42ccf56 --- /dev/null +++ b/Tests/CompileCommandOutput/file_with_underscores.cxx @@ -0,0 +1,3 @@ +#include "file_with_underscores.h" + +void file_with_underscores() {} diff --git a/Tests/CompileCommandOutput/file_with_underscores.h b/Tests/CompileCommandOutput/file_with_underscores.h new file mode 100644 index 000000000..0d73e3159 --- /dev/null +++ b/Tests/CompileCommandOutput/file_with_underscores.h @@ -0,0 +1 @@ +void file_with_underscores(); diff --git a/Tests/CompileCommandOutput/relative.cxx b/Tests/CompileCommandOutput/relative.cxx new file mode 100644 index 000000000..eae11e226 --- /dev/null +++ b/Tests/CompileCommandOutput/relative.cxx @@ -0,0 +1,3 @@ +#include "relative.h" + +void relative() {} diff --git a/Tests/CompileCommandOutput/relative.h b/Tests/CompileCommandOutput/relative.h new file mode 100644 index 000000000..ddfe5519b --- /dev/null +++ b/Tests/CompileCommandOutput/relative.h @@ -0,0 +1,11 @@ +#if defined(_WIN32) +# ifdef test2_EXPORTS +# define TEST2_EXPORT __declspec(dllexport) +# else +# define TEST2_EXPORT __declspec(dllimport) +# endif +#else +# define TEST2_EXPORT +#endif + +TEST2_EXPORT void relative(); diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt new file mode 100644 index 000000000..ec3ad3985 --- /dev/null +++ b/Tests/Complex/CMakeLists.txt @@ -0,0 +1,406 @@ +# +# A more complex test case +# +SET(CMAKE_BACKWARDS_COMPATIBILITY 1.4) +PROJECT (Complex) + +# Try setting a new policy. The IF test is for coverage. +IF(POLICY CMP0003) + CMAKE_POLICY(SET CMP0003 NEW) + + CMAKE_POLICY(GET CMP0003 P3) + IF(NOT "${P3}" STREQUAL "NEW") + MESSAGE(FATAL_ERROR "CMAKE_POLICY(GET) did not report NEW!") + ENDIF(NOT "${P3}" STREQUAL "NEW") +ENDIF(POLICY CMP0003) + +# Test building without per-rule echo lines in Makefiles. +SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES OFF) + +SET(CPACK_SOURCE_IGNORE_FILES "~$;\\.cvsignore$;^C:/hoffman/My Builds/testcase.*/CVS/;^C:/hoffman/My Builds/testcase.*/\\.svn/;^C:/hoffman/My Builds/testcase.*/sweigart/;^C:/hoffman/My Builds/testcase/www/eospaper/solution/eos2001/;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_tables_new/;^C:/hoffman/My Builds/testcase/COPYING$;^C:/hoffman/My Builds/testcase/INSTALL$;^C:/hoffman/My Builds/testcase/Makefile$;^C:/hoffman/My Builds/testcase/Makefile\\.in$;^C:/hoffman/My Builds/testcase/.*\\.lo$;^C:/hoffman/My Builds/testcase/.*\\.la$;^C:/hoffman/My Builds/testcase/mkinstalldirs$;^C:/hoffman/My Builds/testcase/missing$;^C:/hoffman/My Builds/testcase/ltmain\\.sh$;^C:/hoffman/My Builds/testcase/libtool$;^C:/hoffman/My Builds/testcase/install-sh$;^C:/hoffman/My Builds/testcase/configure$;^C:/hoffman/My Builds/testcase/config\\.sub$;^C:/hoffman/My Builds/testcase/config\\.status$;^C:/hoffman/My Builds/testcase/config\\.log$;^C:/hoffman/My Builds/testcase/config\\.guess$;^C:/hoffman/My Builds/testcase/autom4te\\.cache$;^C:/hoffman/My Builds/testcase/aclocal\\.m4$;^C:/hoffman/My Builds/testcase/depcomp$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.075\\.model_cassisi_eos1_10$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.075\\.model_cassisi_eos1_10_corr$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.1\\.model_cassisi_eos1$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.1\\.model_cassisi_scvh$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.1\\.modelc$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.3\\.modelc$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/1\\.0\\.modelc$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/1\\.0\\.rgbtip\\.modelc$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/1\\.0\\.zahb\\.modelc$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.1\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/1\\.0\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.3\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.085\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/.*\\.ps$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange\\.mem$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange\\.log$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange\\.dvi$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange\\.tex\\.bak$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/head\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/body\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/prior-dvi\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j10\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j12\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j16\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j20\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j22\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j26\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j30\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j32\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j36\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/k10\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/k12\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/k20\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/k22\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/k30\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/k32\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/1_exchange_dgamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/1_exchange_dlnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/2_exchange_dgamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/2_exchange_dlnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/linear_exchange_dgamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/linear_exchange_dlnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/noexchange_dgamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/noexchange_dlnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/nr_exchange_dgamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/nr_exchange_dlnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/series_exchange_dgamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/series_exchange_dlnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_JNR_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_Jseries_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_KNR_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_Kseries_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check34_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check35_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check36_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check43_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check44_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check45_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check46_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check47_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check48_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/tc_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/.*\\.pyc$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/context\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/make\\.out.*$;^C:/hoffman/My Builds/testcase/www/Makefile$;^C:/hoffman/My Builds/testcase/www/Makefile\\.in$;^C:/hoffman/My Builds/testcase/src/.*\\.flc$;^C:/hoffman/My Builds/testcase/src/Makefile$;^C:/hoffman/My Builds/testcase/src/Makefile\\.in$;^C:/hoffman/My Builds/testcase/src/\\.deps$;^C:/hoffman/My Builds/testcase/src/\\.libs$;^C:/hoffman/My Builds/testcase/src/.*\\.la$;^C:/hoffman/My Builds/testcase/src/.*\\.lo$;^C:/hoffman/My Builds/testcase/src/make\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/statef.*\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/0\\.1\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/0\\.1\\.model_13$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/0\\.1\\.model_23$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/0\\.3\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/0\\.3\\.model_13$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/0\\.3\\.model_23$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/1\\.0\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/1\\.0\\.model_13$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/1\\.0\\.model_15$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/1\\.0\\.model_23$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/1\\.0\\.model_rel$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/hot_post_agb\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/rgb_tip\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/rgbtip\\.1\\.0\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/rgbtip\\.1\\.0\\.model_13$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/rgbtip\\.1\\.0\\.model_23$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/start_shellflash\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/white_dwarf\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/zahb\\.1\\.0\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/zahb\\.1\\.0\\.model_13$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/zahb\\.1\\.0\\.model_23$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/zahb\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dh/dgamma1$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dh/dlnp$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dh/statef_compare\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fermi_dirac_approx/15gamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fermi_dirac_approx/15lnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fermi_dirac_approx/23gamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fermi_dirac_approx/23lnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/thermodynamic_consistency/.*\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/thermodynamic_consistency/.*\\.results$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/pteh/dgamma1$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/pteh/dlnp$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/pteh/statef_compare\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/newversion_grid/.*\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/newversion_grid/.*\\.err$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/.*\\.ps$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/.*\\.pyc$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_fit\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_fit\\.dvi$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_fit\\.log$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/body\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/head\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/prior-dvi\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/3order_data\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/5order_data\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/8order_data\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check8_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check1_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check3_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check5_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/effo_check3_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/effoo_check3_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fda15gamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fda15lnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fda23gamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fda23lnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/tc_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/make\\.out.*$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/thermodynamic_consistency/statef_compare\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/thermodynamic_consistency/tc\\.results$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_solar/opal_compare_model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_solar/opal_compare_solar\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_solar/opal_solar\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_solar/opal_solar_1995\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_solar/statef_opal_model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_solar/statef_opal_model_1995\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/purehe_newversion_grid/.*\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/purehe_newversion_grid/.*\\.err$;^C:/hoffman/My Builds/testcase/include/Makefile\\.in$;^C:/hoffman/My Builds/testcase/include/Makefile$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/model-loci/0\\.1\\.model_pteh$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/model-loci/1\\.0\\.model_eos1a-eos1$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/model-loci/1\\.0\\.model_pteh$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/model-loci/statef_model_0\\.1\\.model_pteh\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/model-loci/statef_model_1\\.0\\.model_eos1a-eos1\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/model-loci/statef_model_1\\.0\\.model_pteh\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/context/contour\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/context/eos_grid\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/context/statef_grid\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/thermodynamic_consistency/fort\\.91$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/thermodynamic_consistency/statef_compare\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/nocoulomb/dgamma1$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/nocoulomb/dlnp$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/nocoulomb/statef_compare\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/context$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/oldversion_grid$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/2005Ap&SS\\.298\\.\\.135S\\.pdf$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/2007Ap&SS\\.307\\.\\.263C\\.pdf$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/astro-ph\\.9909168_eprint_submitted_to_High_Press\\.Res\\.16,331\\.pdf$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/.*ps.*$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/.*\\.pyc$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/convergence\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/convergence\\.dvi$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/convergence\\.log$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/body\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/head\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/prior-dvi\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/statef_grid-newversion$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/context\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/pureh_context\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/purehe_context\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/old$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/make\\.out.*$;^C:/hoffman/My Builds/testcase/utils/.*\\.flc$;^C:/hoffman/My Builds/testcase/utils/Makefile$;^C:/hoffman/My Builds/testcase/utils/Makefile\\.in$;^C:/hoffman/My Builds/testcase/utils/\\.deps$;^C:/hoffman/My Builds/testcase/utils/\\.libs$;^C:/hoffman/My Builds/testcase/utils/.*\\.la$;^C:/hoffman/My Builds/testcase/utils/.*\\.lo$;^C:/hoffman/My Builds/testcase/utils/free_eos_test$;^C:/hoffman/My Builds/testcase/utils/test_rosenbrock$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/eff_check1\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/eff_check3\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/eff_check5\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/eff_check8\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/eff_checknr\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/effo_check3\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/effoo_check3\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence_20070613$;^C:/hoffman/My Builds/testcase/www/eospaper/text$;^C:/hoffman/My Builds/testcase/www/eospaper/cassisi_book_fig$;^C:/hoffman/My Builds/testcase/www/eospaper/1\\.1\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/2\\.0\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/1\\.2\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/1\\.3\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/1\\.4\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/1\\.5\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/1\\.6\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/figures$;^C:/hoffman/My Builds/testcase/www/eospaper/old$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/.*\\.ps.*$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/coulomb\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/coulomb\\.dvi$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/coulomb\\.log$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/.*\\.pyc$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/body\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/head\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/prior-dvi\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/context\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dh_dgamma1_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dh_dlnp_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dhtau_dgamma1_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dhtau_dlnp_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/nocoulomb_dgamma1_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/nocoulomb_dlnp_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/pteh_dgamma1_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/pteh_dlnp_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/make\\.out.*$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_JNR\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_Jseries\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_KNR\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_Kseries\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_check34\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_check35\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_check36\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_check44\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_check45\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_check46\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/statef_compare_1_exchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/statef_compare_2_exchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/statef_compare_linear_exchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/statef_compare_noexchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/statef_compare_nr_exchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/statef_compare_series_exchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/1_exchange_dgamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/noexchange_dlnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/nr_exchange_dgamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/series_exchange_dlnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/series_exchange_dgamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/linear_exchange_dlnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/2_exchange_dgamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/nr_exchange_dlnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/linear_exchange_dgamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/noexchange_dgamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/1_exchange_dlnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/2_exchange_dlnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/pureh_newversion_grid/.*\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/pureh_newversion_grid/.*\\.err$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dhtau/dgamma1$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dhtau/dlnp$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dhtau/statef_compare\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_0\\.1\\.model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_0\\.3\\.model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_1\\.0\\.model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_1\\.0\\.model_linear\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_1\\.0\\.model_noexchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_1\\.0\\.model_nr\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_1\\.0\\.rgbtip\\.model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_1\\.0\\.zahb\\.model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/1\\.0\\.zahb\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/1\\.0\\.rgbtip\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/1\\.0\\.model_linear$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/1\\.0\\.model_noexchange$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/1\\.0\\.model_nr$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/0\\.1\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/1\\.0\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/0\\.3\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/context/contour\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/context/eos_grid\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/context/statef_grid\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/gong/delta\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/gong/m0085eos1gong\\.ascii$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/gong/m0085eos2gong\\.ascii$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/coulomb_adjust/coulomb_adjust\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/.*\\.ps$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/.*\\.pyc$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/head\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/body\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/prior-dvi\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/solution\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/solution\\.log$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/solution\\.dvi$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/rtc_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/tc_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/make\\.out.*$") + +# +# Define a macro +# +MACRO(ASSERT value msg) + IF (NOT ${value}) + MESSAGE ("Assertion failure:" ${msg} ) + ENDIF (NOT ${value}) +ENDMACRO(ASSERT) + +# invoke the macro +ASSERT(Complex_BINARY_DIR "The PROJECT command is broken") + +# +# Define a var args macro, it must take two or four args +# +MACRO(TEST_ARGC value1 value2) + ADD_DEFINITIONS(${value1} ${value2}) + IF (${ARGC} MATCHES 4) + ADD_DEFINITIONS(${ARGV2} ${ARGV3}) + ENDIF (${ARGC} MATCHES 4) +ENDMACRO(TEST_ARGC) + +# invoke the macro +TEST_ARGC(-DCMAKE_ARGV1 -DCMAKE_ARGV2 -DCMAKE_ARGV3 -DCMAKE_ARGV4) + +MACRO(TEST_VAR_ARG fa) + IF("${ARGV}" MATCHES "^1;2;3$") + MESSAGE(STATUS "ARGV works") + ELSE("${ARGV}" MATCHES "^1;2;3$") + MESSAGE(FATAL_ERROR "ARGV does not work; got \"${ARGV}\" instead of \"1;2;3\"") + ENDIF("${ARGV}" MATCHES "^1;2;3$") + IF("${ARGN}" MATCHES "^2;3$") + MESSAGE(STATUS "ARGN works") + ELSE("${ARGN}" MATCHES "^2;3$") + MESSAGE(FATAL_ERROR "ARGV does not work; got \"${ARGN}\" instead of \"2;3\"") + ENDIF("${ARGN}" MATCHES "^2;3$") +ENDMACRO(TEST_VAR_ARG) + +TEST_VAR_ARG(1 2 3) + +# Floating-point comparison test. +IF(2.4 LESS 2.4) + MESSAGE(FATAL_ERROR "Failed: 2.4 LESS 2.4") +ENDIF(2.4 LESS 2.4) +IF(2.4 GREATER 2.4) + MESSAGE(FATAL_ERROR "Failed: 2.4 GREATER 2.4") +ENDIF(2.4 GREATER 2.4) +IF(NOT 2.4 EQUAL 2.4) + MESSAGE(FATAL_ERROR "Failed: NOT 2.4 EQUAL 2.4") +ENDIF(NOT 2.4 EQUAL 2.4) + +IF(CMAKE_SYSTEM MATCHES "OSF1-V.*") + IF(NOT CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ") + ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) +ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*") + + +ADD_DEFINITIONS(-DCMAKE_IS_FUN) +ADD_DEFINITIONS(-DCMAKE_IS_REALLY_FUN) +SET_PROPERTY(DIRECTORY + PROPERTY COMPILE_DEFINITIONS_RELEASE + CMAKE_IS_FUN_IN_RELEASE_MODE + ) + +SET(TEST_SEP "a b c") +SEPARATE_ARGUMENTS(TEST_SEP) + + +# +# Include vars from a file and from a cache +# +IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) + INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake) +ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) +INCLUDE(fileshouldnotbehere OPTIONAL) +LOAD_CACHE(${Complex_SOURCE_DIR}/Cache + EXCLUDE + CACHE_TEST_VAR_EXCLUDED + INCLUDE_INTERNALS + CACHE_TEST_VAR_INTERNAL) + +LOAD_CACHE(${Complex_SOURCE_DIR}/Cache READ_WITH_PREFIX foo CACHE_TEST_VAR2) +IF(${fooCACHE_TEST_VAR2} MATCHES bar) + MESSAGE("Load cache worked: ${fooCACHE_TEST_VAR2}") +ELSE(${fooCACHE_TEST_VAR2} MATCHES bar) + MESSAGE(FATAL_ERROR "Load cache with prefix failed: ${fooCACHE_TEST_VAR2}") +ENDIF(${fooCACHE_TEST_VAR2} MATCHES bar) + + + +# +# Specify include and lib dirs +# (BEFORE is for coverage) +# +INCLUDE_DIRECTORIES( + Library +) + +INCLUDE_DIRECTORIES(BEFORE + ${Complex_BINARY_DIR} +) +INCLUDE_DIRECTORIES(SYSTEM Library/SystemDir) + +INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile|test).*$" "^cmMissing") + +LINK_DIRECTORIES( + ${Complex_BINARY_DIR}/Library +) + +# +# check for SET CACHE FORCE +# +SET(FORCE_TEST 1 CACHE STRING "a test") +SET(FORCE_TEST 0 CACHE STRING "a test" FORCE) + +# +# Lib and exe path +# +SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${Complex_BINARY_DIR}/lib/static") +SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${Complex_BINARY_DIR}/lib") +SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${Complex_BINARY_DIR}/bin") + +MESSAGE (Test " " escape " " semi-colon " " \; \;) +# +# Exec program (TODO: test a result) +# Increase coverage. +# +MESSAGE("\nIgnore this message") +OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0) +IF (NOT NO_EXEC_PROGRAM) + EXEC_PROGRAM(${CMAKE_COMMAND} ARGS -E echo NO_EXEC_PROGRAM "${Complex_BINARY_DIR}") +ELSE (NOT NO_EXEC_PROGRAM) + MESSAGE("Set this option ON") +ENDIF (NOT NO_EXEC_PROGRAM) + +MARK_AS_ADVANCED(NO_EXEC_PROGRAM) +MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM) + +# Execute a process. Add coverage for this command. +EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -E echo "ABCDEFG" + OUTPUT_VARIABLE TEST_OUT + ) +IF("${TEST_OUT}" MATCHES "^ABCDEFG\n$") +ELSE("${TEST_OUT}" MATCHES "^ABCDEFG\n$") + MESSAGE(SEND_ERROR "EXECUTE_PROCESS output test failed: [${TEST_OUT}]") +ENDIF("${TEST_OUT}" MATCHES "^ABCDEFG\n$") + +# This test has some problems on UNIX systems. Disabling for now. +# +# EXECUTE_PROCESS( +# COMMAND ${CMAKE_COMMAND} -E echo "ABCDEFG" +# COMMAND /process/does/not/exist +# OUTPUT_QUIET +# ERROR_QUIET +# RESULT_VARIABLE RESULT +# ) +# IF("${RESULT}" MATCHES "^0$") +# MESSAGE(SEND_ERROR +# "EXECUTE_PROCESS result test failed with RESULT=[${RESULT}]") +# ELSE("${RESULT}" MATCHES "^0$") +# MESSAGE(STATUS "EXECUTE_PROCESS result test passed with RESULT=[${RESULT}]") +# ENDIF("${RESULT}" MATCHES "^0$") + +# +# Create directory. +# The 'complex' executable will then test if this dir exists, +# sadly it won't be able to remove it. +# +MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir") + +# +# Test FIND_LIBARY +# Create a dummy empty lib +# +CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/Library/dummy + ${Complex_BINARY_DIR}/Library/dummylib.lib + COPYONLY IMMEDIATE) +FOREACH (ext ${CMAKE_SHLIB_SUFFIX};.so;.a;.sl + ${CMAKE_SHARED_LIBRARY_SUFFIX}.2 + ${CMAKE_STATIC_LIBRARY_SUFFIX}.2) + CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/Library/dummy + ${Complex_BINARY_DIR}/Library/libdummylib${ext} + COPYONLY IMMEDIATE) +ENDFOREACH (ext) + +FIND_LIBRARY(FIND_DUMMY_LIB + dummylib + PATHS + ${Complex_BINARY_DIR}/Library DOC "find dummy lib") + +FIND_LIBRARY(FIND_DUMMY_LIB + NAMES dummylib dummylib2 + PATHS + ${Complex_BINARY_DIR}/Library DOC "find dummy lib") + +# This doesn't work for platforms that have a shared library and an import +# library, like Windows with .dll and .lib. Limit is to ".so" now because it's +# known to work there. +IF(CMAKE_SHARED_LIBRARY_SUFFIX STREQUAL ".so") + FIND_LIBRARY(FIND_DUMMY_SHLIB_VERSIONED + NAMES libdummylib${CMAKE_SHARED_LIBRARY_SUFFIX}.2 + PATHS ${Complex_BINARY_DIR}/Library + DOC "find versioned dummy shared lib" + NO_DEFAULT_PATH) + + IF(NOT FIND_DUMMY_SHLIB_VERSIONED MATCHES "/libdummylib${CMAKE_SHARED_LIBRARY_SUFFIX}.2") + MESSAGE(SEND_ERROR "FIND_DUMMY_SHLIB_VERSIONED is not set correctly: " + "${FIND_DUMMY_SHLIB_VERSIONED}") + ENDIF() +ENDIF() + +# Static library, should work everywhere +FIND_LIBRARY(FIND_DUMMY_STLIB_VERSIONED + NAMES libdummylib${CMAKE_STATIC_LIBRARY_SUFFIX}.2 + PATHS ${Complex_BINARY_DIR}/Library + DOC "find versioned dummy static lib" + NO_DEFAULT_PATH) + +IF(NOT FIND_DUMMY_STLIB_VERSIONED MATCHES "/libdummylib${CMAKE_STATIC_LIBRARY_SUFFIX}.2") + MESSAGE(SEND_ERROR "FIND_DUMMY_STLIB_VERSIONED is not set correctly: " + "${FIND_DUMMY_STLIB_VERSIONED}") +ENDIF() + +# +# Test SET_SOURCE_FILES_PROPERTIES +# +SET_SOURCE_FILES_PROPERTIES(nonexisting_file2 + GENERATED + ABSTRACT + WRAP_EXCLUDE + COMPILE_FLAGS "-foo -bar") + +GET_SOURCE_FILE_PROPERTY(FILE_HAS_ABSTRACT nonexisting_file2 ABSTRACT) +GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file2 WRAP_EXCLUDE) +GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file2 COMPILE_FLAGS) + +SET_SOURCE_FILES_PROPERTIES(nonexisting_file3 PROPERTIES + GENERATED 1 + ABSTRACT 1 + WRAP_EXCLUDE 1 + COMPILE_FLAGS "-foo -bar") +GET_SOURCE_FILE_PROPERTY(FILE_HAS_ABSTRACT nonexisting_file3 ABSTRACT) +GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file3 WRAP_EXCLUDE) +GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file3 COMPILE_FLAGS) + +# +# Test registry (win32) +# Create a file, put its path in a registry key, try to find the file in that +# path using that registry key, then remove the file and the key +# +IF (WIN32) + IF (NOT UNIX) + SET(dir "${Complex_BINARY_DIR}/registry_dir") + SET(file "registry_test_dummy") + SET(hkey "HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Tests\\Complex;registry_test") + CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/Library/dummy + "${dir}/${file}" + COPYONLY IMMEDIATE) + EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E write_regv \"${hkey}\" \"${dir}\"") + FIND_PATH(REGISTRY_TEST_PATH + ${file} + "[${hkey}]" DOC "Registry_Test_Path") + EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E delete_regv \"${hkey}\"") + EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E remove \"${dir}/${file}\"") + ENDIF (NOT UNIX) +ENDIF (WIN32) + +# +# Test a set and a remove +# +SET(REMOVE_STRING a b c d e f) +SET(removeVar1 c e) +REMOVE(REMOVE_STRING ${removeVar1} f) + +# +# Test an IF inside a FOREACH. +# +FOREACH(x "a") + IF(${x} MATCHES "a") + # Should always execute. + SET(IF_INSIDE_FOREACH_THEN_EXECUTED 1) + ELSE(${x} MATCHES "a") + # Should never execute. + SET(IF_INSIDE_FOREACH_ELSE_EXECUTED 1) + ENDIF(${x} MATCHES "a") +ENDFOREACH(x) + +# test WHILE command +SET (while_var 1) +WHILE (while_var LESS 1000) + SET(while_var ${while_var}0) +ENDWHILE(while_var LESS 1000) + +SET(SHOULD_BE_ZERO ) +SET(SHOULD_BE_ONE 1) + +# test elseif functionality, the mess below tries to catch problem +# of clauses being executed early or late etc +set (RESULT 3) +if (RESULT EQUAL 1) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +elseif (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) +elseif (RESULT EQUAL 3) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + if (NOT ELSEIF_RESULT EQUAL 1) + set (ELSEIF_RESULT 2) + endif (NOT ELSEIF_RESULT EQUAL 1) + endif (RESULT EQUAL 2) +elseif (RESULT EQUAL 4) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +else (RESULT EQUAL 1) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +endif (RESULT EQUAL 1) + +if (NOT ELSEIF_RESULT EQUAL 2) + set (ELSEIF_RESULT 0) +endif (NOT ELSEIF_RESULT EQUAL 2) + +# test handling of parenthetical groups in conditionals +if (2 GREATER 1 AND (4 LESS 3 OR 5 LESS 6) AND NOT (7 GREATER 8)) + set(CONDITIONAL_PARENTHESES 1) +endif() + + +# +# Configure file +# (plug vars to #define so that they can be tested) +# +CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/cmTestConfigure.h.in + ${Complex_BINARY_DIR}/cmTestConfigure.h) + +SET(STRING_WITH_QUOTES "\"hello world\"") +# test CONFIGURE_FILE with ESCAPE_QUOTES on +CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/cmTestConfigureEscape.h.in + ${Complex_BINARY_DIR}/cmTestConfigureEscape.h ESCAPE_QUOTES) + +# Test regular expression commands. +STRING(REGEX MATCH "b" RESULT "abc") +IF(NOT RESULT) + MESSAGE(SEND_ERROR "STRING(REGEX MATCH ... ) test failed.") +ENDIF(NOT RESULT) +STRING(REGEX MATCHALL "b" RESULT "abcb") +IF(NOT RESULT) + MESSAGE(SEND_ERROR "STRING(REGEX MATCHALL ... ) test failed.") +ENDIF(NOT RESULT) +STRING(REGEX REPLACE ".([bd])." "[\\1]" RESULT "a(b)c(d)e") +IF("x${RESULT}" MATCHES "^xa\\[b\\]c\\[d\\]e$") + SET(STRING_REGEX_PASSED 1) +ENDIF("x${RESULT}" MATCHES "^xa\\[b\\]c\\[d\\]e$") +IF(NOT STRING_REGEX_PASSED) + MESSAGE(SEND_ERROR + "STRING(REGEX REPLACE ... ) test failed (\"${RESULT}\" v. \"a[b]c[d]e\")") +ENDIF(NOT STRING_REGEX_PASSED) + + +# +# Create the libs and the main exe +# +ADD_SUBDIRECTORY(Library) +ADD_SUBDIRECTORY(Executable) +SUBDIR_DEPENDS(Executable Library) +EXPORT_LIBRARY_DEPENDENCIES(${Complex_BINARY_DIR}/ComplexLibraryDepends.cmake) +INCLUDE(${Complex_BINARY_DIR}/ComplexLibraryDepends.cmake OPTIONAL) diff --git a/Tests/Complex/Cache/CMakeCache.txt b/Tests/Complex/Cache/CMakeCache.txt new file mode 100644 index 000000000..17c55aa01 --- /dev/null +++ b/Tests/Complex/Cache/CMakeCache.txt @@ -0,0 +1,34 @@ +# This is the CMakeCache file. +# For build in directory: d:/build/kitware/cmake/CMake-nmake/Tests/Complex +# You can edit this file to change values found and used by cmake. +# If you do not want to change any of the values, simply exit the editor. +# If you do want to change a value, simply edit, save, and exit the editor. +# The syntax for the file is as follows: +# KEY:TYPE=VALUE +# KEY is the name of a varible in the cache. +# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!. +# VALUE is the current value for the KEY. + +######################## +# EXTERNAL cache entries +######################## + +//A var. +CACHE_TEST_VAR1:STRING=foo + +//A var. +CACHE_TEST_VAR2:FILEPATH=bar + +//A var. +CACHE_TEST_VAR3:BOOL=1 + +//A var. +CACHE_TEST_VAR_EXCLUDED:BOOL=1 + + +######################## +# INTERNAL cache entries +######################## + +//A var. +CACHE_TEST_VAR_INTERNAL:INTERNAL=bar diff --git a/Tests/Complex/Executable/A.cxx b/Tests/Complex/Executable/A.cxx new file mode 100644 index 000000000..fb3eb0819 --- /dev/null +++ b/Tests/Complex/Executable/A.cxx @@ -0,0 +1,9 @@ +// Include code from a header that should not be compiled separately. +#include "A.hh" + +#include <stdio.h> +int main() +{ + printf("#define A_VALUE %d\n", A()); + return 0; +} diff --git a/Tests/Complex/Executable/A.h b/Tests/Complex/Executable/A.h new file mode 100644 index 000000000..25c45fcbf --- /dev/null +++ b/Tests/Complex/Executable/A.h @@ -0,0 +1,4 @@ +// This header should not be compiled directly but through inclusion +// in A.cxx through A.hh. +extern int A(); +int A() { return 10; } diff --git a/Tests/Complex/Executable/A.hh b/Tests/Complex/Executable/A.hh new file mode 100644 index 000000000..e6bab022e --- /dev/null +++ b/Tests/Complex/Executable/A.hh @@ -0,0 +1,2 @@ +// This header should not be compiled directly but through inclusion in A.cxx +#include "A.h" diff --git a/Tests/Complex/Executable/A.txt b/Tests/Complex/Executable/A.txt new file mode 100644 index 000000000..8ee9462be --- /dev/null +++ b/Tests/Complex/Executable/A.txt @@ -0,0 +1 @@ +This file should not be compiled! diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt new file mode 100644 index 000000000..345836257 --- /dev/null +++ b/Tests/Complex/Executable/CMakeLists.txt @@ -0,0 +1,170 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 1.3) +# +# Create exe. +# +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_CXX_FLAGS") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTEST_C_FLAGS") + +# Create an imported target for if(TARGET) test below. +ADD_LIBRARY(ExeImportedTarget UNKNOWN IMPORTED) + +# Test if(TARGET) command. +IF(NOT TARGET CMakeTestLibrary) + MESSAGE(FATAL_ERROR "IF(NOT TARGET CMakeTestLibrary) returned true!") +ENDIF(NOT TARGET CMakeTestLibrary) +IF(NOT TARGET ExeImportedTarget) + MESSAGE(FATAL_ERROR "IF(NOT TARGET ExeImportedTarget) returned true!") +ENDIF(NOT TARGET ExeImportedTarget) +IF(TARGET LibImportedTarget) + MESSAGE(FATAL_ERROR "IF(TARGET LibImportedTarget) returned true!") +ENDIF(TARGET LibImportedTarget) +IF(TARGET NotATarget) + MESSAGE(FATAL_ERROR "IF(TARGET NotATarget) returned true!") +ENDIF(TARGET NotATarget) + + # Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to +SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) +LINK_LIBRARIES(${COMPLEX_LIBS}) + +# Test forcing a .cxx file to not build. +SET_SOURCE_FILES_PROPERTIES(complex_nobuild.cxx PROPERTIES + HEADER_FILE_ONLY 1) + +# Test forcing a .c file to not build. +# This makes sure a mixed language library is created +# with header file only sources +SET_SOURCE_FILES_PROPERTIES(complex_nobuild.c PROPERTIES + HEADER_FILE_ONLY 1) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt) +ADD_CUSTOM_COMMAND(OUTPUT Aout.h COMMAND A > Aout.h VERBATIM) +ADD_EXECUTABLE(complex complex testcflags.c Aout.h) +# Sub1/NameConflictTest.c Sub2/NameConflictTest.c) +ADD_EXECUTABLE(complex.file complex.file.cxx complex_nobuild.cxx + complex_nobuild.c) + +IF (UNIX) + TARGET_LINK_LIBRARIES(complex ${CMAKE_DL_LIBS}) +ELSE(UNIX) + IF (NOT BORLAND) + IF(NOT MINGW) + TARGET_LINK_LIBRARIES(complex rpcrt4.lib) + ENDIF(NOT MINGW) + ENDIF(NOT BORLAND) +ENDIF (UNIX) + +# Test linking to static lib when a shared lib has the same name. +IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + ADD_DEFINITIONS(-DCOMPLEX_TEST_LINK_STATIC) + TARGET_LINK_LIBRARIES(complex CMakeTestLinkStatic) +ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + +# can we get the path to a source file +GET_SOURCE_FILE_PROPERTY(A_LOCATION A.cxx LOCATION) +IF ("${A_LOCATION}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/A.cxx") + ADD_DEFINITIONS(-DCMAKE_FOUND_ACXX) +ENDIF ("${A_LOCATION}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/A.cxx") + +# get the directory parent +GET_DIRECTORY_PROPERTY(P_VALUE PARENT_DIRECTORY) +IF ("${P_VALUE}" STREQUAL "${CMAKE_SOURCE_DIR}") + ADD_DEFINITIONS(-DCMAKE_FOUND_PARENT) +ENDIF ("${P_VALUE}" STREQUAL "${CMAKE_SOURCE_DIR}") + +# get the stack of listfiles +INCLUDE(Included.cmake) +IF ("${LF_VALUE}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt;${CMAKE_CURRENT_SOURCE_DIR}/Included.cmake") + ADD_DEFINITIONS(-DCMAKE_FOUND_LISTFILE_STACK) +ENDIF ("${LF_VALUE}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt;${CMAKE_CURRENT_SOURCE_DIR}/Included.cmake") + +# Test add/remove definitions. +ADD_DEFINITIONS( + -DCOMPLEX_DEFINED_PRE + -DCOMPLEX_DEFINED + -DCOMPLEX_DEFINED_POST + -DCOMPLEX_DEFINED + ) +REMOVE_DEFINITIONS(-DCOMPLEX_DEFINED) + +# Test pre-build/pre-link/post-build rules for an executable. +ADD_CUSTOM_COMMAND(TARGET complex PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/prebuild.txt") +ADD_CUSTOM_COMMAND(TARGET complex PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/prelink.txt") +ADD_CUSTOM_COMMAND(TARGET complex POST_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/postbuild.txt") +ADD_CUSTOM_COMMAND(TARGET complex POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy + "${Complex_BINARY_DIR}/Executable/postbuild.txt" + "${Complex_BINARY_DIR}/Executable/postbuild2.txt") + +SET_SOURCE_FILES_PROPERTIES(complex + COMPILE_FLAGS + "-DFILE_HAS_EXTRA_COMPILE_FLAGS" + #" -DFILE_DEFINE_STRING=\\\"hello\\\"" + OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h +) +SET_TARGET_PROPERTIES(complex PROPERTIES COMPILE_FLAGS "-DCOMPLEX_TARGET_FLAG") +ADD_CUSTOM_COMMAND( + TARGET complex + SOURCE ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in + ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h + OUTPUTS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h + DEPENDS ${CMAKE_COMMAND} +) + +# Test creating an executable that is not built by default. +ADD_EXECUTABLE(notInAllExe EXCLUDE_FROM_ALL notInAllExe.cxx) +TARGET_LINK_LIBRARIES(notInAllExe notInAllLib) + +# Test user-value flag mapping for the VS IDE. +IF(MSVC) + SET_TARGET_PROPERTIES(notInAllExe PROPERTIES + LINK_FLAGS "/NODEFAULTLIB:LIBC;LIBCMT;MSVCRT") +ENDIF(MSVC) + +# Test creating a custom target that builds not-in-all targets. +ADD_CUSTOM_TARGET(notInAllCustom) +ADD_DEPENDENCIES(notInAllCustom notInAllExe) + +# +# Output the files required by 'complex' to a file. +# +# This test has been moved to the 'required' subdir so that it +# has no side-effects on the current Makefile (duplicated source file +# due to source list expansion done twice). +# +ADD_SUBDIRECTORY(Temp) + +IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX) + ADD_EXECUTABLE(testSystemDir testSystemDir.cxx) + SET_TARGET_PROPERTIES(testSystemDir PROPERTIES COMPILE_FLAGS "-Werror") +ENDIF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX) + +# +# Extra coverage.Not used. +# +INSTALL_TARGETS(/tmp complex) +INSTALL_PROGRAMS(/tmp complex) + +CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/Executable/cmVersion.h.in + ${Complex_BINARY_DIR}/cmVersion.h) + +SOURCE_GROUP(A_GROUP ".cxx") +SOURCE_GROUP(B_GROUP REGULAR_EXPRESSION "cxx") +SOURCE_GROUP(C_GROUP FILES complex.cxx) + +FILE(WRITE ${Complex_BINARY_DIR}/A/libA.a "test") +FILE(WRITE ${Complex_BINARY_DIR}/A/libC.a "test") +FILE(WRITE ${Complex_BINARY_DIR}/B/libB.a "test") +FILE(WRITE ${Complex_BINARY_DIR}/B/libA.a "test") +FILE(WRITE ${Complex_BINARY_DIR}/C/libC.a "test") +FILE(WRITE ${Complex_BINARY_DIR}/C/libB.a "test") diff --git a/Tests/Complex/Executable/Included.cmake b/Tests/Complex/Executable/Included.cmake new file mode 100644 index 000000000..2d1ea3e8c --- /dev/null +++ b/Tests/Complex/Executable/Included.cmake @@ -0,0 +1,2 @@ +GET_DIRECTORY_PROPERTY(LF_VALUE LISTFILE_STACK) + diff --git a/Tests/Complex/Executable/Sub1/NameConflictTest.c b/Tests/Complex/Executable/Sub1/NameConflictTest.c new file mode 100644 index 000000000..87203861f --- /dev/null +++ b/Tests/Complex/Executable/Sub1/NameConflictTest.c @@ -0,0 +1,4 @@ +int NameConflictTest1() +{ + return 0; +} diff --git a/Tests/Complex/Executable/Sub2/NameConflictTest.c b/Tests/Complex/Executable/Sub2/NameConflictTest.c new file mode 100644 index 000000000..4a3257255 --- /dev/null +++ b/Tests/Complex/Executable/Sub2/NameConflictTest.c @@ -0,0 +1,4 @@ +int NameConflictTest2() +{ + return 0; +} diff --git a/Tests/Complex/Executable/Temp/CMakeLists.txt b/Tests/Complex/Executable/Temp/CMakeLists.txt new file mode 100644 index 000000000..f00955029 --- /dev/null +++ b/Tests/Complex/Executable/Temp/CMakeLists.txt @@ -0,0 +1,8 @@ +# +# Output the files required by 'complex' to a file. +# The 'complex' executable will then test if this file exists and remove it. +# The contents of this file is not tested (absolute paths). +# +OUTPUT_REQUIRED_FILES( + ${Complex_SOURCE_DIR}/Executable/complex.cxx + ${Complex_BINARY_DIR}/Executable/Temp/complex-required.txt) diff --git a/Tests/Complex/Executable/cmVersion.h.in b/Tests/Complex/Executable/cmVersion.h.in new file mode 100644 index 000000000..de7522d1d --- /dev/null +++ b/Tests/Complex/Executable/cmVersion.h.in @@ -0,0 +1 @@ +#define CMAKE_MINIMUM_REQUIRED_VERSION "${CMAKE_MINIMUM_REQUIRED_VERSION}" diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx new file mode 100644 index 000000000..1901d9914 --- /dev/null +++ b/Tests/Complex/Executable/complex.cxx @@ -0,0 +1,1026 @@ +#include "cmTestConfigure.h" +#include "cmTestConfigureEscape.h" +#include "cmTestGeneratedHeader.h" +#include "cmVersion.h" +#include "ExtraSources/file1.h" +#include "Aout.h" +#include "file2.h" +#include "sharedFile.h" +extern "C" { +#include "testConly.h" +} +#include <vector> +#include <string> +#include <iostream> +#include <string.h> + +#include <stdio.h> +#include <sys/stat.h> +#if !defined(S_ISDIR) +# define S_ISDIR(mode) ((mode) & _S_IFDIR) +#endif + +#ifdef COMPLEX_TEST_LINK_STATIC +extern "C" +{ + int TestLinkGetType(); +} +#endif + +int cm_passed = 0; +int cm_failed = 0; +// ====================================================================== + +void cmFailed(const char* Message, const char* m2= "", const char* m3 = "") +{ + std::cout << "FAILED: " << Message << m2 << m3 << "\n"; + cm_failed++; +} + +// ====================================================================== + +void cmPassed(const char* Message, const char* m2="") +{ + std::cout << "Passed: " << Message << m2 << "\n"; + cm_passed++; +} + +#ifndef COMPLEX_DEFINED_PRE +# error "COMPLEX_DEFINED_PRE not defined!" +#endif + +#ifdef COMPLEX_DEFINED +# error "COMPLEX_DEFINED is defined but it should not!" +#endif + +#ifndef COMPLEX_DEFINED_POST +# error "COMPLEX_DEFINED_POST not defined!" +#endif + +#ifndef CMAKE_IS_REALLY_FUN +# error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work +#endif + +#if defined(NDEBUG) && !defined(CMAKE_IS_FUN_IN_RELEASE_MODE) +# error Per-configuration directory-level definition not inherited. +#endif + +// ====================================================================== + +void TestAndRemoveFile(const char* filename) +{ + struct stat st; + if(stat(filename, &st) < 0) + { + cmFailed("Could not find file: ", filename); + } + else + { + if (remove(filename) < 0) + { + cmFailed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename); + } + else + { + cmPassed("Find and remove file: ", filename); + } + } +} + +// ====================================================================== + +void TestDir(const char* filename) +{ + struct stat st; + if(stat(filename, &st) < 0 || !S_ISDIR(st.st_mode)) + { + cmFailed("Could not find dir: ", filename); + } + else + { + cmPassed("Find dir: ", filename); + } +} + +// Here is a stupid function that tries to use std::string methods +// so that the dec cxx compiler will instantiate the stuff that +// we are using from the CMakeLib library.... +void ForceStringUse() +{ + std::vector<std::string> v; + std::vector<std::string> v2; + v = v2; + std::string cachetest = CACHE_TEST_VAR_INTERNAL; + v.push_back(cachetest); + v2 = v; + std::string x(5,'x'); + char buff[5]; + x.copy(buff, 1, 0); + x[0] = 'a'; + std::string::size_type pos = 0; + x.replace(pos, pos, pos, 'x'); + std::string copy = cachetest; + cachetest.find("bar"); + cachetest.rfind("bar"); + copy.append(cachetest); + copy = cachetest.substr(0, cachetest.size()); +} + + +// defined in testcflags.c +extern "C" int TestCFlags(char* m); +extern "C" int TestTargetCompileFlags(char* m); + +#if 0 +// defined in Sub1/NameConflictTest.c +extern "C" int NameConflictTest1(); +// defined in Sub2/NameConflictTest.c +extern "C" int NameConflictTest2(); +#endif + +// ====================================================================== + +int main() +{ +#if 0 + if(NameConflictTest1() == 0 && NameConflictTest2() == 0) + { + cmPassed("Sub dir with same named source works"); + } + else + { + cmFailed("Sub dir with same named source fails"); + } +#endif + if(file1() != 1) + { + cmFailed("Call to file1 function from library failed."); + } + else + { + cmPassed("Call to file1 function returned 1."); + } +#ifndef COMPLEX_TARGET_FLAG + cmFailed("COMPILE_FLAGS did not work with SET_TARGET_PROPERTIES"); +#else + cmPassed("COMPILE_FLAGS did work with SET_TARGET_PROPERTIES"); +#endif + +#ifdef ELSEIF_RESULT + cmPassed("ELSEIF did work"); +#else + cmFailed("ELSEIF did not work"); +#endif + +#ifdef CONDITIONAL_PARENTHESES + cmPassed("CONDITIONAL_PARENTHESES did work"); +#else + cmFailed("CONDITIONAL_PARENTHESES did not work"); +#endif + + if(file2() != 1) + { + cmFailed("Call to file2 function from library failed."); + } + else + { + cmPassed("Call to file2 function returned 1."); + } +#ifndef TEST_CXX_FLAGS + cmFailed("CMake CMAKE_CXX_FLAGS is not being passed to the compiler!"); +#else + cmPassed("CMake CMAKE_CXX_FLAGS is being passed to the compiler."); +#endif + std::string gen = CMAKE_GENERATOR; + // visual studio is currently broken for c flags + char msg[1024]; + if(gen.find("Visual") == gen.npos) + { +#ifdef TEST_C_FLAGS + cmFailed("CMake CMAKE_C_FLAGS are being passed to c++ files the compiler!"); +#else + cmPassed("CMake CMAKE_C_FLAGS are not being passed to c++ files."); +#endif + if(TestCFlags(msg)) + { + cmPassed( + "CMake CMAKE_C_FLAGS are being passed to c files and CXX flags are not."); + } + else + { + cmFailed(msg); + } + } + if(TestTargetCompileFlags(msg)) + { + cmPassed(msg); + } + else + { + cmFailed(msg); + } + + // ---------------------------------------------------------------------- + // Test ADD_DEFINITIONS + +#ifndef CMAKE_IS_FUN + cmFailed("CMake is not fun, so it is broken and should be fixed."); +#else + cmPassed("CMAKE_IS_FUN is defined."); +#endif + +#if defined(CMAKE_ARGV1) && defined(CMAKE_ARGV2) && defined(CMAKE_ARGV3) && defined(CMAKE_ARGV4) + cmPassed("Variable args for MACROs are working."); +#else + cmFailed("Variable args for MACROs are failing."); +#endif + + // ---------------------------------------------------------------------- + // Test GET_SOURCE_FILE_PROPERTY for location +#ifndef CMAKE_FOUND_ACXX + cmFailed("CMake did not get the location of A.cxx correctly"); +#else + cmPassed("CMake found A.cxx properly"); +#endif + + // ---------------------------------------------------------------------- + // Test GET_DIRECTORY_PROPERTY for parent +#ifndef CMAKE_FOUND_PARENT + cmFailed("CMake did not get the location of the parent directory properly"); +#else + cmPassed("CMake found the parent directory properly"); +#endif + + // ---------------------------------------------------------------------- + // Test GET_DIRECTORY_PROPERTY for listfiles +#ifndef CMAKE_FOUND_LISTFILE_STACK + cmFailed("CMake did not get the listfile stack properly"); +#else + cmPassed("CMake found the listfile stack properly"); +#endif + + // ---------------------------------------------------------------------- + // Test SET, VARIABLE_REQUIRES + +#ifdef SHOULD_NOT_BE_DEFINED + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED is defined."); +#endif + +#ifndef ONE_VAR + cmFailed("cmakedefine is broken, ONE_VAR is not defined."); +#else + cmPassed("ONE_VAR is defined."); +#endif + +#ifndef ONE_VAR_IS_DEFINED + cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, " + "ONE_VAR_IS_DEFINED is not defined."); +#else + cmPassed("ONE_VAR_IS_DEFINED is defined."); +#endif + +#ifdef ZERO_VAR + cmFailed("cmakedefine is broken, ZERO_VAR is defined."); +#else + cmPassed("ZERO_VAR is not defined."); +#endif + +#ifndef STRING_VAR + cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined."); +#else + if(strcmp(STRING_VAR, "CMake is great") != 0) + { + cmFailed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ", + STRING_VAR); + } + else + { + cmPassed("STRING_VAR == ", STRING_VAR); + } +#endif + + // ---------------------------------------------------------------------- + // Test various IF/ELSE combinations + +#ifdef SHOULD_NOT_BE_DEFINED_NOT + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_NOT is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_NOT + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_NOT is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_NOT is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_NOT2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_NOT2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_NOT2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_NOT2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_NOT2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_AND + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_AND is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_AND + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_AND is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_AND2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_AND2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_AND2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_AND2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_OR + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_OR is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_OR + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_OR is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_OR2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_OR2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_OR2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_OR2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_MATCHES + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_MATCHES + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_MATCHES is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_MATCHES2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_MATCHES2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_MATCHES2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_MATCHES2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_COMMAND + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_COMMAND + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_COMMAND is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_COMMAND2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_COMMAND2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_COMMAND2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_EXISTS + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EXISTS is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_EXISTS is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_EXISTS + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EXISTS is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_EXISTS is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_EXISTS2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EXISTS2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_EXISTS2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_EXISTS2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EXISTS2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_EXISTS2 is defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_IS_DIRECTORY + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_IS_DIRECTORY is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_IS_DIRECTORY is defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_IS_DIRECTORY2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_IS_DIRECTORY2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_IS_DIRECTORY2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_LESS + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_LESS is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_LESS + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_LESS is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_LESS is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_LESS2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_LESS2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_LESS2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_LESS2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_LESS2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_GREATER + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_GREATER is not defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_EQUAL + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EQUAL is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_EQUAL is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_EQUAL + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EQUAL is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_EQUAL is defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_GREATER + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_GREATER is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_GREATER2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_GREATER2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_GREATER2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_GREATER2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_STRLESS + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_STRLESS + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_STRLESS is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_STRLESS2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_STRLESS2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_STRLESS2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_STRGREATER + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_STRGREATER + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_STRGREATER is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_STRGREATER2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_STRGREATER2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_STRGREATER2 is defined."); +#endif + + // ---------------------------------------------------------------------- + // Test FOREACH + +#ifndef FOREACH_VAR1 + cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " + "FOREACH_VAR1 is not defined."); +#else + if(strcmp(FOREACH_VAR1, "VALUE1") != 0) + { + cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " + "FOREACH_VAR1 == ", FOREACH_VAR1); + } + else + { + cmPassed("FOREACH_VAR1 == ", FOREACH_VAR1); + } +#endif + +#ifndef FOREACH_VAR2 + cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " + "FOREACH_VAR2 is not defined."); +#else + if(strcmp(FOREACH_VAR2, "VALUE2") != 0) + { + cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " + "FOREACH_VAR2 == ", FOREACH_VAR2); + } + else + { + cmPassed("FOREACH_VAR2 == ", FOREACH_VAR2); + } +#endif + +#ifndef FOREACH_CONCAT + cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " + "FOREACH_CONCAT is not defined."); +#else + if(strcmp(FOREACH_CONCAT, "abcdefg") != 0) + { + cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " + "FOREACH_CONCAT == ", FOREACH_CONCAT); + } + else + { + cmPassed("FOREACH_CONCAT == ", FOREACH_CONCAT); + } +#endif + + // ---------------------------------------------------------------------- + // Test WHILE + + if(WHILE_VALUE != 1000) + { + cmFailed("WHILE command is not working"); + } + else + { + cmPassed("WHILE command is working"); + } + + // ---------------------------------------------------------------------- + // Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations + +#ifndef FILENAME_VAR_PATH_NAME + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_PATH_NAME is not defined."); +#else + if((strcmp(FILENAME_VAR_PATH_NAME, "Complex") == 0) || + (strcmp(FILENAME_VAR_PATH_NAME, "ComplexOneConfig") == 0)) + { + cmPassed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME); + } + else + { + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME); + } +#endif + +#ifndef FILENAME_VAR_NAME + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_NAME is not defined."); +#else + if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0) + { + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_NAME == ", FILENAME_VAR_NAME); + } + else + { + cmPassed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME); + } +#endif + +#ifndef FILENAME_VAR_EXT + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_EXT is not defined."); +#else + if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0) + { + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_EXT == ", FILENAME_VAR_EXT); + } + else + { + cmPassed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT); + } +#endif + +#ifndef FILENAME_VAR_NAME_WE + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_NAME_WE is not defined."); +#else + if(strcmp(FILENAME_VAR_NAME_WE, "VarTests") != 0) + { + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE); + } + else + { + cmPassed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE); + } +#endif + +#ifndef PATH_VAR_NAME + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "PATH_VAR_NAME is not defined."); +#else + if((strcmp(PATH_VAR_NAME, "Complex") == 0) || + (strcmp(PATH_VAR_NAME, "ComplexOneConfig") == 0)) + { + cmPassed("PATH_VAR_NAME == ", PATH_VAR_NAME); + } + else + { + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "PATH_VAR_NAME == ", PATH_VAR_NAME); + } +#endif + + // ---------------------------------------------------------------------- + // Test LOAD_CACHE + +#ifndef CACHE_TEST_VAR1 + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR1 is not defined."); +#else + if(strcmp(CACHE_TEST_VAR1, "foo") != 0) + { + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1); + } + else + { + cmPassed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1); + } +#endif + +#ifndef CACHE_TEST_VAR2 + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR2 is not defined."); +#else + if(strcmp(CACHE_TEST_VAR2, "bar") != 0) + { + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2); + } + else + { + cmPassed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2); + } +#endif + +#ifndef CACHE_TEST_VAR3 + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR3 is not defined."); +#else + if(strcmp(CACHE_TEST_VAR3, "1") != 0) + { + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3); + } + else + { + cmPassed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3); + } +#endif + +#ifdef CACHE_TEST_VAR_EXCLUDED + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, " + "CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded)."); +#else + cmPassed("CACHE_TEST_VAR_EXCLUDED is not defined."); +#endif + +#ifndef CACHE_TEST_VAR_INTERNAL + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR_INTERNAL is not defined."); +#else + std::string cachetest = CACHE_TEST_VAR_INTERNAL; + if(cachetest != "bar") + { + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL); + } + else + { + cmPassed("CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL); + } +#endif + + // ---------------------------------------------------------------------- + // Some pre-build/pre-link/post-build custom-commands have been + // attached to the lib (see Library/). + // Each runs ${CREATE_FILE_EXE} which will create a file. + // It also copies that file again using cmake -E. + // Similar rules have been added to this executable. + // + // WARNING: if you run 'complex' manually, this *will* fail, because + // the file was removed the last time 'complex' was run, and it is + // only created during a build. + + TestAndRemoveFile(BINARY_DIR "/Library/prebuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Library/prelink.txt"); + TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/prebuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/prelink.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/postbuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/postbuild2.txt"); + + // ---------------------------------------------------------------------- + // A custom target has been created (see Library/). + // It runs ${CREATE_FILE_EXE} which will create a file. + // + // WARNING: if you run 'complex' manually, this *will* fail, because + // the file was removed the last time 'complex' was run, and it is + // only created during a build. + + TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt"); + + // ---------------------------------------------------------------------- + // A directory has been created. + + TestDir(BINARY_DIR "/make_dir"); + + // ---------------------------------------------------------------------- + // Test OUTPUT_REQUIRED_FILES + // The files required by 'complex' have been output to a file. + // The contents of this file is not tested (absolute paths). + // + // WARNING: if you run 'complex' manually, this *will* fail, because + // the file was removed the last time 'complex' was run, and it is + // only created during a build. + + TestAndRemoveFile(BINARY_DIR "/Executable/Temp/complex-required.txt"); + + // ---------------------------------------------------------------------- + // Test FIND_LIBRARY + +#ifndef FIND_DUMMY_LIB + cmFailed("the CONFIGURE_FILE command is broken, " + "FIND_DUMMY_LIB is not defined."); +#else + if(strstr(FIND_DUMMY_LIB, "dummylib") == NULL) + { + cmFailed("the FIND_LIBRARY or CONFIGURE_FILE command is broken, " + "FIND_DUMMY_LIB == ", FIND_DUMMY_LIB); + } + else + { + cmPassed("FIND_DUMMY_LIB == ", FIND_DUMMY_LIB); + } +#endif + + // ---------------------------------------------------------------------- + // Test SET_SOURCE_FILES_PROPERTIES + +#ifndef FILE_HAS_EXTRA_COMPILE_FLAGS + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_HAS_EXTRA_COMPILE_FLAGS flag"); +#else + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag"); +#endif + +#if 0 // Disable until implemented everywhere. +#ifndef FILE_DEFINE_STRING + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag"); +#else + if(strcmp(FILE_DEFINE_STRING, "hello") != 0) + { + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag correctly"); + } + else + { + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_DEFINE_STRING flag"); + } +#endif +#endif + +#ifndef FILE_HAS_ABSTRACT + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag"); +#else + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting ABSTRACT flag"); +#endif + +#ifndef FILE_HAS_WRAP_EXCLUDE + cmFailed("FILE_HAS_WRAP_EXCLUDE failed at setting WRAP_EXCLUDE flag"); +#else + cmPassed("FILE_HAS_WRAP_EXCLUDE succeeded in setting WRAP_EXCLUDE flag"); +#endif + +#ifndef FILE_COMPILE_FLAGS + cmFailed("the CONFIGURE_FILE command is broken, FILE_COMPILE_FLAGS is not defined."); +#else + if(strcmp(FILE_COMPILE_FLAGS, "-foo -bar") != 0) + { + cmFailed("the SET_SOURCE_FILES_PROPERTIES or CONFIGURE_FILE command is broken. FILE_COMPILE_FLAGS == ", + FILE_COMPILE_FLAGS); + } + else + { + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting extra flags == ", FILE_COMPILE_FLAGS); + } +#endif + + // ---------------------------------------------------------------------- + // Test registry (win32) +#if defined(_WIN32) && !defined(__CYGWIN__) +#ifndef REGISTRY_TEST_PATH + cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not defined."); +#else + std::cout << "REGISTRY_TEST_PATH == " << REGISTRY_TEST_PATH << "\n"; + if(stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) + { + cmFailed("the 'read registry value' function or CONFIGURE_FILE command is broken. REGISTRY_TEST_PATH == ", + REGISTRY_TEST_PATH, " is not " BINARY_DIR "/registry_dir"); + } + else + { + cmPassed("REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH); + } +#endif +#endif // defined(_WIN32) && !defined(__CYGWIN__) + + if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "1.3") == 0) + { + cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 1.3"); + } + else + { + cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 1.3"); + } + + // ---------------------------------------------------------------------- + // Test REMOVE command + if (strcmp("a;b;d",REMOVE_STRING) == 0) + { + cmPassed("REMOVE is working"); + } + else + { + cmFailed("REMOVE is not working"); + } + + // ---------------------------------------------------------------------- + // Test SEPARATE_ARGUMENTS + if(strcmp("a;b;c", TEST_SEP) == 0) + { + cmPassed("SEPARATE_ARGUMENTS is working"); + } + else + { + cmFailed("SEPARATE_ARGUMENTS is not working"); + } + + // ---------------------------------------------------------------------- + // Test Escape Quotes + if(strcmp("\"hello world\"", STRING_WITH_QUOTES) == 0) + { + cmPassed("ESCAPE_QUOTES is working"); + } + else + { + cmFailed("ESCAPE_QUOTES is not working"); + } + + + // ---------------------------------------------------------------------- + // Test if IF command inside a FOREACH works. +#if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) && !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED) + cmPassed("IF inside a FOREACH block works"); +#else + cmFailed("IF inside a FOREACH block is broken"); +#endif + +#if defined(GENERATED_HEADER_INCLUDED) + cmPassed("Generated header included by non-generated source works."); +#else + cmFailed("Generated header included by non-generated source failed."); +#endif + if(SHOULD_BE_ZERO == 0) + { + cmPassed("cmakedefine01 is working for 0"); + } + else + { + cmFailed("cmakedefine01 is not working for 0"); + } + if(SHOULD_BE_ONE == 1) + { + cmPassed("cmakedefine01 is working for 1"); + } + else + { + cmFailed("cmakedefine01 is not working for 1"); + } +#ifdef FORCE_TEST + cmFailed("CMake SET CACHE FORCE"); +#else + cmPassed("CMake SET CACHE FORCE"); +#endif + +#ifdef COMPLEX_TEST_LINK_STATIC + if(TestLinkGetType()) + { + cmPassed("Link to static over shared worked."); + } + else + { + cmFailed("Link to static over shared failed."); + } +#endif + +#if defined(A_VALUE) && A_VALUE == 10 + cmPassed("Single-character executable A worked."); +#else + cmFailed("Single-character executable A failed."); +#endif + + // ---------------------------------------------------------------------- + // Summary + + std::cout << "Passed: " << cm_passed << "\n"; + if(cm_failed) + { + std::cout << "Failed: " << cm_failed << "\n"; + return cm_failed; + } + return 0; +} diff --git a/Tests/Complex/Executable/complex.file.cxx b/Tests/Complex/Executable/complex.file.cxx new file mode 100644 index 000000000..e873fa644 --- /dev/null +++ b/Tests/Complex/Executable/complex.file.cxx @@ -0,0 +1,8 @@ +#if 0 +#include "cmMissingHeader.h" +#endif + +int main(int , char**) +{ + return 0; +} diff --git a/Tests/Complex/Executable/complex_nobuild.c b/Tests/Complex/Executable/complex_nobuild.c new file mode 100644 index 000000000..6b3c2c1e2 --- /dev/null +++ b/Tests/Complex/Executable/complex_nobuild.c @@ -0,0 +1 @@ +#error "This file should not be compiled." diff --git a/Tests/Complex/Executable/complex_nobuild.cxx b/Tests/Complex/Executable/complex_nobuild.cxx new file mode 100644 index 000000000..6b3c2c1e2 --- /dev/null +++ b/Tests/Complex/Executable/complex_nobuild.cxx @@ -0,0 +1 @@ +#error "This file should not be compiled." diff --git a/Tests/Complex/Executable/notInAllExe.cxx b/Tests/Complex/Executable/notInAllExe.cxx new file mode 100644 index 000000000..70275cd51 --- /dev/null +++ b/Tests/Complex/Executable/notInAllExe.cxx @@ -0,0 +1,10 @@ +extern int notInAllLibFunc(); + +int main() +{ + return notInAllLibFunc(); +} + +#if 1 +# error "This target should not be compiled by ALL." +#endif diff --git a/Tests/Complex/Executable/testSystemDir.cxx b/Tests/Complex/Executable/testSystemDir.cxx new file mode 100644 index 000000000..e4815c679 --- /dev/null +++ b/Tests/Complex/Executable/testSystemDir.cxx @@ -0,0 +1,3 @@ +#include <testSystemDir.h> + +int main() { return foo(); } diff --git a/Tests/Complex/Executable/testcflags.c b/Tests/Complex/Executable/testcflags.c new file mode 100644 index 000000000..f4d584844 --- /dev/null +++ b/Tests/Complex/Executable/testcflags.c @@ -0,0 +1,26 @@ +#include <string.h> + +int TestTargetCompileFlags(char* m) +{ +#ifndef COMPLEX_TARGET_FLAG + strcpy(m, "CMAKE SET_TARGET_PROPERTIES COMPILE_FLAGS did not work"); + return 0; +#endif + strcpy(m, "CMAKE SET_TARGET_PROPERTIES COMPILE_FLAGS worked"); + return 1; +} + +int TestCFlags(char* m) +{ + /* TEST_CXX_FLAGS should not be defined in a c file */ +#ifdef TEST_CXX_FLAGS + strcpy(m, "CMake CMAKE_CXX_FLAGS (TEST_CXX_FLAGS) found in c file."); + return 0; +#endif + /* TEST_C_FLAGS should be defined in a c file */ +#ifndef TEST_C_FLAGS + strcpy(m, "CMake CMAKE_C_FLAGS (TEST_C_FLAGS) not found in c file."); + return 0; +#endif + return 1; +} diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt new file mode 100644 index 000000000..c8efc3022 --- /dev/null +++ b/Tests/Complex/Library/CMakeLists.txt @@ -0,0 +1,140 @@ +REMOVE_DEFINITIONS(-DCMAKE_IS_REALLY_FUN) + +# +# Small utility used to create file +# UTILITY_SOURCE is used for coverage and for getting the exact name +# of the executable. +# +UTILITY_SOURCE(CREATE_FILE_EXE create_file "." create_file.cxx) +ADD_EXECUTABLE(create_file create_file.cxx) +SET_TARGET_PROPERTIES(create_file PROPERTIES RUNTIME_OUTPUT_DIRECTORY ".") + +# +# Create static library +# SOURCE_FILES_REMOVE is used for Coverage. empty.h is included for coverage +# +AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources) +SET(LibrarySources ${LibrarySources} + file2 + empty + create_file.cxx + GENERATED + nonexisting_file) +REMOVE(LibrarySources create_file.cxx GENERATED nonexisting_file) +ADD_LIBRARY(CMakeTestLibrary ${LibrarySources}) + +IF(WIN32) + IF(NOT CYGWIN) + IF(NOT BORLAND) + IF(NOT MINGW) + TARGET_LINK_LIBRARIES(CMakeTestLibrary + debug + user32.lib) + TARGET_LINK_LIBRARIES(CMakeTestLibrary + optimized + kernel32.lib) + ENDIF(NOT MINGW) + ENDIF(NOT BORLAND) + ENDIF(NOT CYGWIN) +ENDIF(WIN32) + +# +# Create shared library +# +SET(SharedLibrarySources sharedFile) +ADD_LIBRARY(CMakeTestLibraryShared SHARED ${SharedLibrarySources}) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTEST_C_FLAGS") +ADD_LIBRARY(CMakeTestCLibraryShared SHARED testConly.c) +DEFINE_PROPERTY( + TARGET PROPERTY FOO + BRIEF_DOCS "a test property" + FULL_DOCS "A simple etst proerty that means nothign and is used for nothing" + ) +SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES FOO BAR) +IF(NOT BEOS AND NOT WIN32) # No libm on BeOS. + SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES LINK_FLAGS "-lm") +ENDIF(NOT BEOS AND NOT WIN32) +GET_TARGET_PROPERTY(FOO_BAR_VAR CMakeTestCLibraryShared FOO) +IF(${FOO_BAR_VAR} MATCHES "BAR") +ELSE(${FOO_BAR_VAR} MATCHES "BAR") + MESSAGE(SEND_ERROR "SET_TARGET_PROPERTIES or GET_TARGET_PROPERTY failed, FOO_BAR_VAR should be BAR, but is ${FOO_BAR_VAR}") +ENDIF(${FOO_BAR_VAR} MATCHES "BAR") + +# Create static and shared lib of same name. +IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + ADD_LIBRARY(CMakeTestLinkStatic STATIC TestLink.c) + ADD_LIBRARY(CMakeTestLinkShared SHARED TestLink.c) + SET_TARGET_PROPERTIES(CMakeTestLinkStatic CMakeTestLinkShared + PROPERTIES OUTPUT_NAME CMakeTestLink) +ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + +# +# Attach pre-build/pre-link/post-build custom-commands to the lib. +# Each runs ${CREATE_FILE_EXE} which will create a file. +# The 'complex' executable will then test if this file exists and remove it. +# +ADD_DEPENDENCIES(CMakeTestLibraryShared create_file) +MESSAGE("complex bin dir is ${Complex_BINARY_DIR}") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/prebuild.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/prelink.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared POST_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy + "${Complex_BINARY_DIR}/Library/postbuild.txt" + "${Complex_BINARY_DIR}/Library/postbuild2.txt") + +# +# Add a custom target. +# It runs ${CREATE_FILE_EXE} which will create a file. +# The 'complex' executable will then test if this file exists and remove it. +# +ADD_CUSTOM_TARGET(custom_target1 + ALL + ${CREATE_FILE_EXE} + "${Complex_BINARY_DIR}/Library/custom_target1.txt") + +ADD_DEPENDENCIES(custom_target1 create_file) + +# +# Extra coverage +# +SET_SOURCE_FILES_PROPERTIES(file2 PROPERTIES ABSTRACT 1) + +INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h) +INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h) + +# Test creating a library that is not built by default. +ADD_LIBRARY(notInAllLib EXCLUDE_FROM_ALL notInAllLib.cxx) + +# Create an imported target for if(TARGET) test in Executable dir. +# That test should not see this target. +ADD_LIBRARY(LibImportedTarget UNKNOWN IMPORTED) + +# Test generation of preprocessed sources. +IF("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) + IF(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE) + # Skip running this part of the test on certain platforms + # until they are fixed. + SET(MAYBE_ALL ALL) + LIST(LENGTH CMAKE_OSX_ARCHITECTURES ARCH_COUNT) + IF(ARCH_COUNT GREATER 1) + # OSX does not support preprocessing more than one architecture. + SET(MAYBE_ALL) + ENDIF(ARCH_COUNT GREATER 1) + + # Custom target to try preprocessing invocation. + ADD_CUSTOM_TARGET(test_preprocess ${MAYBE_ALL} + COMMAND ${CMAKE_COMMAND} -E remove CMakeFiles/create_file.dir/create_file.i + COMMAND ${CMAKE_MAKE_PROGRAM} create_file.i + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/test_preprocess.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + ENDIF(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE) +ENDIF("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) diff --git a/Tests/Complex/Library/ExtraSources/file1.cxx b/Tests/Complex/Library/ExtraSources/file1.cxx new file mode 100644 index 000000000..e22812e51 --- /dev/null +++ b/Tests/Complex/Library/ExtraSources/file1.cxx @@ -0,0 +1,4 @@ +int file1() +{ + return 1; +} diff --git a/Tests/Complex/Library/ExtraSources/file1.h b/Tests/Complex/Library/ExtraSources/file1.h new file mode 100644 index 000000000..ce0d818a3 --- /dev/null +++ b/Tests/Complex/Library/ExtraSources/file1.h @@ -0,0 +1 @@ +int file1(); diff --git a/Tests/Complex/Library/SystemDir/testSystemDir.h b/Tests/Complex/Library/SystemDir/testSystemDir.h new file mode 100644 index 000000000..73be3538e --- /dev/null +++ b/Tests/Complex/Library/SystemDir/testSystemDir.h @@ -0,0 +1,2 @@ +// Purposely leave off the return type to create a warning. +foo() { return 0; } diff --git a/Tests/Complex/Library/TestLink.c b/Tests/Complex/Library/TestLink.c new file mode 100644 index 000000000..25dee082f --- /dev/null +++ b/Tests/Complex/Library/TestLink.c @@ -0,0 +1,8 @@ +int TestLinkGetType() +{ +#ifdef CMakeTestLinkShared_EXPORTS + return 0; +#else + return 1; +#endif +} diff --git a/Tests/Complex/Library/create_file.cxx b/Tests/Complex/Library/create_file.cxx new file mode 100644 index 000000000..d41551980 --- /dev/null +++ b/Tests/Complex/Library/create_file.cxx @@ -0,0 +1,28 @@ +#include <stdio.h> +#include <stdlib.h> + +int main (int argc, char *argv[]) +{ + if (argc < 2) + { + fprintf(stderr, "Missing name of file to create.\n"); + return EXIT_FAILURE; + } + + FILE *stream = fopen(argv[1], "w"); + if(stream == NULL) + { + fprintf(stderr, "Unable to open %s for writing!\n", argv[1]); + return EXIT_FAILURE; + } + + if(fclose(stream)) + { + fprintf(stderr, "Unable to close %s!\n", argv[1]); + return EXIT_FAILURE; + } + + fprintf(stdout, ">> Creating %s!\n", argv[1]); + + return EXIT_SUCCESS; +} diff --git a/Tests/Complex/Library/dummy b/Tests/Complex/Library/dummy new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/Complex/Library/dummy diff --git a/Tests/Complex/Library/empty.h b/Tests/Complex/Library/empty.h new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/Complex/Library/empty.h diff --git a/Tests/Complex/Library/file2.cxx b/Tests/Complex/Library/file2.cxx new file mode 100644 index 000000000..863fcaa51 --- /dev/null +++ b/Tests/Complex/Library/file2.cxx @@ -0,0 +1,10 @@ +#include <string.h> + +#ifdef CMAKE_IS_REALLY_FUN +This is a problem. Looks like REMOVE_DEFINITION does not work +#endif + +int file2() +{ + return 1; +} diff --git a/Tests/Complex/Library/file2.h b/Tests/Complex/Library/file2.h new file mode 100644 index 000000000..dea4b80b1 --- /dev/null +++ b/Tests/Complex/Library/file2.h @@ -0,0 +1 @@ +int file2(); diff --git a/Tests/Complex/Library/notInAllLib.cxx b/Tests/Complex/Library/notInAllLib.cxx new file mode 100644 index 000000000..5d928f44a --- /dev/null +++ b/Tests/Complex/Library/notInAllLib.cxx @@ -0,0 +1,5 @@ +int notInAllLibFunc() { return 0; } + +#if 1 +# error "This target should not be compiled by ALL." +#endif diff --git a/Tests/Complex/Library/sharedFile.cxx b/Tests/Complex/Library/sharedFile.cxx new file mode 100644 index 000000000..cafac68f4 --- /dev/null +++ b/Tests/Complex/Library/sharedFile.cxx @@ -0,0 +1,6 @@ +#include "sharedFile.h" + +int sharedFunction() +{ + return 1; +} diff --git a/Tests/Complex/Library/sharedFile.h b/Tests/Complex/Library/sharedFile.h new file mode 100644 index 000000000..65ac2e2ba --- /dev/null +++ b/Tests/Complex/Library/sharedFile.h @@ -0,0 +1,12 @@ +#if defined(_WIN32) || defined(WIN32) /* Win32 version */ +#ifdef CMakeTestLibraryShared_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +#else +# define CMakeTest_EXPORT __declspec(dllimport) +#endif +#else +/* unix needs nothing */ +#define CMakeTest_EXPORT +#endif + +CMakeTest_EXPORT int sharedFunction(); diff --git a/Tests/Complex/Library/testConly.c b/Tests/Complex/Library/testConly.c new file mode 100644 index 000000000..2d83f778e --- /dev/null +++ b/Tests/Complex/Library/testConly.c @@ -0,0 +1,13 @@ +#include "testConly.h" +#include <stdio.h> + +int CsharedFunction() +{ +#ifndef TEST_C_FLAGS + printf("TEST_C_FLAGS failed\n"); + return 0; +#else + printf("Passed: TEST_C_FLAGS passed\n"); +#endif + return 1; +} diff --git a/Tests/Complex/Library/testConly.h b/Tests/Complex/Library/testConly.h new file mode 100644 index 000000000..f1470a8d7 --- /dev/null +++ b/Tests/Complex/Library/testConly.h @@ -0,0 +1,13 @@ +#if defined(_WIN32) || defined(WIN32) /* Win32 version */ +#ifdef CMakeTestCLibraryShared_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +#else +# define CMakeTest_EXPORT __declspec(dllimport) +#endif +#else +/* unix needs nothing */ +#define CMakeTest_EXPORT +#endif + +CMakeTest_EXPORT int CsharedFunction(); + diff --git a/Tests/Complex/Library/test_preprocess.cmake b/Tests/Complex/Library/test_preprocess.cmake new file mode 100644 index 000000000..d2d9fc652 --- /dev/null +++ b/Tests/Complex/Library/test_preprocess.cmake @@ -0,0 +1,7 @@ +SET(TEST_FILE CMakeFiles/create_file.dir/create_file.i) +FILE(READ ${TEST_FILE} CONTENTS) +IF("${CONTENTS}" MATCHES "Unable to close") + MESSAGE(STATUS "${TEST_FILE} created successfully!") +ELSE("${CONTENTS}" MATCHES "Unable to close") + MESSAGE(FATAL_ERROR "${TEST_FILE} creation failed!") +ENDIF("${CONTENTS}" MATCHES "Unable to close") diff --git a/Tests/Complex/VarTests.cmake b/Tests/Complex/VarTests.cmake new file mode 100644 index 000000000..c146d1be0 --- /dev/null +++ b/Tests/Complex/VarTests.cmake @@ -0,0 +1,198 @@ +# +# Test SET +# +SET (ZERO_VAR 0) +SET (ZERO_VAR2 0) + +IF(ZERO_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED) +ELSE(ZERO_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED) +ENDIF(ZERO_VAR) + +SET(ONE_VAR 1) +SET(ONE_VAR2 1) +SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable") + +# +# Test VARIABLE_REQUIRES +# +VARIABLE_REQUIRES(ONE_VAR + ONE_VAR_IS_DEFINED ONE_VAR) + +# +# Test various IF/ELSE combinations +# +IF(NOT ZERO_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_NOT) +ELSE(NOT ZERO_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_NOT) +ENDIF(NOT ZERO_VAR) + +IF(NOT ONE_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_NOT2) +ELSE(NOT ONE_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_NOT2) +ENDIF(NOT ONE_VAR) + +IF(ONE_VAR AND ONE_VAR2) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND) +ELSE(ONE_VAR AND ONE_VAR2) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_AND) +ENDIF(ONE_VAR AND ONE_VAR2) + +IF(ONE_VAR AND ZERO_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_AND2) +ELSE(ONE_VAR AND ZERO_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND2) +ENDIF(ONE_VAR AND ZERO_VAR) + +IF(ZERO_VAR OR ONE_VAR2) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_OR) +ELSE(ZERO_VAR OR ONE_VAR2) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR) +ENDIF(ZERO_VAR OR ONE_VAR2) + +IF(ZERO_VAR OR ZERO_VAR2) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR2) +ELSE(ZERO_VAR OR ZERO_VAR2) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_OR2) +ENDIF(ZERO_VAR OR ZERO_VAR2) + +IF(STRING_VAR MATCHES "^CMake") + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES) +ELSE(STRING_VAR MATCHES "^CMake") + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES) +ENDIF(STRING_VAR MATCHES "^CMake") + +IF(STRING_VAR MATCHES "^foo") + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES2) +ELSE(STRING_VAR MATCHES "^foo") + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES2) +ENDIF(STRING_VAR MATCHES "^foo") + +IF(COMMAND "IF") + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND) +ELSE(COMMAND "IF") + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND) +ENDIF(COMMAND "IF") + +IF(COMMAND "ROQUEFORT") + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND2) +ELSE(COMMAND "ROQUEFORT") + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND2) +ENDIF(COMMAND "ROQUEFORT") + +IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EXISTS) +ELSE(EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EXISTS) +ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) + +IF (EXISTS ${Complex_SOURCE_DIR}/roquefort.txt) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EXISTS2) +ELSE(EXISTS ${Complex_SOURCE_DIR}/roquefort.txt) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EXISTS2) +ENDIF (EXISTS ${Complex_SOURCE_DIR}/roquefort.txt) + +IF (IS_DIRECTORY ${Complex_SOURCE_DIR}) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_IS_DIRECTORY) +ENDIF (IS_DIRECTORY ${Complex_SOURCE_DIR}) + +IF (NOT IS_DIRECTORY ${Complex_SOURCE_DIR}/VarTests.cmake) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_IS_DIRECTORY2) +ENDIF (NOT IS_DIRECTORY ${Complex_SOURCE_DIR}/VarTests.cmake) + +SET (SNUM1_VAR "1") +SET (SNUM2_VAR "2") +SET (SNUM3_VAR "1") + + +IF (SNUM1_VAR LESS SNUM2_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_LESS) +ELSE (SNUM1_VAR LESS SNUM2_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_LESS) +ENDIF (SNUM1_VAR LESS SNUM2_VAR) + +IF (SNUM2_VAR LESS SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_LESS2) +ELSE (SNUM2_VAR LESS SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_LESS2) +ENDIF (SNUM2_VAR LESS SNUM1_VAR) + +IF (SNUM2_VAR GREATER SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_GREATER) +ELSE (SNUM2_VAR GREATER SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_GREATER) +ENDIF (SNUM2_VAR GREATER SNUM1_VAR) + +IF (SNUM2_VAR EQUAL SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EQUAL) +ELSE (SNUM2_VAR EQUAL SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EQUAL) +ENDIF (SNUM2_VAR EQUAL SNUM1_VAR) + +IF (SNUM3_VAR EQUAL SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EQUAL) +ELSE (SNUM3_VAR EQUAL SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EQUAL) +ENDIF (SNUM3_VAR EQUAL SNUM1_VAR) + +IF (SNUM1_VAR GREATER SNUM2_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_GREATER2) +ELSE (SNUM1_VAR GREATER SNUM2_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_GREATER2) +ENDIF (SNUM1_VAR GREATER SNUM2_VAR) + +SET (SSTR1_VAR "abc") +SET (SSTR2_VAR "bcd") + +IF (SSTR1_VAR STRLESS SSTR2_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRLESS) +ELSE (SSTR1_VAR STRLESS SSTR2_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRLESS) +ENDIF (SSTR1_VAR STRLESS SSTR2_VAR) + +IF (SSTR2_VAR STRLESS SSTR1_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRLESS2) +ELSE (SSTR2_VAR STRLESS SSTR1_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRLESS2) +ENDIF (SSTR2_VAR STRLESS SSTR1_VAR) + +IF (SSTR2_VAR STRGREATER SSTR1_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRGREATER) +ELSE (SSTR2_VAR STRGREATER SSTR1_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRGREATER) +ENDIF (SSTR2_VAR STRGREATER SSTR1_VAR) + +IF (SSTR1_VAR STRGREATER SSTR2_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRGREATER2) +ELSE (SSTR1_VAR STRGREATER SSTR2_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRGREATER2) +ENDIF (SSTR1_VAR STRGREATER SSTR2_VAR) + +# +# Test FOREACH +# +FOREACH (INDEX 1 2) + SET(FOREACH_VAR${INDEX} "VALUE${INDEX}") +ENDFOREACH(INDEX) + +SET(FOREACH_CONCAT "") +FOREACH (INDEX a;b;c;d;e;f;g) + SET(FOREACH_CONCAT "${FOREACH_CONCAT}${INDEX}") +ENDFOREACH(INDEX) + +# +# Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations +# +FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR}) + +GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH) +GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME) +GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME) +GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT) +GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE) + +FIND_PATH(PATH_VAR "cmTestConfigure.h.in" ${Complex_SOURCE_DIR}) +GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME) diff --git a/Tests/Complex/cmTestConfigure.h.in b/Tests/Complex/cmTestConfigure.h.in new file mode 100644 index 000000000..7741b6fd5 --- /dev/null +++ b/Tests/Complex/cmTestConfigure.h.in @@ -0,0 +1,85 @@ +// Test SET, VARIABLE_REQUIRES + +#cmakedefine ONE_VAR +#cmakedefine ONE_VAR_IS_DEFINED +#cmakedefine ZERO_VAR + +#define STRING_VAR "${STRING_VAR}" + +// Test FOREACH + +#define FOREACH_VAR1 "${FOREACH_VAR1}" +#define FOREACH_VAR2 "${FOREACH_VAR2}" +#define FOREACH_CONCAT "${FOREACH_CONCAT}" + +// Test WHILE +#define WHILE_VALUE ${while_var} + +// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations + +#define FILENAME_VAR_PATH_NAME "${FILENAME_VAR_PATH_NAME}" +#define FILENAME_VAR_NAME "${FILENAME_VAR_NAME}" +#define FILENAME_VAR_EXT "${FILENAME_VAR_EXT}" +#define FILENAME_VAR_NAME_WE "${FILENAME_VAR_NAME_WE}" + +#define PATH_VAR_NAME "${PATH_VAR_NAME}" + +// Test LOAD_CACHE + +#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}" +#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}" +#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}" +#cmakedefine CACHE_TEST_VAR_EXCLUDED +#define CACHE_TEST_VAR_INTERNAL "${CACHE_TEST_VAR_INTERNAL}" + +// Test internal CMake vars from C++ flags + +#cmakedefine CMAKE_NO_STD_NAMESPACE +#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS +#cmakedefine CMAKE_NO_ANSI_STRING_STREAM +#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE + +#cmakedefine01 SHOULD_BE_ZERO +#cmakedefine01 SHOULD_BE_ONE +// Needed to check for files + +#define BINARY_DIR "${Complex_BINARY_DIR}" + +// Test FIND_LIBRARY + +#define FIND_DUMMY_LIB "${FIND_DUMMY_LIB}" + +// Test SET_SOURCE_FILES_PROPERTIES + +#cmakedefine FILE_HAS_ABSTRACT +#cmakedefine FILE_HAS_WRAP_EXCLUDE +#define FILE_COMPILE_FLAGS "${FILE_COMPILE_FLAGS}" + +#define TEST_SEP "${TEST_SEP}" + +// Test registry read + +#if defined(_WIN32) && !defined(__CYGWIN__) +#define REGISTRY_TEST_PATH "${REGISTRY_TEST_PATH}" +#endif + +// Test Remove command +#define REMOVE_STRING "${REMOVE_STRING}" + +// Test IF inside FOREACH +#cmakedefine IF_INSIDE_FOREACH_THEN_EXECUTED +#cmakedefine IF_INSIDE_FOREACH_ELSE_EXECUTED + +// Test SET CACHE FORCE +#cmakedefine FORCE_TEST +#define CMAKE_GENERATOR "${CMAKE_GENERATOR}" + +#define CMAKE_SHARED_MODULE_PREFIX "${CMAKE_SHARED_MODULE_PREFIX}" +#define CMAKE_SHARED_MODULE_SUFFIX "${CMAKE_SHARED_MODULE_SUFFIX}" + +// test elseif +#cmakedefine ELSEIF_RESULT + +// test parenthesis in conditionals +#cmakedefine CONDITIONAL_PARENTHESES + diff --git a/Tests/Complex/cmTestConfigureEscape.h.in b/Tests/Complex/cmTestConfigureEscape.h.in new file mode 100644 index 000000000..39a8bd627 --- /dev/null +++ b/Tests/Complex/cmTestConfigureEscape.h.in @@ -0,0 +1 @@ +#define STRING_WITH_QUOTES "${STRING_WITH_QUOTES}" diff --git a/Tests/Complex/cmTestGeneratedHeader.h.in b/Tests/Complex/cmTestGeneratedHeader.h.in new file mode 100644 index 000000000..0e9dd3ff3 --- /dev/null +++ b/Tests/Complex/cmTestGeneratedHeader.h.in @@ -0,0 +1 @@ +#define GENERATED_HEADER_INCLUDED diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt new file mode 100644 index 000000000..b50501905 --- /dev/null +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -0,0 +1,376 @@ +# +# A more complex test case +# +SET(CMAKE_BACKWARDS_COMPATIBILITY 1.4) +PROJECT (Complex) + +# Try setting a new policy. The IF test is for coverage. +IF(POLICY CMP0003) + CMAKE_POLICY(SET CMP0003 NEW) + + CMAKE_POLICY(GET CMP0003 P3) + IF(NOT "${P3}" STREQUAL "NEW") + MESSAGE(FATAL_ERROR "CMAKE_POLICY(GET) did not report NEW!") + ENDIF(NOT "${P3}" STREQUAL "NEW") +ENDIF(POLICY CMP0003) + +# Test building without per-rule echo lines in Makefiles. +SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES OFF) + +SET(CPACK_SOURCE_IGNORE_FILES "~$;\\.cvsignore$;^C:/hoffman/My Builds/testcase.*/CVS/;^C:/hoffman/My Builds/testcase.*/\\.svn/;^C:/hoffman/My Builds/testcase.*/sweigart/;^C:/hoffman/My Builds/testcase/www/eospaper/solution/eos2001/;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_tables_new/;^C:/hoffman/My Builds/testcase/COPYING$;^C:/hoffman/My Builds/testcase/INSTALL$;^C:/hoffman/My Builds/testcase/Makefile$;^C:/hoffman/My Builds/testcase/Makefile\\.in$;^C:/hoffman/My Builds/testcase/.*\\.lo$;^C:/hoffman/My Builds/testcase/.*\\.la$;^C:/hoffman/My Builds/testcase/mkinstalldirs$;^C:/hoffman/My Builds/testcase/missing$;^C:/hoffman/My Builds/testcase/ltmain\\.sh$;^C:/hoffman/My Builds/testcase/libtool$;^C:/hoffman/My Builds/testcase/install-sh$;^C:/hoffman/My Builds/testcase/configure$;^C:/hoffman/My Builds/testcase/config\\.sub$;^C:/hoffman/My Builds/testcase/config\\.status$;^C:/hoffman/My Builds/testcase/config\\.log$;^C:/hoffman/My Builds/testcase/config\\.guess$;^C:/hoffman/My Builds/testcase/autom4te\\.cache$;^C:/hoffman/My Builds/testcase/aclocal\\.m4$;^C:/hoffman/My Builds/testcase/depcomp$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.075\\.model_cassisi_eos1_10$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.075\\.model_cassisi_eos1_10_corr$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.1\\.model_cassisi_eos1$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.1\\.model_cassisi_scvh$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.1\\.modelc$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.3\\.modelc$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/1\\.0\\.modelc$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/1\\.0\\.rgbtip\\.modelc$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/1\\.0\\.zahb\\.modelc$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.1\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/1\\.0\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.3\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/0\\.085\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/.*\\.ps$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange\\.mem$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange\\.log$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange\\.dvi$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange\\.tex\\.bak$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/head\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/body\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/prior-dvi\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j10\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j12\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j16\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j20\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j22\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j26\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j30\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j32\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/j36\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/k10\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/k12\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/k20\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/k22\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/k30\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/k32\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/1_exchange_dgamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/1_exchange_dlnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/2_exchange_dgamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/2_exchange_dlnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/linear_exchange_dgamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/linear_exchange_dlnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/noexchange_dgamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/noexchange_dlnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/nr_exchange_dgamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/nr_exchange_dlnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/series_exchange_dgamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/series_exchange_dlnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_JNR_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_Jseries_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_KNR_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_Kseries_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check34_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check35_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check36_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check43_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check44_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check45_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check46_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check47_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check48_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/tc_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/.*\\.pyc$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/context\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/make\\.out.*$;^C:/hoffman/My Builds/testcase/www/Makefile$;^C:/hoffman/My Builds/testcase/www/Makefile\\.in$;^C:/hoffman/My Builds/testcase/src/.*\\.flc$;^C:/hoffman/My Builds/testcase/src/Makefile$;^C:/hoffman/My Builds/testcase/src/Makefile\\.in$;^C:/hoffman/My Builds/testcase/src/\\.deps$;^C:/hoffman/My Builds/testcase/src/\\.libs$;^C:/hoffman/My Builds/testcase/src/.*\\.la$;^C:/hoffman/My Builds/testcase/src/.*\\.lo$;^C:/hoffman/My Builds/testcase/src/make\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/statef.*\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/0\\.1\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/0\\.1\\.model_13$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/0\\.1\\.model_23$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/0\\.3\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/0\\.3\\.model_13$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/0\\.3\\.model_23$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/1\\.0\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/1\\.0\\.model_13$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/1\\.0\\.model_15$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/1\\.0\\.model_23$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/1\\.0\\.model_rel$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/hot_post_agb\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/rgb_tip\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/rgbtip\\.1\\.0\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/rgbtip\\.1\\.0\\.model_13$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/rgbtip\\.1\\.0\\.model_23$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/start_shellflash\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/white_dwarf\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/zahb\\.1\\.0\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/zahb\\.1\\.0\\.model_13$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/zahb\\.1\\.0\\.model_23$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/model-loci/zahb\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dh/dgamma1$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dh/dlnp$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dh/statef_compare\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fermi_dirac_approx/15gamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fermi_dirac_approx/15lnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fermi_dirac_approx/23gamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fermi_dirac_approx/23lnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/thermodynamic_consistency/.*\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/thermodynamic_consistency/.*\\.results$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/pteh/dgamma1$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/pteh/dlnp$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/pteh/statef_compare\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/newversion_grid/.*\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/newversion_grid/.*\\.err$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/.*\\.ps$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/.*\\.pyc$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_fit\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_fit\\.dvi$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_fit\\.log$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/body\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/head\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/prior-dvi\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/3order_data\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/5order_data\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/8order_data\\.tex$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check8_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check1_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check3_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check5_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/effo_check3_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/effoo_check3_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fda15gamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fda15lnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fda23gamma1\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/fda23lnp\\.yplot$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/tc_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/make\\.out.*$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/thermodynamic_consistency/statef_compare\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/thermodynamic_consistency/tc\\.results$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_solar/opal_compare_model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_solar/opal_compare_solar\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_solar/opal_solar\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_solar/opal_solar_1995\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_solar/statef_opal_model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/opal_solar/statef_opal_model_1995\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/purehe_newversion_grid/.*\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/purehe_newversion_grid/.*\\.err$;^C:/hoffman/My Builds/testcase/include/Makefile\\.in$;^C:/hoffman/My Builds/testcase/include/Makefile$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/model-loci/0\\.1\\.model_pteh$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/model-loci/1\\.0\\.model_eos1a-eos1$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/model-loci/1\\.0\\.model_pteh$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/model-loci/statef_model_0\\.1\\.model_pteh\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/model-loci/statef_model_1\\.0\\.model_eos1a-eos1\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/model-loci/statef_model_1\\.0\\.model_pteh\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/context/contour\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/context/eos_grid\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/context/statef_grid\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/thermodynamic_consistency/fort\\.91$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/thermodynamic_consistency/statef_compare\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/nocoulomb/dgamma1$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/nocoulomb/dlnp$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/nocoulomb/statef_compare\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/context$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/oldversion_grid$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/2005Ap&SS\\.298\\.\\.135S\\.pdf$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/2007Ap&SS\\.307\\.\\.263C\\.pdf$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/astro-ph\\.9909168_eprint_submitted_to_High_Press\\.Res\\.16,331\\.pdf$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/.*ps.*$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/.*\\.pyc$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/convergence\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/convergence\\.dvi$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/convergence\\.log$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/body\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/head\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/prior-dvi\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/statef_grid-newversion$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/context\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/pureh_context\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/purehe_context\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/old$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/make\\.out.*$;^C:/hoffman/My Builds/testcase/utils/.*\\.flc$;^C:/hoffman/My Builds/testcase/utils/Makefile$;^C:/hoffman/My Builds/testcase/utils/Makefile\\.in$;^C:/hoffman/My Builds/testcase/utils/\\.deps$;^C:/hoffman/My Builds/testcase/utils/\\.libs$;^C:/hoffman/My Builds/testcase/utils/.*\\.la$;^C:/hoffman/My Builds/testcase/utils/.*\\.lo$;^C:/hoffman/My Builds/testcase/utils/free_eos_test$;^C:/hoffman/My Builds/testcase/utils/test_rosenbrock$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/eff_check1\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/eff_check3\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/eff_check5\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/eff_check8\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/eff_checknr\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/effo_check3\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/eff_check/effoo_check3\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence_20070613$;^C:/hoffman/My Builds/testcase/www/eospaper/text$;^C:/hoffman/My Builds/testcase/www/eospaper/cassisi_book_fig$;^C:/hoffman/My Builds/testcase/www/eospaper/1\\.1\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/2\\.0\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/1\\.2\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/1\\.3\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/1\\.4\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/1\\.5\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/1\\.6\\.0$;^C:/hoffman/My Builds/testcase/www/eospaper/figures$;^C:/hoffman/My Builds/testcase/www/eospaper/old$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/.*\\.ps.*$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/coulomb\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/coulomb\\.dvi$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/coulomb\\.log$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/.*\\.pyc$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/body\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/head\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/prior-dvi\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/context\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dh_dgamma1_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dh_dlnp_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dhtau_dgamma1_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dhtau_dlnp_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/nocoulomb_dgamma1_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/nocoulomb_dlnp_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/pteh_dgamma1_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/pteh_dlnp_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/make\\.out.*$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_JNR\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_Jseries\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_KNR\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_Kseries\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_check34\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_check35\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_check36\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_check44\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_check45\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/exchange_check46\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/statef_compare_1_exchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/statef_compare_2_exchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/statef_compare_linear_exchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/statef_compare_noexchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/statef_compare_nr_exchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/statef_compare_series_exchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/1_exchange_dgamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/noexchange_dlnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/nr_exchange_dgamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/series_exchange_dlnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/series_exchange_dgamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/linear_exchange_dlnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/2_exchange_dgamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/nr_exchange_dlnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/linear_exchange_dgamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/noexchange_dgamma1\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/1_exchange_dlnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/exchange_check/2_exchange_dlnp\\.gnuplot$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/pureh_newversion_grid/.*\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/convergence/pureh_newversion_grid/.*\\.err$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dhtau/dgamma1$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dhtau/dlnp$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/dhtau/statef_compare\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_0\\.1\\.model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_0\\.3\\.model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_1\\.0\\.model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_1\\.0\\.model_linear\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_1\\.0\\.model_noexchange\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_1\\.0\\.model_nr\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_1\\.0\\.rgbtip\\.model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/statef_model_1\\.0\\.zahb\\.model\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/1\\.0\\.zahb\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/1\\.0\\.rgbtip\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/1\\.0\\.model_linear$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/1\\.0\\.model_noexchange$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/1\\.0\\.model_nr$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/0\\.1\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/1\\.0\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/model-loci/0\\.3\\.model$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/context/contour\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/context/eos_grid\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/exchange/context/statef_grid\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/gong/delta\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/gong/m0085eos1gong\\.ascii$;^C:/hoffman/My Builds/testcase/www/eospaper/eff_fit/rho-T-loci/gong/m0085eos2gong\\.ascii$;^C:/hoffman/My Builds/testcase/www/eospaper/coulomb/coulomb_adjust/coulomb_adjust\\.out$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/.*\\.ps$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/.*\\.pyc$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/head\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/body\\.tmp$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/prior-dvi\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/solution\\.aux$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/solution\\.log$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/solution\\.dvi$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/rtc_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/tc_yplot\\.in$;^C:/hoffman/My Builds/testcase/www/eospaper/solution/make\\.out.*$") + +# +# Define a macro +# +MACRO(ASSERT value msg) + IF (NOT ${value}) + MESSAGE ("Assertion failure:" ${msg} ) + ENDIF (NOT ${value}) +ENDMACRO(ASSERT) + +# invoke the macro +ASSERT(Complex_BINARY_DIR "The PROJECT command is broken") + +# +# Define a var args macro, it must take two or four args +# +MACRO(TEST_ARGC value1 value2) + ADD_DEFINITIONS(${value1} ${value2}) + IF (${ARGC} MATCHES 4) + ADD_DEFINITIONS(${ARGV2} ${ARGV3}) + ENDIF (${ARGC} MATCHES 4) +ENDMACRO(TEST_ARGC) + +# invoke the macro +TEST_ARGC(-DCMAKE_ARGV1 -DCMAKE_ARGV2 -DCMAKE_ARGV3 -DCMAKE_ARGV4) + +MACRO(TEST_VAR_ARG fa) + IF("${ARGV}" MATCHES "^1;2;3$") + MESSAGE(STATUS "ARGV works") + ELSE("${ARGV}" MATCHES "^1;2;3$") + MESSAGE(FATAL_ERROR "ARGV does not work; got \"${ARGV}\" instead of \"1;2;3\"") + ENDIF("${ARGV}" MATCHES "^1;2;3$") + IF("${ARGN}" MATCHES "^2;3$") + MESSAGE(STATUS "ARGN works") + ELSE("${ARGN}" MATCHES "^2;3$") + MESSAGE(FATAL_ERROR "ARGV does not work; got \"${ARGN}\" instead of \"2;3\"") + ENDIF("${ARGN}" MATCHES "^2;3$") +ENDMACRO(TEST_VAR_ARG) + +TEST_VAR_ARG(1 2 3) + +# Floating-point comparison test. +IF(2.4 LESS 2.4) + MESSAGE(FATAL_ERROR "Failed: 2.4 LESS 2.4") +ENDIF(2.4 LESS 2.4) +IF(2.4 GREATER 2.4) + MESSAGE(FATAL_ERROR "Failed: 2.4 GREATER 2.4") +ENDIF(2.4 GREATER 2.4) +IF(NOT 2.4 EQUAL 2.4) + MESSAGE(FATAL_ERROR "Failed: NOT 2.4 EQUAL 2.4") +ENDIF(NOT 2.4 EQUAL 2.4) + +IF(CMAKE_SYSTEM MATCHES "OSF1-V.*") + IF(NOT CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ") + ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) +ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*") + + +ADD_DEFINITIONS(-DCMAKE_IS_FUN) +ADD_DEFINITIONS(-DCMAKE_IS_REALLY_FUN) +SET_PROPERTY(DIRECTORY + PROPERTY COMPILE_DEFINITIONS_RELEASE + CMAKE_IS_FUN_IN_RELEASE_MODE + ) + +SET(TEST_SEP "a b c") +SEPARATE_ARGUMENTS(TEST_SEP) + + +# +# Include vars from a file and from a cache +# +IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) + INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake) +ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) +INCLUDE(fileshouldnotbehere OPTIONAL) +LOAD_CACHE(${Complex_SOURCE_DIR}/Cache + EXCLUDE + CACHE_TEST_VAR_EXCLUDED + INCLUDE_INTERNALS + CACHE_TEST_VAR_INTERNAL) + +LOAD_CACHE(${Complex_SOURCE_DIR}/Cache READ_WITH_PREFIX foo CACHE_TEST_VAR2) +IF(${fooCACHE_TEST_VAR2} MATCHES bar) + MESSAGE("Load cache worked: ${fooCACHE_TEST_VAR2}") +ELSE(${fooCACHE_TEST_VAR2} MATCHES bar) + MESSAGE(FATAL_ERROR "Load cache with prefix failed: ${fooCACHE_TEST_VAR2}") +ENDIF(${fooCACHE_TEST_VAR2} MATCHES bar) + + + +# +# Specify include and lib dirs +# (BEFORE is for coverage) +# +INCLUDE_DIRECTORIES( + Library +) + +INCLUDE_DIRECTORIES(BEFORE + ${Complex_BINARY_DIR} +) +INCLUDE_DIRECTORIES(SYSTEM Library/SystemDir) + +INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile|test).*$" "^cmMissing") + +LINK_DIRECTORIES( + ${Complex_BINARY_DIR}/Library +) + +# +# check for SET CACHE FORCE +# +SET(FORCE_TEST 1 CACHE STRING "a test") +SET(FORCE_TEST 0 CACHE STRING "a test" FORCE) + +# +# Lib and exe path +# +SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${Complex_BINARY_DIR}/lib/static") +SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${Complex_BINARY_DIR}/lib") +SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${Complex_BINARY_DIR}/bin") + +MESSAGE (Test " " escape " " semi-colon " " \; \;) +# +# Exec program (TODO: test a result) +# Increase coverage. +# +MESSAGE("\nIgnore this message") +OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0) +IF (NOT NO_EXEC_PROGRAM) + EXEC_PROGRAM(${CMAKE_COMMAND} ARGS -E echo NO_EXEC_PROGRAM "${Complex_BINARY_DIR}") +ELSE (NOT NO_EXEC_PROGRAM) + MESSAGE("Set this option ON") +ENDIF (NOT NO_EXEC_PROGRAM) + +MARK_AS_ADVANCED(NO_EXEC_PROGRAM) +MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM) + +# Execute a process. Add coverage for this command. +EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -E echo "ABCDEFG" + OUTPUT_VARIABLE TEST_OUT + ) +IF("${TEST_OUT}" MATCHES "^ABCDEFG\n$") +ELSE("${TEST_OUT}" MATCHES "^ABCDEFG\n$") + MESSAGE(SEND_ERROR "EXECUTE_PROCESS output test failed: [${TEST_OUT}]") +ENDIF("${TEST_OUT}" MATCHES "^ABCDEFG\n$") + +# This test has some problems on UNIX systems. Disabling for now. +# +# EXECUTE_PROCESS( +# COMMAND ${CMAKE_COMMAND} -E echo "ABCDEFG" +# COMMAND /process/does/not/exist +# OUTPUT_QUIET +# ERROR_QUIET +# RESULT_VARIABLE RESULT +# ) +# IF("${RESULT}" MATCHES "^0$") +# MESSAGE(SEND_ERROR +# "EXECUTE_PROCESS result test failed with RESULT=[${RESULT}]") +# ELSE("${RESULT}" MATCHES "^0$") +# MESSAGE(STATUS "EXECUTE_PROCESS result test passed with RESULT=[${RESULT}]") +# ENDIF("${RESULT}" MATCHES "^0$") + +# +# Create directory. +# The 'complex' executable will then test if this dir exists, +# sadly it won't be able to remove it. +# +MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir") + +# +# Test FIND_LIBARY +# Create a dummy empty lib +# +CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/Library/dummy + ${Complex_BINARY_DIR}/Library/dummylib.lib + COPYONLY IMMEDIATE) +FOREACH (ext ${CMAKE_SHLIB_SUFFIX};.so;.a;.sl) + CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/Library/dummy + ${Complex_BINARY_DIR}/Library/libdummylib${ext} + COPYONLY IMMEDIATE) +ENDFOREACH (ext) + +FIND_LIBRARY(FIND_DUMMY_LIB + dummylib + PATHS + ${Complex_BINARY_DIR}/Library DOC "find dummy lib") + +FIND_LIBRARY(FIND_DUMMY_LIB + NAMES dummylib dummylib2 + PATHS + ${Complex_BINARY_DIR}/Library DOC "find dummy lib") + +# +# Test SET_SOURCE_FILES_PROPERTIES +# +SET_SOURCE_FILES_PROPERTIES(nonexisting_file2 + GENERATED + ABSTRACT + WRAP_EXCLUDE + COMPILE_FLAGS "-foo -bar") + +GET_SOURCE_FILE_PROPERTY(FILE_HAS_ABSTRACT nonexisting_file2 ABSTRACT) +GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file2 WRAP_EXCLUDE) +GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file2 COMPILE_FLAGS) + +SET_SOURCE_FILES_PROPERTIES(nonexisting_file3 PROPERTIES + GENERATED 1 + ABSTRACT 1 + WRAP_EXCLUDE 1 + COMPILE_FLAGS "-foo -bar") +GET_SOURCE_FILE_PROPERTY(FILE_HAS_ABSTRACT nonexisting_file3 ABSTRACT) +GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file3 WRAP_EXCLUDE) +GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file3 COMPILE_FLAGS) + +# +# Test registry (win32) +# Create a file, put its path in a registry key, try to find the file in that +# path using that registry key, then remove the file and the key +# +IF (WIN32) + IF (NOT UNIX) + SET(dir "${Complex_BINARY_DIR}/registry_dir") + SET(file "registry_test_dummy") + SET(hkey "HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Tests\\Complex;registry_test") + CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/Library/dummy + "${dir}/${file}" + COPYONLY IMMEDIATE) + EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E write_regv \"${hkey}\" \"${dir}\"") + FIND_PATH(REGISTRY_TEST_PATH + ${file} + "[${hkey}]" DOC "Registry_Test_Path") + EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E delete_regv \"${hkey}\"") + EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E remove \"${dir}/${file}\"") + ENDIF (NOT UNIX) +ENDIF (WIN32) + +# +# Test a set and a remove +# +SET(REMOVE_STRING a b c d e f) +SET(removeVar1 c e) +REMOVE(REMOVE_STRING ${removeVar1} f) + +# +# Test an IF inside a FOREACH. +# +FOREACH(x "a") + IF(${x} MATCHES "a") + # Should always execute. + SET(IF_INSIDE_FOREACH_THEN_EXECUTED 1) + ELSE(${x} MATCHES "a") + # Should never execute. + SET(IF_INSIDE_FOREACH_ELSE_EXECUTED 1) + ENDIF(${x} MATCHES "a") +ENDFOREACH(x) + +# test WHILE command +SET (while_var 1) +WHILE (while_var LESS 1000) + SET(while_var ${while_var}0) +ENDWHILE(while_var LESS 1000) + +SET(SHOULD_BE_ZERO ) +SET(SHOULD_BE_ONE 1) + +# test elseif functionality, the mess below tries to catch problem +# of clauses being executed early or late etc +set (RESULT 3) +if (RESULT EQUAL 1) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +elseif (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) +elseif (RESULT EQUAL 3) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + if (NOT ELSEIF_RESULT EQUAL 1) + set (ELSEIF_RESULT 2) + endif (NOT ELSEIF_RESULT EQUAL 1) + endif (RESULT EQUAL 2) +elseif (RESULT EQUAL 4) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +else (RESULT EQUAL 1) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +endif (RESULT EQUAL 1) + +if (NOT ELSEIF_RESULT EQUAL 2) + set (ELSEIF_RESULT 0) +endif (NOT ELSEIF_RESULT EQUAL 2) + +# test handling of parenthetical groups in conditionals +if (2 GREATER 1 AND (4 LESS 3 OR 5 LESS 6) AND NOT (7 GREATER 8)) + set(CONDITIONAL_PARENTHESES 1) +endif() + + +# +# Configure file +# (plug vars to #define so that they can be tested) +# +CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/cmTestConfigure.h.in + ${Complex_BINARY_DIR}/cmTestConfigure.h) + +SET(STRING_WITH_QUOTES "\"hello world\"") +# test CONFIGURE_FILE with ESCAPE_QUOTES on +CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/cmTestConfigureEscape.h.in + ${Complex_BINARY_DIR}/cmTestConfigureEscape.h ESCAPE_QUOTES) + +# Test regular expression commands. +STRING(REGEX MATCH "b" RESULT "abc") +IF(NOT RESULT) + MESSAGE(SEND_ERROR "STRING(REGEX MATCH ... ) test failed.") +ENDIF(NOT RESULT) +STRING(REGEX MATCHALL "b" RESULT "abcb") +IF(NOT RESULT) + MESSAGE(SEND_ERROR "STRING(REGEX MATCHALL ... ) test failed.") +ENDIF(NOT RESULT) +STRING(REGEX REPLACE ".([bd])." "[\\1]" RESULT "a(b)c(d)e") +IF("x${RESULT}" MATCHES "^xa\\[b\\]c\\[d\\]e$") + SET(STRING_REGEX_PASSED 1) +ENDIF("x${RESULT}" MATCHES "^xa\\[b\\]c\\[d\\]e$") +IF(NOT STRING_REGEX_PASSED) + MESSAGE(SEND_ERROR + "STRING(REGEX REPLACE ... ) test failed (\"${RESULT}\" v. \"a[b]c[d]e\")") +ENDIF(NOT STRING_REGEX_PASSED) + + +# +# Create the libs and the main exe +# +ADD_SUBDIRECTORY(Library) +ADD_SUBDIRECTORY(Executable) +SUBDIR_DEPENDS(Executable Library) +EXPORT_LIBRARY_DEPENDENCIES(${Complex_BINARY_DIR}/ComplexLibraryDepends.cmake) +INCLUDE(${Complex_BINARY_DIR}/ComplexLibraryDepends.cmake OPTIONAL) diff --git a/Tests/ComplexOneConfig/Cache/CMakeCache.txt b/Tests/ComplexOneConfig/Cache/CMakeCache.txt new file mode 100644 index 000000000..17c55aa01 --- /dev/null +++ b/Tests/ComplexOneConfig/Cache/CMakeCache.txt @@ -0,0 +1,34 @@ +# This is the CMakeCache file. +# For build in directory: d:/build/kitware/cmake/CMake-nmake/Tests/Complex +# You can edit this file to change values found and used by cmake. +# If you do not want to change any of the values, simply exit the editor. +# If you do want to change a value, simply edit, save, and exit the editor. +# The syntax for the file is as follows: +# KEY:TYPE=VALUE +# KEY is the name of a varible in the cache. +# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!. +# VALUE is the current value for the KEY. + +######################## +# EXTERNAL cache entries +######################## + +//A var. +CACHE_TEST_VAR1:STRING=foo + +//A var. +CACHE_TEST_VAR2:FILEPATH=bar + +//A var. +CACHE_TEST_VAR3:BOOL=1 + +//A var. +CACHE_TEST_VAR_EXCLUDED:BOOL=1 + + +######################## +# INTERNAL cache entries +######################## + +//A var. +CACHE_TEST_VAR_INTERNAL:INTERNAL=bar diff --git a/Tests/ComplexOneConfig/Executable/A.cxx b/Tests/ComplexOneConfig/Executable/A.cxx new file mode 100644 index 000000000..fb3eb0819 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/A.cxx @@ -0,0 +1,9 @@ +// Include code from a header that should not be compiled separately. +#include "A.hh" + +#include <stdio.h> +int main() +{ + printf("#define A_VALUE %d\n", A()); + return 0; +} diff --git a/Tests/ComplexOneConfig/Executable/A.h b/Tests/ComplexOneConfig/Executable/A.h new file mode 100644 index 000000000..25c45fcbf --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/A.h @@ -0,0 +1,4 @@ +// This header should not be compiled directly but through inclusion +// in A.cxx through A.hh. +extern int A(); +int A() { return 10; } diff --git a/Tests/ComplexOneConfig/Executable/A.hh b/Tests/ComplexOneConfig/Executable/A.hh new file mode 100644 index 000000000..e6bab022e --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/A.hh @@ -0,0 +1,2 @@ +// This header should not be compiled directly but through inclusion in A.cxx +#include "A.h" diff --git a/Tests/ComplexOneConfig/Executable/A.txt b/Tests/ComplexOneConfig/Executable/A.txt new file mode 100644 index 000000000..8ee9462be --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/A.txt @@ -0,0 +1 @@ +This file should not be compiled! diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt new file mode 100644 index 000000000..345836257 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt @@ -0,0 +1,170 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 1.3) +# +# Create exe. +# +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_CXX_FLAGS") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTEST_C_FLAGS") + +# Create an imported target for if(TARGET) test below. +ADD_LIBRARY(ExeImportedTarget UNKNOWN IMPORTED) + +# Test if(TARGET) command. +IF(NOT TARGET CMakeTestLibrary) + MESSAGE(FATAL_ERROR "IF(NOT TARGET CMakeTestLibrary) returned true!") +ENDIF(NOT TARGET CMakeTestLibrary) +IF(NOT TARGET ExeImportedTarget) + MESSAGE(FATAL_ERROR "IF(NOT TARGET ExeImportedTarget) returned true!") +ENDIF(NOT TARGET ExeImportedTarget) +IF(TARGET LibImportedTarget) + MESSAGE(FATAL_ERROR "IF(TARGET LibImportedTarget) returned true!") +ENDIF(TARGET LibImportedTarget) +IF(TARGET NotATarget) + MESSAGE(FATAL_ERROR "IF(TARGET NotATarget) returned true!") +ENDIF(TARGET NotATarget) + + # Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to +SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) +LINK_LIBRARIES(${COMPLEX_LIBS}) + +# Test forcing a .cxx file to not build. +SET_SOURCE_FILES_PROPERTIES(complex_nobuild.cxx PROPERTIES + HEADER_FILE_ONLY 1) + +# Test forcing a .c file to not build. +# This makes sure a mixed language library is created +# with header file only sources +SET_SOURCE_FILES_PROPERTIES(complex_nobuild.c PROPERTIES + HEADER_FILE_ONLY 1) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt) +ADD_CUSTOM_COMMAND(OUTPUT Aout.h COMMAND A > Aout.h VERBATIM) +ADD_EXECUTABLE(complex complex testcflags.c Aout.h) +# Sub1/NameConflictTest.c Sub2/NameConflictTest.c) +ADD_EXECUTABLE(complex.file complex.file.cxx complex_nobuild.cxx + complex_nobuild.c) + +IF (UNIX) + TARGET_LINK_LIBRARIES(complex ${CMAKE_DL_LIBS}) +ELSE(UNIX) + IF (NOT BORLAND) + IF(NOT MINGW) + TARGET_LINK_LIBRARIES(complex rpcrt4.lib) + ENDIF(NOT MINGW) + ENDIF(NOT BORLAND) +ENDIF (UNIX) + +# Test linking to static lib when a shared lib has the same name. +IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + ADD_DEFINITIONS(-DCOMPLEX_TEST_LINK_STATIC) + TARGET_LINK_LIBRARIES(complex CMakeTestLinkStatic) +ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + +# can we get the path to a source file +GET_SOURCE_FILE_PROPERTY(A_LOCATION A.cxx LOCATION) +IF ("${A_LOCATION}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/A.cxx") + ADD_DEFINITIONS(-DCMAKE_FOUND_ACXX) +ENDIF ("${A_LOCATION}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/A.cxx") + +# get the directory parent +GET_DIRECTORY_PROPERTY(P_VALUE PARENT_DIRECTORY) +IF ("${P_VALUE}" STREQUAL "${CMAKE_SOURCE_DIR}") + ADD_DEFINITIONS(-DCMAKE_FOUND_PARENT) +ENDIF ("${P_VALUE}" STREQUAL "${CMAKE_SOURCE_DIR}") + +# get the stack of listfiles +INCLUDE(Included.cmake) +IF ("${LF_VALUE}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt;${CMAKE_CURRENT_SOURCE_DIR}/Included.cmake") + ADD_DEFINITIONS(-DCMAKE_FOUND_LISTFILE_STACK) +ENDIF ("${LF_VALUE}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt;${CMAKE_CURRENT_SOURCE_DIR}/Included.cmake") + +# Test add/remove definitions. +ADD_DEFINITIONS( + -DCOMPLEX_DEFINED_PRE + -DCOMPLEX_DEFINED + -DCOMPLEX_DEFINED_POST + -DCOMPLEX_DEFINED + ) +REMOVE_DEFINITIONS(-DCOMPLEX_DEFINED) + +# Test pre-build/pre-link/post-build rules for an executable. +ADD_CUSTOM_COMMAND(TARGET complex PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/prebuild.txt") +ADD_CUSTOM_COMMAND(TARGET complex PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/prelink.txt") +ADD_CUSTOM_COMMAND(TARGET complex POST_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/postbuild.txt") +ADD_CUSTOM_COMMAND(TARGET complex POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy + "${Complex_BINARY_DIR}/Executable/postbuild.txt" + "${Complex_BINARY_DIR}/Executable/postbuild2.txt") + +SET_SOURCE_FILES_PROPERTIES(complex + COMPILE_FLAGS + "-DFILE_HAS_EXTRA_COMPILE_FLAGS" + #" -DFILE_DEFINE_STRING=\\\"hello\\\"" + OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h +) +SET_TARGET_PROPERTIES(complex PROPERTIES COMPILE_FLAGS "-DCOMPLEX_TARGET_FLAG") +ADD_CUSTOM_COMMAND( + TARGET complex + SOURCE ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in + ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h + OUTPUTS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h + DEPENDS ${CMAKE_COMMAND} +) + +# Test creating an executable that is not built by default. +ADD_EXECUTABLE(notInAllExe EXCLUDE_FROM_ALL notInAllExe.cxx) +TARGET_LINK_LIBRARIES(notInAllExe notInAllLib) + +# Test user-value flag mapping for the VS IDE. +IF(MSVC) + SET_TARGET_PROPERTIES(notInAllExe PROPERTIES + LINK_FLAGS "/NODEFAULTLIB:LIBC;LIBCMT;MSVCRT") +ENDIF(MSVC) + +# Test creating a custom target that builds not-in-all targets. +ADD_CUSTOM_TARGET(notInAllCustom) +ADD_DEPENDENCIES(notInAllCustom notInAllExe) + +# +# Output the files required by 'complex' to a file. +# +# This test has been moved to the 'required' subdir so that it +# has no side-effects on the current Makefile (duplicated source file +# due to source list expansion done twice). +# +ADD_SUBDIRECTORY(Temp) + +IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX) + ADD_EXECUTABLE(testSystemDir testSystemDir.cxx) + SET_TARGET_PROPERTIES(testSystemDir PROPERTIES COMPILE_FLAGS "-Werror") +ENDIF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX) + +# +# Extra coverage.Not used. +# +INSTALL_TARGETS(/tmp complex) +INSTALL_PROGRAMS(/tmp complex) + +CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/Executable/cmVersion.h.in + ${Complex_BINARY_DIR}/cmVersion.h) + +SOURCE_GROUP(A_GROUP ".cxx") +SOURCE_GROUP(B_GROUP REGULAR_EXPRESSION "cxx") +SOURCE_GROUP(C_GROUP FILES complex.cxx) + +FILE(WRITE ${Complex_BINARY_DIR}/A/libA.a "test") +FILE(WRITE ${Complex_BINARY_DIR}/A/libC.a "test") +FILE(WRITE ${Complex_BINARY_DIR}/B/libB.a "test") +FILE(WRITE ${Complex_BINARY_DIR}/B/libA.a "test") +FILE(WRITE ${Complex_BINARY_DIR}/C/libC.a "test") +FILE(WRITE ${Complex_BINARY_DIR}/C/libB.a "test") diff --git a/Tests/ComplexOneConfig/Executable/Included.cmake b/Tests/ComplexOneConfig/Executable/Included.cmake new file mode 100644 index 000000000..2d1ea3e8c --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/Included.cmake @@ -0,0 +1,2 @@ +GET_DIRECTORY_PROPERTY(LF_VALUE LISTFILE_STACK) + diff --git a/Tests/ComplexOneConfig/Executable/Sub1/NameConflictTest.c b/Tests/ComplexOneConfig/Executable/Sub1/NameConflictTest.c new file mode 100644 index 000000000..87203861f --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/Sub1/NameConflictTest.c @@ -0,0 +1,4 @@ +int NameConflictTest1() +{ + return 0; +} diff --git a/Tests/ComplexOneConfig/Executable/Sub2/NameConflictTest.c b/Tests/ComplexOneConfig/Executable/Sub2/NameConflictTest.c new file mode 100644 index 000000000..4a3257255 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/Sub2/NameConflictTest.c @@ -0,0 +1,4 @@ +int NameConflictTest2() +{ + return 0; +} diff --git a/Tests/ComplexOneConfig/Executable/Temp/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/Temp/CMakeLists.txt new file mode 100644 index 000000000..f00955029 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/Temp/CMakeLists.txt @@ -0,0 +1,8 @@ +# +# Output the files required by 'complex' to a file. +# The 'complex' executable will then test if this file exists and remove it. +# The contents of this file is not tested (absolute paths). +# +OUTPUT_REQUIRED_FILES( + ${Complex_SOURCE_DIR}/Executable/complex.cxx + ${Complex_BINARY_DIR}/Executable/Temp/complex-required.txt) diff --git a/Tests/ComplexOneConfig/Executable/cmVersion.h.in b/Tests/ComplexOneConfig/Executable/cmVersion.h.in new file mode 100644 index 000000000..de7522d1d --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/cmVersion.h.in @@ -0,0 +1 @@ +#define CMAKE_MINIMUM_REQUIRED_VERSION "${CMAKE_MINIMUM_REQUIRED_VERSION}" diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx new file mode 100644 index 000000000..1901d9914 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -0,0 +1,1026 @@ +#include "cmTestConfigure.h" +#include "cmTestConfigureEscape.h" +#include "cmTestGeneratedHeader.h" +#include "cmVersion.h" +#include "ExtraSources/file1.h" +#include "Aout.h" +#include "file2.h" +#include "sharedFile.h" +extern "C" { +#include "testConly.h" +} +#include <vector> +#include <string> +#include <iostream> +#include <string.h> + +#include <stdio.h> +#include <sys/stat.h> +#if !defined(S_ISDIR) +# define S_ISDIR(mode) ((mode) & _S_IFDIR) +#endif + +#ifdef COMPLEX_TEST_LINK_STATIC +extern "C" +{ + int TestLinkGetType(); +} +#endif + +int cm_passed = 0; +int cm_failed = 0; +// ====================================================================== + +void cmFailed(const char* Message, const char* m2= "", const char* m3 = "") +{ + std::cout << "FAILED: " << Message << m2 << m3 << "\n"; + cm_failed++; +} + +// ====================================================================== + +void cmPassed(const char* Message, const char* m2="") +{ + std::cout << "Passed: " << Message << m2 << "\n"; + cm_passed++; +} + +#ifndef COMPLEX_DEFINED_PRE +# error "COMPLEX_DEFINED_PRE not defined!" +#endif + +#ifdef COMPLEX_DEFINED +# error "COMPLEX_DEFINED is defined but it should not!" +#endif + +#ifndef COMPLEX_DEFINED_POST +# error "COMPLEX_DEFINED_POST not defined!" +#endif + +#ifndef CMAKE_IS_REALLY_FUN +# error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work +#endif + +#if defined(NDEBUG) && !defined(CMAKE_IS_FUN_IN_RELEASE_MODE) +# error Per-configuration directory-level definition not inherited. +#endif + +// ====================================================================== + +void TestAndRemoveFile(const char* filename) +{ + struct stat st; + if(stat(filename, &st) < 0) + { + cmFailed("Could not find file: ", filename); + } + else + { + if (remove(filename) < 0) + { + cmFailed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename); + } + else + { + cmPassed("Find and remove file: ", filename); + } + } +} + +// ====================================================================== + +void TestDir(const char* filename) +{ + struct stat st; + if(stat(filename, &st) < 0 || !S_ISDIR(st.st_mode)) + { + cmFailed("Could not find dir: ", filename); + } + else + { + cmPassed("Find dir: ", filename); + } +} + +// Here is a stupid function that tries to use std::string methods +// so that the dec cxx compiler will instantiate the stuff that +// we are using from the CMakeLib library.... +void ForceStringUse() +{ + std::vector<std::string> v; + std::vector<std::string> v2; + v = v2; + std::string cachetest = CACHE_TEST_VAR_INTERNAL; + v.push_back(cachetest); + v2 = v; + std::string x(5,'x'); + char buff[5]; + x.copy(buff, 1, 0); + x[0] = 'a'; + std::string::size_type pos = 0; + x.replace(pos, pos, pos, 'x'); + std::string copy = cachetest; + cachetest.find("bar"); + cachetest.rfind("bar"); + copy.append(cachetest); + copy = cachetest.substr(0, cachetest.size()); +} + + +// defined in testcflags.c +extern "C" int TestCFlags(char* m); +extern "C" int TestTargetCompileFlags(char* m); + +#if 0 +// defined in Sub1/NameConflictTest.c +extern "C" int NameConflictTest1(); +// defined in Sub2/NameConflictTest.c +extern "C" int NameConflictTest2(); +#endif + +// ====================================================================== + +int main() +{ +#if 0 + if(NameConflictTest1() == 0 && NameConflictTest2() == 0) + { + cmPassed("Sub dir with same named source works"); + } + else + { + cmFailed("Sub dir with same named source fails"); + } +#endif + if(file1() != 1) + { + cmFailed("Call to file1 function from library failed."); + } + else + { + cmPassed("Call to file1 function returned 1."); + } +#ifndef COMPLEX_TARGET_FLAG + cmFailed("COMPILE_FLAGS did not work with SET_TARGET_PROPERTIES"); +#else + cmPassed("COMPILE_FLAGS did work with SET_TARGET_PROPERTIES"); +#endif + +#ifdef ELSEIF_RESULT + cmPassed("ELSEIF did work"); +#else + cmFailed("ELSEIF did not work"); +#endif + +#ifdef CONDITIONAL_PARENTHESES + cmPassed("CONDITIONAL_PARENTHESES did work"); +#else + cmFailed("CONDITIONAL_PARENTHESES did not work"); +#endif + + if(file2() != 1) + { + cmFailed("Call to file2 function from library failed."); + } + else + { + cmPassed("Call to file2 function returned 1."); + } +#ifndef TEST_CXX_FLAGS + cmFailed("CMake CMAKE_CXX_FLAGS is not being passed to the compiler!"); +#else + cmPassed("CMake CMAKE_CXX_FLAGS is being passed to the compiler."); +#endif + std::string gen = CMAKE_GENERATOR; + // visual studio is currently broken for c flags + char msg[1024]; + if(gen.find("Visual") == gen.npos) + { +#ifdef TEST_C_FLAGS + cmFailed("CMake CMAKE_C_FLAGS are being passed to c++ files the compiler!"); +#else + cmPassed("CMake CMAKE_C_FLAGS are not being passed to c++ files."); +#endif + if(TestCFlags(msg)) + { + cmPassed( + "CMake CMAKE_C_FLAGS are being passed to c files and CXX flags are not."); + } + else + { + cmFailed(msg); + } + } + if(TestTargetCompileFlags(msg)) + { + cmPassed(msg); + } + else + { + cmFailed(msg); + } + + // ---------------------------------------------------------------------- + // Test ADD_DEFINITIONS + +#ifndef CMAKE_IS_FUN + cmFailed("CMake is not fun, so it is broken and should be fixed."); +#else + cmPassed("CMAKE_IS_FUN is defined."); +#endif + +#if defined(CMAKE_ARGV1) && defined(CMAKE_ARGV2) && defined(CMAKE_ARGV3) && defined(CMAKE_ARGV4) + cmPassed("Variable args for MACROs are working."); +#else + cmFailed("Variable args for MACROs are failing."); +#endif + + // ---------------------------------------------------------------------- + // Test GET_SOURCE_FILE_PROPERTY for location +#ifndef CMAKE_FOUND_ACXX + cmFailed("CMake did not get the location of A.cxx correctly"); +#else + cmPassed("CMake found A.cxx properly"); +#endif + + // ---------------------------------------------------------------------- + // Test GET_DIRECTORY_PROPERTY for parent +#ifndef CMAKE_FOUND_PARENT + cmFailed("CMake did not get the location of the parent directory properly"); +#else + cmPassed("CMake found the parent directory properly"); +#endif + + // ---------------------------------------------------------------------- + // Test GET_DIRECTORY_PROPERTY for listfiles +#ifndef CMAKE_FOUND_LISTFILE_STACK + cmFailed("CMake did not get the listfile stack properly"); +#else + cmPassed("CMake found the listfile stack properly"); +#endif + + // ---------------------------------------------------------------------- + // Test SET, VARIABLE_REQUIRES + +#ifdef SHOULD_NOT_BE_DEFINED + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED is defined."); +#endif + +#ifndef ONE_VAR + cmFailed("cmakedefine is broken, ONE_VAR is not defined."); +#else + cmPassed("ONE_VAR is defined."); +#endif + +#ifndef ONE_VAR_IS_DEFINED + cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, " + "ONE_VAR_IS_DEFINED is not defined."); +#else + cmPassed("ONE_VAR_IS_DEFINED is defined."); +#endif + +#ifdef ZERO_VAR + cmFailed("cmakedefine is broken, ZERO_VAR is defined."); +#else + cmPassed("ZERO_VAR is not defined."); +#endif + +#ifndef STRING_VAR + cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined."); +#else + if(strcmp(STRING_VAR, "CMake is great") != 0) + { + cmFailed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ", + STRING_VAR); + } + else + { + cmPassed("STRING_VAR == ", STRING_VAR); + } +#endif + + // ---------------------------------------------------------------------- + // Test various IF/ELSE combinations + +#ifdef SHOULD_NOT_BE_DEFINED_NOT + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_NOT is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_NOT + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_NOT is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_NOT is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_NOT2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_NOT2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_NOT2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_NOT2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_NOT2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_AND + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_AND is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_AND + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_AND is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_AND2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_AND2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_AND2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_AND2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_OR + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_OR is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_OR + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_OR is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_OR2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_OR2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_OR2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_OR2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_MATCHES + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_MATCHES + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_MATCHES is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_MATCHES2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_MATCHES2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_MATCHES2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_MATCHES2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_COMMAND + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_COMMAND + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_COMMAND is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_COMMAND2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_COMMAND2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_COMMAND2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_EXISTS + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EXISTS is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_EXISTS is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_EXISTS + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EXISTS is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_EXISTS is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_EXISTS2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EXISTS2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_EXISTS2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_EXISTS2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EXISTS2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_EXISTS2 is defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_IS_DIRECTORY + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_IS_DIRECTORY is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_IS_DIRECTORY is defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_IS_DIRECTORY2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_IS_DIRECTORY2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_IS_DIRECTORY2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_LESS + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_LESS is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_LESS + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_LESS is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_LESS is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_LESS2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_LESS2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_LESS2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_LESS2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_LESS2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_GREATER + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_GREATER is not defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_EQUAL + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EQUAL is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_EQUAL is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_EQUAL + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EQUAL is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_EQUAL is defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_GREATER + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_GREATER is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_GREATER2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_GREATER2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_GREATER2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_GREATER2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_STRLESS + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_STRLESS + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_STRLESS is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_STRLESS2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_STRLESS2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_STRLESS2 is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_STRGREATER + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_STRGREATER + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_STRGREATER is defined."); +#endif + +#ifdef SHOULD_NOT_BE_DEFINED_STRGREATER2 + cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER2 is defined."); +#else + cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER2 is not defined."); +#endif + +#ifndef SHOULD_BE_DEFINED_STRGREATER2 + cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER2 is not defined.\n"); +#else + cmPassed("SHOULD_BE_DEFINED_STRGREATER2 is defined."); +#endif + + // ---------------------------------------------------------------------- + // Test FOREACH + +#ifndef FOREACH_VAR1 + cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " + "FOREACH_VAR1 is not defined."); +#else + if(strcmp(FOREACH_VAR1, "VALUE1") != 0) + { + cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " + "FOREACH_VAR1 == ", FOREACH_VAR1); + } + else + { + cmPassed("FOREACH_VAR1 == ", FOREACH_VAR1); + } +#endif + +#ifndef FOREACH_VAR2 + cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " + "FOREACH_VAR2 is not defined."); +#else + if(strcmp(FOREACH_VAR2, "VALUE2") != 0) + { + cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " + "FOREACH_VAR2 == ", FOREACH_VAR2); + } + else + { + cmPassed("FOREACH_VAR2 == ", FOREACH_VAR2); + } +#endif + +#ifndef FOREACH_CONCAT + cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " + "FOREACH_CONCAT is not defined."); +#else + if(strcmp(FOREACH_CONCAT, "abcdefg") != 0) + { + cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, " + "FOREACH_CONCAT == ", FOREACH_CONCAT); + } + else + { + cmPassed("FOREACH_CONCAT == ", FOREACH_CONCAT); + } +#endif + + // ---------------------------------------------------------------------- + // Test WHILE + + if(WHILE_VALUE != 1000) + { + cmFailed("WHILE command is not working"); + } + else + { + cmPassed("WHILE command is working"); + } + + // ---------------------------------------------------------------------- + // Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations + +#ifndef FILENAME_VAR_PATH_NAME + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_PATH_NAME is not defined."); +#else + if((strcmp(FILENAME_VAR_PATH_NAME, "Complex") == 0) || + (strcmp(FILENAME_VAR_PATH_NAME, "ComplexOneConfig") == 0)) + { + cmPassed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME); + } + else + { + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME); + } +#endif + +#ifndef FILENAME_VAR_NAME + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_NAME is not defined."); +#else + if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0) + { + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_NAME == ", FILENAME_VAR_NAME); + } + else + { + cmPassed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME); + } +#endif + +#ifndef FILENAME_VAR_EXT + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_EXT is not defined."); +#else + if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0) + { + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_EXT == ", FILENAME_VAR_EXT); + } + else + { + cmPassed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT); + } +#endif + +#ifndef FILENAME_VAR_NAME_WE + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_NAME_WE is not defined."); +#else + if(strcmp(FILENAME_VAR_NAME_WE, "VarTests") != 0) + { + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE); + } + else + { + cmPassed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE); + } +#endif + +#ifndef PATH_VAR_NAME + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "PATH_VAR_NAME is not defined."); +#else + if((strcmp(PATH_VAR_NAME, "Complex") == 0) || + (strcmp(PATH_VAR_NAME, "ComplexOneConfig") == 0)) + { + cmPassed("PATH_VAR_NAME == ", PATH_VAR_NAME); + } + else + { + cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " + "PATH_VAR_NAME == ", PATH_VAR_NAME); + } +#endif + + // ---------------------------------------------------------------------- + // Test LOAD_CACHE + +#ifndef CACHE_TEST_VAR1 + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR1 is not defined."); +#else + if(strcmp(CACHE_TEST_VAR1, "foo") != 0) + { + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1); + } + else + { + cmPassed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1); + } +#endif + +#ifndef CACHE_TEST_VAR2 + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR2 is not defined."); +#else + if(strcmp(CACHE_TEST_VAR2, "bar") != 0) + { + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2); + } + else + { + cmPassed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2); + } +#endif + +#ifndef CACHE_TEST_VAR3 + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR3 is not defined."); +#else + if(strcmp(CACHE_TEST_VAR3, "1") != 0) + { + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3); + } + else + { + cmPassed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3); + } +#endif + +#ifdef CACHE_TEST_VAR_EXCLUDED + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, " + "CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded)."); +#else + cmPassed("CACHE_TEST_VAR_EXCLUDED is not defined."); +#endif + +#ifndef CACHE_TEST_VAR_INTERNAL + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR_INTERNAL is not defined."); +#else + std::string cachetest = CACHE_TEST_VAR_INTERNAL; + if(cachetest != "bar") + { + cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " + "CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL); + } + else + { + cmPassed("CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL); + } +#endif + + // ---------------------------------------------------------------------- + // Some pre-build/pre-link/post-build custom-commands have been + // attached to the lib (see Library/). + // Each runs ${CREATE_FILE_EXE} which will create a file. + // It also copies that file again using cmake -E. + // Similar rules have been added to this executable. + // + // WARNING: if you run 'complex' manually, this *will* fail, because + // the file was removed the last time 'complex' was run, and it is + // only created during a build. + + TestAndRemoveFile(BINARY_DIR "/Library/prebuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Library/prelink.txt"); + TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/prebuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/prelink.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/postbuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/postbuild2.txt"); + + // ---------------------------------------------------------------------- + // A custom target has been created (see Library/). + // It runs ${CREATE_FILE_EXE} which will create a file. + // + // WARNING: if you run 'complex' manually, this *will* fail, because + // the file was removed the last time 'complex' was run, and it is + // only created during a build. + + TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt"); + + // ---------------------------------------------------------------------- + // A directory has been created. + + TestDir(BINARY_DIR "/make_dir"); + + // ---------------------------------------------------------------------- + // Test OUTPUT_REQUIRED_FILES + // The files required by 'complex' have been output to a file. + // The contents of this file is not tested (absolute paths). + // + // WARNING: if you run 'complex' manually, this *will* fail, because + // the file was removed the last time 'complex' was run, and it is + // only created during a build. + + TestAndRemoveFile(BINARY_DIR "/Executable/Temp/complex-required.txt"); + + // ---------------------------------------------------------------------- + // Test FIND_LIBRARY + +#ifndef FIND_DUMMY_LIB + cmFailed("the CONFIGURE_FILE command is broken, " + "FIND_DUMMY_LIB is not defined."); +#else + if(strstr(FIND_DUMMY_LIB, "dummylib") == NULL) + { + cmFailed("the FIND_LIBRARY or CONFIGURE_FILE command is broken, " + "FIND_DUMMY_LIB == ", FIND_DUMMY_LIB); + } + else + { + cmPassed("FIND_DUMMY_LIB == ", FIND_DUMMY_LIB); + } +#endif + + // ---------------------------------------------------------------------- + // Test SET_SOURCE_FILES_PROPERTIES + +#ifndef FILE_HAS_EXTRA_COMPILE_FLAGS + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_HAS_EXTRA_COMPILE_FLAGS flag"); +#else + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag"); +#endif + +#if 0 // Disable until implemented everywhere. +#ifndef FILE_DEFINE_STRING + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag"); +#else + if(strcmp(FILE_DEFINE_STRING, "hello") != 0) + { + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag correctly"); + } + else + { + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_DEFINE_STRING flag"); + } +#endif +#endif + +#ifndef FILE_HAS_ABSTRACT + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag"); +#else + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting ABSTRACT flag"); +#endif + +#ifndef FILE_HAS_WRAP_EXCLUDE + cmFailed("FILE_HAS_WRAP_EXCLUDE failed at setting WRAP_EXCLUDE flag"); +#else + cmPassed("FILE_HAS_WRAP_EXCLUDE succeeded in setting WRAP_EXCLUDE flag"); +#endif + +#ifndef FILE_COMPILE_FLAGS + cmFailed("the CONFIGURE_FILE command is broken, FILE_COMPILE_FLAGS is not defined."); +#else + if(strcmp(FILE_COMPILE_FLAGS, "-foo -bar") != 0) + { + cmFailed("the SET_SOURCE_FILES_PROPERTIES or CONFIGURE_FILE command is broken. FILE_COMPILE_FLAGS == ", + FILE_COMPILE_FLAGS); + } + else + { + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting extra flags == ", FILE_COMPILE_FLAGS); + } +#endif + + // ---------------------------------------------------------------------- + // Test registry (win32) +#if defined(_WIN32) && !defined(__CYGWIN__) +#ifndef REGISTRY_TEST_PATH + cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not defined."); +#else + std::cout << "REGISTRY_TEST_PATH == " << REGISTRY_TEST_PATH << "\n"; + if(stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) + { + cmFailed("the 'read registry value' function or CONFIGURE_FILE command is broken. REGISTRY_TEST_PATH == ", + REGISTRY_TEST_PATH, " is not " BINARY_DIR "/registry_dir"); + } + else + { + cmPassed("REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH); + } +#endif +#endif // defined(_WIN32) && !defined(__CYGWIN__) + + if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "1.3") == 0) + { + cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 1.3"); + } + else + { + cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 1.3"); + } + + // ---------------------------------------------------------------------- + // Test REMOVE command + if (strcmp("a;b;d",REMOVE_STRING) == 0) + { + cmPassed("REMOVE is working"); + } + else + { + cmFailed("REMOVE is not working"); + } + + // ---------------------------------------------------------------------- + // Test SEPARATE_ARGUMENTS + if(strcmp("a;b;c", TEST_SEP) == 0) + { + cmPassed("SEPARATE_ARGUMENTS is working"); + } + else + { + cmFailed("SEPARATE_ARGUMENTS is not working"); + } + + // ---------------------------------------------------------------------- + // Test Escape Quotes + if(strcmp("\"hello world\"", STRING_WITH_QUOTES) == 0) + { + cmPassed("ESCAPE_QUOTES is working"); + } + else + { + cmFailed("ESCAPE_QUOTES is not working"); + } + + + // ---------------------------------------------------------------------- + // Test if IF command inside a FOREACH works. +#if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) && !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED) + cmPassed("IF inside a FOREACH block works"); +#else + cmFailed("IF inside a FOREACH block is broken"); +#endif + +#if defined(GENERATED_HEADER_INCLUDED) + cmPassed("Generated header included by non-generated source works."); +#else + cmFailed("Generated header included by non-generated source failed."); +#endif + if(SHOULD_BE_ZERO == 0) + { + cmPassed("cmakedefine01 is working for 0"); + } + else + { + cmFailed("cmakedefine01 is not working for 0"); + } + if(SHOULD_BE_ONE == 1) + { + cmPassed("cmakedefine01 is working for 1"); + } + else + { + cmFailed("cmakedefine01 is not working for 1"); + } +#ifdef FORCE_TEST + cmFailed("CMake SET CACHE FORCE"); +#else + cmPassed("CMake SET CACHE FORCE"); +#endif + +#ifdef COMPLEX_TEST_LINK_STATIC + if(TestLinkGetType()) + { + cmPassed("Link to static over shared worked."); + } + else + { + cmFailed("Link to static over shared failed."); + } +#endif + +#if defined(A_VALUE) && A_VALUE == 10 + cmPassed("Single-character executable A worked."); +#else + cmFailed("Single-character executable A failed."); +#endif + + // ---------------------------------------------------------------------- + // Summary + + std::cout << "Passed: " << cm_passed << "\n"; + if(cm_failed) + { + std::cout << "Failed: " << cm_failed << "\n"; + return cm_failed; + } + return 0; +} diff --git a/Tests/ComplexOneConfig/Executable/complex.file.cxx b/Tests/ComplexOneConfig/Executable/complex.file.cxx new file mode 100644 index 000000000..e873fa644 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/complex.file.cxx @@ -0,0 +1,8 @@ +#if 0 +#include "cmMissingHeader.h" +#endif + +int main(int , char**) +{ + return 0; +} diff --git a/Tests/ComplexOneConfig/Executable/complex_nobuild.c b/Tests/ComplexOneConfig/Executable/complex_nobuild.c new file mode 100644 index 000000000..6b3c2c1e2 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/complex_nobuild.c @@ -0,0 +1 @@ +#error "This file should not be compiled." diff --git a/Tests/ComplexOneConfig/Executable/complex_nobuild.cxx b/Tests/ComplexOneConfig/Executable/complex_nobuild.cxx new file mode 100644 index 000000000..6b3c2c1e2 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/complex_nobuild.cxx @@ -0,0 +1 @@ +#error "This file should not be compiled." diff --git a/Tests/ComplexOneConfig/Executable/notInAllExe.cxx b/Tests/ComplexOneConfig/Executable/notInAllExe.cxx new file mode 100644 index 000000000..70275cd51 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/notInAllExe.cxx @@ -0,0 +1,10 @@ +extern int notInAllLibFunc(); + +int main() +{ + return notInAllLibFunc(); +} + +#if 1 +# error "This target should not be compiled by ALL." +#endif diff --git a/Tests/ComplexOneConfig/Executable/testSystemDir.cxx b/Tests/ComplexOneConfig/Executable/testSystemDir.cxx new file mode 100644 index 000000000..e4815c679 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/testSystemDir.cxx @@ -0,0 +1,3 @@ +#include <testSystemDir.h> + +int main() { return foo(); } diff --git a/Tests/ComplexOneConfig/Executable/testcflags.c b/Tests/ComplexOneConfig/Executable/testcflags.c new file mode 100644 index 000000000..f4d584844 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/testcflags.c @@ -0,0 +1,26 @@ +#include <string.h> + +int TestTargetCompileFlags(char* m) +{ +#ifndef COMPLEX_TARGET_FLAG + strcpy(m, "CMAKE SET_TARGET_PROPERTIES COMPILE_FLAGS did not work"); + return 0; +#endif + strcpy(m, "CMAKE SET_TARGET_PROPERTIES COMPILE_FLAGS worked"); + return 1; +} + +int TestCFlags(char* m) +{ + /* TEST_CXX_FLAGS should not be defined in a c file */ +#ifdef TEST_CXX_FLAGS + strcpy(m, "CMake CMAKE_CXX_FLAGS (TEST_CXX_FLAGS) found in c file."); + return 0; +#endif + /* TEST_C_FLAGS should be defined in a c file */ +#ifndef TEST_C_FLAGS + strcpy(m, "CMake CMAKE_C_FLAGS (TEST_C_FLAGS) not found in c file."); + return 0; +#endif + return 1; +} diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt new file mode 100644 index 000000000..c8efc3022 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt @@ -0,0 +1,140 @@ +REMOVE_DEFINITIONS(-DCMAKE_IS_REALLY_FUN) + +# +# Small utility used to create file +# UTILITY_SOURCE is used for coverage and for getting the exact name +# of the executable. +# +UTILITY_SOURCE(CREATE_FILE_EXE create_file "." create_file.cxx) +ADD_EXECUTABLE(create_file create_file.cxx) +SET_TARGET_PROPERTIES(create_file PROPERTIES RUNTIME_OUTPUT_DIRECTORY ".") + +# +# Create static library +# SOURCE_FILES_REMOVE is used for Coverage. empty.h is included for coverage +# +AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources) +SET(LibrarySources ${LibrarySources} + file2 + empty + create_file.cxx + GENERATED + nonexisting_file) +REMOVE(LibrarySources create_file.cxx GENERATED nonexisting_file) +ADD_LIBRARY(CMakeTestLibrary ${LibrarySources}) + +IF(WIN32) + IF(NOT CYGWIN) + IF(NOT BORLAND) + IF(NOT MINGW) + TARGET_LINK_LIBRARIES(CMakeTestLibrary + debug + user32.lib) + TARGET_LINK_LIBRARIES(CMakeTestLibrary + optimized + kernel32.lib) + ENDIF(NOT MINGW) + ENDIF(NOT BORLAND) + ENDIF(NOT CYGWIN) +ENDIF(WIN32) + +# +# Create shared library +# +SET(SharedLibrarySources sharedFile) +ADD_LIBRARY(CMakeTestLibraryShared SHARED ${SharedLibrarySources}) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTEST_C_FLAGS") +ADD_LIBRARY(CMakeTestCLibraryShared SHARED testConly.c) +DEFINE_PROPERTY( + TARGET PROPERTY FOO + BRIEF_DOCS "a test property" + FULL_DOCS "A simple etst proerty that means nothign and is used for nothing" + ) +SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES FOO BAR) +IF(NOT BEOS AND NOT WIN32) # No libm on BeOS. + SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES LINK_FLAGS "-lm") +ENDIF(NOT BEOS AND NOT WIN32) +GET_TARGET_PROPERTY(FOO_BAR_VAR CMakeTestCLibraryShared FOO) +IF(${FOO_BAR_VAR} MATCHES "BAR") +ELSE(${FOO_BAR_VAR} MATCHES "BAR") + MESSAGE(SEND_ERROR "SET_TARGET_PROPERTIES or GET_TARGET_PROPERTY failed, FOO_BAR_VAR should be BAR, but is ${FOO_BAR_VAR}") +ENDIF(${FOO_BAR_VAR} MATCHES "BAR") + +# Create static and shared lib of same name. +IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + ADD_LIBRARY(CMakeTestLinkStatic STATIC TestLink.c) + ADD_LIBRARY(CMakeTestLinkShared SHARED TestLink.c) + SET_TARGET_PROPERTIES(CMakeTestLinkStatic CMakeTestLinkShared + PROPERTIES OUTPUT_NAME CMakeTestLink) +ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + +# +# Attach pre-build/pre-link/post-build custom-commands to the lib. +# Each runs ${CREATE_FILE_EXE} which will create a file. +# The 'complex' executable will then test if this file exists and remove it. +# +ADD_DEPENDENCIES(CMakeTestLibraryShared create_file) +MESSAGE("complex bin dir is ${Complex_BINARY_DIR}") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/prebuild.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/prelink.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared POST_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy + "${Complex_BINARY_DIR}/Library/postbuild.txt" + "${Complex_BINARY_DIR}/Library/postbuild2.txt") + +# +# Add a custom target. +# It runs ${CREATE_FILE_EXE} which will create a file. +# The 'complex' executable will then test if this file exists and remove it. +# +ADD_CUSTOM_TARGET(custom_target1 + ALL + ${CREATE_FILE_EXE} + "${Complex_BINARY_DIR}/Library/custom_target1.txt") + +ADD_DEPENDENCIES(custom_target1 create_file) + +# +# Extra coverage +# +SET_SOURCE_FILES_PROPERTIES(file2 PROPERTIES ABSTRACT 1) + +INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h) +INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h) + +# Test creating a library that is not built by default. +ADD_LIBRARY(notInAllLib EXCLUDE_FROM_ALL notInAllLib.cxx) + +# Create an imported target for if(TARGET) test in Executable dir. +# That test should not see this target. +ADD_LIBRARY(LibImportedTarget UNKNOWN IMPORTED) + +# Test generation of preprocessed sources. +IF("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) + IF(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE) + # Skip running this part of the test on certain platforms + # until they are fixed. + SET(MAYBE_ALL ALL) + LIST(LENGTH CMAKE_OSX_ARCHITECTURES ARCH_COUNT) + IF(ARCH_COUNT GREATER 1) + # OSX does not support preprocessing more than one architecture. + SET(MAYBE_ALL) + ENDIF(ARCH_COUNT GREATER 1) + + # Custom target to try preprocessing invocation. + ADD_CUSTOM_TARGET(test_preprocess ${MAYBE_ALL} + COMMAND ${CMAKE_COMMAND} -E remove CMakeFiles/create_file.dir/create_file.i + COMMAND ${CMAKE_MAKE_PROGRAM} create_file.i + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/test_preprocess.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + ENDIF(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE) +ENDIF("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) diff --git a/Tests/ComplexOneConfig/Library/ExtraSources/file1.cxx b/Tests/ComplexOneConfig/Library/ExtraSources/file1.cxx new file mode 100644 index 000000000..e22812e51 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/ExtraSources/file1.cxx @@ -0,0 +1,4 @@ +int file1() +{ + return 1; +} diff --git a/Tests/ComplexOneConfig/Library/ExtraSources/file1.h b/Tests/ComplexOneConfig/Library/ExtraSources/file1.h new file mode 100644 index 000000000..ce0d818a3 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/ExtraSources/file1.h @@ -0,0 +1 @@ +int file1(); diff --git a/Tests/ComplexOneConfig/Library/SystemDir/testSystemDir.h b/Tests/ComplexOneConfig/Library/SystemDir/testSystemDir.h new file mode 100644 index 000000000..73be3538e --- /dev/null +++ b/Tests/ComplexOneConfig/Library/SystemDir/testSystemDir.h @@ -0,0 +1,2 @@ +// Purposely leave off the return type to create a warning. +foo() { return 0; } diff --git a/Tests/ComplexOneConfig/Library/TestLink.c b/Tests/ComplexOneConfig/Library/TestLink.c new file mode 100644 index 000000000..25dee082f --- /dev/null +++ b/Tests/ComplexOneConfig/Library/TestLink.c @@ -0,0 +1,8 @@ +int TestLinkGetType() +{ +#ifdef CMakeTestLinkShared_EXPORTS + return 0; +#else + return 1; +#endif +} diff --git a/Tests/ComplexOneConfig/Library/create_file.cxx b/Tests/ComplexOneConfig/Library/create_file.cxx new file mode 100644 index 000000000..d41551980 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/create_file.cxx @@ -0,0 +1,28 @@ +#include <stdio.h> +#include <stdlib.h> + +int main (int argc, char *argv[]) +{ + if (argc < 2) + { + fprintf(stderr, "Missing name of file to create.\n"); + return EXIT_FAILURE; + } + + FILE *stream = fopen(argv[1], "w"); + if(stream == NULL) + { + fprintf(stderr, "Unable to open %s for writing!\n", argv[1]); + return EXIT_FAILURE; + } + + if(fclose(stream)) + { + fprintf(stderr, "Unable to close %s!\n", argv[1]); + return EXIT_FAILURE; + } + + fprintf(stdout, ">> Creating %s!\n", argv[1]); + + return EXIT_SUCCESS; +} diff --git a/Tests/ComplexOneConfig/Library/dummy b/Tests/ComplexOneConfig/Library/dummy new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/ComplexOneConfig/Library/dummy diff --git a/Tests/ComplexOneConfig/Library/empty.h b/Tests/ComplexOneConfig/Library/empty.h new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/ComplexOneConfig/Library/empty.h diff --git a/Tests/ComplexOneConfig/Library/file2.cxx b/Tests/ComplexOneConfig/Library/file2.cxx new file mode 100644 index 000000000..863fcaa51 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/file2.cxx @@ -0,0 +1,10 @@ +#include <string.h> + +#ifdef CMAKE_IS_REALLY_FUN +This is a problem. Looks like REMOVE_DEFINITION does not work +#endif + +int file2() +{ + return 1; +} diff --git a/Tests/ComplexOneConfig/Library/file2.h b/Tests/ComplexOneConfig/Library/file2.h new file mode 100644 index 000000000..dea4b80b1 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/file2.h @@ -0,0 +1 @@ +int file2(); diff --git a/Tests/ComplexOneConfig/Library/notInAllLib.cxx b/Tests/ComplexOneConfig/Library/notInAllLib.cxx new file mode 100644 index 000000000..5d928f44a --- /dev/null +++ b/Tests/ComplexOneConfig/Library/notInAllLib.cxx @@ -0,0 +1,5 @@ +int notInAllLibFunc() { return 0; } + +#if 1 +# error "This target should not be compiled by ALL." +#endif diff --git a/Tests/ComplexOneConfig/Library/sharedFile.cxx b/Tests/ComplexOneConfig/Library/sharedFile.cxx new file mode 100644 index 000000000..cafac68f4 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/sharedFile.cxx @@ -0,0 +1,6 @@ +#include "sharedFile.h" + +int sharedFunction() +{ + return 1; +} diff --git a/Tests/ComplexOneConfig/Library/sharedFile.h b/Tests/ComplexOneConfig/Library/sharedFile.h new file mode 100644 index 000000000..65ac2e2ba --- /dev/null +++ b/Tests/ComplexOneConfig/Library/sharedFile.h @@ -0,0 +1,12 @@ +#if defined(_WIN32) || defined(WIN32) /* Win32 version */ +#ifdef CMakeTestLibraryShared_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +#else +# define CMakeTest_EXPORT __declspec(dllimport) +#endif +#else +/* unix needs nothing */ +#define CMakeTest_EXPORT +#endif + +CMakeTest_EXPORT int sharedFunction(); diff --git a/Tests/ComplexOneConfig/Library/testConly.c b/Tests/ComplexOneConfig/Library/testConly.c new file mode 100644 index 000000000..2d83f778e --- /dev/null +++ b/Tests/ComplexOneConfig/Library/testConly.c @@ -0,0 +1,13 @@ +#include "testConly.h" +#include <stdio.h> + +int CsharedFunction() +{ +#ifndef TEST_C_FLAGS + printf("TEST_C_FLAGS failed\n"); + return 0; +#else + printf("Passed: TEST_C_FLAGS passed\n"); +#endif + return 1; +} diff --git a/Tests/ComplexOneConfig/Library/testConly.h b/Tests/ComplexOneConfig/Library/testConly.h new file mode 100644 index 000000000..f1470a8d7 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/testConly.h @@ -0,0 +1,13 @@ +#if defined(_WIN32) || defined(WIN32) /* Win32 version */ +#ifdef CMakeTestCLibraryShared_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +#else +# define CMakeTest_EXPORT __declspec(dllimport) +#endif +#else +/* unix needs nothing */ +#define CMakeTest_EXPORT +#endif + +CMakeTest_EXPORT int CsharedFunction(); + diff --git a/Tests/ComplexOneConfig/Library/test_preprocess.cmake b/Tests/ComplexOneConfig/Library/test_preprocess.cmake new file mode 100644 index 000000000..d2d9fc652 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/test_preprocess.cmake @@ -0,0 +1,7 @@ +SET(TEST_FILE CMakeFiles/create_file.dir/create_file.i) +FILE(READ ${TEST_FILE} CONTENTS) +IF("${CONTENTS}" MATCHES "Unable to close") + MESSAGE(STATUS "${TEST_FILE} created successfully!") +ELSE("${CONTENTS}" MATCHES "Unable to close") + MESSAGE(FATAL_ERROR "${TEST_FILE} creation failed!") +ENDIF("${CONTENTS}" MATCHES "Unable to close") diff --git a/Tests/ComplexOneConfig/VarTests.cmake b/Tests/ComplexOneConfig/VarTests.cmake new file mode 100644 index 000000000..c146d1be0 --- /dev/null +++ b/Tests/ComplexOneConfig/VarTests.cmake @@ -0,0 +1,198 @@ +# +# Test SET +# +SET (ZERO_VAR 0) +SET (ZERO_VAR2 0) + +IF(ZERO_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED) +ELSE(ZERO_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED) +ENDIF(ZERO_VAR) + +SET(ONE_VAR 1) +SET(ONE_VAR2 1) +SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable") + +# +# Test VARIABLE_REQUIRES +# +VARIABLE_REQUIRES(ONE_VAR + ONE_VAR_IS_DEFINED ONE_VAR) + +# +# Test various IF/ELSE combinations +# +IF(NOT ZERO_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_NOT) +ELSE(NOT ZERO_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_NOT) +ENDIF(NOT ZERO_VAR) + +IF(NOT ONE_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_NOT2) +ELSE(NOT ONE_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_NOT2) +ENDIF(NOT ONE_VAR) + +IF(ONE_VAR AND ONE_VAR2) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND) +ELSE(ONE_VAR AND ONE_VAR2) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_AND) +ENDIF(ONE_VAR AND ONE_VAR2) + +IF(ONE_VAR AND ZERO_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_AND2) +ELSE(ONE_VAR AND ZERO_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND2) +ENDIF(ONE_VAR AND ZERO_VAR) + +IF(ZERO_VAR OR ONE_VAR2) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_OR) +ELSE(ZERO_VAR OR ONE_VAR2) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR) +ENDIF(ZERO_VAR OR ONE_VAR2) + +IF(ZERO_VAR OR ZERO_VAR2) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR2) +ELSE(ZERO_VAR OR ZERO_VAR2) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_OR2) +ENDIF(ZERO_VAR OR ZERO_VAR2) + +IF(STRING_VAR MATCHES "^CMake") + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES) +ELSE(STRING_VAR MATCHES "^CMake") + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES) +ENDIF(STRING_VAR MATCHES "^CMake") + +IF(STRING_VAR MATCHES "^foo") + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES2) +ELSE(STRING_VAR MATCHES "^foo") + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES2) +ENDIF(STRING_VAR MATCHES "^foo") + +IF(COMMAND "IF") + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND) +ELSE(COMMAND "IF") + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND) +ENDIF(COMMAND "IF") + +IF(COMMAND "ROQUEFORT") + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND2) +ELSE(COMMAND "ROQUEFORT") + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND2) +ENDIF(COMMAND "ROQUEFORT") + +IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EXISTS) +ELSE(EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EXISTS) +ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) + +IF (EXISTS ${Complex_SOURCE_DIR}/roquefort.txt) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EXISTS2) +ELSE(EXISTS ${Complex_SOURCE_DIR}/roquefort.txt) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EXISTS2) +ENDIF (EXISTS ${Complex_SOURCE_DIR}/roquefort.txt) + +IF (IS_DIRECTORY ${Complex_SOURCE_DIR}) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_IS_DIRECTORY) +ENDIF (IS_DIRECTORY ${Complex_SOURCE_DIR}) + +IF (NOT IS_DIRECTORY ${Complex_SOURCE_DIR}/VarTests.cmake) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_IS_DIRECTORY2) +ENDIF (NOT IS_DIRECTORY ${Complex_SOURCE_DIR}/VarTests.cmake) + +SET (SNUM1_VAR "1") +SET (SNUM2_VAR "2") +SET (SNUM3_VAR "1") + + +IF (SNUM1_VAR LESS SNUM2_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_LESS) +ELSE (SNUM1_VAR LESS SNUM2_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_LESS) +ENDIF (SNUM1_VAR LESS SNUM2_VAR) + +IF (SNUM2_VAR LESS SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_LESS2) +ELSE (SNUM2_VAR LESS SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_LESS2) +ENDIF (SNUM2_VAR LESS SNUM1_VAR) + +IF (SNUM2_VAR GREATER SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_GREATER) +ELSE (SNUM2_VAR GREATER SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_GREATER) +ENDIF (SNUM2_VAR GREATER SNUM1_VAR) + +IF (SNUM2_VAR EQUAL SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EQUAL) +ELSE (SNUM2_VAR EQUAL SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EQUAL) +ENDIF (SNUM2_VAR EQUAL SNUM1_VAR) + +IF (SNUM3_VAR EQUAL SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EQUAL) +ELSE (SNUM3_VAR EQUAL SNUM1_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EQUAL) +ENDIF (SNUM3_VAR EQUAL SNUM1_VAR) + +IF (SNUM1_VAR GREATER SNUM2_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_GREATER2) +ELSE (SNUM1_VAR GREATER SNUM2_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_GREATER2) +ENDIF (SNUM1_VAR GREATER SNUM2_VAR) + +SET (SSTR1_VAR "abc") +SET (SSTR2_VAR "bcd") + +IF (SSTR1_VAR STRLESS SSTR2_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRLESS) +ELSE (SSTR1_VAR STRLESS SSTR2_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRLESS) +ENDIF (SSTR1_VAR STRLESS SSTR2_VAR) + +IF (SSTR2_VAR STRLESS SSTR1_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRLESS2) +ELSE (SSTR2_VAR STRLESS SSTR1_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRLESS2) +ENDIF (SSTR2_VAR STRLESS SSTR1_VAR) + +IF (SSTR2_VAR STRGREATER SSTR1_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRGREATER) +ELSE (SSTR2_VAR STRGREATER SSTR1_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRGREATER) +ENDIF (SSTR2_VAR STRGREATER SSTR1_VAR) + +IF (SSTR1_VAR STRGREATER SSTR2_VAR) + ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRGREATER2) +ELSE (SSTR1_VAR STRGREATER SSTR2_VAR) + ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRGREATER2) +ENDIF (SSTR1_VAR STRGREATER SSTR2_VAR) + +# +# Test FOREACH +# +FOREACH (INDEX 1 2) + SET(FOREACH_VAR${INDEX} "VALUE${INDEX}") +ENDFOREACH(INDEX) + +SET(FOREACH_CONCAT "") +FOREACH (INDEX a;b;c;d;e;f;g) + SET(FOREACH_CONCAT "${FOREACH_CONCAT}${INDEX}") +ENDFOREACH(INDEX) + +# +# Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations +# +FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR}) + +GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH) +GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME) +GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME) +GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT) +GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE) + +FIND_PATH(PATH_VAR "cmTestConfigure.h.in" ${Complex_SOURCE_DIR}) +GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME) diff --git a/Tests/ComplexOneConfig/cmTestConfigure.h.in b/Tests/ComplexOneConfig/cmTestConfigure.h.in new file mode 100644 index 000000000..7741b6fd5 --- /dev/null +++ b/Tests/ComplexOneConfig/cmTestConfigure.h.in @@ -0,0 +1,85 @@ +// Test SET, VARIABLE_REQUIRES + +#cmakedefine ONE_VAR +#cmakedefine ONE_VAR_IS_DEFINED +#cmakedefine ZERO_VAR + +#define STRING_VAR "${STRING_VAR}" + +// Test FOREACH + +#define FOREACH_VAR1 "${FOREACH_VAR1}" +#define FOREACH_VAR2 "${FOREACH_VAR2}" +#define FOREACH_CONCAT "${FOREACH_CONCAT}" + +// Test WHILE +#define WHILE_VALUE ${while_var} + +// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations + +#define FILENAME_VAR_PATH_NAME "${FILENAME_VAR_PATH_NAME}" +#define FILENAME_VAR_NAME "${FILENAME_VAR_NAME}" +#define FILENAME_VAR_EXT "${FILENAME_VAR_EXT}" +#define FILENAME_VAR_NAME_WE "${FILENAME_VAR_NAME_WE}" + +#define PATH_VAR_NAME "${PATH_VAR_NAME}" + +// Test LOAD_CACHE + +#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}" +#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}" +#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}" +#cmakedefine CACHE_TEST_VAR_EXCLUDED +#define CACHE_TEST_VAR_INTERNAL "${CACHE_TEST_VAR_INTERNAL}" + +// Test internal CMake vars from C++ flags + +#cmakedefine CMAKE_NO_STD_NAMESPACE +#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS +#cmakedefine CMAKE_NO_ANSI_STRING_STREAM +#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE + +#cmakedefine01 SHOULD_BE_ZERO +#cmakedefine01 SHOULD_BE_ONE +// Needed to check for files + +#define BINARY_DIR "${Complex_BINARY_DIR}" + +// Test FIND_LIBRARY + +#define FIND_DUMMY_LIB "${FIND_DUMMY_LIB}" + +// Test SET_SOURCE_FILES_PROPERTIES + +#cmakedefine FILE_HAS_ABSTRACT +#cmakedefine FILE_HAS_WRAP_EXCLUDE +#define FILE_COMPILE_FLAGS "${FILE_COMPILE_FLAGS}" + +#define TEST_SEP "${TEST_SEP}" + +// Test registry read + +#if defined(_WIN32) && !defined(__CYGWIN__) +#define REGISTRY_TEST_PATH "${REGISTRY_TEST_PATH}" +#endif + +// Test Remove command +#define REMOVE_STRING "${REMOVE_STRING}" + +// Test IF inside FOREACH +#cmakedefine IF_INSIDE_FOREACH_THEN_EXECUTED +#cmakedefine IF_INSIDE_FOREACH_ELSE_EXECUTED + +// Test SET CACHE FORCE +#cmakedefine FORCE_TEST +#define CMAKE_GENERATOR "${CMAKE_GENERATOR}" + +#define CMAKE_SHARED_MODULE_PREFIX "${CMAKE_SHARED_MODULE_PREFIX}" +#define CMAKE_SHARED_MODULE_SUFFIX "${CMAKE_SHARED_MODULE_SUFFIX}" + +// test elseif +#cmakedefine ELSEIF_RESULT + +// test parenthesis in conditionals +#cmakedefine CONDITIONAL_PARENTHESES + diff --git a/Tests/ComplexOneConfig/cmTestConfigureEscape.h.in b/Tests/ComplexOneConfig/cmTestConfigureEscape.h.in new file mode 100644 index 000000000..39a8bd627 --- /dev/null +++ b/Tests/ComplexOneConfig/cmTestConfigureEscape.h.in @@ -0,0 +1 @@ +#define STRING_WITH_QUOTES "${STRING_WITH_QUOTES}" diff --git a/Tests/ComplexOneConfig/cmTestGeneratedHeader.h.in b/Tests/ComplexOneConfig/cmTestGeneratedHeader.h.in new file mode 100644 index 000000000..0e9dd3ff3 --- /dev/null +++ b/Tests/ComplexOneConfig/cmTestGeneratedHeader.h.in @@ -0,0 +1 @@ +#define GENERATED_HEADER_INCLUDED diff --git a/Tests/Contracts/Trilinos-10-6/CMakeLists.txt b/Tests/Contracts/Trilinos-10-6/CMakeLists.txt new file mode 100644 index 000000000..79ed669a2 --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/CMakeLists.txt @@ -0,0 +1,103 @@ +cmake_minimum_required(VERSION 2.8) +project(Trilinos-10-6) + +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() + + if(NOT HOME AND WIN32) + # Try for USERPROFILE as HOME equivalent: + string(REPLACE "\\" "/" HOME "$ENV{USERPROFILE}") + + # But just use root of SystemDrive if USERPROFILE contains any spaces: + # (Default on XP and earlier...) + if(HOME MATCHES " ") + string(REPLACE "\\" "/" HOME "$ENV{SystemDrive}") + endif() + endif() +endif() +message(STATUS "HOME='${HOME}'") + +if(NOT DEFINED url) + set(url "http://www.cmake.org/files/contracts/trilinos-10.6.1.tar.gz") +endif() +message(STATUS "url='${url}'") + +if(NOT DEFINED md5) + set(md5 "690230465dd21a76e3c6636fd07bd2f0") +endif() +message(STATUS "md5='${md5}'") + +string(SUBSTRING "${md5}" 0 8 shorttag) +set(shorttag "m${shorttag}") + +set(download_dir "${HOME}/.cmake/Downloads") + +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}'") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/Dashboard.cmake.in" + "${script_dir}/Dashboard.cmake" + @ONLY) + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/ValidateBuild.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/ValidateBuild.cmake" + @ONLY) + +# Source dir for this project exists outside the CMake build tree because it +# is absolutely huge. Source dir is therefore cached under a '.cmake/Contracts' +# dir in your HOME directory. Downloads are cached under '.cmake/Downloads' +# +if(EXISTS "${source_dir}/cmake/ctest/TrilinosCTestDriverCore.cmake") + # 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 pulls the tarball from the web (or + # no-ops if it already exists with the given md5 sum): + # + ExternalProject_Add(download-${PROJECT_NAME} + DOWNLOAD_DIR "${download_dir}" + URL "${url}" + URL_MD5 "${md5}" + SOURCE_DIR "${source_dir}" + PATCH_COMMAND ${CMAKE_COMMAND} -Dsource_dir=${source_dir} -P "${CMAKE_CURRENT_SOURCE_DIR}/Patch.cmake" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +endif() + +ExternalProject_Add(build-${PROJECT_NAME} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND ${CMAKE_COMMAND} -P "${script_dir}/Dashboard.cmake" + INSTALL_COMMAND "" + DEPENDS download-${PROJECT_NAME} + ) diff --git a/Tests/Contracts/Trilinos-10-6/Dashboard.cmake.in b/Tests/Contracts/Trilinos-10-6/Dashboard.cmake.in new file mode 100644 index 000000000..cc2950232 --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/Dashboard.cmake.in @@ -0,0 +1,63 @@ +# This "cmake -P" script may be configured to drive a dashboard on any machine. +# +set(CTEST_BINARY_DIRECTORY "@binary_dir@") +set(CTEST_BUILD_NAME "@BUILDNAME@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_SITE "@SITE@") +set(CTEST_SOURCE_DIRECTORY "@source_dir@") + +# Set the environment: +# +set(ENV{CTEST_BUILD_NAME} "${CTEST_BUILD_NAME}") +set(ENV{CTEST_CMAKE_GENERATOR} "${CTEST_CMAKE_GENERATOR}") +set(ENV{CTEST_SITE} "${CTEST_SITE}") + +# Allow override of the environment on a per-client basis: +# +set(ENV_SCRIPT "$ENV{CMAKE_CONTRACT_Trilinos_10_6_ENV_SCRIPT}") +if(ENV_SCRIPT AND EXISTS "${ENV_SCRIPT}") + include("${ENV_SCRIPT}") +endif() + +# Empty build dir to start with: +# +message("Cleaning binary dir '${CTEST_BINARY_DIRECTORY}'") +file(REMOVE_RECURSE "${CTEST_BINARY_DIRECTORY}") + +# Generate 'do-configure' script: +# +file(WRITE "${CTEST_BINARY_DIRECTORY}/do-configure" " +\"${CMAKE_COMMAND}\" -G \"${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\" +") + +# Make the 'do-configure' script executable and execute it: +# +if(WIN32) + configure_file( + "${CTEST_BINARY_DIRECTORY}/do-configure" + "${CTEST_BINARY_DIRECTORY}/do-configure.cmd" + COPYONLY) + execute_process(COMMAND "${CTEST_BINARY_DIRECTORY}/do-configure.cmd" + WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}") +else() + execute_process(COMMAND chmod +x "${CTEST_BINARY_DIRECTORY}/do-configure") + execute_process(COMMAND "${CTEST_BINARY_DIRECTORY}/do-configure" + WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}") +endif() + +# Run an experimental Trilinos dashboard: +# +execute_process(COMMAND + "${CMAKE_CTEST_COMMAND}" + -S "${CTEST_SOURCE_DIRECTORY}/cmake/ctest/experimental_build_test.cmake" + -VV + WORKING_DIRECTORY "${CTEST_BINARY_DIRECTORY}" + RESULT_VARIABLE rv + ) + +if(NOT "${rv}" STREQUAL "0") + message("error(s) (or warnings or test failures) running Trilinos dashboard +script experimental_build_test.cmake... +ctest returned rv='${rv}' +") +endif() diff --git a/Tests/Contracts/Trilinos-10-6/EnvScript.cmake b/Tests/Contracts/Trilinos-10-6/EnvScript.cmake new file mode 100644 index 000000000..dacb704f7 --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/EnvScript.cmake @@ -0,0 +1,32 @@ +# Site specific settings: +# +if(CTEST_SITE MATCHES "faraway") + set(CTEST_SITE "faraway.kitware") + set(ENV{CTEST_SITE} "${CTEST_SITE}") +endif() + +if(CTEST_SITE STREQUAL "HUT11") + set(CTEST_SITE "hut11.kitware") + set(ENV{CTEST_SITE} "${CTEST_SITE}") + + set(ENV{CLAPACK_DIR} "C:/T/clapack/b/clapack-prefix/src/clapack-build") +endif() + +if(CTEST_SITE MATCHES "qwghlm") + set(CTEST_SITE "qwghlm.kitware") + set(ENV{CTEST_SITE} "${CTEST_SITE}") + + set(ENV{PATH} "/opt/local/bin:$ENV{PATH}") + set(ENV{CC} "gcc-mp-4.3") + set(ENV{CXX} "g++-mp-4.3") + set(ENV{FC} "gfortran-mp-4.3") +endif() + +# Submit to alternate CDash server: +# +#set(ENV{CTEST_DROP_SITE} "localhost") +#set(ENV{CTEST_DROP_LOCATION} "/CDash/submit.php?project=Trilinos") + +# Limit packages built: +# +set(ENV{Trilinos_PACKAGES} "Teuchos;Kokkos") diff --git a/Tests/Contracts/Trilinos-10-6/Patch.cmake b/Tests/Contracts/Trilinos-10-6/Patch.cmake new file mode 100644 index 000000000..76051eb98 --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/Patch.cmake @@ -0,0 +1,38 @@ +if(NOT DEFINED source_dir) + message(FATAL_ERROR "variable 'source_dir' not defined") +endif() + + +if(NOT EXISTS "${source_dir}/CMakeLists.txt") + message(FATAL_ERROR "error: No CMakeLists.txt file to patch!") +endif() + +set(text " + +# +# Reference variables typically given as experimental_build_test configure +# options to avoid CMake warnings about unused variables +# + +MESSAGE(\"Trilinos_ALLOW_NO_PACKAGES='\${Trilinos_ALLOW_NO_PACKAGES}'\") +MESSAGE(\"Trilinos_WARNINGS_AS_ERRORS_FLAGS='\${Trilinos_WARNINGS_AS_ERRORS_FLAGS}'\") +") + +file(APPEND "${source_dir}/CMakeLists.txt" "${text}") + + +if(NOT EXISTS "${source_dir}/CTestConfig.cmake") + message(FATAL_ERROR "error: No CTestConfig.cmake file to patch!") +endif() + +set(text " + +# +# Use newer than 10.6.1 CTestConfig settings from the Trilinos project. +# Send the Trilinos dashboards to the new Trilinos CDash server instance. +# +SET(CTEST_NIGHTLY_START_TIME \"04:00:00 UTC\") # 10 PM MDT or 9 PM MST +SET(CTEST_DROP_SITE \"testing.sandia.gov\") +") + +file(APPEND "${source_dir}/CTestConfig.cmake" "${text}") diff --git a/Tests/Contracts/Trilinos-10-6/RunTest.cmake b/Tests/Contracts/Trilinos-10-6/RunTest.cmake new file mode 100644 index 000000000..30124d8e9 --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/RunTest.cmake @@ -0,0 +1,7 @@ +# ValidateBuild.cmake is configured into this location when the test is built: +set(dir "${CMAKE_CURRENT_BINARY_DIR}/Contracts/${project}") + +set(exe "${CMAKE_COMMAND}") +set(args -P "${dir}/ValidateBuild.cmake") + +set(Trilinos-10-6_RUN_TEST ${exe} ${args}) diff --git a/Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake.in b/Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake.in new file mode 100644 index 000000000..04bbf214e --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/ValidateBuild.cmake.in @@ -0,0 +1,39 @@ +# +# This code validates that the Trilinos build was "successful enough" (since it +# is difficult to detect this from the caller of the experimental_build_test +# dashboard script...) +# +set(binary_dir "@binary_dir@") +message("binary_dir='${binary_dir}'") + + +# Count *.exe files: +# +file(GLOB_RECURSE exes "${binary_dir}/*.exe") +message(STATUS "exes='${exes}'") +list(LENGTH exes len) +if(len LESS 47) + message(FATAL_ERROR "len='${len}' is less than minimum expected='47' (count of executables)") +endif() +message(STATUS "Found len='${len}' *.exe files") + + +# Try to find the Teuchos unit tests executable: +# +file(GLOB_RECURSE exe "${binary_dir}/Teuchos_UnitTest_UnitTests.exe") +list(LENGTH exe len) +if(NOT len EQUAL 1) + message(FATAL_ERROR "len='${len}' is not the expected='1' (count of Teuchos_UnitTest_UnitTests.exe)") +endif() +message(STATUS "Found exe='${exe}'") + + +# Try to run it: +execute_process(COMMAND ${exe} RESULT_VARIABLE rv) +if(NOT "${rv}" STREQUAL "0") + message(FATAL_ERROR "rv='${rv}' is not the expected='0' (result of running Teuchos_UnitTest_UnitTests.exe)") +endif() +message(STATUS "Ran exe='${exe}' rv='${rv}'") + + +message(STATUS "All Trilinos build validation tests pass.") diff --git a/Tests/Contracts/cse-snapshot/CMakeLists.txt b/Tests/Contracts/cse-snapshot/CMakeLists.txt new file mode 100644 index 000000000..913421010 --- /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 000000000..138eb3f81 --- /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 000000000..7eb630116 --- /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 000000000..cfb8b1600 --- /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 000000000..4f48e5cd2 --- /dev/null +++ b/Tests/Contracts/vtk542/RunTest.cmake @@ -0,0 +1 @@ +SET(vtk542_RUN_TEST VTK-build/bin/CommonCxxTests otherArrays) diff --git a/Tests/CrossCompile/CMakeLists.txt b/Tests/CrossCompile/CMakeLists.txt new file mode 100644 index 000000000..96a57a051 --- /dev/null +++ b/Tests/CrossCompile/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CrossCompile) + +UNSET(run_result CACHE) + +#Simulate the cross compile condition +SET(CMAKE_CROSSCOMPILING ON) + +ADD_EXECUTABLE(CrossCompile main.c) + +TRY_RUN(run_result compile_result + ${CrossCompile_BINARY_DIR} + ${CrossCompile_SOURCE_DIR}/main.c) diff --git a/Tests/CrossCompile/main.c b/Tests/CrossCompile/main.c new file mode 100644 index 000000000..8488f4e58 --- /dev/null +++ b/Tests/CrossCompile/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/CustComDepend/CMakeLists.txt b/Tests/CustComDepend/CMakeLists.txt new file mode 100644 index 000000000..d5266842d --- /dev/null +++ b/Tests/CustComDepend/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required (VERSION 2.6) +project(CustComDepend) +include_directories("${CustComDepend_SOURCE_DIR}") +add_definitions(-D_CRT_SECURE_NO_DEPRECATE=1) +set(EXECUTABLE_OUTPUT_PATH ${CustComDepend_BINARY_DIR}/bin) +add_executable(foo foo.cxx) +add_custom_command( + OUTPUT ${CustComDepend_BINARY_DIR}/bar.c + COMMAND ${CustComDepend_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/foo + ${CustComDepend_BINARY_DIR}/bar.c + DEPENDS ${CustComDepend_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/foo +) + +add_library(bar SHARED ${CustComDepend_BINARY_DIR}/bar.c) diff --git a/Tests/CustComDepend/bar.h b/Tests/CustComDepend/bar.h new file mode 100644 index 000000000..d462c9b5b --- /dev/null +++ b/Tests/CustComDepend/bar.h @@ -0,0 +1,9 @@ +#ifdef _WIN32 +# ifdef bar_EXPORTS +# define BAR_EXPORT __declspec( dllexport ) +# else +# define BAR_EXPORT __declspec( dllimport ) +# endif +#else +# define BAR_EXPORT +#endif diff --git a/Tests/CustComDepend/foo.cxx b/Tests/CustComDepend/foo.cxx new file mode 100644 index 000000000..3c204f8a2 --- /dev/null +++ b/Tests/CustComDepend/foo.cxx @@ -0,0 +1,15 @@ +#include <stdio.h> + +int main(int ac, char** av) +{ + FILE* fout = fopen(av[1], "w"); + printf("create %s\n", av[1]); + if(!fout) + { + return -1; + } + fprintf(fout, "#include <bar.h>\nBAR_EXPORT int bar(){ return 10;}\n"); + fclose(fout); + return 0; +} + diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt new file mode 100644 index 000000000..b7c9ea268 --- /dev/null +++ b/Tests/CustomCommand/CMakeLists.txt @@ -0,0 +1,438 @@ +# +# Wrapping +# +cmake_minimum_required (VERSION 2.6) +PROJECT (CustomCommand) + +ADD_SUBDIRECTORY(GeneratedHeader) + +# +# Lib and exe path +# +IF(NOT DEFINED bin_dir) + SET(bin_dir "bin") +ENDIF() + +SET (LIBRARY_OUTPUT_PATH + ${PROJECT_BINARY_DIR}/${bin_dir} CACHE INTERNAL + "Single output directory for building all libraries.") + +SET (EXECUTABLE_OUTPUT_PATH + ${PROJECT_BINARY_DIR}/${bin_dir} CACHE INTERNAL + "Single output directory for building all executables.") + +################################################################ +# +# First test using a compiled generator to create a .c file +# +################################################################ +# add the executable that will generate the file +ADD_EXECUTABLE(generator generator.cxx) + +GET_TARGET_PROPERTY(generator_PATH generator LOCATION) +MESSAGE("Location ${generator_PATH}") + +################################################################ +# +# Test using a wrapper to wrap a header file +# +################################################################ +# add the executable that will generate the file +ADD_EXECUTABLE(wrapper wrapper.cxx) + +ADD_CUSTOM_COMMAND( + OUTPUT ${PROJECT_BINARY_DIR}/wrapped.c ${PROJECT_BINARY_DIR}/wrapped_help.c + DEPENDS wrapper + MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/wrapped.h + COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/wrapper + ${PROJECT_BINARY_DIR}/wrapped.c ${PROJECT_BINARY_DIR}/wrapped_help.c + ${CMAKE_CFG_INTDIR} # this argument tests passing of the configuration + VERBATIM # passing of configuration should work in this mode + ) + +################################################################ +# +# Test creating files from a custom target +# +################################################################ +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 + ${PROJECT_BINARY_DIR}/doc1.dvi + ) + +ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/doc1.h + COMMAND ${CMAKE_COMMAND} -E echo " Copying doc1.dvi to doc1temp.h." + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1.dvi + ${PROJECT_BINARY_DIR}/doc1temp.h + ) +ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/doc1.h APPEND + DEPENDS ${PROJECT_BINARY_DIR}/doc1.dvi + COMMAND ${CMAKE_COMMAND} -E echo " Copying doc1temp.h to doc1.h." + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1temp.h + ${PROJECT_BINARY_DIR}/doc1.h + COMMAND ${CMAKE_COMMAND} -E echo " Removing doc1temp.h." + COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_BINARY_DIR}/doc1temp.h + ) + +# Add custom command to generate foo.h. +ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/foo.h + DEPENDS ${PROJECT_SOURCE_DIR}/foo.h.in + COMMAND ${CMAKE_COMMAND} -E echo " Copying foo.h.in to foo.h." + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/foo.h.in + ${PROJECT_BINARY_DIR}/foo.h + ) + +# Add the location of foo.h to the include path. +INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}) + +# Test generation of a file to the build tree without full path. As +# of CMake 2.6 custom command outputs specified by relative path go in +# the build tree. +ADD_CUSTOM_COMMAND( + OUTPUT doc1.txt + COMMAND ${CMAKE_COMMAND} -E echo "Example Document Target" > doc1.txt + DEPENDS doc1.tex + VERBATIM + ) + +# Add a custom target to drive generation of doc1.h. +ADD_CUSTOM_TARGET(TDocument ALL + COMMAND ${CMAKE_COMMAND} -E echo " Copying doc1.h to doc2.h." + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1.h + ${PROJECT_BINARY_DIR}/doc2.h + DEPENDS doc1.txt ${PROJECT_BINARY_DIR}//doc1.h # test 2 slashes + COMMENT "Running top-level TDocument commands" + SOURCES doc1.tex + ) + +# Setup a pre- and post-build pair that will fail if not run in the +# proper order. +ADD_CUSTOM_COMMAND( + TARGET TDocument PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E echo " Writing doc1pre.txt." + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/doc1.tex ${PROJECT_BINARY_DIR}/doc1pre.txt + COMMENT "Running TDocument pre-build commands" + ) +ADD_CUSTOM_COMMAND( + TARGET TDocument POST_BUILD + COMMAND ${CMAKE_COMMAND} -E echo " Copying doc1pre.txt to doc2post.txt." + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1pre.txt + ${PROJECT_BINARY_DIR}/doc2post.txt + COMMENT "Running TDocument post-build commands" + ) + +################################################################ +# +# Test using a multistep generated file +# +################################################################ +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 + ) + +ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/foo.c + DEPENDS ${PROJECT_BINARY_DIR}/foo.pre + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${PROJECT_BINARY_DIR}/foo.pre + ${PROJECT_BINARY_DIR}/foo.c + ) + +# Add custom command to generate not_included.h, which is a header +# file that is not included by any source in this project. This will +# test whether all custom command outputs explicitly listed as sources +# get generated even if they are not needed by an object file. +ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/not_included.h + DEPENDS ${PROJECT_SOURCE_DIR}/foo.h.in + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/foo.h.in + ${PROJECT_BINARY_DIR}/not_included.h + ) + +# Tell the executable where to find not_included.h. +CONFIGURE_FILE( + ${PROJECT_SOURCE_DIR}/config.h.in + ${PROJECT_BINARY_DIR}/config.h + @ONLY IMMEDIATE + ) + +# add the executable +ADD_EXECUTABLE(CustomCommand + ${PROJECT_BINARY_DIR}/foo.h + ${PROJECT_BINARY_DIR}/foo.c + ${PROJECT_BINARY_DIR}/wrapped.c + ${PROJECT_BINARY_DIR}/wrapped_help.c + ${PROJECT_BINARY_DIR}/generated.c + ${PROJECT_BINARY_DIR}/not_included.h + gen_redirect.c # default location for custom commands is in build tree + ) + +# Add the rule to create generated.c at build time. This is placed +# here to test adding the generation rule after referencing the +# generated source in a target. +ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/generated.c + DEPENDS generator + COMMAND ${generator_PATH} + ARGS ${PROJECT_BINARY_DIR}/generated.c + ) + +TARGET_LINK_LIBRARIES(CustomCommand GeneratedHeader) + +############################################################################## +# Test for using just the target name as executable in the COMMAND +# section. Has to be recognized and replaced by CMake with the output +# actual location of the executable. +# Additionally the generator is created in an extra subdir after the +# ADD_CUSTOM_COMMAND() is used. +# +# Test the same for ADD_CUSTOM_TARGET() + +ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated_extern.cxx + COMMAND generator_extern ${CMAKE_CURRENT_BINARY_DIR}/generated_extern.cxx + ) + +ADD_EXECUTABLE(CustomCommandUsingTargetTest main.cxx ${CMAKE_CURRENT_BINARY_DIR}/generated_extern.cxx ) + +ADD_CUSTOM_TARGET(RunTarget + COMMAND generator_extern ${CMAKE_CURRENT_BINARY_DIR}/run_target.cxx + ) + +ADD_CUSTOM_COMMAND(TARGET CustomCommandUsingTargetTest POST_BUILD + COMMAND dummy_generator ${CMAKE_CURRENT_BINARY_DIR}/generated_dummy.cxx) + +ADD_SUBDIRECTORY(GeneratorInExtraDir) + +############################################################################## +# Test shell operators in custom commands. + +ADD_EXECUTABLE(tcat tcat.cxx) + +ADD_CUSTOM_COMMAND(OUTPUT gen_redirect.c + DEPENDS tcat gen_redirect_in.c + COMMAND tcat < ${CMAKE_CURRENT_SOURCE_DIR}/gen_redirect_in.c > gen_redirect.c + COMMAND ${CMAKE_COMMAND} -E echo "#endif" >> gen_redirect.c + VERBATIM + ) + +############################################################################## +# Test non-trivial command line arguments in custom commands. +SET(EXPECTED_ARGUMENTS) +SET(CHECK_ARGS) +IF(NOT MSVC71) + SET(CHECK_ARGS -DPATH=c:/posix/path) +ENDIF() +SET(CHECK_ARGS + ${CHECK_ARGS} + c:/posix/path + c:\\windows\\path + 'single-quotes' + single'quote + \"double-quotes\" + "\\;semi-colons\\;" + "semi\\;colon" + `back-ticks` + back`tick + "(parens)" + "(lparen" + "rparen)" + {curly} + {lcurly} + rcurly} + <angle> + <langle + rangle> + [square] + [lsquare # these have funny behavior due to special cases for + rsquare] # windows registry value names in list expansion + $dollar-signs$ + dollar$sign + &ersands&x # Borland make does not like trailing ampersand + one&ersand + @two-ats@ + one@at + ~two-tilda~ + one~tilda + ^two-carrots^ + one^carrot + %two-percents% + one%percent + !two-exclamations! + one!exclamation + ?two-questions? + one?question + *two-stars* + one*star + =two+equals= + one=equals + _two-underscores_ + one_underscore + ,two-commas, + one,comma + .two-periods. + one.period + |two-pipes| + one|pipe + |nopipe + "#two-pounds#" + "one#pound" + "#nocomment" + "c:/posix/path/with space" + "c:\\windows\\path\\with space" + "'single quotes with space'" + "single'quote with space" + "\"double-quotes with space\"" + "\\;semi-colons w s\\;" + "semi\\;colon w s" + "`back-ticks` w s" + "back`tick w s" + "(parens) w s" + "(lparen w s" + "rparen) w s" + "{curly} w s" + "{lcurly w s" + "rcurly} w s" + "<angle> w s" + "<langle w s" + "rangle> w s" + "[square] w s" + "[lsquare w s" # these have funny behavior due to special cases for + "rsquare] w s" # windows registry value names in list expansion + "$dollar-signs$ w s" + "dollar$sign w s" + "&ersands& w s" + "one&ersand w s" + "@two-ats@ w s" + "one@at w s" + "~two-tilda~ w s" + "one~tilda w s" + "^two-carrots^ w s" + "one^carrot w s" + "%two-percents% w s" + "one%percent w s" + "!two-exclamations! w s" + "one!exclamation w s" + "*two-stars* w s" + "one*star w s" + "=two+equals= w s" + "one=equals w s" + "_two-underscores_ w s" + "one_underscore w s" + "?two-questions? w s" + "one?question w s" + ",two-commas, w s" + "one,comma w s" + ".two-periods. w s" + "one.period w s" + "|two-pipes| w s" + "one|pipe w s" + "#two-pounds# w s" + "one#pound w s" + ~ ` ! @ \# $ % ^ & _ - + = : "\;" \" ' , . ? "(" ")" { } [] + ) +IF(NOT MINGW) + # * # MinGW programs on windows always expands the wildcard! + # / # MSys make converts a leading slash to the mingw home directory + LIST(APPEND CHECK_ARGS * /) +ENDIF(NOT MINGW) + +# The windows command shell does not support a double quote by itself: +# double\"quote +# without messing up quoting of arguments following it. + +# Make tools need help with escaping a single backslash +# \ +# at the end of a command because they think it is a continuation +# character. + +# We now have special cases for shell operators: +# | < > << >> &> 2>&1 1>&2 +# to allow custom commands to perform redirection. + +FOREACH(arg ${CHECK_ARGS} "") + SET(ARG "${arg}") + STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ARG "${ARG}") + STRING(REGEX REPLACE "\"" "\\\\\"" ARG "${ARG}") + SET(EXPECTED_ARGUMENTS + "${EXPECTED_ARGUMENTS} \"${ARG}\", +") +ENDFOREACH(arg) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/check_command_line.c.in + ${CMAKE_CURRENT_BINARY_DIR}/check_command_line.c + @ONLY IMMEDIATE) +ADD_EXECUTABLE(check_command_line + ${CMAKE_CURRENT_BINARY_DIR}/check_command_line.c) +SET(output_name "check_command_line") +SET_PROPERTY(TARGET check_command_line + PROPERTY OUTPUT_NAME ${output_name}) +# SET_TARGET_PROPERTIES(check_command_line PROPERTIES +# COMPILE_FLAGS -DCHECK_COMMAND_LINE_VERBOSE) +ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/command_line_check + COMMAND ${CMAKE_COMMAND} -DMARK_FILE=${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt + -P ${CMAKE_CURRENT_SOURCE_DIR}/check_mark.cmake + COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${output_name} + ${CHECK_ARGS} "" + VERBATIM + COMMENT "Checking custom command line escapes (single'quote)" + ) +SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/command_line_check + PROPERTIES SYMBOLIC 1) +ADD_CUSTOM_TARGET(do_check_command_line ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/command_line_check + COMMAND ${CMAKE_COMMAND} -E echo "Checking custom target command escapes" + COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${output_name} + ${CHECK_ARGS} "" + VERBATIM + COMMENT "Checking custom target command line escapes ($dollar-signs$)" + ) +ADD_DEPENDENCIES(do_check_command_line check_command_line) + +ADD_CUSTOM_TARGET(pre_check_command_line + COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt + ) +ADD_DEPENDENCIES(do_check_command_line pre_check_command_line) + +# <SameNameTest> +# +# Add a custom target called "SameName" -- then add a custom command in a +# different target whose output is a full-path file called "SameName" -- then +# add a second custom target that depends on the full-path file ".../SameName" +# +# At first, this reproduces a bug reported by a customer. After fixing it, +# having this test here makes sure it stays fixed moving forward. +# +ADD_CUSTOM_COMMAND( + OUTPUT SameName1.txt + COMMAND ${CMAKE_COMMAND} -E touch SameName1.txt + ) +ADD_CUSTOM_TARGET(SameName ALL + DEPENDS SameName1.txt + ) + +ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/subdir/SameName + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/subdir + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/subdir/SameName + ) +ADD_CUSTOM_TARGET(DifferentName ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/subdir/SameName + ) +# +# </SameNameTest> + +# Per-config target name and generator expressions. +ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../PerConfig PerConfig) +ADD_CUSTOM_COMMAND( + OUTPUT perconfig.out + COMMAND ${PerConfig_COMMAND} + DEPENDS ${PerConfig_DEPENDS} + VERBATIM + ) +SET_PROPERTY(SOURCE perconfig.out PROPERTY SYMBOLIC 1) +ADD_CUSTOM_TARGET(perconfig_target ALL + COMMAND ${CMAKE_COMMAND} -E echo "perconfig=$<TARGET_FILE:perconfig>" "config=$<CONFIGURATION>" + DEPENDS perconfig.out) diff --git a/Tests/CustomCommand/GeneratedHeader/CMakeLists.txt b/Tests/CustomCommand/GeneratedHeader/CMakeLists.txt new file mode 100644 index 000000000..2d47d8749 --- /dev/null +++ b/Tests/CustomCommand/GeneratedHeader/CMakeLists.txt @@ -0,0 +1,13 @@ +# Simulate in-source build include-file behavior for out-of-source +# builds. +SET(CMAKE_INCLUDE_CURRENT_DIR 1) + +ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated.h + COMMAND + ${CMAKE_COMMAND} ARGS -E + copy ${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in + ${CMAKE_CURRENT_BINARY_DIR}/generated.h +) + +ADD_LIBRARY(GeneratedHeader main.cpp ${CMAKE_CURRENT_BINARY_DIR}/generated.h) + diff --git a/Tests/CustomCommand/GeneratedHeader/generated.h.in b/Tests/CustomCommand/GeneratedHeader/generated.h.in new file mode 100644 index 000000000..ae6f64c1c --- /dev/null +++ b/Tests/CustomCommand/GeneratedHeader/generated.h.in @@ -0,0 +1 @@ +//hello diff --git a/Tests/CustomCommand/GeneratedHeader/main.cpp b/Tests/CustomCommand/GeneratedHeader/main.cpp new file mode 100644 index 000000000..0b43ffe83 --- /dev/null +++ b/Tests/CustomCommand/GeneratedHeader/main.cpp @@ -0,0 +1,5 @@ +#include "generated.h" +int mainGeneratedHeader() +{ + return 0; +} diff --git a/Tests/CustomCommand/GeneratorInExtraDir/CMakeLists.txt b/Tests/CustomCommand/GeneratorInExtraDir/CMakeLists.txt new file mode 100644 index 000000000..195a47792 --- /dev/null +++ b/Tests/CustomCommand/GeneratorInExtraDir/CMakeLists.txt @@ -0,0 +1,8 @@ +ADD_DEFINITIONS(-DGENERATOR_EXTERN) + +# add the executable which will be used for generating files +ADD_EXECUTABLE(generator_extern ../generator.cxx) +SET_TARGET_PROPERTIES(generator_extern PROPERTIES OUTPUT_NAME the_external_generator) + +# add an executable which will be called from ADD_CUSTOM_COMMAND( ... POST_BUILD) +ADD_EXECUTABLE(dummy_generator ../generator.cxx) diff --git a/Tests/CustomCommand/check_command_line.c.in b/Tests/CustomCommand/check_command_line.c.in new file mode 100644 index 000000000..e0e0d2142 --- /dev/null +++ b/Tests/CustomCommand/check_command_line.c.in @@ -0,0 +1,36 @@ +#include <stdio.h> +#include <string.h> + +const char* expected_arguments[] = +{ +@EXPECTED_ARGUMENTS@ 0 +}; + +int main(int argc, const char* argv[]) +{ + const char** a = argv+1; + const char** e = expected_arguments; + (void)argc; + for(;*a && *e; ++a, ++e) + { + if(strcmp(*a, *e) != 0) + { + fprintf(stderr, "Argument [%s] does not match expected [%s].\n", + *a, *e); + return 1; + } + else + { +#if defined(CHECK_COMMAND_LINE_VERBOSE) + printf("[%s]\n", *a); +#endif + } + } + if(*a || *e) + { + fprintf(stderr, "Number of arguments does not match expected.\n"); + return 1; + } + printf("Command line escapes work!\n"); + return 0; +} diff --git a/Tests/CustomCommand/check_mark.cmake b/Tests/CustomCommand/check_mark.cmake new file mode 100644 index 000000000..8b0551f83 --- /dev/null +++ b/Tests/CustomCommand/check_mark.cmake @@ -0,0 +1,5 @@ +IF(EXISTS "${MARK_FILE}") + MESSAGE(FATAL_ERROR "Custom command run more than once!") +ELSE(EXISTS "${MARK_FILE}") + FILE(WRITE "${MARK_FILE}" "check for running custom command twice\n") +ENDIF(EXISTS "${MARK_FILE}") diff --git a/Tests/CustomCommand/config.h.in b/Tests/CustomCommand/config.h.in new file mode 100644 index 000000000..86c97bd95 --- /dev/null +++ b/Tests/CustomCommand/config.h.in @@ -0,0 +1 @@ +#define PROJECT_BINARY_DIR "@PROJECT_BINARY_DIR@" diff --git a/Tests/CustomCommand/doc1.tex b/Tests/CustomCommand/doc1.tex new file mode 100644 index 000000000..e6b6ccbe5 --- /dev/null +++ b/Tests/CustomCommand/doc1.tex @@ -0,0 +1 @@ +int doc() { return 7;} diff --git a/Tests/CustomCommand/foo.h.in b/Tests/CustomCommand/foo.h.in new file mode 100644 index 000000000..d7721a2a5 --- /dev/null +++ b/Tests/CustomCommand/foo.h.in @@ -0,0 +1 @@ +/* Empty header file just used to test header generation. */ diff --git a/Tests/CustomCommand/foo.in b/Tests/CustomCommand/foo.in new file mode 100644 index 000000000..08c559df4 --- /dev/null +++ b/Tests/CustomCommand/foo.in @@ -0,0 +1,28 @@ +#include "doc1.h" +#include "foo.h" +#include "config.h" + +#include <stdio.h> + +int generated(); +int wrapped(); + +int main () +{ + if (generated()*wrapped()*doc() == 3*5*7) + { + FILE* fin = fopen(PROJECT_BINARY_DIR "/not_included.h", "r"); + if(fin) + { + fclose(fin); + return 0; + } + else + { + return -2; + } + } + + return -1; +} + diff --git a/Tests/CustomCommand/gen_redirect_in.c b/Tests/CustomCommand/gen_redirect_in.c new file mode 100644 index 000000000..8dd8f43f0 --- /dev/null +++ b/Tests/CustomCommand/gen_redirect_in.c @@ -0,0 +1,5 @@ +#if 1 + +int gen_redirect() { return 3; } + +/* endif should be concatenated to generated file */ diff --git a/Tests/CustomCommand/generator.cxx b/Tests/CustomCommand/generator.cxx new file mode 100644 index 000000000..cceac073a --- /dev/null +++ b/Tests/CustomCommand/generator.cxx @@ -0,0 +1,19 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + if ( argc < 2 ) + { + fprintf(stderr, "Usage: %s <file>\n", argv[0]); + return 1; + } + FILE *fp = fopen(argv[1],"w"); +#ifdef GENERATOR_EXTERN + fprintf(fp,"int generated() { return 3; }\n"); +#else + fprintf(fp,"extern int gen_redirect(void);\n"); + fprintf(fp,"int generated() { return gen_redirect(); }\n"); +#endif + fclose(fp); + return 0; +} diff --git a/Tests/CustomCommand/main.cxx b/Tests/CustomCommand/main.cxx new file mode 100644 index 000000000..600e751dd --- /dev/null +++ b/Tests/CustomCommand/main.cxx @@ -0,0 +1,6 @@ +extern int generated(); + +int main() +{ + return generated(); +} diff --git a/Tests/CustomCommand/tcat.cxx b/Tests/CustomCommand/tcat.cxx new file mode 100644 index 000000000..89e3cb0a2 --- /dev/null +++ b/Tests/CustomCommand/tcat.cxx @@ -0,0 +1,11 @@ +#include <stdio.h> + +int main() +{ + int c; + while((c = getc(stdin), c != EOF)) + { + putc(c, stdout); + } + return 0; +} diff --git a/Tests/CustomCommand/wrapped.h b/Tests/CustomCommand/wrapped.h new file mode 100644 index 000000000..fa882cb5b --- /dev/null +++ b/Tests/CustomCommand/wrapped.h @@ -0,0 +1 @@ +/* empty file */ diff --git a/Tests/CustomCommand/wrapper.cxx b/Tests/CustomCommand/wrapper.cxx new file mode 100644 index 000000000..93cb079fe --- /dev/null +++ b/Tests/CustomCommand/wrapper.cxx @@ -0,0 +1,36 @@ +#include <stdio.h> +#include <string.h> + +int main(int argc, char *argv[]) +{ + if ( argc < 3 ) + { + fprintf(stderr, "Usage: %s <file1> <file2>\n", argv[0]); + return 1; + } + FILE *fp = fopen(argv[1],"w"); + fprintf(fp,"extern int wrapped_help();\n"); + fprintf(fp,"int wrapped() { return wrapped_help(); }\n"); + fclose(fp); + fp = fopen(argv[2],"w"); + fprintf(fp,"int wrapped_help() { return 5; }\n"); + fclose(fp); +#ifdef CMAKE_INTDIR + /* The VS6 IDE passes a leading ".\\" in its variable expansion. */ +# if defined(_MSC_VER) && _MSC_VER == 1200 +# define CFG_DIR ".\\" CMAKE_INTDIR +# else +# define CFG_DIR CMAKE_INTDIR +# endif + const char* cfg = (argc >= 4)? argv[3] : ""; + if(strcmp(cfg, CFG_DIR) != 0) + { + fprintf(stderr, + "Did not receive expected configuration argument:\n" + " expected [" CFG_DIR "]\n" + " received [%s]\n", cfg); + return 1; + } +#endif + return 0; +} diff --git a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt new file mode 100644 index 000000000..36d32e4a0 --- /dev/null +++ b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(TestWorkingDir) + +ADD_CUSTOM_COMMAND( + OUTPUT "${TestWorkingDir_BINARY_DIR}/working.c" + COMMAND "${CMAKE_COMMAND}" -E copy ./working.c.in "${TestWorkingDir_BINARY_DIR}/working.c" + WORKING_DIRECTORY "${TestWorkingDir_SOURCE_DIR}" + COMMENT "custom command" +) + +SET_SOURCE_FILES_PROPERTIES( + "${TestWorkingDir_BINARY_DIR}/customTarget.c" + "${TestWorkingDir_BINARY_DIR}/customTarget2.c" + PROPERTIES GENERATED 1) + +ADD_EXECUTABLE(working "${TestWorkingDir_BINARY_DIR}/working.c" + "${TestWorkingDir_BINARY_DIR}/customTarget.c") + +ADD_CUSTOM_TARGET( + Custom ALL + COMMAND "${CMAKE_COMMAND}" -E copy_if_different ./customTarget.c "${TestWorkingDir_BINARY_DIR}/customTarget.c" + WORKING_DIRECTORY "${TestWorkingDir_SOURCE_DIR}" +) + +ADD_DEPENDENCIES(working Custom) + +file(MAKE_DIRECTORY ${TestWorkingDir_BINARY_DIR}/work) +add_custom_command( + OUTPUT working2.c # Relative to build tree + COMMAND "${CMAKE_COMMAND}" -E copy ${TestWorkingDir_SOURCE_DIR}/working.c.in ../working2.c + DEPENDS ${TestWorkingDir_SOURCE_DIR}/working.c.in/ # trailing slash should be removed + WORKING_DIRECTORY work/ # Relative to build tree, trailing slash + ) +add_executable(working2 working2.c ${TestWorkingDir_BINARY_DIR}/customTarget2.c) + +add_custom_target( + Custom2 ALL + COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${TestWorkingDir_SOURCE_DIR}/customTarget.c ../customTarget2.c + WORKING_DIRECTORY work/ # Relative to build tree, trailing slash +) + +add_dependencies(working2 Custom2) diff --git a/Tests/CustomCommandWorkingDirectory/customTarget.c b/Tests/CustomCommandWorkingDirectory/customTarget.c new file mode 100644 index 000000000..8dbf0d478 --- /dev/null +++ b/Tests/CustomCommandWorkingDirectory/customTarget.c @@ -0,0 +1,4 @@ +int customTarget() +{ + return 0; +} diff --git a/Tests/CustomCommandWorkingDirectory/working.c.in b/Tests/CustomCommandWorkingDirectory/working.c.in new file mode 100644 index 000000000..cf75bd164 --- /dev/null +++ b/Tests/CustomCommandWorkingDirectory/working.c.in @@ -0,0 +1,7 @@ +int customTarget(); + +int main() +{ + return customTarget(); +} + diff --git a/Tests/CxxOnly/CMakeLists.txt b/Tests/CxxOnly/CMakeLists.txt new file mode 100644 index 000000000..e62f3c797 --- /dev/null +++ b/Tests/CxxOnly/CMakeLists.txt @@ -0,0 +1,13 @@ +# a simple CXX only test case +project (CxxOnly CXX) + +set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") +if(WIN32) + set(EXTRA_SRCS test.CPP) +endif() +add_library(testcxx1.my STATIC libcxx1.cxx ${EXTRA_SRCS}) +add_library(testcxx2 SHARED libcxx2.cxx) +add_executable (CxxOnly cxxonly.cxx) +target_link_libraries(CxxOnly testcxx1.my testcxx2) + +add_library(testCxxModule MODULE testCxxModule.cxx) diff --git a/Tests/CxxOnly/cxxonly.cxx b/Tests/CxxOnly/cxxonly.cxx new file mode 100644 index 000000000..9cf6f2d29 --- /dev/null +++ b/Tests/CxxOnly/cxxonly.cxx @@ -0,0 +1,25 @@ +#include "libcxx1.h" +#include "libcxx2.h" +#ifdef _MSC_VER +extern int testCPP; +#endif + +#include <stdio.h> + +int main () +{ +#ifdef _MSC_VER + testCPP = 1; +#endif + if ( LibCxx1Class::Method() != 2.0 ) + { + printf("Problem with libcxx1\n"); + return 1; + } + if ( LibCxx2Class::Method() != 1.0 ) + { + printf("Problem with libcxx2\n"); + return 1; + } + return 0; +} diff --git a/Tests/CxxOnly/libcxx1.cxx b/Tests/CxxOnly/libcxx1.cxx new file mode 100644 index 000000000..da18019d3 --- /dev/null +++ b/Tests/CxxOnly/libcxx1.cxx @@ -0,0 +1,6 @@ +#include "libcxx1.h" + +float LibCxx1Class::Method() +{ + return 2.0; +} diff --git a/Tests/CxxOnly/libcxx1.h b/Tests/CxxOnly/libcxx1.h new file mode 100644 index 000000000..9452a64b1 --- /dev/null +++ b/Tests/CxxOnly/libcxx1.h @@ -0,0 +1,5 @@ +class LibCxx1Class +{ +public: + static float Method(); +}; diff --git a/Tests/CxxOnly/libcxx2.cxx b/Tests/CxxOnly/libcxx2.cxx new file mode 100644 index 000000000..453039c58 --- /dev/null +++ b/Tests/CxxOnly/libcxx2.cxx @@ -0,0 +1,6 @@ +#include "libcxx2.h" + +float LibCxx2Class::Method() +{ + return 1.0; +} diff --git a/Tests/CxxOnly/libcxx2.h b/Tests/CxxOnly/libcxx2.h new file mode 100644 index 000000000..5dd84f6c2 --- /dev/null +++ b/Tests/CxxOnly/libcxx2.h @@ -0,0 +1,15 @@ +#ifdef _WIN32 +# ifdef testcxx2_EXPORTS +# define CM_TEST_LIB_EXPORT __declspec( dllexport ) +# else +# define CM_TEST_LIB_EXPORT __declspec( dllimport ) +# endif +#else +# define CM_TEST_LIB_EXPORT +#endif + +class CM_TEST_LIB_EXPORT LibCxx2Class +{ +public: + static float Method(); +}; diff --git a/Tests/CxxOnly/test.CPP b/Tests/CxxOnly/test.CPP new file mode 100644 index 000000000..8a3cde262 --- /dev/null +++ b/Tests/CxxOnly/test.CPP @@ -0,0 +1 @@ +int testCPP; diff --git a/Tests/CxxOnly/testCxxModule.cxx b/Tests/CxxOnly/testCxxModule.cxx new file mode 100644 index 000000000..dd16d2bfa --- /dev/null +++ b/Tests/CxxOnly/testCxxModule.cxx @@ -0,0 +1,6 @@ +#ifdef _WIN32 +# define TEST_EXPORT __declspec(dllexport) +#else +# define TEST_EXPORT +#endif +TEST_EXPORT int testCxxModule(void) { return 0; } diff --git a/Tests/Dependency/1/CMakeLists.txt b/Tests/Dependency/1/CMakeLists.txt new file mode 100644 index 000000000..b50b2e9c5 --- /dev/null +++ b/Tests/Dependency/1/CMakeLists.txt @@ -0,0 +1,3 @@ +ADD_LIBRARY( One OneSrc.c ) +# This library has no dependencies +TARGET_LINK_LIBRARIES( One "" ) diff --git a/Tests/Dependency/1/OneSrc.c b/Tests/Dependency/1/OneSrc.c new file mode 100644 index 000000000..9801c2524 --- /dev/null +++ b/Tests/Dependency/1/OneSrc.c @@ -0,0 +1,3 @@ +void OneFunction() +{ +} diff --git a/Tests/Dependency/CMakeLists.txt b/Tests/Dependency/CMakeLists.txt new file mode 100644 index 000000000..86e128f58 --- /dev/null +++ b/Tests/Dependency/CMakeLists.txt @@ -0,0 +1,53 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT( Dependency ) + +# to test directories with only one character One was changed to 1 +# There is one executable that depends on eight libraries. The +# system has the following dependency graph: +# +# NoDepA: +# NoDepB: NoDepA +# NoDepC: NoDepA +# 1: +# Two: Three +# Three: 1 Four +# Four: 1 Two NoDepA +# Five: Two +# SixA: Two Five +# SixB: Four Five +# Seven: Two +# Eight: Seven +# +# Exec: NoDepB NoDepC SixA SixB +# Exec2: Eight Five +# Exec3: Eight Five +# Exec4: Five Two +# +# The libraries One,...,Eight have their dependencies explicitly +# encoded. The libraries NoDepA,...,NoDepC do not. +# +# Although SixB does not depend on Two, there is a dependency listed +# in the corresponding CMakeLists.txt just because of commands used. + +ADD_SUBDIRECTORY(NoDepA) +ADD_SUBDIRECTORY(NoDepB) +ADD_SUBDIRECTORY(NoDepC) +ADD_SUBDIRECTORY(1) +ADD_SUBDIRECTORY(Two) +ADD_SUBDIRECTORY(Three) +ADD_SUBDIRECTORY(Four) +ADD_SUBDIRECTORY(Five) +ADD_SUBDIRECTORY(Six) +ADD_SUBDIRECTORY(Seven) +ADD_SUBDIRECTORY(Eight) +ADD_SUBDIRECTORY(Exec) +ADD_SUBDIRECTORY(Exec2) +ADD_SUBDIRECTORY(Exec3) +ADD_SUBDIRECTORY(Exec4) + +# Specific cases added to test fixes to problems found in real +# projects. +ADD_SUBDIRECTORY(Case1) +ADD_SUBDIRECTORY(Case2) +ADD_SUBDIRECTORY(Case3) +ADD_SUBDIRECTORY(Case4) diff --git a/Tests/Dependency/Case1/CMakeLists.txt b/Tests/Dependency/Case1/CMakeLists.txt new file mode 100644 index 000000000..4c5fc2037 --- /dev/null +++ b/Tests/Dependency/Case1/CMakeLists.txt @@ -0,0 +1,19 @@ +project(CASE1) + +# The old anaylize lib depends stuff in cmTarget gets this case wrong. +# The cmComputeLinkDepends implementation gets it right. + +add_library(case1a STATIC a.c) + +add_library(case1b STATIC b.c b2.c) +target_link_libraries(case1b case1a) + +add_library(case1c STATIC c.c c2.c) +target_link_libraries(case1c case1b) + +add_library(case1d STATIC d.c) +target_link_libraries(case1d case1c) + +add_executable(hello main.c) +target_link_libraries(hello case1c case1b case1d case1c) + diff --git a/Tests/Dependency/Case1/a.c b/Tests/Dependency/Case1/a.c new file mode 100644 index 000000000..d702db1af --- /dev/null +++ b/Tests/Dependency/Case1/a.c @@ -0,0 +1,5 @@ +int a() +{ + return 5; +} + diff --git a/Tests/Dependency/Case1/b.c b/Tests/Dependency/Case1/b.c new file mode 100644 index 000000000..6bdfafafb --- /dev/null +++ b/Tests/Dependency/Case1/b.c @@ -0,0 +1,6 @@ +extern int a(); + +int b() +{ + return a()+17; +} diff --git a/Tests/Dependency/Case1/b2.c b/Tests/Dependency/Case1/b2.c new file mode 100644 index 000000000..f37e1bb75 --- /dev/null +++ b/Tests/Dependency/Case1/b2.c @@ -0,0 +1,4 @@ +int b2() +{ + return 3; +} diff --git a/Tests/Dependency/Case1/c.c b/Tests/Dependency/Case1/c.c new file mode 100644 index 000000000..c180a59b6 --- /dev/null +++ b/Tests/Dependency/Case1/c.c @@ -0,0 +1,6 @@ +extern int b(); + +int c() +{ + return b()+42; +} diff --git a/Tests/Dependency/Case1/c2.c b/Tests/Dependency/Case1/c2.c new file mode 100644 index 000000000..4cf4426e5 --- /dev/null +++ b/Tests/Dependency/Case1/c2.c @@ -0,0 +1,6 @@ +extern int b2(); + +int c2() +{ + return b2()+1; +} diff --git a/Tests/Dependency/Case1/d.c b/Tests/Dependency/Case1/d.c new file mode 100644 index 000000000..ea5457d4d --- /dev/null +++ b/Tests/Dependency/Case1/d.c @@ -0,0 +1,7 @@ +extern int c2(); + +int d() +{ + return c2()+2; +} + diff --git a/Tests/Dependency/Case1/main.c b/Tests/Dependency/Case1/main.c new file mode 100644 index 000000000..1e5f6d4aa --- /dev/null +++ b/Tests/Dependency/Case1/main.c @@ -0,0 +1,10 @@ +extern int b(); +extern int c(); +extern int d(); + +int main() +{ + c(); + b(); + d(); +} diff --git a/Tests/Dependency/Case2/CMakeLists.txt b/Tests/Dependency/Case2/CMakeLists.txt new file mode 100644 index 000000000..21caaad3e --- /dev/null +++ b/Tests/Dependency/Case2/CMakeLists.txt @@ -0,0 +1,22 @@ +project(CASE2 C) + +add_library(case2Foo1 STATIC foo1.c foo1b.c foo1c.c) +add_library(case2Foo2 STATIC foo2.c foo2b.c foo2c.c) +add_library(case2Foo3 STATIC foo3.c foo3b.c foo3c.c) +target_link_libraries(case2Foo1 case2Foo2) +target_link_libraries(case2Foo2 case2Foo3) +target_link_libraries(case2Foo3 case2Foo1) +set_property(TARGET case2Foo1 PROPERTY LINK_INTERFACE_MULTIPLICITY 3) + +add_library(case2Bar1 STATIC bar1.c) +add_library(case2Bar2 STATIC bar2.c) +add_library(case2Bar3 STATIC bar3.c) +target_link_libraries(case2Bar1 case2Bar2 case2Foo1) +target_link_libraries(case2Bar2 case2Bar3) +target_link_libraries(case2Bar3 case2Bar1) + +add_executable(case2Zot zot.c) +target_link_libraries(case2Zot case2Bar1) + +#set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1) +#set(CMAKE_LINK_DEPENDS_DEBUG_MODE 1) diff --git a/Tests/Dependency/Case2/bar1.c b/Tests/Dependency/Case2/bar1.c new file mode 100644 index 000000000..6108fba72 --- /dev/null +++ b/Tests/Dependency/Case2/bar1.c @@ -0,0 +1,4 @@ +extern int foo1(); +extern int bar2(void); +int bar1(void) { return bar2(); } +int bar1_from_bar3(void) { return foo1(); } diff --git a/Tests/Dependency/Case2/bar2.c b/Tests/Dependency/Case2/bar2.c new file mode 100644 index 000000000..b9a236090 --- /dev/null +++ b/Tests/Dependency/Case2/bar2.c @@ -0,0 +1,2 @@ +extern int bar3(void); +int bar2(void) { return bar3(); } diff --git a/Tests/Dependency/Case2/bar3.c b/Tests/Dependency/Case2/bar3.c new file mode 100644 index 000000000..73e85567a --- /dev/null +++ b/Tests/Dependency/Case2/bar3.c @@ -0,0 +1,2 @@ +extern int bar1_from_bar3(void); +int bar3(void) { return bar1_from_bar3(); } diff --git a/Tests/Dependency/Case2/foo1.c b/Tests/Dependency/Case2/foo1.c new file mode 100644 index 000000000..5f1f8ac84 --- /dev/null +++ b/Tests/Dependency/Case2/foo1.c @@ -0,0 +1,2 @@ +extern int foo2(void); +int foo1(void) { return foo2(); } diff --git a/Tests/Dependency/Case2/foo1b.c b/Tests/Dependency/Case2/foo1b.c new file mode 100644 index 000000000..e2b6dc341 --- /dev/null +++ b/Tests/Dependency/Case2/foo1b.c @@ -0,0 +1,2 @@ +extern int foo2b(void); +int foo1b(void) { return foo2b(); } diff --git a/Tests/Dependency/Case2/foo1c.c b/Tests/Dependency/Case2/foo1c.c new file mode 100644 index 000000000..1dcca58c6 --- /dev/null +++ b/Tests/Dependency/Case2/foo1c.c @@ -0,0 +1,2 @@ +extern int foo2c(void); +int foo1c(void) { return foo2c(); } diff --git a/Tests/Dependency/Case2/foo2.c b/Tests/Dependency/Case2/foo2.c new file mode 100644 index 000000000..601923663 --- /dev/null +++ b/Tests/Dependency/Case2/foo2.c @@ -0,0 +1,2 @@ +extern int foo3(void); +int foo2(void) { return foo3(); } diff --git a/Tests/Dependency/Case2/foo2b.c b/Tests/Dependency/Case2/foo2b.c new file mode 100644 index 000000000..34d694411 --- /dev/null +++ b/Tests/Dependency/Case2/foo2b.c @@ -0,0 +1,2 @@ +extern int foo3b(void); +int foo2b(void) { return foo3b(); } diff --git a/Tests/Dependency/Case2/foo2c.c b/Tests/Dependency/Case2/foo2c.c new file mode 100644 index 000000000..dbc54de74 --- /dev/null +++ b/Tests/Dependency/Case2/foo2c.c @@ -0,0 +1,2 @@ +extern int foo3c(void); +int foo2c(void) { return foo3c(); } diff --git a/Tests/Dependency/Case2/foo3.c b/Tests/Dependency/Case2/foo3.c new file mode 100644 index 000000000..dacef6ae4 --- /dev/null +++ b/Tests/Dependency/Case2/foo3.c @@ -0,0 +1,2 @@ +extern int foo1b(void); +int foo3(void) { return foo1b(); } diff --git a/Tests/Dependency/Case2/foo3b.c b/Tests/Dependency/Case2/foo3b.c new file mode 100644 index 000000000..ca25fd8ff --- /dev/null +++ b/Tests/Dependency/Case2/foo3b.c @@ -0,0 +1,2 @@ +extern int foo1c(void); +int foo3b(void) { return foo1c(); } diff --git a/Tests/Dependency/Case2/foo3c.c b/Tests/Dependency/Case2/foo3c.c new file mode 100644 index 000000000..0ad65fe44 --- /dev/null +++ b/Tests/Dependency/Case2/foo3c.c @@ -0,0 +1 @@ +int foo3c(void) { return 0; } diff --git a/Tests/Dependency/Case2/zot.c b/Tests/Dependency/Case2/zot.c new file mode 100644 index 000000000..f25b49343 --- /dev/null +++ b/Tests/Dependency/Case2/zot.c @@ -0,0 +1,5 @@ +extern int bar1(void); +int main(void) +{ + return bar1(); +} diff --git a/Tests/Dependency/Case3/CMakeLists.txt b/Tests/Dependency/Case3/CMakeLists.txt new file mode 100644 index 000000000..f01dd057a --- /dev/null +++ b/Tests/Dependency/Case3/CMakeLists.txt @@ -0,0 +1,10 @@ +project(CASE3 C) + +add_library(case3Foo1 STATIC foo1.c foo1b.c) +add_library(case3Foo2 STATIC foo2.c) + +add_executable(case3Bar bar.c) +target_link_libraries(case3Bar case3Foo1 case3Foo2 case3Foo1) + +#set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1) +#set(CMAKE_LINK_DEPENDS_DEBUG_MODE 1) diff --git a/Tests/Dependency/Case3/bar.c b/Tests/Dependency/Case3/bar.c new file mode 100644 index 000000000..62959c1cb --- /dev/null +++ b/Tests/Dependency/Case3/bar.c @@ -0,0 +1,5 @@ +extern int foo1(void); +int main(void) +{ + return foo1(); +} diff --git a/Tests/Dependency/Case3/foo1.c b/Tests/Dependency/Case3/foo1.c new file mode 100644 index 000000000..5f1f8ac84 --- /dev/null +++ b/Tests/Dependency/Case3/foo1.c @@ -0,0 +1,2 @@ +extern int foo2(void); +int foo1(void) { return foo2(); } diff --git a/Tests/Dependency/Case3/foo1b.c b/Tests/Dependency/Case3/foo1b.c new file mode 100644 index 000000000..6ae3babdc --- /dev/null +++ b/Tests/Dependency/Case3/foo1b.c @@ -0,0 +1 @@ +int foo1b(void) { return 0; } diff --git a/Tests/Dependency/Case3/foo2.c b/Tests/Dependency/Case3/foo2.c new file mode 100644 index 000000000..33dbbfce6 --- /dev/null +++ b/Tests/Dependency/Case3/foo2.c @@ -0,0 +1,2 @@ +extern int foo1b(void); +int foo2(void) { return foo1b(); } diff --git a/Tests/Dependency/Case4/CMakeLists.txt b/Tests/Dependency/Case4/CMakeLists.txt new file mode 100644 index 000000000..a71049da3 --- /dev/null +++ b/Tests/Dependency/Case4/CMakeLists.txt @@ -0,0 +1,19 @@ +project(CASE4 C) + +# This is not really a circular dependency. "case4Bar" refers to a +# third-party library that happens to match the executable name, which +# is okay when the executable is not a linkable target (ENABLE_EXPORTS +# is not set). This tests whether CMake avoids incorrectly reporting +# a circular dependency. In practice case4Foo may be a shared +# library, but we skip that here because we do not want it to actually +# have to find the third-party library. +add_library(case4Foo STATIC foo.c) +target_link_libraries(case4Foo case4Bar) + +# The executable avoids linking to a library with its own name, which +# has been a CMake-ism for a long time, so we will not get a link +# failure. An imported target or executable with an OUTPUT_NAME set +# may be used if the user really wants to link a third-party library +# into an executable of the same name. +add_executable(case4Bar bar.c) +target_link_libraries(case4Bar case4Foo) diff --git a/Tests/Dependency/Case4/bar.c b/Tests/Dependency/Case4/bar.c new file mode 100644 index 000000000..d0bb0c43c --- /dev/null +++ b/Tests/Dependency/Case4/bar.c @@ -0,0 +1,2 @@ +extern int foo(); +int main() { return foo(); } diff --git a/Tests/Dependency/Case4/foo.c b/Tests/Dependency/Case4/foo.c new file mode 100644 index 000000000..9fe07f82f --- /dev/null +++ b/Tests/Dependency/Case4/foo.c @@ -0,0 +1 @@ +int foo() { return 0; } diff --git a/Tests/Dependency/Eight/CMakeLists.txt b/Tests/Dependency/Eight/CMakeLists.txt new file mode 100644 index 000000000..5d8e7564e --- /dev/null +++ b/Tests/Dependency/Eight/CMakeLists.txt @@ -0,0 +1,3 @@ +ADD_LIBRARY( Eight EightSrc.c ) +TARGET_LINK_LIBRARIES( Eight Seven ) + diff --git a/Tests/Dependency/Eight/EightSrc.c b/Tests/Dependency/Eight/EightSrc.c new file mode 100644 index 000000000..7bfa481e2 --- /dev/null +++ b/Tests/Dependency/Eight/EightSrc.c @@ -0,0 +1,6 @@ +void SevenFunction(); + +void EightFunction() +{ + SevenFunction(); +} diff --git a/Tests/Dependency/Exec/CMakeLists.txt b/Tests/Dependency/Exec/CMakeLists.txt new file mode 100644 index 000000000..97fffe706 --- /dev/null +++ b/Tests/Dependency/Exec/CMakeLists.txt @@ -0,0 +1,7 @@ +# This executable directly depends on NoDepB, NoDepC, SixA and SixB. However, +# since NoDepB and NoDepC do not have explicit dependency information, +# and they depend on NoDepA, we have to manually specify that dependency. +LINK_LIBRARIES( NoDepB NoDepC NoDepA SixB SixA ) + +ADD_EXECUTABLE( exec ExecMain.c ) + diff --git a/Tests/Dependency/Exec/ExecMain.c b/Tests/Dependency/Exec/ExecMain.c new file mode 100644 index 000000000..d2f551c7a --- /dev/null +++ b/Tests/Dependency/Exec/ExecMain.c @@ -0,0 +1,18 @@ +#include <stdio.h> + +void NoDepBFunction(); +void NoDepCFunction(); +void SixAFunction(); +void SixBFunction(); + +int main( ) +{ + SixAFunction(); + SixBFunction(); + NoDepBFunction(); + NoDepCFunction(); + + printf("Dependency test executable ran successfully.\n"); + + return 0; +} diff --git a/Tests/Dependency/Exec2/CMakeLists.txt b/Tests/Dependency/Exec2/CMakeLists.txt new file mode 100644 index 000000000..ee0c74d13 --- /dev/null +++ b/Tests/Dependency/Exec2/CMakeLists.txt @@ -0,0 +1,12 @@ +# Here, Eight depends on Seven, which has the same dependencies as Five. +# If the dependencies of Five are emitted, and then we attempt to emit the +# dependencies of Seven, then we find that they have already been done. So: +# Original line: Eight Five +# Add deps of Five: Eight Five Two ... NoDepA +# Now, we must make sure that Seven gets inserted between Five and Two, and +# not at the end. Unfortunately, if we get it wrong, the test will only +# fail on a platform where the link order makes a difference. +LINK_LIBRARIES( Eight Five ) + +ADD_EXECUTABLE( exec2 ExecMain.c ) + diff --git a/Tests/Dependency/Exec2/ExecMain.c b/Tests/Dependency/Exec2/ExecMain.c new file mode 100644 index 000000000..d08a796c3 --- /dev/null +++ b/Tests/Dependency/Exec2/ExecMain.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void FiveFunction(); +void EightFunction(); + +int main( ) +{ + FiveFunction(); + EightFunction(); + + printf("Dependency test executable ran successfully.\n"); + + return 0; +} diff --git a/Tests/Dependency/Exec3/CMakeLists.txt b/Tests/Dependency/Exec3/CMakeLists.txt new file mode 100644 index 000000000..b33e732a2 --- /dev/null +++ b/Tests/Dependency/Exec3/CMakeLists.txt @@ -0,0 +1,6 @@ +# Here, Five already has it's immediate dependency, Two satisfied. We must +# make sure Two gets output anyway, because Eight indirectly depends on it. +LINK_LIBRARIES( Five Two Eight Five ) + +ADD_EXECUTABLE( exec3 ExecMain.c ) + diff --git a/Tests/Dependency/Exec3/ExecMain.c b/Tests/Dependency/Exec3/ExecMain.c new file mode 100644 index 000000000..d08a796c3 --- /dev/null +++ b/Tests/Dependency/Exec3/ExecMain.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void FiveFunction(); +void EightFunction(); + +int main( ) +{ + FiveFunction(); + EightFunction(); + + printf("Dependency test executable ran successfully.\n"); + + return 0; +} diff --git a/Tests/Dependency/Exec4/CMakeLists.txt b/Tests/Dependency/Exec4/CMakeLists.txt new file mode 100644 index 000000000..6fcb15383 --- /dev/null +++ b/Tests/Dependency/Exec4/CMakeLists.txt @@ -0,0 +1,6 @@ +# Even though Five's dependency on Two is explicitly satisfied, Two +# must be emitted again in order to satisfy a cyclic dependency on Three. +LINK_LIBRARIES( Five Two Five ) + +ADD_EXECUTABLE( exec4 ExecMain.c ) + diff --git a/Tests/Dependency/Exec4/ExecMain.c b/Tests/Dependency/Exec4/ExecMain.c new file mode 100644 index 000000000..3f53573bf --- /dev/null +++ b/Tests/Dependency/Exec4/ExecMain.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void FiveFunction(); +void TwoFunction(); + +int main( ) +{ + FiveFunction(); + TwoFunction(); + + printf("Dependency test executable ran successfully.\n"); + + return 0; +} diff --git a/Tests/Dependency/Five/CMakeLists.txt b/Tests/Dependency/Five/CMakeLists.txt new file mode 100644 index 000000000..27f6a1f5b --- /dev/null +++ b/Tests/Dependency/Five/CMakeLists.txt @@ -0,0 +1,3 @@ +ADD_LIBRARY( Five FiveSrc.c ) +TARGET_LINK_LIBRARIES( Five Two ) + diff --git a/Tests/Dependency/Five/FiveSrc.c b/Tests/Dependency/Five/FiveSrc.c new file mode 100644 index 000000000..33d8ad7dc --- /dev/null +++ b/Tests/Dependency/Five/FiveSrc.c @@ -0,0 +1,6 @@ +void TwoFunction(); + +void FiveFunction() +{ + TwoFunction(); +} diff --git a/Tests/Dependency/Four/CMakeLists.txt b/Tests/Dependency/Four/CMakeLists.txt new file mode 100644 index 000000000..df0f1624e --- /dev/null +++ b/Tests/Dependency/Four/CMakeLists.txt @@ -0,0 +1,6 @@ +INCLUDE_DIRECTORIES(${Dependency_BINARY_DIR}/Two) +ADD_LIBRARY( Four FourSrc.c ) +TARGET_LINK_LIBRARIES( Four One Two NoDepA ) + +# TwoCustom must build before Four. +ADD_DEPENDENCIES(Four TwoCustom) diff --git a/Tests/Dependency/Four/FourSrc.c b/Tests/Dependency/Four/FourSrc.c new file mode 100644 index 000000000..23a66a49a --- /dev/null +++ b/Tests/Dependency/Four/FourSrc.c @@ -0,0 +1,15 @@ +#include <two-test.h> /* Requires TwoCustom to be built first. */ +void NoDepAFunction(); +void OneFunction(); +void TwoFunction(); + +void FourFunction() +{ + static int count = 0; + if( count == 0 ) { + ++count; + TwoFunction(); + } + OneFunction(); + NoDepAFunction(); +} diff --git a/Tests/Dependency/NoDepA/CMakeLists.txt b/Tests/Dependency/NoDepA/CMakeLists.txt new file mode 100644 index 000000000..cedf185fa --- /dev/null +++ b/Tests/Dependency/NoDepA/CMakeLists.txt @@ -0,0 +1 @@ +ADD_LIBRARY( NoDepA NoDepASrc.c ) diff --git a/Tests/Dependency/NoDepA/NoDepASrc.c b/Tests/Dependency/NoDepA/NoDepASrc.c new file mode 100644 index 000000000..8c4072bd1 --- /dev/null +++ b/Tests/Dependency/NoDepA/NoDepASrc.c @@ -0,0 +1,3 @@ +void NoDepAFunction() +{ +} diff --git a/Tests/Dependency/NoDepB/CMakeLists.txt b/Tests/Dependency/NoDepB/CMakeLists.txt new file mode 100644 index 000000000..0d69f6841 --- /dev/null +++ b/Tests/Dependency/NoDepB/CMakeLists.txt @@ -0,0 +1,3 @@ +ADD_LIBRARY( NoDepB NoDepBSrc.c ) +# This library depends on NoDepA, but the +# dependency is not explicitly specified. diff --git a/Tests/Dependency/NoDepB/NoDepBSrc.c b/Tests/Dependency/NoDepB/NoDepBSrc.c new file mode 100644 index 000000000..ddc71c527 --- /dev/null +++ b/Tests/Dependency/NoDepB/NoDepBSrc.c @@ -0,0 +1,6 @@ +void NoDepAFunction(); + +void NoDepBFunction() +{ + NoDepAFunction(); +} diff --git a/Tests/Dependency/NoDepC/CMakeLists.txt b/Tests/Dependency/NoDepC/CMakeLists.txt new file mode 100644 index 000000000..88b29ba6f --- /dev/null +++ b/Tests/Dependency/NoDepC/CMakeLists.txt @@ -0,0 +1,3 @@ +ADD_LIBRARY( NoDepC NoDepCSrc.c ) +# This library depends on NoDepA, but the +# dependency is not explicitly specified. diff --git a/Tests/Dependency/NoDepC/NoDepCSrc.c b/Tests/Dependency/NoDepC/NoDepCSrc.c new file mode 100644 index 000000000..b478c596d --- /dev/null +++ b/Tests/Dependency/NoDepC/NoDepCSrc.c @@ -0,0 +1,6 @@ +void NoDepAFunction(); + +void NoDepCFunction() +{ + NoDepAFunction(); +} diff --git a/Tests/Dependency/Seven/CMakeLists.txt b/Tests/Dependency/Seven/CMakeLists.txt new file mode 100644 index 000000000..51a38d8ed --- /dev/null +++ b/Tests/Dependency/Seven/CMakeLists.txt @@ -0,0 +1,3 @@ +ADD_LIBRARY( Seven SevenSrc.c ) +TARGET_LINK_LIBRARIES( Seven Two ) + diff --git a/Tests/Dependency/Seven/SevenSrc.c b/Tests/Dependency/Seven/SevenSrc.c new file mode 100644 index 000000000..e1f3329e8 --- /dev/null +++ b/Tests/Dependency/Seven/SevenSrc.c @@ -0,0 +1,6 @@ +void TwoFunction(); + +void SevenFunction() +{ + TwoFunction(); +} diff --git a/Tests/Dependency/Six/CMakeLists.txt b/Tests/Dependency/Six/CMakeLists.txt new file mode 100644 index 000000000..d0abdd695 --- /dev/null +++ b/Tests/Dependency/Six/CMakeLists.txt @@ -0,0 +1,12 @@ +# In some projects, people don't use TARGET_LINK_LIBRARIES, but just +# use an all-encompassing LINK_LIBRARIES. And sometimes they don't +# specify them in the correct order. + +LINK_LIBRARIES( Two ) +LINK_LIBRARIES( Five ) + +ADD_LIBRARY( SixA SixASrc.c ) + +ADD_LIBRARY( SixB SixBSrc.c ) +TARGET_LINK_LIBRARIES( SixB Four ) + diff --git a/Tests/Dependency/Six/SixASrc.c b/Tests/Dependency/Six/SixASrc.c new file mode 100644 index 000000000..7ea3711f2 --- /dev/null +++ b/Tests/Dependency/Six/SixASrc.c @@ -0,0 +1,8 @@ +void FiveFunction(); +void TwoFunction(); + +void SixAFunction() +{ + FiveFunction(); + TwoFunction(); +} diff --git a/Tests/Dependency/Six/SixBSrc.c b/Tests/Dependency/Six/SixBSrc.c new file mode 100644 index 000000000..92f9607f8 --- /dev/null +++ b/Tests/Dependency/Six/SixBSrc.c @@ -0,0 +1,10 @@ +void TwoFunction(); +void FiveFunction(); +void FourFunction(); + +void SixBFunction() +{ + TwoFunction(); + FiveFunction(); + FourFunction(); +} diff --git a/Tests/Dependency/Three/CMakeLists.txt b/Tests/Dependency/Three/CMakeLists.txt new file mode 100644 index 000000000..6b20dcb81 --- /dev/null +++ b/Tests/Dependency/Three/CMakeLists.txt @@ -0,0 +1,3 @@ +ADD_LIBRARY( Three ThreeSrc.c ) +TARGET_LINK_LIBRARIES( Three One Four ) + diff --git a/Tests/Dependency/Three/ThreeSrc.c b/Tests/Dependency/Three/ThreeSrc.c new file mode 100644 index 000000000..9c77f17a0 --- /dev/null +++ b/Tests/Dependency/Three/ThreeSrc.c @@ -0,0 +1,12 @@ +void OneFunction(); +void FourFunction(); + +void ThreeFunction() +{ + static int count = 0; + if( count == 0 ) { + ++count; + FourFunction(); + } + OneFunction(); +} diff --git a/Tests/Dependency/Two/CMakeLists.txt b/Tests/Dependency/Two/CMakeLists.txt new file mode 100644 index 000000000..587c848f7 --- /dev/null +++ b/Tests/Dependency/Two/CMakeLists.txt @@ -0,0 +1,20 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +ADD_LIBRARY( Two TwoSrc.c ) +TARGET_LINK_LIBRARIES( Two Three ) + +# Setup a target to cause failure if Two does not depend on it or if +# Two actually links to it. This will test that a utility dependency +# on a library target works properly. +ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/two-test.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/two-test.h.in + ${CMAKE_CURRENT_BINARY_DIR}/two-test.h + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/two-test.h.in + ) +ADD_LIBRARY( TwoCustom TwoCustomSrc.c ${CMAKE_CURRENT_BINARY_DIR}/two-test.h) +SET_TARGET_PROPERTIES(TwoCustom PROPERTIES EXCLUDE_FROM_ALL 1) +TARGET_LINK_LIBRARIES(TwoCustom Three) + +# Add a utility dependency to make sure it works without linking. +ADD_DEPENDENCIES(Two TwoCustom) diff --git a/Tests/Dependency/Two/TwoCustomSrc.c b/Tests/Dependency/Two/TwoCustomSrc.c new file mode 100644 index 000000000..ac31dcf37 --- /dev/null +++ b/Tests/Dependency/Two/TwoCustomSrc.c @@ -0,0 +1,10 @@ +extern void NoFunction(); + +/* Provide a function that is supposed to be found in the Three + library. If Two links to TwoCustom then TwoCustom will come before + Three and this symbol will be used. Since NoFunction is not + defined, that will cause a link failure. */ +void ThreeFunction() +{ + NoFunction(); +} diff --git a/Tests/Dependency/Two/TwoSrc.c b/Tests/Dependency/Two/TwoSrc.c new file mode 100644 index 000000000..0b3366b2b --- /dev/null +++ b/Tests/Dependency/Two/TwoSrc.c @@ -0,0 +1,10 @@ +#include <two-test.h> + +void TwoFunction() +{ + static int count = 0; + if( count == 0 ) { + ++count; + ThreeFunction(); + } +} diff --git a/Tests/Dependency/Two/two-test.h.in b/Tests/Dependency/Two/two-test.h.in new file mode 100644 index 000000000..8c6a7f770 --- /dev/null +++ b/Tests/Dependency/Two/two-test.h.in @@ -0,0 +1 @@ +extern void ThreeFunction(); diff --git a/Tests/DocTest/CMakeLists.txt b/Tests/DocTest/CMakeLists.txt new file mode 100644 index 000000000..837328e81 --- /dev/null +++ b/Tests/DocTest/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 2.6) +project (DocTest) + +add_executable (DocTest DocTest.cxx) + +set_property(GLOBAL PROPERTY REPORT_UNDEFINED_PROPERTIES + "${CMAKE_CURRENT_BINARY_DIR}/UndefinedProperties.txt") diff --git a/Tests/DocTest/DocTest.cxx b/Tests/DocTest/DocTest.cxx new file mode 100644 index 000000000..2263cbd73 --- /dev/null +++ b/Tests/DocTest/DocTest.cxx @@ -0,0 +1,33 @@ +#include <fstream> +#include <iostream> +#include <stdio.h> + +int main () +{ + int result = 0; + + // parse the dart test file + std::ifstream fin("UndefinedProperties.txt"); + if(!fin) + { + fprintf(stderr,"failed to find undefined properties file"); + return 1; + } + + char buffer[1024]; + while ( fin ) + { + buffer[0] = 0; + fin.getline(buffer, 1023); + buffer[1023] = 0; + std::string line = buffer; + if(line.size() && line.find("with scope VARIABLE") == std::string::npos) + { + fprintf(stderr, "%s\n", line.c_str()); + result = 1; + } + } + fin.close(); + + return result; +} diff --git a/Tests/DoubleProject/CMakeLists.txt b/Tests/DoubleProject/CMakeLists.txt new file mode 100644 index 000000000..02a627597 --- /dev/null +++ b/Tests/DoubleProject/CMakeLists.txt @@ -0,0 +1,3 @@ +project(dumb) +project(dumber) +add_executable(just_silly silly.c) diff --git a/Tests/DoubleProject/silly.c b/Tests/DoubleProject/silly.c new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/DoubleProject/silly.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/EmptyLibrary/CMakeLists.txt b/Tests/EmptyLibrary/CMakeLists.txt new file mode 100644 index 000000000..baddbbf5e --- /dev/null +++ b/Tests/EmptyLibrary/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 2.6) +project(TestEmptyLibrary) + +add_subdirectory(subdir) diff --git a/Tests/EmptyLibrary/subdir/CMakeLists.txt b/Tests/EmptyLibrary/subdir/CMakeLists.txt new file mode 100644 index 000000000..e273f8db9 --- /dev/null +++ b/Tests/EmptyLibrary/subdir/CMakeLists.txt @@ -0,0 +1 @@ +add_library(test test.h) diff --git a/Tests/EmptyLibrary/subdir/test.h b/Tests/EmptyLibrary/subdir/test.h new file mode 100644 index 000000000..8511f53d6 --- /dev/null +++ b/Tests/EmptyLibrary/subdir/test.h @@ -0,0 +1 @@ +extern int dummy; diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in new file mode 100644 index 000000000..c9028a391 --- /dev/null +++ b/Tests/EnforceConfig.cmake.in @@ -0,0 +1,26 @@ +# Choose a configuration with which to drive CTest tests. +IF(CTEST_CONFIGURATION_TYPE) + SET(CTestTest_CONFIG "${CTEST_CONFIGURATION_TYPE}") +ELSE(CTEST_CONFIGURATION_TYPE) + SET(CTestTest_CONFIG "@CTestTest_CONFIG@") +ENDIF(CTEST_CONFIGURATION_TYPE) + +# Choose a configuration that was built if none is given. +IF(NOT CTEST_CONFIGURATION_TYPE) + SET(CTEST_CMD "@CMAKE_CTEST_COMMAND@@CMAKE_EXECUTABLE_SUFFIX@") + GET_FILENAME_COMPONENT(CTEST_DIR "${CTEST_CMD}" PATH) + GET_FILENAME_COMPONENT(CTEST_EXE "${CTEST_CMD}" NAME) + FOREACH(cfg Release Debug MinSizeRel RelWithDebInfo) + IF(NOT CTEST_CONFIGURATION_TYPE) + IF(EXISTS "${CTEST_DIR}/${cfg}/${CTEST_EXE}") + SET(CTEST_CONFIGURATION_TYPE ${cfg}) + ENDIF(EXISTS "${CTEST_DIR}/${cfg}/${CTEST_EXE}") + ENDIF(NOT CTEST_CONFIGURATION_TYPE) + ENDFOREACH(cfg) + IF(NOT CTEST_CONFIGURATION_TYPE) + SET(CTEST_CONFIGURATION_TYPE NoConfig) + ENDIF(NOT CTEST_CONFIGURATION_TYPE) + MESSAGE("Guessing configuration ${CTEST_CONFIGURATION_TYPE}") +ENDIF(NOT CTEST_CONFIGURATION_TYPE) + +@TEST_HOME_ENV_CODE@ diff --git a/Tests/Environment/CMakeLists.txt b/Tests/Environment/CMakeLists.txt new file mode 100644 index 000000000..2b18d2466 --- /dev/null +++ b/Tests/Environment/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 2.6) +project(EnvironmentProj) + +add_executable(Environment main.cxx) + +enable_testing() + +add_test(Environment1 Environment) +add_test(Environment2 Environment) +add_test(EchoEnvironment1 ${CMAKE_COMMAND} -E environment) +add_test(EchoEnvironment2 ${CMAKE_COMMAND} -E environment) + +# Make sure "CMAKE_ENV.*Happy Thanksgiving" is in the output of +# the "1" tests: +# +set_tests_properties(Environment1 EchoEnvironment1 PROPERTIES + ENVIRONMENT "CMAKE_ENVIRONMENT_TEST_VAR=Happy Thanksgiving!" + PASS_REGULAR_EXPRESSION "CMAKE_ENV.*Happy Thanksgiving" +) + +# Make sure "CMAKE_ENV.*Happy Thanksgiving" is *NOT* in the output of +# the "2" tests: +# +set_tests_properties(Environment2 EchoEnvironment2 PROPERTIES + FAIL_REGULAR_EXPRESSION "CMAKE_ENV.*Happy Thanksgiving" +) diff --git a/Tests/Environment/main.cxx b/Tests/Environment/main.cxx new file mode 100644 index 000000000..2e1bf4c28 --- /dev/null +++ b/Tests/Environment/main.cxx @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char *argv[]) +{ + char* var = getenv("CMAKE_ENVIRONMENT_TEST_VAR"); + if (!var) + { + var = "(null)"; + } + + fprintf(stdout, "Environment:\n"); + fprintf(stdout, " CMAKE_ENVIRONMENT_TEST_VAR='%s'\n", var); + + return 0; +} diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt new file mode 100644 index 000000000..ccfb8940c --- /dev/null +++ b/Tests/ExportImport/CMakeLists.txt @@ -0,0 +1,75 @@ +cmake_minimum_required (VERSION 2.7.20090711) +project(ExportImport C CXX) + +# Wipe out the install tree to make sure the exporter works. +add_custom_command( + OUTPUT ${ExportImport_BINARY_DIR}/CleanupProject + COMMAND ${CMAKE_COMMAND} -E remove_directory ${ExportImport_BINARY_DIR}/Root + ) +add_custom_target(CleanupTarget ALL DEPENDS ${ExportImport_BINARY_DIR}/CleanupProject) +set_property( + SOURCE ${ExportImport_BINARY_DIR}/CleanupProject + PROPERTY SYMBOLIC 1 + ) + +if(CMAKE_CONFIGURATION_TYPES) + set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") +else(CMAKE_CONFIGURATION_TYPES) + if(CMAKE_BUILD_TYPE) + set(NESTED_CONFIG_TYPE -C "${CMAKE_BUILD_TYPE}") + else(CMAKE_BUILD_TYPE) + set(NESTED_CONFIG_TYPE) + endif(CMAKE_BUILD_TYPE) +endif(CMAKE_CONFIGURATION_TYPES) + +if(MINGW OR MSYS) + # Test CMAKE_GNUtoMS whether we have VS or not. + set(ExportImport_GNUtoMS 1) +endif() + +configure_file(${ExportImport_SOURCE_DIR}/InitialCache.cmake.in + ${ExportImport_BINARY_DIR}/InitialCache.cmake @ONLY) + +# Build and install the exporter. +add_custom_command( + OUTPUT ${ExportImport_BINARY_DIR}/ExportProject + COMMAND ${CMAKE_CTEST_COMMAND} ${NESTED_CONFIG_TYPE} + --build-and-test + ${ExportImport_SOURCE_DIR}/Export + ${ExportImport_BINARY_DIR}/Export + --build-noclean + --build-project Export + --build-target install + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-options -C${ExportImport_BINARY_DIR}/InitialCache.cmake + ) +add_custom_target(ExportTarget ALL DEPENDS ${ExportImport_BINARY_DIR}/ExportProject) +add_dependencies(ExportTarget CleanupTarget) +set_property( + SOURCE ${ExportImport_BINARY_DIR}/ExportProject + PROPERTY SYMBOLIC 1 + ) + +# Build and install the importer. +add_custom_command( + OUTPUT ${ExportImport_BINARY_DIR}/ImportProject + COMMAND ${CMAKE_CTEST_COMMAND} ${NESTED_CONFIG_TYPE} + --build-and-test + ${ExportImport_SOURCE_DIR}/Import + ${ExportImport_BINARY_DIR}/Import + --build-noclean + --build-project Import + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-options -C${ExportImport_BINARY_DIR}/InitialCache.cmake + ) +add_custom_target(ImportTarget ALL DEPENDS ${ExportImport_BINARY_DIR}/ImportProject) +add_dependencies(ImportTarget ExportTarget) +set_property( + SOURCE ${ExportImport_BINARY_DIR}/ImportProject + PROPERTY SYMBOLIC 1 + ) + +add_executable(ExportImport main.c) +add_dependencies(ExportImport ImportTarget) diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt new file mode 100644 index 000000000..f06a4659f --- /dev/null +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -0,0 +1,145 @@ +cmake_minimum_required (VERSION 2.7.20090711) +project(Export C CXX) + +# Pretend that RelWithDebInfo should link to debug libraries to test +# the DEBUG_CONFIGURATIONS property. +set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS Debug RelWithDebInfo) + +add_library(testExe1lib STATIC testExe1lib.c) # not exported +add_executable(testExe1 testExe1.c) +target_link_libraries(testExe1 testExe1lib) +set_property(TARGET testExe1 PROPERTY VERSION 4) + +add_library(testExe2libImp SHARED testExe2libImp.c) +set_property(TARGET testExe2libImp PROPERTY LIBRARY_OUTPUT_DIRECTORY impl) +add_library(testExe2lib SHARED testExe2lib.c) +target_link_libraries(testExe2lib testExe2libImp) +set_property(TARGET testExe2lib PROPERTY LINK_INTERFACE_LIBRARIES "") +add_executable(testExe2 testExe2.c) +set_property(TARGET testExe2 PROPERTY ENABLE_EXPORTS 1) +set_property(TARGET testExe2 PROPERTY LINK_INTERFACE_LIBRARIES testExe2lib) + +add_library(testLib1 STATIC testLib1.c) +add_library(testLib2 STATIC testLib2.c) +target_link_libraries(testLib2 testLib1) + +# Test library with empty link interface. Link it to an implementation +# dependency that itself links to dependencies publicly. +add_library(testLib3ImpDep SHARED testLib3ImpDep.c) +set_property(TARGET testLib3ImpDep PROPERTY LIBRARY_OUTPUT_DIRECTORY impl/dep) +add_library(testLib3Imp SHARED testLib3Imp.c) +set_property(TARGET testLib3Imp PROPERTY LIBRARY_OUTPUT_DIRECTORY impl) +target_link_libraries(testLib3Imp testLib3ImpDep) +add_library(testLib3 SHARED testLib3.c) +target_link_libraries(testLib3 testLib3Imp) +set_property(TARGET testLib3 PROPERTY LINK_INTERFACE_LIBRARIES "") +set_property(TARGET testLib3 PROPERTY VERSION 1.2) +set_property(TARGET testLib3 PROPERTY SOVERSION 3) + +# Test <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME[_<CONFIG>] properties. +set_property(TARGET testLib3 PROPERTY RUNTIME_OUTPUT_NAME_DEBUG testLib3dll-d) +set_property(TARGET testLib3 PROPERTY RUNTIME_OUTPUT_NAME_RELEASE testLib3dll-r) +set_property(TARGET testLib3 PROPERTY RUNTIME_OUTPUT_NAME testLib3dll) +set_property(TARGET testLib3 PROPERTY LIBRARY_OUTPUT_NAME_DEBUG testLib3lib-d) +set_property(TARGET testLib3 PROPERTY LIBRARY_OUTPUT_NAME_RELEASE testLib3lib-r) +set_property(TARGET testLib3 PROPERTY LIBRARY_OUTPUT_NAME testLib3lib) +set_property(TARGET testLib3 PROPERTY ARCHIVE_OUTPUT_NAME testLib3import) + +add_library(testLib4 SHARED testLib4.c) +set_property(TARGET testLib4 PROPERTY FRAMEWORK 1) + +add_library(testLib5 SHARED testLib5.c) + +add_library(testLib6 STATIC testLib6.cxx testLib6c.c) + +# Work-around: Visual Studio 6 does not support per-target object files. +set(VS6) +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6") + set(VS6 1) +endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6") + +# Test using the target_link_libraries command to set the +# LINK_INTERFACE_LIBRARIES* properties. We construct two libraries +# providing the same two symbols. In each library one of the symbols +# will work and the other one will fail to link. The import part of +# this test will try to use the symbol corresponding to the +# configuration in which it is built. If the proper library is not +# used via the link interface the import test will fail to link. +add_library(testLib4lib STATIC testLib4lib.c) +add_library(testLib4libdbg STATIC testLib4libopt.c testLib4libdbg${VS6}.c) +add_library(testLib4libopt STATIC testLib4libdbg.c testLib4libopt${VS6}.c) +set_property(TARGET testLib4libdbg PROPERTY COMPILE_DEFINITIONS LIB_DBG) +set_property(TARGET testLib4libopt PROPERTY COMPILE_DEFINITIONS LIB_OPT) +target_link_libraries(testLib4 + LINK_INTERFACE_LIBRARIES + testLib4lib debug testLib4libdbg optimized testLib4libopt + ) + +add_executable(testExe3 testExe3.c) +set_property(TARGET testExe3 PROPERTY MACOSX_BUNDLE 1) + +# Test cyclic dependencies. +add_library(testLibCycleA STATIC + testLibCycleA1.c testLibCycleA2.c testLibCycleA3.c) +add_library(testLibCycleB STATIC + testLibCycleB1.c testLibCycleB2.c testLibCycleB3.c) +target_link_libraries(testLibCycleA testLibCycleB) +target_link_libraries(testLibCycleB testLibCycleA) +set_property(TARGET testLibCycleA PROPERTY LINK_INTERFACE_MULTIPLICITY 3) + +# Install and export from install tree. +install( + TARGETS + testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3 + testExe2lib testLib4lib testLib4libdbg testLib4libopt + testLib6 + testLibCycleA testLibCycleB + EXPORT exp + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib NAMELINK_SKIP + ARCHIVE DESTINATION lib + FRAMEWORK DESTINATION Frameworks + BUNDLE DESTINATION Applications + ) +install( + TARGETS + testExe2libImp testLib3Imp + EXPORT exp + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib/impl + ARCHIVE DESTINATION lib/impl + ) +install( + TARGETS + testLib3ImpDep + EXPORT exp + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib/impl/dep + ARCHIVE DESTINATION lib/impl/dep + ) +install( + TARGETS testLib5 + EXPORT exp + # Leave out RUNTIME DESTINATION to test implib-only export. + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + ) +install(EXPORT exp NAMESPACE exp_ DESTINATION lib/exp) + +# Install testLib5.dll outside the export. +if(WIN32) + install(TARGETS testLib5 RUNTIME DESTINATION bin) +endif(WIN32) + +# Export from build tree. +export(TARGETS testExe1 testLib1 testLib2 testLib3 + testExe2libImp testLib3Imp testLib3ImpDep + NAMESPACE bld_ + FILE ExportBuildTree.cmake + ) +export(TARGETS testExe2 testLib4 testLib5 testLib6 testExe3 testExe2lib + testLib4lib testLib4libdbg testLib4libopt + testLibCycleA testLibCycleB + NAMESPACE bld_ + APPEND FILE ExportBuildTree.cmake + ) diff --git a/Tests/ExportImport/Export/testExe1.c b/Tests/ExportImport/Export/testExe1.c new file mode 100644 index 000000000..e00fac74f --- /dev/null +++ b/Tests/ExportImport/Export/testExe1.c @@ -0,0 +1,26 @@ +#include <stdio.h> + +extern int testExe1lib(void); + +int main(int argc, const char* argv[]) +{ + if(argc < 2) + { + fprintf(stderr, "Must specify output file.\n"); + return 1; + } + { + FILE* f = fopen(argv[1], "w"); + if(f) + { + fprintf(f, "int generated_by_testExe1() { return 0; }\n"); + fclose(f); + } + else + { + fprintf(stderr, "Error writing to %s\n", argv[1]); + return 1; + } + } + return testExe1lib(); +} diff --git a/Tests/ExportImport/Export/testExe1lib.c b/Tests/ExportImport/Export/testExe1lib.c new file mode 100644 index 000000000..7ad48a392 --- /dev/null +++ b/Tests/ExportImport/Export/testExe1lib.c @@ -0,0 +1 @@ +int testExe1lib(void) { return 0; } diff --git a/Tests/ExportImport/Export/testExe2.c b/Tests/ExportImport/Export/testExe2.c new file mode 100644 index 000000000..f7d93453a --- /dev/null +++ b/Tests/ExportImport/Export/testExe2.c @@ -0,0 +1,12 @@ +#if defined(_WIN32) || defined(__CYGWIN__) +# define testExe2_EXPORT __declspec(dllexport) +#else +# define testExe2_EXPORT +#endif + +testExe2_EXPORT int testExe2Func(void) { return 123; } + +int main() +{ + return 0; +} diff --git a/Tests/ExportImport/Export/testExe2lib.c b/Tests/ExportImport/Export/testExe2lib.c new file mode 100644 index 000000000..199143900 --- /dev/null +++ b/Tests/ExportImport/Export/testExe2lib.c @@ -0,0 +1,10 @@ +#if defined(_WIN32) || defined(__CYGWIN__) +# define testExe2lib_EXPORT __declspec(dllexport) +# define testExe2libImp_IMPORT __declspec(dllimport) +#else +# define testExe2lib_EXPORT +# define testExe2libImp_IMPORT +#endif + +testExe2libImp_IMPORT int testExe2libImp(void); +testExe2lib_EXPORT int testExe2lib(void) { return testExe2libImp(); } diff --git a/Tests/ExportImport/Export/testExe2libImp.c b/Tests/ExportImport/Export/testExe2libImp.c new file mode 100644 index 000000000..f5a23af55 --- /dev/null +++ b/Tests/ExportImport/Export/testExe2libImp.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) || defined(__CYGWIN__) +# define testExe2libImp_EXPORT __declspec(dllexport) +#else +# define testExe2libImp_EXPORT +#endif + +testExe2libImp_EXPORT int testExe2libImp(void) { return 0; } diff --git a/Tests/ExportImport/Export/testExe3.c b/Tests/ExportImport/Export/testExe3.c new file mode 100644 index 000000000..895e2fc2d --- /dev/null +++ b/Tests/ExportImport/Export/testExe3.c @@ -0,0 +1,24 @@ +#include <stdio.h> + +int main(int argc, const char* argv[]) +{ + if(argc < 2) + { + fprintf(stderr, "Must specify output file.\n"); + return 1; + } + { + FILE* f = fopen(argv[1], "w"); + if(f) + { + fprintf(f, "int generated_by_testExe3() { return 0; }\n"); + fclose(f); + } + else + { + fprintf(stderr, "Error writing to %s\n", argv[1]); + return 1; + } + } + return 0; +} diff --git a/Tests/ExportImport/Export/testLib1.c b/Tests/ExportImport/Export/testLib1.c new file mode 100644 index 000000000..35bb1e5db --- /dev/null +++ b/Tests/ExportImport/Export/testLib1.c @@ -0,0 +1 @@ +int testLib1(void) { return 0; } diff --git a/Tests/ExportImport/Export/testLib2.c b/Tests/ExportImport/Export/testLib2.c new file mode 100644 index 000000000..aabc0d30f --- /dev/null +++ b/Tests/ExportImport/Export/testLib2.c @@ -0,0 +1,4 @@ + +extern int testLib1(void); + +int testLib2(void) { return testLib1(); } diff --git a/Tests/ExportImport/Export/testLib3.c b/Tests/ExportImport/Export/testLib3.c new file mode 100644 index 000000000..31cec9435 --- /dev/null +++ b/Tests/ExportImport/Export/testLib3.c @@ -0,0 +1,10 @@ +#if defined(_WIN32) || defined(__CYGWIN__) +# define testLib3_EXPORT __declspec(dllexport) +# define testLib3Imp_IMPORT __declspec(dllimport) +#else +# define testLib3_EXPORT +# define testLib3Imp_IMPORT +#endif + +testLib3Imp_IMPORT int testLib3Imp(void); +testLib3_EXPORT int testLib3(void) { return testLib3Imp(); } diff --git a/Tests/ExportImport/Export/testLib3Imp.c b/Tests/ExportImport/Export/testLib3Imp.c new file mode 100644 index 000000000..c27bccd40 --- /dev/null +++ b/Tests/ExportImport/Export/testLib3Imp.c @@ -0,0 +1,10 @@ +#if defined(_WIN32) || defined(__CYGWIN__) +# define testLib3Imp_EXPORT __declspec(dllexport) +# define testLib3ImpDep_IMPORT __declspec(dllimport) +#else +# define testLib3Imp_EXPORT +# define testLib3ImpDep_IMPORT +#endif + +testLib3ImpDep_IMPORT int testLib3ImpDep(void); +testLib3Imp_EXPORT int testLib3Imp(void) { return testLib3ImpDep(); } diff --git a/Tests/ExportImport/Export/testLib3ImpDep.c b/Tests/ExportImport/Export/testLib3ImpDep.c new file mode 100644 index 000000000..578ac30ef --- /dev/null +++ b/Tests/ExportImport/Export/testLib3ImpDep.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) || defined(__CYGWIN__) +# define testLib3ImpDep_EXPORT __declspec(dllexport) +#else +# define testLib3ImpDep_EXPORT +#endif + +testLib3ImpDep_EXPORT int testLib3ImpDep(void) { return 0; } diff --git a/Tests/ExportImport/Export/testLib4.c b/Tests/ExportImport/Export/testLib4.c new file mode 100644 index 000000000..846b4389b --- /dev/null +++ b/Tests/ExportImport/Export/testLib4.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) || defined(__CYGWIN__) +# define testLib4_EXPORT __declspec(dllexport) +#else +# define testLib4_EXPORT +#endif + +testLib4_EXPORT int testLib4(void) { return 0; } diff --git a/Tests/ExportImport/Export/testLib4lib.c b/Tests/ExportImport/Export/testLib4lib.c new file mode 100644 index 000000000..bf3c11ec6 --- /dev/null +++ b/Tests/ExportImport/Export/testLib4lib.c @@ -0,0 +1,4 @@ +int testLib4lib(void) +{ + return 0; +} diff --git a/Tests/ExportImport/Export/testLib4libdbg.c b/Tests/ExportImport/Export/testLib4libdbg.c new file mode 100644 index 000000000..453f26282 --- /dev/null +++ b/Tests/ExportImport/Export/testLib4libdbg.c @@ -0,0 +1,14 @@ +#ifdef LIB_DBG +/* We are building in testLib4libdbg. Provide the correct symbol. */ +int testLib4libdbg(void) +{ + return 0; +} +#else +/* We are not building in testLib4libdbg. Poison the symbol. */ +extern int testLib4libdbg_noexist(void); +int testLib4libdbg(void) +{ + return testLib4libdbg_noexist(); +} +#endif diff --git a/Tests/ExportImport/Export/testLib4libdbg1.c b/Tests/ExportImport/Export/testLib4libdbg1.c new file mode 100644 index 000000000..cc56cf933 --- /dev/null +++ b/Tests/ExportImport/Export/testLib4libdbg1.c @@ -0,0 +1 @@ +#include "testLib4libdbg.c" diff --git a/Tests/ExportImport/Export/testLib4libopt.c b/Tests/ExportImport/Export/testLib4libopt.c new file mode 100644 index 000000000..605edd05b --- /dev/null +++ b/Tests/ExportImport/Export/testLib4libopt.c @@ -0,0 +1,14 @@ +#ifdef LIB_OPT +/* We are building in testLib4libopt. Provide the correct symbol. */ +int testLib4libopt(void) +{ + return 0; +} +#else +/* We are not building in testLib4libopt. Poison the symbol. */ +extern int testLib4libopt_noexist(void); +int testLib4libopt(void) +{ + return testLib4libopt_noexist(); +} +#endif diff --git a/Tests/ExportImport/Export/testLib4libopt1.c b/Tests/ExportImport/Export/testLib4libopt1.c new file mode 100644 index 000000000..d9b55879d --- /dev/null +++ b/Tests/ExportImport/Export/testLib4libopt1.c @@ -0,0 +1 @@ +#include "testLib4libopt.c" diff --git a/Tests/ExportImport/Export/testLib5.c b/Tests/ExportImport/Export/testLib5.c new file mode 100644 index 000000000..20a821513 --- /dev/null +++ b/Tests/ExportImport/Export/testLib5.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) || defined(__CYGWIN__) +# define testLib5_EXPORT __declspec(dllexport) +#else +# define testLib5_EXPORT +#endif + +testLib5_EXPORT int testLib5(void) { return 0; } diff --git a/Tests/ExportImport/Export/testLib6.cxx b/Tests/ExportImport/Export/testLib6.cxx new file mode 100644 index 000000000..338e6399a --- /dev/null +++ b/Tests/ExportImport/Export/testLib6.cxx @@ -0,0 +1,6 @@ +extern "C" int testLib6cxx(void) +{ + // Reference C++ standard library symbols. + delete new int; + return 0; +} diff --git a/Tests/ExportImport/Export/testLib6c.c b/Tests/ExportImport/Export/testLib6c.c new file mode 100644 index 000000000..493ca070e --- /dev/null +++ b/Tests/ExportImport/Export/testLib6c.c @@ -0,0 +1,5 @@ +extern int testLib6cxx(void); +int testLib6(void) +{ + return testLib6cxx(); +} diff --git a/Tests/ExportImport/Export/testLibCycleA1.c b/Tests/ExportImport/Export/testLibCycleA1.c new file mode 100644 index 000000000..3db9e5356 --- /dev/null +++ b/Tests/ExportImport/Export/testLibCycleA1.c @@ -0,0 +1,2 @@ +extern int testLibCycleB1(void); +int testLibCycleA1(void) { return testLibCycleB1(); } diff --git a/Tests/ExportImport/Export/testLibCycleA2.c b/Tests/ExportImport/Export/testLibCycleA2.c new file mode 100644 index 000000000..29ad46d4e --- /dev/null +++ b/Tests/ExportImport/Export/testLibCycleA2.c @@ -0,0 +1,2 @@ +extern int testLibCycleB2(void); +int testLibCycleA2(void) { return testLibCycleB2(); } diff --git a/Tests/ExportImport/Export/testLibCycleA3.c b/Tests/ExportImport/Export/testLibCycleA3.c new file mode 100644 index 000000000..565447b21 --- /dev/null +++ b/Tests/ExportImport/Export/testLibCycleA3.c @@ -0,0 +1,2 @@ +extern int testLibCycleB3(void); +int testLibCycleA3(void) { return testLibCycleB3(); } diff --git a/Tests/ExportImport/Export/testLibCycleB1.c b/Tests/ExportImport/Export/testLibCycleB1.c new file mode 100644 index 000000000..36cb7b0e9 --- /dev/null +++ b/Tests/ExportImport/Export/testLibCycleB1.c @@ -0,0 +1,2 @@ +extern int testLibCycleA2(void); +int testLibCycleB1(void) { return testLibCycleA2(); } diff --git a/Tests/ExportImport/Export/testLibCycleB2.c b/Tests/ExportImport/Export/testLibCycleB2.c new file mode 100644 index 000000000..ff1209302 --- /dev/null +++ b/Tests/ExportImport/Export/testLibCycleB2.c @@ -0,0 +1,2 @@ +extern int testLibCycleA3(void); +int testLibCycleB2(void) { return testLibCycleA3(); } diff --git a/Tests/ExportImport/Export/testLibCycleB3.c b/Tests/ExportImport/Export/testLibCycleB3.c new file mode 100644 index 000000000..ca8d47005 --- /dev/null +++ b/Tests/ExportImport/Export/testLibCycleB3.c @@ -0,0 +1 @@ +int testLibCycleB3(void) { return 0; } diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt new file mode 100644 index 000000000..a21e1b0f8 --- /dev/null +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -0,0 +1,150 @@ +# Import targets from the exported build tree. +include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake) + +# Import targets from the exported install tree. +include(${CMAKE_INSTALL_PREFIX}/lib/exp/exp.cmake) + +# Try referencing an executable imported from the install tree. +add_custom_command( + OUTPUT ${Import_BINARY_DIR}/exp_generated.c + COMMAND exp_testExe1 ${Import_BINARY_DIR}/exp_generated.c + DEPENDS exp_testExe1 + ) +add_custom_command( + OUTPUT ${Import_BINARY_DIR}/exp_generated3.c + COMMAND exp_testExe3 ${Import_BINARY_DIR}/exp_generated3.c + DEPENDS exp_testExe3 + ) + +add_executable(imp_testExe1 + imp_testExe1.c + ${Import_BINARY_DIR}/exp_generated.c + ${Import_BINARY_DIR}/exp_generated3.c + ) + +# Try linking to a library imported from the install tree. +target_link_libraries(imp_testExe1 + exp_testLib2 + exp_testLib3 + exp_testLib4 + exp_testLib5 + exp_testLib6 + exp_testLibCycleA + ) + +# Try building a plugin to an executable imported from the install tree. +add_library(imp_mod1 MODULE imp_mod1.c) +target_link_libraries(imp_mod1 exp_testExe2) + +# Try referencing an executable imported from the build tree. +add_custom_command( + OUTPUT ${Import_BINARY_DIR}/bld_generated.c + COMMAND bld_testExe1 ${Import_BINARY_DIR}/bld_generated.c + DEPENDS bld_testExe1 + ) +add_custom_command( + OUTPUT ${Import_BINARY_DIR}/bld_generated3.c + COMMAND bld_testExe3 ${Import_BINARY_DIR}/bld_generated3.c + DEPENDS bld_testExe3 + ) + +add_executable(imp_testExe1b + imp_testExe1.c + ${Import_BINARY_DIR}/bld_generated.c + ${Import_BINARY_DIR}/bld_generated3.c + ) + +# Try linking to a library imported from the build tree. +target_link_libraries(imp_testExe1b + bld_testLib2 + bld_testLib3 + bld_testLib4 + bld_testLib5 + bld_testLib6 + bld_testLibCycleA + ) + +# Try building a plugin to an executable imported from the build tree. +add_library(imp_mod1b MODULE imp_mod1.c) +target_link_libraries(imp_mod1b bld_testExe2) + +# Export/CMakeLists.txt pretends the RelWithDebInfo (as well as Debug) +# configuration should link to debug libs. +foreach(c DEBUG RELWITHDEBINFO) + set_property(TARGET imp_testExe1 PROPERTY COMPILE_DEFINITIONS_${c} EXE_DBG) + 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) +target_link_libraries(imp_lib1b bld_testLib2) + +#----------------------------------------------------------------------------- +# Test that handling imported targets, including transitive dependencies, +# works in CheckFunctionExists (...and hopefully all other try_compile() checks +include(CheckFunctionExists) +unset(HAVE_TESTLIB1_FUNCTION CACHE) +set(CMAKE_REQUIRED_LIBRARIES exp_testLib2) +check_function_exists(testLib1 HAVE_TESTLIB1_FUNCTION) +if (NOT HAVE_TESTLIB1_FUNCTION) + message(SEND_ERROR "Using imported target testLib2 in check_function_exists() failed !") +endif() diff --git a/Tests/ExportImport/Import/A/imp_lib1.c b/Tests/ExportImport/Import/A/imp_lib1.c new file mode 100644 index 000000000..5b3215e99 --- /dev/null +++ b/Tests/ExportImport/Import/A/imp_lib1.c @@ -0,0 +1,6 @@ +#include "testLib2.h" + +int imp_lib1(void) +{ + return testLib2(); +} diff --git a/Tests/ExportImport/Import/A/imp_mod1.c b/Tests/ExportImport/Import/A/imp_mod1.c new file mode 100644 index 000000000..579d949c3 --- /dev/null +++ b/Tests/ExportImport/Import/A/imp_mod1.c @@ -0,0 +1,13 @@ +#if defined(_WIN32) || defined(__CYGWIN__) +# define testExe2_IMPORT __declspec(dllimport) +#else +# define testExe2_IMPORT +#endif + +testExe2_IMPORT int testExe2Func(void); +testExe2_IMPORT int testExe2lib(void); + +int imp_mod1() +{ + return testExe2Func() + testExe2lib(); +} diff --git a/Tests/ExportImport/Import/A/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c new file mode 100644 index 000000000..451998ab7 --- /dev/null +++ b/Tests/ExportImport/Import/A/imp_testExe1.c @@ -0,0 +1,25 @@ +extern int generated_by_testExe1(); +extern int generated_by_testExe3(); +extern int testLib2(); +extern int testLib3(); +extern int testLib4(); +extern int testLib4lib(); +extern int testLib5(); +extern int testLib6(); +extern int testLibCycleA1(); + +/* Switch a symbol between debug and optimized builds to make sure the + proper library is found from the testLib4 link interface. */ +#ifdef EXE_DBG +# define testLib4libcfg testLib4libdbg +#else +# define testLib4libcfg testLib4libopt +#endif +extern testLib4libcfg(void); + +int main() +{ + return (testLib2() + generated_by_testExe1() + testLib3() + testLib4() + + testLib5() + testLib6() + testLibCycleA1() + + generated_by_testExe3() + testLib4lib() + testLib4libcfg()); +} diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt new file mode 100644 index 000000000..3fc78a280 --- /dev/null +++ b/Tests/ExportImport/Import/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required (VERSION 2.7.20090711) +project(Import C CXX) + +# Import everything in a subdirectory. +add_subdirectory(A) + +# Make sure the imported targets are scoped inside the subdirectory. +if(TARGET exp_testLib2) + message(FATAL_ERROR "Imported target exp_testLib2 is not scoped in subdir!") +endif() +if(TARGET bld_testLib2) + message(FATAL_ERROR "Imported target bld_testLib2 is not scoped in subdir!") +endif() + +# Test transitive linking to a target imported in the subdirectory. +add_executable(imp_testTransExe1 imp_testTransExe1.c) +target_link_libraries(imp_testTransExe1 imp_lib1) +add_executable(imp_testTransExe1b imp_testTransExe1.c) +target_link_libraries(imp_testTransExe1b imp_lib1b) diff --git a/Tests/ExportImport/Import/imp_testTransExe1.c b/Tests/ExportImport/Import/imp_testTransExe1.c new file mode 100644 index 000000000..360a112ac --- /dev/null +++ b/Tests/ExportImport/Import/imp_testTransExe1.c @@ -0,0 +1,6 @@ +extern int imp_lib1(void); + +int main() +{ + return imp_lib1(); +} diff --git a/Tests/ExportImport/InitialCache.cmake.in b/Tests/ExportImport/InitialCache.cmake.in new file mode 100644 index 000000000..4893f7020 --- /dev/null +++ b/Tests/ExportImport/InitialCache.cmake.in @@ -0,0 +1,15 @@ +SET(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@" CACHE STRING "C Compiler") +SET(CMAKE_C_FLAGS "@CMAKE_C_FLAGS@" CACHE STRING "C Flags") +SET(CMAKE_C_FLAGS_DEBUG "@CMAKE_C_FLAGS_DEBUG@" CACHE STRING "C Flags") +SET(CMAKE_C_FLAGS_RELEASE "@CMAKE_C_FLAGS_RELEASE@" CACHE STRING "C Flags") +SET(CMAKE_C_FLAGS_MINSIZEREL "@CMAKE_C_FLAGS_MINSIZEREL@" CACHE STRING "C Flags") +SET(CMAKE_C_FLAGS_RELWITHDEBINFO "@CMAKE_C_FLAGS_RELWITHDEBINFO@" CACHE STRING "C Flags") +SET(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@" CACHE STRING "C++ Compiler") +SET(CMAKE_CXX_FLAGS "@CMAKE_CXX_FLAGS@" CACHE STRING "C++ Flags") +SET(CMAKE_CXX_FLAGS_DEBUG "@CMAKE_CXX_FLAGS_DEBUG@" CACHE STRING "C++ Flags") +SET(CMAKE_CXX_FLAGS_RELEASE "@CMAKE_CXX_FLAGS_RELEASE@" CACHE STRING "C++ Flags") +SET(CMAKE_CXX_FLAGS_MINSIZEREL "@CMAKE_CXX_FLAGS_MINSIZEREL@" CACHE STRING "C++ Flags") +SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@" CACHE STRING "C++ Flags") +SET(CMAKE_INSTALL_PREFIX "@ExportImport_BINARY_DIR@/Root" CACHE STRING "Installation Prefix") +SET(CMAKE_SKIP_RPATH ON CACHE BOOL "No RPATH") +SET(CMAKE_GNUtoMS "@ExportImport_GNUtoMS@" CACHE BOOL "CMAKE_GNUtoMS") diff --git a/Tests/ExportImport/main.c b/Tests/ExportImport/main.c new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/ExportImport/main.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/ExternalOBJ/CMakeLists.txt b/Tests/ExternalOBJ/CMakeLists.txt new file mode 100644 index 000000000..683e7997c --- /dev/null +++ b/Tests/ExternalOBJ/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT (ExternalOBJ) + +IF(APPLE) + # set _CMAKE_OSX_MACHINE to umame -m + EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE _CMAKE_OSX_MACHINE) + # check for Power PC and change to ppc + IF("${_CMAKE_OSX_MACHINE}" MATCHES "Power") + SET(_CMAKE_OSX_MACHINE ppc) + ENDIF("${_CMAKE_OSX_MACHINE}" MATCHES "Power") + SET(CMAKE_OSX_ARCHITECTURES ${_CMAKE_OSX_MACHINE}) +ENDIF(APPLE) + +# Build the external object file. +TRY_COMPILE(EXTERNAL_OBJECT_BUILT + ${ExternalOBJ_BINARY_DIR}/Object + ${ExternalOBJ_SOURCE_DIR}/Object + Object + external + OUTPUT_VARIABLE OUTPUT + ) +IF(EXTERNAL_OBJECT_BUILT) + MESSAGE( + "Building external_object.cxx succeeded with the following output:\n" + "[${OUTPUT}]" + ) +ELSE(EXTERNAL_OBJECT_BUILT) + MESSAGE(FATAL_ERROR + "Building external_object.cxx failed with the following output:\n" + "[${OUTPUT}]" + ) +ENDIF(EXTERNAL_OBJECT_BUILT) + +# Find the external object file. +SET(DIR ${ExternalOBJ_BINARY_DIR}/Object) +FILE(GLOB_RECURSE EXTERNAL_OBJECT + "${DIR}/external_object*${CMAKE_CXX_OUTPUT_EXTENSION}") +IF(EXTERNAL_OBJECT) + LIST (GET EXTERNAL_OBJECT 0 EXTERNAL_OBJECT) + MESSAGE("Found \"${EXTERNAL_OBJECT}\".") +ELSE(EXTERNAL_OBJECT) + MESSAGE(FATAL_ERROR "Could not find external object.") +ENDIF(EXTERNAL_OBJECT) + +# Test creation of external objects by custom commands. +SET(CUSTOM_OBJECT + ${CMAKE_CURRENT_BINARY_DIR}/custom_object${CMAKE_C_OUTPUT_EXTENSION}) +ADD_CUSTOM_COMMAND( + OUTPUT ${CUSTOM_OBJECT} + COMMAND ${CMAKE_COMMAND} -E copy ${EXTERNAL_OBJECT} ${CUSTOM_OBJECT} + DEPENDS ${EXTERNAL_OBJECT} + ) + +message("${EXTERNAL_OBJECT}") +# Build an executable using the external object file. +ADD_EXECUTABLE(ExternalOBJ executable.cxx ${CUSTOM_OBJECT}) +# A bug showed up in VS2010 where an object file that was +# part of a custom commad output worked, but ones that were +# not didn't work. So, repeat the executable using the object +# directly and not from the output of the copy. +ADD_EXECUTABLE(ExternalOBJ2 executable.cxx ${EXTERNAL_OBJECT}) + +ADD_SUBDIRECTORY(Sub) diff --git a/Tests/ExternalOBJ/Object/CMakeLists.txt b/Tests/ExternalOBJ/Object/CMakeLists.txt new file mode 100644 index 000000000..6f1d7e3fb --- /dev/null +++ b/Tests/ExternalOBJ/Object/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(Object) +IF(APPLE) + # set _CMAKE_OSX_MACHINE to umame -m + EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE _CMAKE_OSX_MACHINE) + # check for Power PC and change to ppc + IF("${_CMAKE_OSX_MACHINE}" MATCHES "Power") + SET(_CMAKE_OSX_MACHINE ppc) + ENDIF("${_CMAKE_OSX_MACHINE}" MATCHES "Power") + SET(CMAKE_OSX_ARCHITECTURES ${_CMAKE_OSX_MACHINE}) +ENDIF(APPLE) + +ADD_EXECUTABLE(external external_object.cxx external_main.cxx) diff --git a/Tests/ExternalOBJ/Object/external_main.cxx b/Tests/ExternalOBJ/Object/external_main.cxx new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/ExternalOBJ/Object/external_main.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/ExternalOBJ/Object/external_object.cxx b/Tests/ExternalOBJ/Object/external_object.cxx new file mode 100644 index 000000000..5b4adaf0c --- /dev/null +++ b/Tests/ExternalOBJ/Object/external_object.cxx @@ -0,0 +1,4 @@ +int external_object_function() +{ + return 0; +} diff --git a/Tests/ExternalOBJ/Sub/CMakeLists.txt b/Tests/ExternalOBJ/Sub/CMakeLists.txt new file mode 100644 index 000000000..35cd30c7d --- /dev/null +++ b/Tests/ExternalOBJ/Sub/CMakeLists.txt @@ -0,0 +1,3 @@ +set_property(SOURCE ${CUSTOM_OBJECT} PROPERTY GENERATED 1) +add_executable(ExternalOBJSub ../executable.cxx ${CUSTOM_OBJECT}) +add_dependencies(ExternalOBJSub ExternalOBJ) # depend on generating target diff --git a/Tests/ExternalOBJ/executable.cxx b/Tests/ExternalOBJ/executable.cxx new file mode 100644 index 000000000..f9ec61df5 --- /dev/null +++ b/Tests/ExternalOBJ/executable.cxx @@ -0,0 +1,5 @@ +extern int external_object_function(); +int main() +{ + return external_object_function(); +} diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt new file mode 100644 index 000000000..7a7626199 --- /dev/null +++ b/Tests/ExternalProject/CMakeLists.txt @@ -0,0 +1,585 @@ +cmake_minimum_required(VERSION 2.8) +project(ExternalProjectTest NONE) + +include(ExternalProject) + +find_package(CVS) +find_package(Subversion) +find_package(Git) + +option(ExternalProjectTest_USE_FOLDERS "Enable folder grouping in IDEs." ON) +if(ExternalProjectTest_USE_FOLDERS) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) +else() + set_property(GLOBAL PROPERTY USE_FOLDERS OFF) +endif() + +set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER + "CMakePredefinedTargets-in-ExternalProjectTest") + +set(base "${CMAKE_BINARY_DIR}/CMakeExternals") +set(binary_base "${base}/Build") +set_property(DIRECTORY PROPERTY EP_BASE ${base}) +set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) + +if(NOT DEFINED can_build_tutorial_step5) + set(can_build_tutorial_step5 1) + + # Tutorial Step5 cannot build correctly using Visual Studio 6 + # on Windows 98 if the path of its build tree exceeds 72 + # characters in length... So don't attempt to build it + # in a long path on Win98: + # + if(CMAKE_SYSTEM STREQUAL "Windows-4.10") + string(LENGTH "${binary_base}/TutorialStep5-Local" n) + if(n GREATER 72) + set(can_build_tutorial_step5 0) + endif() + endif() + + # The ExternalProject builds of Tutorial Step5 cannot be built + # correctly 2nd and later times in an in-source build... + # (because the CMakeCache.txt from the real in-source build of + # the Tests/Tutorial/Step5 directory gets copied when we do + # the "source directory copy" step... but it still refers to + # its original path which yields a configure error.) So: + # + if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + set(can_build_tutorial_step5 0) + endif() +endif() + + +# Empty projects that test all the known ExternalProject_Add argument key words: +# +set(proj AAA-TestAlphabetization) +ExternalProject_Add(${proj} + BUILD_COMMAND "" + CONFIGURE_COMMAND "" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" +) + +set(proj ZZZ-TestAlphabetization) +ExternalProject_Add(${proj} + BUILD_COMMAND "" + CONFIGURE_COMMAND "" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" +) + +set(proj TargetNameSameAsFolder) +ExternalProject_Add(${proj} + BUILD_COMMAND "" + CONFIGURE_COMMAND "" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" +) +set_property(TARGET ${proj} PROPERTY FOLDER "${proj}") + +set(proj MinimalNoOpProject) +ExternalProject_Add(${proj} + BUILD_COMMAND "" + CONFIGURE_COMMAND "" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" +) + +set(proj EmptyNoOpProject) +ExternalProject_Add(${proj} + BUILD_COMMAND "" + CMAKE_ARGS "" + CONFIGURE_COMMAND "" + CVS_REPOSITORY "" + CVS_MODULE "" + CVS_TAG "" + DEPENDS "MinimalNoOpProject" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" + PATCH_COMMAND "" + STEP_TARGETS install update + SVN_REPOSITORY "" + SVN_REVISION "" + SVN_USERNAME "" + SVN_PASSWORD "" + SVN_TRUST_CERT 1 + TEST_COMMAND "" + TIMEOUT "" + URL "" + URL_MD5 "" + UPDATE_COMMAND "" +) +set_property(TARGET ${proj} PROPERTY FOLDER "") + + +# Local DIR: +# +if(can_build_tutorial_step5) + set(proj TutorialStep5-Local) + ExternalProject_Add(${proj} + URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" + CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + CMAKE_ARGS -G ${CMAKE_GENERATOR} <SOURCE_DIR> + TEST_BEFORE_INSTALL 1 + LOG_INSTALL 1 + ) + set_property(TARGET ${proj} PROPERTY FOLDER "Local") + ExternalProject_Get_Property(${proj} install_dir) + set(TutorialStep5_install_dir ${install_dir}) + + set(proj TutorialStep5-Local-TestAfterInstall) + ExternalProject_Add(${proj} + URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> + TEST_AFTER_INSTALL 1 + LOG_TEST 1 + ) + set_property(TARGET ${proj} PROPERTY FOLDER "Local") +endif() + + +# Local TAR: +# +set(proj TutorialStep1-LocalTAR) +ExternalProject_Add(${proj} + URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tar" + URL_MD5 a87c5b47c0201c09ddfe1d5738fdb1e3 + LIST_SEPARATOR :: + PATCH_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/Step1Patch.cmake + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + -DTEST_LIST:STRING=A::B::C + INSTALL_COMMAND "" + LOG_CONFIGURE 1 +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/TAR") + +set(proj TutorialStep1-LocalNoDirTAR) +ExternalProject_Add(${proj} + URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tar" + URL_MD5 d09e3d370c5c908fa035c30939ee438e + LIST_SEPARATOR @@ + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> + -DTEST_LIST:STRING=1@@2@@3 + INSTALL_COMMAND "" +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/TAR") +ExternalProject_Add_Step(${proj} mypatch + COMMAND ${CMAKE_COMMAND} -E echo "This is a custom external project step." + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/Step1Patch.cmake + WORKING_DIRECTORY <SOURCE_DIR> + DEPENDEES download + DEPENDERS configure + ) + + +# Local TGZ: +# +set(proj TutorialStep1-LocalTGZ) +ExternalProject_Add(${proj} + URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tgz" + URL_MD5 38c648e817339c356f6be00eeed79bd0 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR> + INSTALL_COMMAND "" + LOG_BUILD 1 +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/TGZ") + +set(proj TutorialStep1-LocalNoDirTGZ) +ExternalProject_Add(${proj} + URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tgz" + URL_MD5 0b8182edcecdf40bf1c9d71d7d259f78 + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/TGZ") + + +# Local BZ2: +# +# (The bz2 tests are here just to verify that the bz2 decompression is executed +# during a test suite run... The configure and build commands are set to +# nothing to make the test quicker. To make this more complete, I should add +# a diff between this and the TGZ source tree since that one does build...) +# +set(proj TutorialStep1-LocalBZ2) +ExternalProject_Add(${proj} + URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tar.bz2" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/BZ2") + +set(proj TutorialStep1-LocalNoDirBZ2) +ExternalProject_Add(${proj} + URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tar.bz2" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/BZ2") + + +# Local ZIP: +# +# (The zip tests are here just to verify that the zip decompression is executed +# during a test suite run... The configure and build commands are set to +# nothing to make the test quicker. To make this more complete, I should add +# a diff between this and the TGZ source tree since that one does build...) +# +set(proj TutorialStep1-LocalZIP) +ExternalProject_Add(${proj} + URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1.zip" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/ZIP") + +set(proj TutorialStep1-LocalNoDirZIP) +ExternalProject_Add(${proj} + URL "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.zip" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" +) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/ZIP") + + +# CVS-based tests: +# +set(do_cvs_tests 0) + +if(CVS_EXECUTABLE) + set(do_cvs_tests 1) +endif() + +if(do_cvs_tests AND NOT UNIX) + if("${CVS_EXECUTABLE}" MATCHES "cygwin") + message(STATUS "No ExternalProject cvs tests with cygwin cvs.exe outside cygwin!") + set(do_cvs_tests 0) + endif() +endif() + +if(do_cvs_tests) + # Unzip/untar the CVS repository in our source folder so that other + # projects below may use it to test CVS args of ExternalProject_Add + # + set(proj SetupLocalCVSRepository) + set(local_cvs_repo "${CMAKE_CURRENT_BINARY_DIR}/LocalRepositories/CVS") + ExternalProject_Add(${proj} + SOURCE_DIR ${local_cvs_repo} + URL ${CMAKE_CURRENT_SOURCE_DIR}/cvsrepo.tgz + URL_MD5 55fc85825ffdd9ed2597123c68b79f7e + BUILD_COMMAND "" + CONFIGURE_COMMAND "${CVS_EXECUTABLE}" --version + INSTALL_COMMAND "" + ) + set_property(TARGET ${proj} + PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing") + + # The MSYS cvs tool interprets "c:/" as a "machine:" name for SSH. + # Detect the MSYS cvs and convert the repo path to an MSYS path. + if(WIN32) + if(EXISTS "${CVS_EXECUTABLE}") + file(STRINGS "${CVS_EXECUTABLE}" cvs_is_msys LIMIT_COUNT 1 REGEX "[Mm][Ss][Yy][Ss]") + if(cvs_is_msys) + message(STATUS "'${CVS_EXECUTABLE}' is from MSYS (contains '${cvs_is_msys}')") + string(REGEX REPLACE "^([A-Za-z]):" "/\\1" local_cvs_repo "${local_cvs_repo}") + endif() + endif() + endif() + + # CVS by date stamp: + # + set(proj TutorialStep1-CVS-20090626) + ExternalProject_Add(${proj} + CVS_REPOSITORY "${local_cvs_repo}" + CVS_MODULE "TutorialStep1" + CVS_TAG "-D2009-06-26 16:50:00 UTC" + UPDATE_COMMAND "" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" + DEPENDS "SetupLocalCVSRepository" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "CVS") + + # CVS by tag: + # + set(proj TutorialStep1-CVS-testtag1) + ExternalProject_Add(${proj} + CVS_REPOSITORY "${local_cvs_repo}" + CVS_MODULE "TutorialStep1" + CVS_TAG -rtesttag1 + UPDATE_COMMAND "" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" + DEPENDS "SetupLocalCVSRepository" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "CVS") + + # Live CVS / HEAD (no CVS_TAG): + # + set(proj TutorialStep1-CVS-HEAD) + ExternalProject_Add(${proj} + CVS_REPOSITORY "${local_cvs_repo}" + CVS_MODULE "TutorialStep1" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" + DEPENDS "SetupLocalCVSRepository" + DEPENDS "EmptyNoOpProject" + DEPENDS "TutorialStep1-LocalTAR" + DEPENDS "TutorialStep1-LocalNoDirTAR" + DEPENDS "TutorialStep1-LocalTGZ" + DEPENDS "TutorialStep1-LocalNoDirTGZ" + DEPENDS "TutorialStep1-CVS-20090626" + DEPENDS "TutorialStep1-CVS-testtag1" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "CVS") +endif() + + +# SVN-based tests: +# +set(do_svn_tests 0) + +if(Subversion_SVN_EXECUTABLE) + set(do_svn_tests 1) +endif() + +# Only do svn tests with svn >= version 1.2 +# +if(do_svn_tests) + if(Subversion_VERSION_SVN VERSION_LESS 1.2) + message(STATUS "No ExternalProject svn tests with svn client less than version 1.2") + set(do_svn_tests 0) + endif() +endif() + +# Only do svn tests in cygwin/cygwin or not-cygwin/not-cygwin arrangements: +# +if(do_svn_tests) + if(CMAKE_CURRENT_BINARY_DIR MATCHES "cygdrive/" AND + NOT "${Subversion_SVN_EXECUTABLE}" MATCHES "cygwin") + message(STATUS "No ExternalProject svn tests with non-cygwin svn client in a /cygdrive based build") + set(do_svn_tests 0) + endif() +endif() + +if(do_svn_tests) + # Unzip/untar the SVN repository in our source folder so that other + # projects below may use it to test SVN args of ExternalProject_Add + # + set(proj SetupLocalSVNRepository) + set(local_svn_repo "${CMAKE_CURRENT_BINARY_DIR}/LocalRepositories/SVN") + set(local_svn_repo_url "file:///${local_svn_repo}/TutorialStep1") + ExternalProject_Add(${proj} + SOURCE_DIR ${local_svn_repo} + URL ${CMAKE_CURRENT_SOURCE_DIR}/svnrepo.tgz + URL_MD5 2f468be4ed1fa96377fca0cc830819c4 + BUILD_COMMAND "" + CONFIGURE_COMMAND "${Subversion_SVN_EXECUTABLE}" --version + INSTALL_COMMAND "" + ) + set_property(TARGET ${proj} + PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing") + + # SVN by date stamp: + # + set(proj TutorialStep1-SVN-20090626) + ExternalProject_Add(${proj} + SVN_REPOSITORY "${local_svn_repo_url}" + SVN_REVISION "-r{2009-06-26 16:50:00 +0000}" + UPDATE_COMMAND "" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" + DEPENDS "SetupLocalSVNRepository" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "SVN") + + # SVN by revision number: + # + set(proj TutorialStep1-SVN-r2) + ExternalProject_Add(${proj} + SVN_REPOSITORY "${local_svn_repo_url}" + SVN_REVISION "-r2" + UPDATE_COMMAND "" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" + DEPENDS "SetupLocalSVNRepository" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "SVN") + + # Live SVN / trunk (no SVN_REVISION): + # + set(proj TutorialStep1-SVN-trunk) + ExternalProject_Add(${proj} + SVN_REPOSITORY "${local_svn_repo_url}" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" + DEPENDS "SetupLocalSVNRepository" + LOG_DOWNLOAD 1 + ) + set_property(TARGET ${proj} PROPERTY FOLDER "SVN") +endif() + + +set(do_git_tests 0) + +if(GIT_EXECUTABLE) + set(do_git_tests 1) + + execute_process( + COMMAND "${GIT_EXECUTABLE}" --version + OUTPUT_VARIABLE ov + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + string(REGEX REPLACE "^git version (.+)$" "\\1" git_version "${ov}") + message(STATUS "git_version='${git_version}'") + + if(git_version VERSION_LESS 1.6.5) + message(STATUS "No ExternalProject git tests with git client less than version 1.6.5") + set(do_git_tests 0) + endif() +endif() + + +if(do_git_tests) + set(local_git_repo "../../LocalRepositories/GIT") + + # Unzip/untar the git repository in our source folder so that other + # projects below may use it to test git args of ExternalProject_Add + # + set(proj SetupLocalGITRepository) + ExternalProject_Add(${proj} + SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/LocalRepositories/GIT + URL ${CMAKE_CURRENT_SOURCE_DIR}/gitrepo.tgz + BUILD_COMMAND "" + CONFIGURE_COMMAND "${GIT_EXECUTABLE}" --version + INSTALL_COMMAND "" + ) + set_property(TARGET ${proj} + PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing") + + # git by commit id: + # + set(proj TutorialStep1-GIT-byhash) + ExternalProject_Add(${proj} + GIT_REPOSITORY "${local_git_repo}" + GIT_TAG d1970730310fe8bc07e73f15dc570071f9f9654a + UPDATE_COMMAND "" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" + DEPENDS "SetupLocalGITRepository" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + + # git by explicit branch/tag name: + # + set(proj TutorialStep1-GIT-bytag) + ExternalProject_Add(${proj} + GIT_REPOSITORY "${local_git_repo}" + GIT_TAG "origin/master" + UPDATE_COMMAND "" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" + DEPENDS "SetupLocalGITRepository" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + + # Live git / master (no GIT_TAG): + # + set(proj TutorialStep1-GIT-master) + ExternalProject_Add(${proj} + GIT_REPOSITORY "${local_git_repo}" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" + DEPENDS "SetupLocalGITRepository" + LOG_UPDATE 1 + ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") +endif() + + +# Test the testable built/installed products: +# +enable_testing() + + +# Do at least a smoke test of a built executable from each +# project's build directory... +# +# BuildTree tests: +# +if(can_build_tutorial_step5) + add_test(TutorialStep5-Local-BuildTreeTest + "${binary_base}/TutorialStep5-Local/Tutorial" 42) + set_property(TEST TutorialStep5-Local-BuildTreeTest + APPEND PROPERTY LABELS Step5 BuildTree) +endif() + +add_test(TutorialStep1-LocalTAR-BuildTreeTest + "${binary_base}/TutorialStep1-LocalTAR/EP-Tutorial" 36) +set_property(TEST TutorialStep1-LocalTAR-BuildTreeTest + APPEND PROPERTY LABELS TAR) + +add_test(TutorialStep1-LocalNoDirTAR-BuildTreeTest + "${binary_base}/TutorialStep1-LocalNoDirTAR/EP-Tutorial" 25) + +add_test(TutorialStep1-LocalTGZ-BuildTreeTest + "${binary_base}/TutorialStep1-LocalTGZ/Tutorial" 16) +set_property(TEST TutorialStep1-LocalTGZ-BuildTreeTest + APPEND PROPERTY LABELS TGZ) + +add_test(TutorialStep1-LocalNoDirTGZ-BuildTreeTest + "${binary_base}/TutorialStep1-LocalNoDirTGZ/Tutorial" 9) + +if(do_cvs_tests) + add_test(TutorialStep1-CVS-20090626-BuildTreeTest + "${binary_base}/TutorialStep1-CVS-20090626/Tutorial" 4) + + add_test(TutorialStep1-CVS-testtag1-BuildTreeTest + "${binary_base}/TutorialStep1-CVS-testtag1/Tutorial" 64) + + add_test(TutorialStep1-CVS-HEAD-BuildTreeTest + "${binary_base}/TutorialStep1-CVS-HEAD/Tutorial" 81) +endif() + +if(do_svn_tests) + add_test(TutorialStep1-SVN-20090626-BuildTreeTest + "${binary_base}/TutorialStep1-SVN-20090626/Tutorial" 100) + + add_test(TutorialStep1-SVN-r2-BuildTreeTest + "${binary_base}/TutorialStep1-SVN-r2/Tutorial" 99) + + add_test(TutorialStep1-SVN-trunk-BuildTreeTest + "${binary_base}/TutorialStep1-SVN-trunk/Tutorial" 98) +endif() + + +# InstallTree tests: +# +if(can_build_tutorial_step5) + add_test(TutorialStep5-InstallTreeTest + "${TutorialStep5_install_dir}/bin/Tutorial" 49) + set_property(TEST TutorialStep5-InstallTreeTest + APPEND PROPERTY LABELS Step5 InstallTree) +endif() + + +message(STATUS "can_build_tutorial_step5='${can_build_tutorial_step5}'") +message(STATUS "do_cvs_tests='${do_cvs_tests}'") +message(STATUS "do_svn_tests='${do_svn_tests}'") +message(STATUS "do_git_tests='${do_git_tests}'") +message(STATUS "GIT_EXECUTABLE='${GIT_EXECUTABLE}'") diff --git a/Tests/ExternalProject/Example/CMakeLists.txt b/Tests/ExternalProject/Example/CMakeLists.txt new file mode 100644 index 000000000..69ebaaf51 --- /dev/null +++ b/Tests/ExternalProject/Example/CMakeLists.txt @@ -0,0 +1,11 @@ +# This is the canonical simplest ExternalProject example CMakeLists.txt file: +cmake_minimum_required(VERSION 2.8) +project(ExternalProjectExample NONE) +include(ExternalProject) + +ExternalProject_Add( + cmake281 + URL http://www.cmake.org/files/v2.8/cmake-2.8.1.tar.gz + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + BUILD_COMMAND "" +) diff --git a/Tests/ExternalProject/Step1.tar b/Tests/ExternalProject/Step1.tar Binary files differnew file mode 100644 index 000000000..3711f07fb --- /dev/null +++ b/Tests/ExternalProject/Step1.tar diff --git a/Tests/ExternalProject/Step1.tar.bz2 b/Tests/ExternalProject/Step1.tar.bz2 Binary files differnew file mode 100644 index 000000000..49b5f23a6 --- /dev/null +++ b/Tests/ExternalProject/Step1.tar.bz2 diff --git a/Tests/ExternalProject/Step1.tgz b/Tests/ExternalProject/Step1.tgz Binary files differnew file mode 100644 index 000000000..d9b4cd259 --- /dev/null +++ b/Tests/ExternalProject/Step1.tgz diff --git a/Tests/ExternalProject/Step1.zip b/Tests/ExternalProject/Step1.zip Binary files differnew file mode 100644 index 000000000..49dac24ed --- /dev/null +++ b/Tests/ExternalProject/Step1.zip diff --git a/Tests/ExternalProject/Step1NoDir.tar b/Tests/ExternalProject/Step1NoDir.tar Binary files differnew file mode 100644 index 000000000..03664b856 --- /dev/null +++ b/Tests/ExternalProject/Step1NoDir.tar diff --git a/Tests/ExternalProject/Step1NoDir.tar.bz2 b/Tests/ExternalProject/Step1NoDir.tar.bz2 Binary files differnew file mode 100644 index 000000000..92eb480d6 --- /dev/null +++ b/Tests/ExternalProject/Step1NoDir.tar.bz2 diff --git a/Tests/ExternalProject/Step1NoDir.tgz b/Tests/ExternalProject/Step1NoDir.tgz Binary files differnew file mode 100644 index 000000000..71a2d8142 --- /dev/null +++ b/Tests/ExternalProject/Step1NoDir.tgz diff --git a/Tests/ExternalProject/Step1NoDir.zip b/Tests/ExternalProject/Step1NoDir.zip Binary files differnew file mode 100644 index 000000000..b42d31879 --- /dev/null +++ b/Tests/ExternalProject/Step1NoDir.zip diff --git a/Tests/ExternalProject/Step1Patch.cmake b/Tests/ExternalProject/Step1Patch.cmake new file mode 100644 index 000000000..35e09d948 --- /dev/null +++ b/Tests/ExternalProject/Step1Patch.cmake @@ -0,0 +1,25 @@ +# Verify the current working directory. +if(NOT EXISTS CMakeLists.txt) + message(FATAL_ERROR "File does not exist:\n ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt") +endif() +if(NOT EXISTS tutorial.cxx) + message(FATAL_ERROR "File does not exist:\n ${CMAKE_CURRENT_SOURCE_DIR}/tutorial.cxx") +endif() + +# Check if the patch is already applied. +file(STRINGS CMakeLists.txt prop_line REGEX "^set_property") +if(prop_line) + message(STATUS "Patch already applied!") + return() +endif() + +# Apply the patch. +file(APPEND CMakeLists.txt " +# Patch by ExternalProject test: +set_property(TARGET Tutorial PROPERTY OUTPUT_NAME EP-Tutorial) +list(LENGTH TEST_LIST len) +if(NOT len EQUAL 3) + message(FATAL_ERROR \"TEST_LIST length is \${len}, not 3\") +endif() +") +message(STATUS "Patched ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt") diff --git a/Tests/ExternalProject/TryCheckout.cmake b/Tests/ExternalProject/TryCheckout.cmake new file mode 100644 index 000000000..de069ebe4 --- /dev/null +++ b/Tests/ExternalProject/TryCheckout.cmake @@ -0,0 +1,54 @@ +find_package(CVS) +find_package(Subversion) + + +function(try_cvs_checkout repository module dir result_var) + # Assume cvs checkouts will not work: + set(${result_var} 0 PARENT_SCOPE) + + if(CVS_EXECUTABLE) + message(STATUS "try_cvs_checkout") + + # Ensure directory exists so we can call cvs in it: + file(MAKE_DIRECTORY "${dir}") + + # Try to do the cvs checkout command: + execute_process(COMMAND ${CVS_EXECUTABLE} -d ${repository} co ${module} + WORKING_DIRECTORY ${dir} + TIMEOUT 30 + RESULT_VARIABLE rv) + + # If it worked, cvs checkouts will work: + if(rv EQUAL 0) + set(${result_var} 1 PARENT_SCOPE) + endif() + + message(STATUS "try_cvs_checkout -- done") + endif() +endfunction(try_cvs_checkout) + + +function(try_svn_checkout repository dir result_var) + # Assume svn checkouts will not work: + set(${result_var} 0 PARENT_SCOPE) + + if(Subversion_SVN_EXECUTABLE) + message(STATUS "try_svn_checkout") + + # Ensure directory exists so we can call svn in it: + file(MAKE_DIRECTORY "${dir}") + + # Try to do the svn checkout command: + execute_process(COMMAND ${Subversion_SVN_EXECUTABLE} co ${repository} ${dir} + WORKING_DIRECTORY ${dir} + TIMEOUT 30 + RESULT_VARIABLE rv) + + # If it worked, svn checkouts will work: + if(rv EQUAL 0) + set(${result_var} 1 PARENT_SCOPE) + endif() + + message(STATUS "try_svn_checkout -- done") + endif() +endfunction(try_svn_checkout) diff --git a/Tests/ExternalProject/cvsrepo.tgz b/Tests/ExternalProject/cvsrepo.tgz Binary files differnew file mode 100644 index 000000000..baba6d3c2 --- /dev/null +++ b/Tests/ExternalProject/cvsrepo.tgz diff --git a/Tests/ExternalProject/gitrepo.tgz b/Tests/ExternalProject/gitrepo.tgz Binary files differnew file mode 100644 index 000000000..0a84bda7c --- /dev/null +++ b/Tests/ExternalProject/gitrepo.tgz diff --git a/Tests/ExternalProject/svnrepo.tgz b/Tests/ExternalProject/svnrepo.tgz Binary files differnew file mode 100644 index 000000000..b8484165e --- /dev/null +++ b/Tests/ExternalProject/svnrepo.tgz diff --git a/Tests/FindModulesExecuteAll/CMakeLists.txt b/Tests/FindModulesExecuteAll/CMakeLists.txt new file mode 100644 index 000000000..df5162652 --- /dev/null +++ b/Tests/FindModulesExecuteAll/CMakeLists.txt @@ -0,0 +1,30 @@ +# This file includes all FindXXX.cmake modules, so they are all executed. +# As it is it doesn't test a lot. +# It makes sure that the modules don't contain basic syntax errors. +# It also makes sure that modules don't fail with an error if something +# wasn't found but REQUIRED was not given. +# +# I guess more things could be added, like checking whether variables are +# defined after running the modules (e.g. FOO_FOUND etc.). +project(FindModulesExecuteAll) +cmake_minimum_required(VERSION 2.7) + +file(GLOB all_modules "${CMAKE_CURRENT_SOURCE_DIR}/../../Modules/Find*cmake") + +foreach(module ${all_modules}) + message(STATUS "module: ${module}") + include("${module}") + + # get the "basename" of the package, so the existence of variables like + # FOO_FOUND could be tested later on, Alex + string(REGEX REPLACE ".+Find([^\\.]+)\\.cmake" "\\1" packageName "${module}") + string(TOUPPER "${packageName}" packageNameUpper) + +# disabled for now, since too many modules break: +# if(NOT DEFINED ${packageNameUpper}_FOUND) +# message(SEND_ERROR "${packageNameUpper}_FOUND not defined !") +# endif(NOT DEFINED ${packageNameUpper}_FOUND) + +endforeach(module ${all_modules}) + +add_executable(FindModulesExecuteAll main.c) diff --git a/Tests/FindModulesExecuteAll/main.c b/Tests/FindModulesExecuteAll/main.c new file mode 100644 index 000000000..c13815cea --- /dev/null +++ b/Tests/FindModulesExecuteAll/main.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt new file mode 100644 index 000000000..3674f0efe --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -0,0 +1,31 @@ + + +if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") + + # Test whether the make is GNU make, and only add the test in this case, + # since the configured makefile in this test uses $(shell ...), which + # is AFAIK a GNU make extension. Alex + execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} -v + OUTPUT_VARIABLE makeVersionOutput + ERROR_QUIET + TIMEOUT 10) + string(TOUPPER "${makeVersionOutput}" MAKE_VERSION_OUTPUT) + if("${MAKE_VERSION_OUTPUT}" MATCHES ".*GNU MAKE.*") + + # build a library which we can search during the test + add_library(foo STATIC foo.cpp) + + # configure a FindFoo.cmake so it knows where the library can be found + configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY) + + # now set up the test: + get_target_property(cmakeExecutable cmake LOCATION) + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) + + add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile ) + + endif() + +endif() diff --git a/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in b/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in new file mode 100644 index 000000000..dc62bac41 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in @@ -0,0 +1,9 @@ + +find_library(FOO_LIBRARY NAMES foo HINTS "@CMAKE_CURRENT_BINARY_DIR@" ) +find_path(FOO_INCLUDE_DIR NAMES foo.h HINTS "@CMAKE_CURRENT_SOURCE_DIR@" ) + +set(FOO_LIBRARIES ${FOO_LIBRARY}) +set(FOO_INCLUDE_DIRS "${FOO_INCLUDE_DIR}" "/some/path/with a space/include" ) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Foo DEFAULT_MSG FOO_LIBRARY FOO_INCLUDE_DIR ) diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in new file mode 100644 index 000000000..f647901e7 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -0,0 +1,29 @@ +CMAKE = "@cmakeExecutable@" +CMAKE_CURRENT_BINARY_DIR = "@CMAKE_CURRENT_BINARY_DIR@" +CMAKE_CXX_COMPILER = "@CMAKE_CXX_COMPILER@" +CMAKE_CXX_COMPILER_ID = "@CMAKE_CXX_COMPILER_ID@" + +CMAKE_FOO = $(CMAKE) --find-package -DCMAKE_MODULE_PATH=$(CMAKE_CURRENT_BINARY_DIR) -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=$(CMAKE_CXX_COMPILER_ID) + +tmp = tmp.txt + +all: clean pngtest + +main.o: main.cpp + @$(CMAKE_FOO) -DMODE=COMPILE >$(tmp) + @foo="`cat $(tmp)`"; \ + printf '"%s" %s %s -c main.cpp\n' $(CMAKE_CXX_COMPILER) "$(CXXFLAGS)" "$$foo" >$(tmp) + @cat $(tmp) + @sh $(tmp) + @rm -f $(tmp) + +pngtest: main.o + @$(CMAKE_FOO) -DMODE=LINK >$(tmp) + @foo="`cat $(tmp)`"; \ + printf '"%s" %s %s -o pngtest main.o %s\n' $(CMAKE_CXX_COMPILER) "$(CXXFLAGS)" "$(LDFLAGS)" "$$foo" >$(tmp) + @cat $(tmp) + @sh $(tmp) + @rm -f $(tmp) + +clean: + rm -f $(tmp) *.o pngtest diff --git a/Tests/FindPackageModeMakefileTest/foo.cpp b/Tests/FindPackageModeMakefileTest/foo.cpp new file mode 100644 index 000000000..6aea22629 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/foo.cpp @@ -0,0 +1,4 @@ +int foo() +{ + return 1477; +} diff --git a/Tests/FindPackageModeMakefileTest/foo.h b/Tests/FindPackageModeMakefileTest/foo.h new file mode 100644 index 000000000..4ec598ad5 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/foo.h @@ -0,0 +1,6 @@ +#ifndef FOO_H +#define FOO_H + +int foo(); + +#endif diff --git a/Tests/FindPackageModeMakefileTest/main.cpp b/Tests/FindPackageModeMakefileTest/main.cpp new file mode 100644 index 000000000..e5f9134ce --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/main.cpp @@ -0,0 +1,8 @@ +#include <stdio.h> +#include <foo.h> + +int main() +{ + printf("foo is: %d\n", foo()); + return 0; +} diff --git a/Tests/FindPackageTest/A/wibble-config.cmake b/Tests/FindPackageTest/A/wibble-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/A/wibble-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/B/wibble-config.cmake b/Tests/FindPackageTest/B/wibble-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/B/wibble-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/Baz 1.1/BazConfig.cmake b/Tests/FindPackageTest/Baz 1.1/BazConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/Baz 1.1/BazConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/Baz 1.1/BazConfigVersion.cmake b/Tests/FindPackageTest/Baz 1.1/BazConfigVersion.cmake new file mode 100644 index 000000000..321fa118e --- /dev/null +++ b/Tests/FindPackageTest/Baz 1.1/BazConfigVersion.cmake @@ -0,0 +1,8 @@ +SET(PACKAGE_VERSION 1.1) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1) + diff --git a/Tests/FindPackageTest/Baz 1.2/CMake/BazConfig.cmake b/Tests/FindPackageTest/Baz 1.2/CMake/BazConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/Baz 1.2/CMake/BazConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/Baz 1.2/CMake/BazConfigVersion.cmake b/Tests/FindPackageTest/Baz 1.2/CMake/BazConfigVersion.cmake new file mode 100644 index 000000000..4576809f5 --- /dev/null +++ b/Tests/FindPackageTest/Baz 1.2/CMake/BazConfigVersion.cmake @@ -0,0 +1,8 @@ +SET(PACKAGE_VERSION 1.2) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 2) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 2) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1) + diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt new file mode 100644 index 000000000..e85fb4dd2 --- /dev/null +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -0,0 +1,533 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(FindPackageTest) + +LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +# Look for a package which uses FindPackageHandleStandardArgs.cmake with the +# new (as of cmake 2.8.3) syntax. This works only if CMP0017 is set to NEW, +# because otherwise FindPackageHandleStandardArgs.cmake from the current +# directory is included (via CMAKE_MODULE_PATH). +CMAKE_POLICY(SET CMP0017 NEW) +FIND_PACKAGE(ZLIB QUIET) + +# Look for a package that has a find module and may be found. +FIND_PACKAGE(OpenGL QUIET) + +# Look for a package that has no find module and will not be found. +FIND_PACKAGE(NotAPackage QUIET) + +# Look for a package that has an advanced find module. +FIND_PACKAGE(VTK QUIET) + +ADD_EXECUTABLE(FindPackageTest FindPackageTest.cxx) + +# test behaviour of cmFindBase wrt. the CMAKE_PREFIX_PATH variable +# foo.h should be found in ${CMAKE_CURRENT_SOURCE_DIR}/include: + +SET(CMAKE_PREFIX_PATH /blub /blah "${CMAKE_CURRENT_SOURCE_DIR}") +FIND_PATH(FOO_DIR foo.h) + +IF(NOT FOO_DIR) + MESSAGE(FATAL_ERROR "Did not find foo.h which is in ${CMAKE_CURRENT_SOURCE_DIR}/include + CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}") +ENDIF(NOT FOO_DIR) + +FIND_PACKAGE(VersionTestA 1) +FIND_PACKAGE(VersionTestB 1.2) +FIND_PACKAGE(VersionTestC 1.2.3) +FIND_PACKAGE(VersionTestD 1.2.3.4) + + +FIND_PACKAGE(LotsOfComponents COMPONENTS AComp OPTIONAL_COMPONENTS BComp CComp) +IF(NOT LOTSOFCOMPONENTS_FOUND) + MESSAGE(SEND_ERROR "LotsOfComponents not found !") +ENDIF() + +#----------------------------------------------------------------------------- +# Test system package registry if possible. +SET(CMakeTestSystemPackage "") +IF(WIN32 AND NOT CYGWIN) + # Try writing a value to the system package registry. + SET(_data "${FindPackageTest_SOURCE_DIR}/SystemPackage") + SET(_key "HKLM\\Software\\Kitware\\CMake\\Packages\\CMakeTestSystemPackage") + SET(_file "${FindPackageTest_BINARY_DIR}/CMakeTestSystemPackage.data") + FILE(WRITE ${_file} "${_data}\n") + EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -E md5sum ${_file} + OUTPUT_VARIABLE _output ERROR_VARIABLE _error RESULT_VARIABLE _failed + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + STRING(REGEX REPLACE " .*" "" _value "${_output}") + IF(NOT _failed AND _value) + EXECUTE_PROCESS( + COMMAND reg add "${_key}" /v "${_value}" /t REG_SZ /d "${_data}" /f + OUTPUT_VARIABLE _output ERROR_VARIABLE _output RESULT_VARIABLE _failed + ) + ENDIF() + # If the above worked, add the rest of the test and a rule to + # cleanup the value. + IF(NOT _failed) + MESSAGE(STATUS "HKLM is writable: enabling CMakeTestSystemPackage") + SET(CMakeTestSystemPackage_CLEANUP reg delete "${_key}" /v "${_value}" /f) + SET(CMakeTestSystemPackage CMakeTestSystemPackage) + ELSE() + MESSAGE(STATUS "HKLM is readonly: disabling CMakeTestSystemPackage") + ENDIF() +ENDIF() + +#----------------------------------------------------------------------------- + +#SET(CMAKE_FIND_DEBUG_MODE 1) + +# For purposes of the test wipe out previous find results. +SET(PACKAGES + foo Foo Bar Blub TFramework Tframework TApp Tapp Special + VersionedA VersionedB VersionedC VersionedD VersionedE + WrongA WrongB WrongC WrongD + wibbleA wibbleB + RecursiveA RecursiveB RecursiveC + ArchA ArchB ArchC ArchD + EnvA EnvB + SetFoundTRUE SetFoundFALSE + ${CMakeTestSystemPackage} + ) +FOREACH(p ${PACKAGES}) + SET(${p}_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) +ENDFOREACH(p) + +# Enable framework and bundle searching. Make sure bundles are found +# before unix-syle packages. +SET(CMAKE_FIND_FRAMEWORK LAST) +SET(CMAKE_FIND_APPBUNDLE FIRST) + +# Set the wrong answer for a find to make sure it re-finds. +set(VersionedA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/cmake/zot-4.0) + +# Test that CMAKE_IGNORE_PATH can ignore the purposely bad package +# files in the lib/cmake/zot-3.1 directory. +set(CMAKE_IGNORE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/cmake/zot-3.1) + +# Look for packages with new-style signatures. +FIND_PACKAGE(foo NO_MODULE) +FIND_PACKAGE(Foo CONFIGS FooConfig.cmake) +FIND_PACKAGE(Bar) +SET(CMAKE_DISABLE_FIND_PACKAGE_Blub TRUE) +FIND_PACKAGE(Blub NO_MODULE) +FIND_PACKAGE(TFramework CONFIGS TFrameworkConfig.cmake) +FIND_PACKAGE(Tframework) +FIND_PACKAGE(TApp) +FIND_PACKAGE(Tapp CONFIGS tapp-config.cmake) +FIND_PACKAGE(Special NAMES Suffix SuffixTest PATH_SUFFIXES test) +FIND_PACKAGE(VersionedA 2 NAMES zot) +FIND_PACKAGE(VersionedB 3.1 EXACT NAMES zot) +FIND_PACKAGE(VersionedC 4.0 EXACT NAMES zot) +FIND_PACKAGE(VersionedD 1.1 EXACT NAMES Baz) +FIND_PACKAGE(VersionedE 1.2 EXACT NAMES Baz) + +# Test Config files which set Xyz_FOUND themselves: +FIND_PACKAGE(SetFoundTRUE NO_MODULE) +FIND_PACKAGE(SetFoundFALSE NO_MODULE) + +# Test wrong initial path when result is present. +SET(WrongA_DIR "${VersionedD_DIR}") +FIND_PACKAGE(WrongA 1.2 EXACT NAMES Baz) + +# Test wrong initial cache entry of UNINITIALIZED type when result is present. +SET(WrongB_DIR "${VersionedD_DIR}" CACHE UNINITIALIZED "Wrong Value" FORCE) +GET_PROPERTY(type CACHE WrongB_DIR PROPERTY TYPE) +FIND_PACKAGE(WrongB 1.2 EXACT NAMES Baz) + +# Test wrong initial path when result is missing. +SET(WrongC_DIR "${VersionedD_DIR}") +FIND_PACKAGE(WrongC 1.3 EXACT QUIET NAMES Baz) + +# Test wrong initial cache entry of UNINITIALIZED type when result is missing. +SET(WrongD_DIR "${VersionedD_DIR}" CACHE UNINITIALIZED "Wrong Value" FORCE) +GET_PROPERTY(type CACHE WrongD_DIR PROPERTY TYPE) +FIND_PACKAGE(WrongD 1.3 EXACT QUIET NAMES Baz) + +# HINTS should override the system but PATHS should not +LIST(INSERT CMAKE_SYSTEM_PREFIX_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/A") +FIND_PACKAGE(wibbleA NAMES wibble PATHS B) +FIND_PACKAGE(wibbleB NAMES wibble HINTS B) + +# Look for package with recursive find-modules. +FIND_PACKAGE(RecursiveA COMPONENTS A) +FIND_PACKAGE(RecursiveB 2) +FIND_PACKAGE(RecursiveC 3.1 EXACT) + +# Test architecture-specific search directories. +SET(CMAKE_LIBRARY_ARCHITECTURE arch) +FIND_PACKAGE(ArchA NAMES Bar) +FIND_PACKAGE(ArchB NAMES Foo CONFIGS FooConfig.cmake) +FIND_PACKAGE(ArchC 3.1 EXACT NAMES zot) +FIND_PACKAGE(ArchD 4.0 EXACT NAMES zot) +UNSET(CMAKE_LIBRARY_ARCHITECTURE) + +# Test <Package>_DIR environment variable. +# We erase the main prefix path to ensure the env var is used. +SET(CMAKE_PREFIX_PATH) +SET(ENV{EnvA_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/lib/zot-3.1") +FIND_PACKAGE(EnvA 3.1 EXACT QUIET NAMES zot) # Should Work +FIND_PACKAGE(EnvB 3.1 EXACT QUIET NAMES zot) # Should Fail + +# Test system package registry if available. +IF(CMakeTestSystemPackage) + FIND_PACKAGE(CMakeTestSystemPackage) + EXECUTE_PROCESS(COMMAND ${CMakeTestSystemPackage_CLEANUP} + OUTPUT_VARIABLE _output ERROR_VARIABLE _error) +ENDIF() + +# Expected locations at which packages should be found. +SET(foo_EXPECTED "lib/foo-1.2/foo-config.cmake") +SET(Foo_EXPECTED "lib/foo-1.2/CMake/FooConfig.cmake") +SET(Bar_EXPECTED "lib/Bar/BarConfig.cmake") +SET(Blub_MISSING "") +SET(Special_EXPECTED "lib/suffix/test/SuffixTestConfig.cmake") +SET(TFramework_EXPECTED + "TFramework.framework/Versions/A/Resources/CMake/TFrameworkConfig.cmake") +SET(Tframework_EXPECTED + "TFramework.framework/Versions/A/Resources/tframework-config.cmake") +SET(TApp_EXPECTED + "TApp.app/Contents/Resources/TAppConfig.cmake") +SET(Tapp_EXPECTED + "TApp.app/Contents/Resources/cmake/tapp-config.cmake") +SET(VersionedA_EXPECTED "lib/zot-2.0/zot-config.cmake") +SET(VersionedB_EXPECTED "lib/zot-3.1/zot-config.cmake") +SET(VersionedC_EXPECTED "lib/cmake/zot-4.0/zot-config.cmake") +SET(VersionedD_EXPECTED "Baz 1.1/BazConfig.cmake") +SET(VersionedE_EXPECTED "Baz 1.2/CMake/BazConfig.cmake") +SET(WrongA_EXPECTED "${VersionedE_EXPECTED}") +SET(WrongB_EXPECTED "${VersionedE_EXPECTED}") +SET(WrongC_MISSING "WrongC_DIR-NOTFOUND") +SET(WrongD_MISSING "WrongD_DIR-NOTFOUND") +SET(wibbleA_EXPECTED "A/wibble-config.cmake") +SET(wibbleB_EXPECTED "B/wibble-config.cmake") +SET(RecursiveA_EXPECTED "lib/RecursiveA/recursivea-config.cmake") +SET(RecursiveB_EXPECTED "lib/zot-2.0/zot-config.cmake") +SET(RecursiveC_EXPECTED "lib/zot-3.1/zot-config.cmake") +SET(ArchA_EXPECTED "lib/arch/Bar/BarConfig.cmake") +SET(ArchB_EXPECTED "lib/arch/foo-1.2/CMake/FooConfig.cmake") +SET(ArchC_EXPECTED "lib/arch/zot-3.1/zot-config.cmake") +SET(ArchD_EXPECTED "lib/arch/cmake/zot-4.0/zot-config.cmake") +SET(EnvA_EXPECTED "lib/zot-3.1/zot-config.cmake") +SET(EnvB_MISSING "EnvB_DIR-NOTFOUND") +SET(SetFoundTRUE_EXPECTED "cmake/SetFoundTRUEConfig.cmake") +SET(SetFoundFALSE_MISSING "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +SET(CMakeTestSystemPackage_EXPECTED "SystemPackage/CMakeTestSystemPackageConfig.cmake") + +# Check the results. +FOREACH(p ${PACKAGES}) + IF(DEFINED ${p}_MISSING) + # Check and report failure. + IF(NOT "${${p}_DIR}" STREQUAL "${${p}_MISSING}") + MESSAGE(SEND_ERROR + "Package ${p} should have been [${${p}_MISSING}] but " + "was [${${p}_DIR}]") + ENDIF() + IF(${p}_FOUND) + MESSAGE(SEND_ERROR + "Package ${p} should not have been found, but ${p}_FOUND is set to " + "\"${${p}_FOUND}\"") + ENDIF() + ELSEIF(${p}_FOUND) + # Convert to relative path for comparison to expected location. + FILE(RELATIVE_PATH REL_${p}_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}" + "${${p}_CONFIG}") + + # Debugging output. + IF(CMAKE_FIND_DEBUG_MODE) + MESSAGE("Package ${p} found [${REL_${p}_CONFIG}]") + ENDIF(CMAKE_FIND_DEBUG_MODE) + + # Check and report failure. + IF(NOT "${REL_${p}_CONFIG}" STREQUAL "${${p}_EXPECTED}") + MESSAGE(SEND_ERROR + "Package ${p} should have been [${${p}_EXPECTED}] but " + "was [${REL_${p}_CONFIG}]") + ENDIF(NOT "${REL_${p}_CONFIG}" STREQUAL "${${p}_EXPECTED}") + ELSE() + MESSAGE(SEND_ERROR "Package ${p} not found!") + ENDIF() +ENDFOREACH(p) + +# Check that version information was extracted. +IF(NOT "${VersionedA_VERSION}" STREQUAL "2.0") + MESSAGE(SEND_ERROR + "Package VersionedA is version [${VersionedA_VERSION}], not [2.0]") +ENDIF(NOT "${VersionedA_VERSION}" STREQUAL "2.0") +IF(NOT "${VersionedA_VERSION_MAJOR}" STREQUAL "2") + MESSAGE(SEND_ERROR + "Package VersionedA is major version [${VersionedA_VERSION_MAJOR}], not [2]") +ENDIF(NOT "${VersionedA_VERSION_MAJOR}" STREQUAL "2") +IF(NOT "${VersionedA_VERSION_MINOR}" STREQUAL "0") + MESSAGE(SEND_ERROR + "Package VersionedA is minor version [${VersionedA_VERSION_MINOR}], not [0]") +ENDIF(NOT "${VersionedA_VERSION_MINOR}" STREQUAL "0") + +IF(NOT "${VersionedB_VERSION}" STREQUAL "3.1") + MESSAGE(SEND_ERROR + "Package VersionedB is version [${VersionedB_VERSION}], not [3.1]") +ENDIF(NOT "${VersionedB_VERSION}" STREQUAL "3.1") +IF(NOT "${VersionedB_VERSION_MAJOR}" STREQUAL "3") + MESSAGE(SEND_ERROR + "Package VersionedB is major version [${VersionedB_VERSION_MAJOR}], not [3]") +ENDIF(NOT "${VersionedB_VERSION_MAJOR}" STREQUAL "3") +IF(NOT "${VersionedB_VERSION_MINOR}" STREQUAL "1") + MESSAGE(SEND_ERROR + "Package VersionedB is minor version [${VersionedB_VERSION_MINOR}], not [1]") +ENDIF(NOT "${VersionedB_VERSION_MINOR}" STREQUAL "1") + +IF(NOT "${Special_VERSION}" STREQUAL "1.2") + MESSAGE(SEND_ERROR + "Package Special is version [${Special_VERSION}], not [1.2]") +ENDIF(NOT "${Special_VERSION}" STREQUAL "1.2") +IF(NOT "${Special_VERSION_MAJOR}" STREQUAL "1") + MESSAGE(SEND_ERROR + "Package Special is major version [${Special_VERSION_MAJOR}], not [1]") +ENDIF(NOT "${Special_VERSION_MAJOR}" STREQUAL "1") +IF(NOT "${Special_VERSION_MINOR}" STREQUAL "2") + MESSAGE(SEND_ERROR + "Package Special is minor version [${Special_VERSION_MINOR}], not [2]") +ENDIF(NOT "${Special_VERSION_MINOR}" STREQUAL "2") + +# Test version number comparison. +IF(NOT "1.2.3.4" VERSION_LESS "1.2.3.5") + MESSAGE(SEND_ERROR "1.2.3.4 VERSION_LESS 1.2.3.5 is not true!") +ENDIF() +IF(NOT "1.2" VERSION_LESS "1.10") + MESSAGE(SEND_ERROR "1.2 VERSION_LESS 1.10 is not true!") +ENDIF() +IF(NOT "1.02" VERSION_GREATER "1.1") + MESSAGE(SEND_ERROR "1.02 VERSION_GREATER 1.1 is not true!") +ENDIF() +IF("1.2.3" VERSION_GREATER "1.2.3.4") + MESSAGE(SEND_ERROR "1.2.3 VERSION_GREATER 1.2.3.4 is not false!") +ENDIF() +IF(NOT "1.2" VERSION_EQUAL "1.2.0.0") + MESSAGE(SEND_ERROR "1.2 VERSION_EQUAL 1.2.0.0 is not true!") +ENDIF() + +#----------------------------------------------------------------------------- +# Test export(PACKAGE) with find_package. +MESSAGE(STATUS "Preparing export(PACKAGE) test project") +TRY_COMPILE(EXPORTER_COMPILED + ${FindPackageTest_BINARY_DIR}/Exporter + ${FindPackageTest_SOURCE_DIR}/Exporter + CMakeTestExportPackage dummy + OUTPUT_VARIABLE output) +MESSAGE(STATUS "Searching for export(PACKAGE) test project") +SET(CMakeTestExportPackage_DIR "" CACHE FILEPATH + "Wipe out find results for testing." FORCE) +STRING(REGEX REPLACE "-.*$" "" version ${CMAKE_VERSION}) +FIND_PACKAGE(CMakeTestExportPackage 1.${version} EXACT REQUIRED) + +#----------------------------------------------------------------------------- +# Test configure_package_config_file(). + +include(CMakePackageConfigHelpers) + +set(INCLUDE_INSTALL_DIR include ) +set(SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/" ) +set(CURRENT_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}" ) + +configure_package_config_file(RelocatableConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/RelocatableConfig.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}" + PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR + ) + +set(Relocatable_FIND_COMPONENTS AComp BComp CComp) +set(Relocatable_FIND_REQUIRED_BComp 1) +include("${CMAKE_CURRENT_BINARY_DIR}/RelocatableConfig.cmake") + +if(NOT "${RELOC_INCLUDE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/include") + message(SEND_ERROR "RELOC_INCLUDE_DIR set by configure_package_config_file() is set to \"${RELOC_INCLUDE_DIR}\" (expected \"${CMAKE_CURRENT_BINARY_DIR}/include\")") +endif() + +if(NOT "${RELOC_SHARE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/share/") + message(SEND_ERROR "RELOC_SHARE_DIR set by configure_package_config_file() is set to \"${RELOC_SHARE_DIR}\" (expected \"${CMAKE_CURRENT_BINARY_DIR}/share/\")") +endif() + +if(NOT "${RELOC_BUILD_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") + message(SEND_ERROR "RELOC_BUILD_DIR set by configure_package_config_file() is set to \"${RELOC_BUILD_DIR}\" (expected \"${CMAKE_CURRENT_BINARY_DIR}\")") +endif() + +if(NOT DEFINED Relocatable_FOUND) + message(SEND_ERROR "Relocatable_FOUND not defined !") +endif() + +if(Relocatable_FOUND) + message(SEND_ERROR "Relocatable_FOUND set to TRUE !") +endif() + +#----------------------------------------------------------------------------- +# Test write_basic_config_version_file(). + +# also test that an empty CMAKE_SIZEOF_VOID_P is accepted: +set(_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) +set(CMAKE_SIZEOF_VOID_P "") + +write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake + VERSION 1.2.3 + COMPATIBILITY AnyNewerVersion) + +set(CMAKE_SIZEOF_VOID_P ${_CMAKE_SIZEOF_VOID_P}) + +set(PACKAGE_FIND_VERSION 2.3.4) +include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Foo123 with version 1.2.3, but 2.3.4 was requested !") +endif() + +set(PACKAGE_FIND_VERSION 0.0.1) +include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (0.0.1 was requested) !") +endif() + +if(PACKAGE_VERSION_UNSUITABLE) + message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !") +endif() + +set(PACKAGE_FIND_VERSION 1.0.0) +include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.0.0 was requested) !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 1.2.3) +include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.2.3 was requested) !") +endif() +if(NOT PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !") +endif() + + +####################### +include(WriteBasicConfigVersionFile) + +write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake + VERSION 1.2.3 + COMPATIBILITY SameMajorVersion) + +unset(PACKAGE_VERSION_UNSUITABLE) +set(PACKAGE_VERSION_EXACT FALSE) +set(PACKAGE_FIND_VERSION 2.3.4) +set(PACKAGE_FIND_VERSION_MAJOR 2) +include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Boo123 with version 1.2.3, but 2.3.4 was requested !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 0.0.1) +set(PACKAGE_FIND_VERSION_MAJOR 0) +include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Boo123 with version 1.2.3, but 0.0.1 was requested !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 1.0.0) +set(PACKAGE_FIND_VERSION_MAJOR 1) +include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.0.0 was requested) !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 1.2.3) +set(PACKAGE_FIND_VERSION_MAJOR 1) +include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.2.3 was requested) !") +endif() +if(NOT PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !") +endif() + +if(PACKAGE_VERSION_UNSUITABLE) + message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !") +endif() + +####################### + +write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake + VERSION 1.2.3.17 + COMPATIBILITY ExactVersion) + +unset(PACKAGE_VERSION_UNSUITABLE) +set(PACKAGE_VERSION_EXACT FALSE) +set(PACKAGE_FIND_VERSION 2.3.4) +include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Bar123 with version 1.2.3 (2.3.4 was requested) !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 1.2) +include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Bar123 with version 1.2.3 (1.2 was requested) !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 1) +include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Bar123 with version 1.2.3 (1 was requested) !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 1.2.3.4) +include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (1.2.3.4 was requested) !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 1.2.3) +set(PACKAGE_VERSION_EXACT FALSE) +set(PACKAGE_VERSION_COMPATIBLE FALSE) +include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (1.2.3 was requested) !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + + +set(PACKAGE_FIND_VERSION 1.2.3.17) +set(PACKAGE_VERSION_EXACT FALSE) +set(PACKAGE_VERSION_COMPATIBLE FALSE) +include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (1.2.3.17 was requested) !") +endif() +if(NOT PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !") +endif() + +if(PACKAGE_VERSION_UNSUITABLE) + message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !") +endif() diff --git a/Tests/FindPackageTest/Exporter/CMakeLists.txt b/Tests/FindPackageTest/Exporter/CMakeLists.txt new file mode 100644 index 000000000..d25a2e74c --- /dev/null +++ b/Tests/FindPackageTest/Exporter/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 2.7.20090831) +project(CMakeTestExportPackage C) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeTestExportPackageConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeTestExportPackageConfig.cmake + @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeTestExportPackageConfigVersion.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeTestExportPackageConfigVersion.cmake + @ONLY) +export(PACKAGE CMakeTestExportPackage) + +add_executable(dummy dummy.c) diff --git a/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfig.cmake.in b/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfig.cmake.in new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfig.cmake.in @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfigVersion.cmake.in b/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfigVersion.cmake.in new file mode 100644 index 000000000..ff450a145 --- /dev/null +++ b/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfigVersion.cmake.in @@ -0,0 +1,6 @@ +# Test config file. +SET(PACKAGE_VERSION "1.@CMAKE_VERSION@") +IF("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "${PACKAGE_VERSION}") + SET(PACKAGE_VERSION_COMPATIBLE 1) + SET(PACKAGE_VERSION_EXACT 1) +ENDIF() diff --git a/Tests/FindPackageTest/Exporter/dummy.c b/Tests/FindPackageTest/Exporter/dummy.c new file mode 100644 index 000000000..76e819701 --- /dev/null +++ b/Tests/FindPackageTest/Exporter/dummy.c @@ -0,0 +1 @@ +int main() { return 0; } diff --git a/Tests/FindPackageTest/FindLotsOfComponents.cmake b/Tests/FindPackageTest/FindLotsOfComponents.cmake new file mode 100644 index 000000000..9076d86ed --- /dev/null +++ b/Tests/FindPackageTest/FindLotsOfComponents.cmake @@ -0,0 +1,10 @@ +set(LOC_FOO TRUE) + +set(LotsOfComponents_AComp_FOUND TRUE) +set(LotsOfComponents_BComp_FOUND FALSE) +set(LotsOfComponents_CComp_FOUND TRUE) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(LotsOfComponents REQUIRED_VARS LOC_FOO + HANDLE_COMPONENTS) diff --git a/Tests/FindPackageTest/FindPackageHandleStandardArgs.cmake b/Tests/FindPackageTest/FindPackageHandleStandardArgs.cmake new file mode 100644 index 000000000..7e41c96c9 --- /dev/null +++ b/Tests/FindPackageTest/FindPackageHandleStandardArgs.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This file (${CMAKE_CURRENT_LIST_FILE}) must not be included, but FindPackageHandleStandardArgs.cmake from Modules/ instead !") diff --git a/Tests/FindPackageTest/FindPackageTest.cxx b/Tests/FindPackageTest/FindPackageTest.cxx new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/FindPackageTest/FindPackageTest.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/FindPackageTest/FindRecursiveA.cmake b/Tests/FindPackageTest/FindRecursiveA.cmake new file mode 100644 index 000000000..3af7e99a3 --- /dev/null +++ b/Tests/FindPackageTest/FindRecursiveA.cmake @@ -0,0 +1 @@ +FIND_PACKAGE(RecursiveA NO_MODULE) diff --git a/Tests/FindPackageTest/FindRecursiveB.cmake b/Tests/FindPackageTest/FindRecursiveB.cmake new file mode 100644 index 000000000..c609ab127 --- /dev/null +++ b/Tests/FindPackageTest/FindRecursiveB.cmake @@ -0,0 +1 @@ +FIND_PACKAGE(RecursiveB NAMES zot) diff --git a/Tests/FindPackageTest/FindRecursiveC.cmake b/Tests/FindPackageTest/FindRecursiveC.cmake new file mode 100644 index 000000000..018cc7302 --- /dev/null +++ b/Tests/FindPackageTest/FindRecursiveC.cmake @@ -0,0 +1 @@ +FIND_PACKAGE(RecursiveC NAMES zot) diff --git a/Tests/FindPackageTest/FindVersionTestA.cmake b/Tests/FindPackageTest/FindVersionTestA.cmake new file mode 100644 index 000000000..55c67e257 --- /dev/null +++ b/Tests/FindPackageTest/FindVersionTestA.cmake @@ -0,0 +1,18 @@ +IF(NOT "${VersionTestA_FIND_VERSION}" STREQUAL "1") + MESSAGE(SEND_ERROR "VersionTestA_FIND_VERSION=${VersionTestA_FIND_VERSION} is not 1") +ENDIF(NOT "${VersionTestA_FIND_VERSION}" STREQUAL "1") +IF(NOT "${VersionTestA_FIND_VERSION_MAJOR}" STREQUAL "1") + MESSAGE(SEND_ERROR "VersionTestA_FIND_VERSION_MAJOR=${VersionTestA_FIND_VERSION_MAJOR} is not 1") +ENDIF(NOT "${VersionTestA_FIND_VERSION_MAJOR}" STREQUAL "1") +IF(NOT "${VersionTestA_FIND_VERSION_MINOR}" STREQUAL "0") + MESSAGE(SEND_ERROR "VersionTestA_FIND_VERSION_MINOR=${VersionTestA_FIND_VERSION_MINOR} is not 0") +ENDIF(NOT "${VersionTestA_FIND_VERSION_MINOR}" STREQUAL "0") +IF(NOT "${VersionTestA_FIND_VERSION_PATCH}" STREQUAL "0") + MESSAGE(SEND_ERROR "VersionTestA_FIND_VERSION_PATCH=${VersionTestA_FIND_VERSION_PATCH} is not 0") +ENDIF(NOT "${VersionTestA_FIND_VERSION_PATCH}" STREQUAL "0") +IF(NOT "${VersionTestA_FIND_VERSION_TWEAK}" STREQUAL "0") + MESSAGE(SEND_ERROR "VersionTestA_FIND_VERSION_TWEAK=${VersionTestA_FIND_VERSION_TWEAK} is not 0") +ENDIF(NOT "${VersionTestA_FIND_VERSION_TWEAK}" STREQUAL "0") +IF(NOT "${VersionTestA_FIND_VERSION_COUNT}" STREQUAL "1") + MESSAGE(SEND_ERROR "VersionTestA_FIND_VERSION_COUNT=${VersionTestA_FIND_VERSION_COUNT} is not 1") +ENDIF(NOT "${VersionTestA_FIND_VERSION_COUNT}" STREQUAL "1") diff --git a/Tests/FindPackageTest/FindVersionTestB.cmake b/Tests/FindPackageTest/FindVersionTestB.cmake new file mode 100644 index 000000000..03173c65a --- /dev/null +++ b/Tests/FindPackageTest/FindVersionTestB.cmake @@ -0,0 +1,18 @@ +IF(NOT "${VersionTestB_FIND_VERSION}" STREQUAL "1.2") + MESSAGE(SEND_ERROR "VersionTestB_FIND_VERSION=${VersionTestB_FIND_VERSION} is not 1.2") +ENDIF(NOT "${VersionTestB_FIND_VERSION}" STREQUAL "1.2") +IF(NOT "${VersionTestB_FIND_VERSION_MAJOR}" STREQUAL "1") + MESSAGE(SEND_ERROR "VersionTestB_FIND_VERSION_MAJOR=${VersionTestB_FIND_VERSION_MAJOR} is not 1") +ENDIF(NOT "${VersionTestB_FIND_VERSION_MAJOR}" STREQUAL "1") +IF(NOT "${VersionTestB_FIND_VERSION_MINOR}" STREQUAL "2") + MESSAGE(SEND_ERROR "VersionTestB_FIND_VERSION_MINOR=${VersionTestB_FIND_VERSION_MINOR} is not 2") +ENDIF(NOT "${VersionTestB_FIND_VERSION_MINOR}" STREQUAL "2") +IF(NOT "${VersionTestB_FIND_VERSION_PATCH}" STREQUAL "0") + MESSAGE(SEND_ERROR "VersionTestB_FIND_VERSION_PATCH=${VersionTestB_FIND_VERSION_PATCH} is not 0") +ENDIF(NOT "${VersionTestB_FIND_VERSION_PATCH}" STREQUAL "0") +IF(NOT "${VersionTestB_FIND_VERSION_TWEAK}" STREQUAL "0") + MESSAGE(SEND_ERROR "VersionTestB_FIND_VERSION_TWEAK=${VersionTestB_FIND_VERSION_TWEAK} is not 0") +ENDIF(NOT "${VersionTestB_FIND_VERSION_TWEAK}" STREQUAL "0") +IF(NOT "${VersionTestB_FIND_VERSION_COUNT}" STREQUAL "2") + MESSAGE(SEND_ERROR "VersionTestB_FIND_VERSION_COUNT=${VersionTestB_FIND_VERSION_COUNT} is not 2") +ENDIF(NOT "${VersionTestB_FIND_VERSION_COUNT}" STREQUAL "2") diff --git a/Tests/FindPackageTest/FindVersionTestC.cmake b/Tests/FindPackageTest/FindVersionTestC.cmake new file mode 100644 index 000000000..1344cbc22 --- /dev/null +++ b/Tests/FindPackageTest/FindVersionTestC.cmake @@ -0,0 +1,18 @@ +IF(NOT "${VersionTestC_FIND_VERSION}" STREQUAL "1.2.3") + MESSAGE(SEND_ERROR "VersionTestC_FIND_VERSION=${VersionTestC_FIND_VERSION} is not 1.2.3") +ENDIF(NOT "${VersionTestC_FIND_VERSION}" STREQUAL "1.2.3") +IF(NOT "${VersionTestC_FIND_VERSION_MAJOR}" STREQUAL "1") + MESSAGE(SEND_ERROR "VersionTestC_FIND_VERSION_MAJOR=${VersionTestC_FIND_VERSION_MAJOR} is not 1") +ENDIF(NOT "${VersionTestC_FIND_VERSION_MAJOR}" STREQUAL "1") +IF(NOT "${VersionTestC_FIND_VERSION_MINOR}" STREQUAL "2") + MESSAGE(SEND_ERROR "VersionTestC_FIND_VERSION_MINOR=${VersionTestC_FIND_VERSION_MINOR} is not 2") +ENDIF(NOT "${VersionTestC_FIND_VERSION_MINOR}" STREQUAL "2") +IF(NOT "${VersionTestC_FIND_VERSION_PATCH}" STREQUAL "3") + MESSAGE(SEND_ERROR "VersionTestC_FIND_VERSION_PATCH=${VersionTestC_FIND_VERSION_PATCH} is not 3") +ENDIF(NOT "${VersionTestC_FIND_VERSION_PATCH}" STREQUAL "3") +IF(NOT "${VersionTestC_FIND_VERSION_TWEAK}" STREQUAL "0") + MESSAGE(SEND_ERROR "VersionTestC_FIND_VERSION_TWEAK=${VersionTestC_FIND_VERSION_TWEAK} is not 0") +ENDIF(NOT "${VersionTestC_FIND_VERSION_TWEAK}" STREQUAL "0") +IF(NOT "${VersionTestC_FIND_VERSION_COUNT}" STREQUAL "3") + MESSAGE(SEND_ERROR "VersionTestC_FIND_VERSION_COUNT=${VersionTestC_FIND_VERSION_COUNT} is not 3") +ENDIF(NOT "${VersionTestC_FIND_VERSION_COUNT}" STREQUAL "3") diff --git a/Tests/FindPackageTest/FindVersionTestD.cmake b/Tests/FindPackageTest/FindVersionTestD.cmake new file mode 100644 index 000000000..d3e3f509e --- /dev/null +++ b/Tests/FindPackageTest/FindVersionTestD.cmake @@ -0,0 +1,18 @@ +IF(NOT "${VersionTestD_FIND_VERSION}" STREQUAL "1.2.3.4") + MESSAGE(SEND_ERROR "VersionTestD_FIND_VERSION=${VersionTestD_FIND_VERSION} is not 1.2.3.4") +ENDIF(NOT "${VersionTestD_FIND_VERSION}" STREQUAL "1.2.3.4") +IF(NOT "${VersionTestD_FIND_VERSION_MAJOR}" STREQUAL "1") + MESSAGE(SEND_ERROR "VersionTestD_FIND_VERSION_MAJOR=${VersionTestD_FIND_VERSION_MAJOR} is not 1") +ENDIF(NOT "${VersionTestD_FIND_VERSION_MAJOR}" STREQUAL "1") +IF(NOT "${VersionTestD_FIND_VERSION_MINOR}" STREQUAL "2") + MESSAGE(SEND_ERROR "VersionTestD_FIND_VERSION_MINOR=${VersionTestD_FIND_VERSION_MINOR} is not 2") +ENDIF(NOT "${VersionTestD_FIND_VERSION_MINOR}" STREQUAL "2") +IF(NOT "${VersionTestD_FIND_VERSION_PATCH}" STREQUAL "3") + MESSAGE(SEND_ERROR "VersionTestD_FIND_VERSION_PATCH=${VersionTestD_FIND_VERSION_PATCH} is not 3") +ENDIF(NOT "${VersionTestD_FIND_VERSION_PATCH}" STREQUAL "3") +IF(NOT "${VersionTestD_FIND_VERSION_TWEAK}" STREQUAL "4") + MESSAGE(SEND_ERROR "VersionTestD_FIND_VERSION_TWEAK=${VersionTestD_FIND_VERSION_TWEAK} is not 4") +ENDIF(NOT "${VersionTestD_FIND_VERSION_TWEAK}" STREQUAL "4") +IF(NOT "${VersionTestD_FIND_VERSION_COUNT}" STREQUAL "4") + MESSAGE(SEND_ERROR "VersionTestD_FIND_VERSION_COUNT=${VersionTestD_FIND_VERSION_COUNT} is not 4") +ENDIF(NOT "${VersionTestD_FIND_VERSION_COUNT}" STREQUAL "4") diff --git a/Tests/FindPackageTest/RelocatableConfig.cmake.in b/Tests/FindPackageTest/RelocatableConfig.cmake.in new file mode 100644 index 000000000..4a4b4e9c6 --- /dev/null +++ b/Tests/FindPackageTest/RelocatableConfig.cmake.in @@ -0,0 +1,11 @@ +@PACKAGE_INIT@ + +set(RELOC_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") +set(RELOC_SHARE_DIR "@PACKAGE_SHARE_INSTALL_DIR@") +set_and_check(RELOC_BUILD_DIR "@PACKAGE_CURRENT_BUILD_DIR@") + +set(Relocatable_AComp_FOUND TRUE) +set(Relocatable_BComp_FOUND FALSE) +set(Relocatable_CComp_FOUND FALSE) + +check_required_components(Relocatable) diff --git a/Tests/FindPackageTest/SystemPackage/CMakeTestSystemPackageConfig.cmake b/Tests/FindPackageTest/SystemPackage/CMakeTestSystemPackageConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/SystemPackage/CMakeTestSystemPackageConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/TApp.app/Contents/Resources/TAppConfig.cmake b/Tests/FindPackageTest/TApp.app/Contents/Resources/TAppConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/TApp.app/Contents/Resources/TAppConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/TApp.app/Contents/Resources/cmake/tapp-config.cmake b/Tests/FindPackageTest/TApp.app/Contents/Resources/cmake/tapp-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/TApp.app/Contents/Resources/cmake/tapp-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/TFramework.framework/Versions/A/Resources/CMake/TFrameworkConfig.cmake b/Tests/FindPackageTest/TFramework.framework/Versions/A/Resources/CMake/TFrameworkConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/TFramework.framework/Versions/A/Resources/CMake/TFrameworkConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/TFramework.framework/Versions/A/Resources/tframework-config.cmake b/Tests/FindPackageTest/TFramework.framework/Versions/A/Resources/tframework-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/TFramework.framework/Versions/A/Resources/tframework-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/cmake/SetFoundFALSEConfig.cmake b/Tests/FindPackageTest/cmake/SetFoundFALSEConfig.cmake new file mode 100644 index 000000000..ae6bd1454 --- /dev/null +++ b/Tests/FindPackageTest/cmake/SetFoundFALSEConfig.cmake @@ -0,0 +1 @@ +set(SetFoundFALSE_FOUND FALSE) diff --git a/Tests/FindPackageTest/cmake/SetFoundTRUEConfig.cmake b/Tests/FindPackageTest/cmake/SetFoundTRUEConfig.cmake new file mode 100644 index 000000000..19d071144 --- /dev/null +++ b/Tests/FindPackageTest/cmake/SetFoundTRUEConfig.cmake @@ -0,0 +1 @@ +set(SetFoundTRUE_FOUND TRUE) diff --git a/Tests/FindPackageTest/include/foo.h b/Tests/FindPackageTest/include/foo.h new file mode 100644 index 000000000..2392aee71 --- /dev/null +++ b/Tests/FindPackageTest/include/foo.h @@ -0,0 +1 @@ +/* empty header file */ diff --git a/Tests/FindPackageTest/lib/Bar/BarConfig.cmake b/Tests/FindPackageTest/lib/Bar/BarConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/Bar/BarConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/Bar/cmake/bar-config.cmake b/Tests/FindPackageTest/lib/Bar/cmake/bar-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/Bar/cmake/bar-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/Blub/BlubConfig.cmake b/Tests/FindPackageTest/lib/Blub/BlubConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/Blub/BlubConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/RecursiveA/recursivea-config.cmake b/Tests/FindPackageTest/lib/RecursiveA/recursivea-config.cmake new file mode 100644 index 000000000..eff4d4fd0 --- /dev/null +++ b/Tests/FindPackageTest/lib/RecursiveA/recursivea-config.cmake @@ -0,0 +1,4 @@ +# Test config file. +if(NOT "${RecursiveA_FIND_COMPONENTS}" STREQUAL "A") + message(FATAL_ERROR "find_package(RecursiveA NO_MODULE) did not forward components") +endif() diff --git a/Tests/FindPackageTest/lib/TApp/TAppConfig.cmake b/Tests/FindPackageTest/lib/TApp/TAppConfig.cmake new file mode 100644 index 000000000..cbf06036e --- /dev/null +++ b/Tests/FindPackageTest/lib/TApp/TAppConfig.cmake @@ -0,0 +1,2 @@ +# Test config file that should not be found. +MESSAGE("Package TApp found non-bundle first!") diff --git a/Tests/FindPackageTest/lib/arch/Bar/BarConfig.cmake b/Tests/FindPackageTest/lib/arch/Bar/BarConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/arch/Bar/BarConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config-version.cmake b/Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config-version.cmake new file mode 100644 index 000000000..2f768e8f5 --- /dev/null +++ b/Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config-version.cmake @@ -0,0 +1,7 @@ +SET(PACKAGE_VERSION 4.0) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 4) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 0) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 0) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 4) diff --git a/Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config.cmake b/Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/arch/foo-1.2/CMake/FooConfig.cmake b/Tests/FindPackageTest/lib/arch/foo-1.2/CMake/FooConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/arch/foo-1.2/CMake/FooConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/arch/zot-3.1/zot-config-version.cmake b/Tests/FindPackageTest/lib/arch/zot-3.1/zot-config-version.cmake new file mode 100644 index 000000000..13763adf1 --- /dev/null +++ b/Tests/FindPackageTest/lib/arch/zot-3.1/zot-config-version.cmake @@ -0,0 +1,7 @@ +SET(PACKAGE_VERSION 3.1) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) diff --git a/Tests/FindPackageTest/lib/arch/zot-3.1/zot-config.cmake b/Tests/FindPackageTest/lib/arch/zot-3.1/zot-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/arch/zot-3.1/zot-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config-version.cmake b/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config-version.cmake new file mode 100644 index 000000000..bee2f0eea --- /dev/null +++ b/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config-version.cmake @@ -0,0 +1,4 @@ +# Claim to be any version to test that CMAKE_IGNORE_PATH hides us. +SET(PACKAGE_VERSION 3.1) +SET(PACKAGE_VERSION_COMPATIBLE 1) +SET(PACKAGE_VERSION_EXACT 1) diff --git a/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config.cmake b/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config.cmake new file mode 100644 index 000000000..2fbd525f3 --- /dev/null +++ b/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config.cmake @@ -0,0 +1,2 @@ +# Test config file. +message(WARNING "CMAKE_IGNORE_PATH failed to ignore this file!") diff --git a/Tests/FindPackageTest/lib/cmake/zot-4.0/zot-config-version.cmake b/Tests/FindPackageTest/lib/cmake/zot-4.0/zot-config-version.cmake new file mode 100644 index 000000000..606945f2d --- /dev/null +++ b/Tests/FindPackageTest/lib/cmake/zot-4.0/zot-config-version.cmake @@ -0,0 +1,8 @@ +SET(PACKAGE_VERSION 4.0) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 4) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 0) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 0) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 4) + diff --git a/Tests/FindPackageTest/lib/cmake/zot-4.0/zot-config.cmake b/Tests/FindPackageTest/lib/cmake/zot-4.0/zot-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/cmake/zot-4.0/zot-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/foo-1.2/CMake/FooConfig.cmake b/Tests/FindPackageTest/lib/foo-1.2/CMake/FooConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/foo-1.2/CMake/FooConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/foo-1.2/foo-config.cmake b/Tests/FindPackageTest/lib/foo-1.2/foo-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/foo-1.2/foo-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/suffix/test/SuffixTestConfig.cmake b/Tests/FindPackageTest/lib/suffix/test/SuffixTestConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/suffix/test/SuffixTestConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/suffix/test/SuffixTestConfigVersion.cmake b/Tests/FindPackageTest/lib/suffix/test/SuffixTestConfigVersion.cmake new file mode 100644 index 000000000..5c3bddece --- /dev/null +++ b/Tests/FindPackageTest/lib/suffix/test/SuffixTestConfigVersion.cmake @@ -0,0 +1,7 @@ +SET(PACKAGE_VERSION 1.2) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 2) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 2) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1) diff --git a/Tests/FindPackageTest/lib/zot-1.0/zot-config.cmake b/Tests/FindPackageTest/lib/zot-1.0/zot-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-1.0/zot-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/zot-2.0/zot-config-version.cmake b/Tests/FindPackageTest/lib/zot-2.0/zot-config-version.cmake new file mode 100644 index 000000000..10ac53d19 --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-2.0/zot-config-version.cmake @@ -0,0 +1,5 @@ +SET(PACKAGE_VERSION 2.0) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 2) + SET(PACKAGE_VERSION_COMPATIBLE 1) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 2) + diff --git a/Tests/FindPackageTest/lib/zot-2.0/zot-config.cmake b/Tests/FindPackageTest/lib/zot-2.0/zot-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-2.0/zot-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/zot-3.0/zot-config-version.cmake b/Tests/FindPackageTest/lib/zot-3.0/zot-config-version.cmake new file mode 100644 index 000000000..af57cfa5c --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-3.0/zot-config-version.cmake @@ -0,0 +1,5 @@ +SET(PACKAGE_VERSION 3.0) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) + SET(PACKAGE_VERSION_COMPATIBLE 1) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) + diff --git a/Tests/FindPackageTest/lib/zot-3.0/zot-config.cmake b/Tests/FindPackageTest/lib/zot-3.0/zot-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-3.0/zot-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/zot-3.1/zot-config-version.cmake b/Tests/FindPackageTest/lib/zot-3.1/zot-config-version.cmake new file mode 100644 index 000000000..b54d94ce6 --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-3.1/zot-config-version.cmake @@ -0,0 +1,8 @@ +SET(PACKAGE_VERSION 3.1) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) + diff --git a/Tests/FindPackageTest/lib/zot-3.1/zot-config.cmake b/Tests/FindPackageTest/lib/zot-3.1/zot-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-3.1/zot-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/zot/zot-config-version.cmake b/Tests/FindPackageTest/lib/zot/zot-config-version.cmake new file mode 100644 index 000000000..2a6be8640 --- /dev/null +++ b/Tests/FindPackageTest/lib/zot/zot-config-version.cmake @@ -0,0 +1,10 @@ +# This version should never, ever be used. +SET(PACKAGE_VERSION_UNSUITABLE 1) +SET(PACKAGE_VERSION 3.1) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) + diff --git a/Tests/FindPackageTest/lib/zot/zot-config.cmake b/Tests/FindPackageTest/lib/zot/zot-config.cmake new file mode 100644 index 000000000..442b8a4ec --- /dev/null +++ b/Tests/FindPackageTest/lib/zot/zot-config.cmake @@ -0,0 +1,2 @@ +# Test config file that is unsuitable. +MESSAGE(FATAL_ERROR "Unsuitable version of zot was found") diff --git a/Tests/ForceInclude/CMakeLists.txt b/Tests/ForceInclude/CMakeLists.txt new file mode 100644 index 000000000..5c02ebbd0 --- /dev/null +++ b/Tests/ForceInclude/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.8.3.20110103) +project(ForceInclude C) + +# Make sure the proper compiler is in use. +if(NOT MSVC AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") + message(FATAL_ERROR "The ForceInclude test works only with MSVC or Intel") +endif() + +add_executable(foo foo.c) +set_property(SOURCE foo.c PROPERTY COMPILE_FLAGS "/FIfoo1.h /FIfoo2.h") diff --git a/Tests/ForceInclude/foo.c b/Tests/ForceInclude/foo.c new file mode 100644 index 000000000..af898f4aa --- /dev/null +++ b/Tests/ForceInclude/foo.c @@ -0,0 +1,7 @@ +#ifndef FOO_1 +# error "foo1.h not included by /FI" +#endif +#ifndef FOO_2 +# error "foo2.h not included by /FI" +#endif +int main(void) { return 0; } diff --git a/Tests/ForceInclude/foo1.h b/Tests/ForceInclude/foo1.h new file mode 100644 index 000000000..2c1cb7bb3 --- /dev/null +++ b/Tests/ForceInclude/foo1.h @@ -0,0 +1 @@ +#define FOO_1 diff --git a/Tests/ForceInclude/foo2.h b/Tests/ForceInclude/foo2.h new file mode 100644 index 000000000..e47524dfa --- /dev/null +++ b/Tests/ForceInclude/foo2.h @@ -0,0 +1 @@ +#define FOO_2 diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt new file mode 100644 index 000000000..a995f68dd --- /dev/null +++ b/Tests/Fortran/CMakeLists.txt @@ -0,0 +1,220 @@ +cmake_minimum_required (VERSION 2.6) +project(testf C CXX Fortran) +message("CTEST_FULL_OUTPUT ") +set(CMAKE_VERBOSE_MAKEFILE 1) +message("ENV_FLAGS = $ENV{FFLAGS}") +message("CMAKE_Fortran_COMPILER_INIT = ${CMAKE_Fortran_COMPILER_INIT}") +message("CMAKE_Fortran_COMPILER_FULLPATH = ${CMAKE_Fortran_COMPILER_FULLPATH}") +message("CMAKE_Fortran_COMPILER = ${CMAKE_Fortran_COMPILER}") +message("CMAKE_Fortran_FLAGS = ${CMAKE_Fortran_FLAGS}") + +set(_SHARED SHARED) +if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(XL|VisualAge)$") + # We do not implement SHARED Fortran libs on AIX yet! + # Workaround: Set LINKER_LANGUAGE to C, which uses 'xlc' and Fortran implicits. + set(_SHARED STATIC) +elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU") + # g77 2.96 does not support shared libs on Itanium because g2c is not -fPIC + execute_process(COMMAND ${CMAKE_Fortran_COMPILER} --version + OUTPUT_VARIABLE output ERROR_VARIABLE output) + if("${output}" MATCHES "Red Hat .* 2\\.96") + set(_SHARED STATIC) + endif() +endif() + +# Pick a module .def file with the properly mangled symbol name. +set(world_def "") +if(WIN32 AND NOT CYGWIN) + if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") + set(world_def world_gnu.def) + elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel" OR + "${CMAKE_GENERATOR}" MATCHES "Visual Studio") # Intel plugin + set(world_def world_icl.def) + endif() +endif() + +add_library(hello STATIC hello.f) +add_library(world ${_SHARED} world.f ${world_def}) +add_executable(testf testf.f) +target_link_libraries(testf hello world) + +function(test_fortran_c_interface_module) + message(STATUS "Testing FortranCInterface module") + # test the C to Fortran interface module + include(FortranCInterface) + FortranCInterface_VERIFY() + FortranCInterface_VERIFY(CXX) + if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) + if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro|PathScale|Absoft") + set(module_expected 1) + endif() + if(FortranCInterface_MODULE_FOUND OR module_expected) + set(srcs foo.f) + set(FORTRAN_FUNCTIONS test_mod:sub) + set(MYC_DEFS TEST_MOD) + else() + message("${CMAKE_Fortran_COMPILER_ID} compilers do not support" + " linking Fortran module procedures from C") + endif() + endif() + list(APPEND FORTRAN_FUNCTIONS my_sub mysub) + FortranCInterface_HEADER(foo.h + MACRO_NAMESPACE "FC_" + SYMBOL_NAMESPACE "F_" + SYMBOLS ${FORTRAN_FUNCTIONS} + ) + include_directories("${testf_BINARY_DIR}") + + # if the name mangling is not found for a F90 compiler + # print out some diagnostic stuff for the dashboard + if(NOT FortranCInterface_GLOBAL_FOUND OR + (NOT FortranCInterface_MODULE_FOUND AND module_expected) ) + find_program(FortranCInterface_EXE + NAMES FortranCInterface + PATHS ${FortranCInterface_BINARY_DIR} ${FortranCInterface_BINARY_DIR}/Debug + NO_DEFAULT_PATH + ) + find_program(DUMPBIN dumpbin) + find_program(NM nm) + if(FortranCInterface_EXE) + if(DEPENDS) + execute_process(COMMAND ${DUMPBIN} /symbols "${FortranCInterface_EXE}" + OUTPUT_VARIABLE out) + message("symbols in ${FortranCInterface_EXE}:\n${out}") + endif() + if(NM) + execute_process(COMMAND ${NM} "${FortranCInterface_EXE}" + OUTPUT_VARIABLE out) + message("symbols in ${FortranCInterface_EXE}:\n${out}") + endif() + endif() + endif() + message("Fortran = ${CMAKE_Fortran_COMPILER_ID}") + message("C = ${CMAKE_C_COMPILER_ID}") + + add_library(myfort mysub.f ${srcs}) + + add_library(myc myc.c) + target_link_libraries(myc myfort) + set_property(TARGET myc PROPERTY COMPILE_DEFINITIONS ${MYC_DEFS}) + + add_library(mycxx mycxx.cxx) + target_link_libraries(mycxx myc) + + add_executable(mainc mainc.c) + target_link_libraries(mainc myc) + add_executable(maincxx maincxx.c) + target_link_libraries(maincxx mycxx) + + # print out some stuff to help debug on machines via cdash + file(READ "${testf_BINARY_DIR}/foo.h" fooh) + message("foo.h contents:\n${fooh}") +endfunction() + +# if the id's match or the compilers are compatible, then +# call the test_fortran_c_interface_module function +if("${CMAKE_Fortran_COMPILER_ID}:${CMAKE_C_COMPILER_ID}" MATCHES + "(Intel:MSVC|Absoft:GNU)" + OR ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "${CMAKE_C_COMPILER_ID}" )) + test_fortran_c_interface_module() +else() + message("Fortran does not match c compiler") + message("Fortran = ${CMAKE_Fortran_COMPILER_ID}") + message("C = ${CMAKE_C_COMPILER_ID}") + # hack to make g77 work after CL has been enabled + # as a languge, cmake needs language specific versions + # of these variables.... + if(WIN32 AND "${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") + set(CMAKE_CREATE_CONSOLE_EXE ) + set(CMAKE_LIBRARY_PATH_FLAG "-L") + set(CMAKE_LINK_LIBRARY_FLAG "-l") + set(CMAKE_LINK_LIBRARY_SUFFIX ) + endif() + # gnu and sunpro do not use the same flags here... + # however if LDFLAGS is used to set -m64 it causes odd stuf + # with the fortran build + if( ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") + AND ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "SunPro")) + set(CMAKE_EXE_LINKER_FLAGS "") + set(CMAKE_Fortran_FLAGS "") + endif() + +endif() + + + + +set(TEST_MODULE_DEPENDS 0) +if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) + add_executable(test_module + test_module_main.f90 + test_module_implementation.f90 + test_module_interface.f90) + + add_executable(test_use_in_comment_fixedform + test_use_in_comment_fixedform.f) + set_property(SOURCE test_use_in_comment_fixedform.f PROPERTY Fortran_FORMAT FIXED) + add_executable(test_use_in_comment_freeform + test_use_in_comment_freeform.f90) + set_property(SOURCE test_use_in_comment_freeform.f90 PROPERTY Fortran_FORMAT FREE) + + add_executable(test_in_interface + in_interface/main.f90 + in_interface/module.f90) + + add_definitions(-DFOO -DBAR=1) + include_directories(${testf_SOURCE_DIR}/include) + add_executable(test_preprocess test_preprocess.F90) + + set(TEST_MODULE_DEPENDS 1) +endif(CMAKE_Fortran_COMPILER_SUPPORTS_F90) + +if(TEST_MODULE_DEPENDS) + # Build the external project separately using a custom target. + # Make sure it uses the same build configuration as this test. + if(CMAKE_CONFIGURATION_TYPES) + set(External_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") + set(External_BUILD_TYPE) + else(CMAKE_CONFIGURATION_TYPES) + set(External_CONFIG_TYPE) + set(External_BUILD_TYPE -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}) + endif(CMAKE_CONFIGURATION_TYPES) + set(External_SOURCE_DIR "${testf_SOURCE_DIR}/External") + set(External_BINARY_DIR "${testf_BINARY_DIR}/External") + if("${testf_BINARY_DIR}" MATCHES " ") + # Our build tree has a space, so the build tool supports spaces. + # Test using modules from a path with spaces. + set(External_BINARY_DIR "${External_BINARY_DIR} Build") + endif() + add_custom_command( + OUTPUT ${testf_BINARY_DIR}/ExternalProject + COMMAND ${CMAKE_CTEST_COMMAND} + ARGS ${External_CONFIG_TYPE} + --build-and-test + ${External_SOURCE_DIR} + ${External_BINARY_DIR} + --build-noclean + --build-two-config + --build-project ExtFort + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-options -DCMAKE_Fortran_COMPILER:STRING=${CMAKE_Fortran_COMPILER} + -DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS} + -DCMAKE_Fortran_FLAGS_DEBUG:STRING=${CMAKE_Fortran_FLAGS_DEBUG} + -DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE} + -DCMAKE_Fortran_FLAGS_MINSIZEREL:STRING=${CMAKE_Fortran_FLAGS_MINSIZEREL} + -DCMAKE_Fortran_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} + ${External_BUILD_TYPE} + ) + add_custom_target(ExternalTarget ALL DEPENDS ${testf_BINARY_DIR}/ExternalProject) + + # Test module output directory if available. + if(CMAKE_Fortran_MODDIR_FLAG) + set(Library_MODDIR "${testf_BINARY_DIR}/Library/modules") + else(CMAKE_Fortran_MODDIR_FLAG) + set(Library_MODDIR "${testf_BINARY_DIR}/Library") + endif(CMAKE_Fortran_MODDIR_FLAG) + + add_subdirectory(Library) + add_subdirectory(Executable) +endif(TEST_MODULE_DEPENDS) diff --git a/Tests/Fortran/Executable/CMakeLists.txt b/Tests/Fortran/Executable/CMakeLists.txt new file mode 100644 index 000000000..55f21ad46 --- /dev/null +++ b/Tests/Fortran/Executable/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories(${Library_MODDIR}) +include_directories(${External_BINARY_DIR}) +link_directories(${External_BINARY_DIR}) + +add_executable(subdir_exe2 main.f90) +target_link_libraries(subdir_exe2 subdir_mods) +add_dependencies(subdir_exe2 ExternalTarget) +target_link_libraries(subdir_exe2 myext) diff --git a/Tests/Fortran/Executable/main.f90 b/Tests/Fortran/Executable/main.f90 new file mode 100644 index 000000000..f21156cda --- /dev/null +++ b/Tests/Fortran/Executable/main.f90 @@ -0,0 +1,6 @@ +PROGRAM MAINF90 + USE libraryModuleA + USE libraryModuleB + USE externalMod + CALL printExtModGreeting +END PROGRAM MAINF90 diff --git a/Tests/Fortran/External/CMakeLists.txt b/Tests/Fortran/External/CMakeLists.txt new file mode 100644 index 000000000..0eb1cfeed --- /dev/null +++ b/Tests/Fortran/External/CMakeLists.txt @@ -0,0 +1,4 @@ +project(ExtFort Fortran) + +add_library(myext a.f90) + diff --git a/Tests/Fortran/External/a.f90 b/Tests/Fortran/External/a.f90 new file mode 100644 index 000000000..2be73c53c --- /dev/null +++ b/Tests/Fortran/External/a.f90 @@ -0,0 +1,7 @@ +MODULE externalMod +! +CONTAINS + SUBROUTINE printExtModGreeting + WRITE(*,*) "Greetings from Module externalMod" + END SUBROUTINE +END MODULE diff --git a/Tests/Fortran/Library/CMakeLists.txt b/Tests/Fortran/Library/CMakeLists.txt new file mode 100644 index 000000000..fe1368a07 --- /dev/null +++ b/Tests/Fortran/Library/CMakeLists.txt @@ -0,0 +1,11 @@ +INCLUDE_DIRECTORIES(${Library_MODDIR}) +ADD_LIBRARY(subdir_mods a.f90 b.f90) +ADD_EXECUTABLE(subdir_exe main.f90) +TARGET_LINK_LIBRARIES(subdir_exe subdir_mods) + +# Test module output directory if available. +IF(CMAKE_Fortran_MODDIR_FLAG) + SET_TARGET_PROPERTIES(subdir_mods PROPERTIES + Fortran_MODULE_DIRECTORY modules + ) +ENDIF(CMAKE_Fortran_MODDIR_FLAG) diff --git a/Tests/Fortran/Library/a.f90 b/Tests/Fortran/Library/a.f90 new file mode 100644 index 000000000..3031c0723 --- /dev/null +++ b/Tests/Fortran/Library/a.f90 @@ -0,0 +1,3 @@ +MODULE libraryModuleA + USE libraryModuleB +END MODULE diff --git a/Tests/Fortran/Library/b.f90 b/Tests/Fortran/Library/b.f90 new file mode 100644 index 000000000..ae1edcb20 --- /dev/null +++ b/Tests/Fortran/Library/b.f90 @@ -0,0 +1,2 @@ +MODULE libraryModuleB +END MODULE diff --git a/Tests/Fortran/Library/main.f90 b/Tests/Fortran/Library/main.f90 new file mode 100644 index 000000000..2385408a2 --- /dev/null +++ b/Tests/Fortran/Library/main.f90 @@ -0,0 +1,3 @@ +PROGRAM MAINF90 + USE libraryModuleA +END PROGRAM MAINF90 diff --git a/Tests/Fortran/foo.f b/Tests/Fortran/foo.f new file mode 100644 index 000000000..dbbb3a4e9 --- /dev/null +++ b/Tests/Fortran/foo.f @@ -0,0 +1,9 @@ + module test_mod + interface dummy + module procedure sub + end interface + contains + subroutine sub + end subroutine + + end module test_mod diff --git a/Tests/Fortran/hello.f b/Tests/Fortran/hello.f new file mode 100644 index 000000000..aa0de7715 --- /dev/null +++ b/Tests/Fortran/hello.f @@ -0,0 +1,6 @@ + SUBROUTINE HELLO + + PRINT *, 'Hello' + + END + diff --git a/Tests/Fortran/in_interface/main.f90 b/Tests/Fortran/in_interface/main.f90 new file mode 100644 index 000000000..28bcf36d5 --- /dev/null +++ b/Tests/Fortran/in_interface/main.f90 @@ -0,0 +1,3 @@ +program hello + use test_interface +end program hello diff --git a/Tests/Fortran/in_interface/module.f90 b/Tests/Fortran/in_interface/module.f90 new file mode 100644 index 000000000..1064d74b0 --- /dev/null +++ b/Tests/Fortran/in_interface/module.f90 @@ -0,0 +1,12 @@ +module test_interface + + interface dummy + module procedure module_function + end interface + +contains + + subroutine module_function + end subroutine + +end module test_interface
\ No newline at end of file diff --git a/Tests/Fortran/include/test_preprocess.h b/Tests/Fortran/include/test_preprocess.h new file mode 100644 index 000000000..29ac4b65f --- /dev/null +++ b/Tests/Fortran/include/test_preprocess.h @@ -0,0 +1,5 @@ +#ifdef BAR + PRINT * , 'BAR was defined via ADD_DEFINITIONS' +#else + PRINT *, 'If you can read this something went wrong' +#endif diff --git a/Tests/Fortran/mainc.c b/Tests/Fortran/mainc.c new file mode 100644 index 000000000..9efafc5c0 --- /dev/null +++ b/Tests/Fortran/mainc.c @@ -0,0 +1,5 @@ +extern int myc(void); +int main() +{ + return myc(); +} diff --git a/Tests/Fortran/maincxx.c b/Tests/Fortran/maincxx.c new file mode 100644 index 000000000..d35ea7e25 --- /dev/null +++ b/Tests/Fortran/maincxx.c @@ -0,0 +1,6 @@ +extern int myc(void); +extern int mycxx(void); +int main() +{ + return myc() + mycxx(); +} diff --git a/Tests/Fortran/myc.c b/Tests/Fortran/myc.c new file mode 100644 index 000000000..efd9b68aa --- /dev/null +++ b/Tests/Fortran/myc.c @@ -0,0 +1,12 @@ +#include "foo.h" +extern F_test_mod_sub(void); +extern F_mysub(void); +int myc(void) +{ + F_mysub(); + F_my_sub(); +#ifdef TEST_MOD + F_test_mod_sub(); +#endif + return 0; +} diff --git a/Tests/Fortran/mycxx.cxx b/Tests/Fortran/mycxx.cxx new file mode 100644 index 000000000..bf04062ed --- /dev/null +++ b/Tests/Fortran/mycxx.cxx @@ -0,0 +1,6 @@ +extern "C" int myc(void); +extern "C" int mycxx(void) +{ + delete new int; + return myc(); +} diff --git a/Tests/Fortran/mysub.f b/Tests/Fortran/mysub.f new file mode 100644 index 000000000..4b108e333 --- /dev/null +++ b/Tests/Fortran/mysub.f @@ -0,0 +1,5 @@ + subroutine mysub + print *, 'Printing this requires fortran language libraries' + end subroutine + subroutine my_sub + end subroutine diff --git a/Tests/Fortran/test_module_implementation.f90 b/Tests/Fortran/test_module_implementation.f90 new file mode 100644 index 000000000..de3cb574c --- /dev/null +++ b/Tests/Fortran/test_module_implementation.f90 @@ -0,0 +1,6 @@ +FUNCTION TEST_MODULE_FUNCTION(A,B) + REAL :: TEST_MODULE_FUNCTION + REAL, INTENT(IN) :: A + REAL, INTENT(IN) :: B + TEST_MODULE_FUNCTION = A + B +END FUNCTION TEST_MODULE_FUNCTION diff --git a/Tests/Fortran/test_module_interface.f90 b/Tests/Fortran/test_module_interface.f90 new file mode 100644 index 000000000..dd0f35c56 --- /dev/null +++ b/Tests/Fortran/test_module_interface.f90 @@ -0,0 +1,9 @@ +MODULE TEST_MODULE + INTERFACE + FUNCTION TEST_MODULE_FUNCTION(A,B) + REAL :: TEST_MODULE_FUNCTION + REAL, INTENT(IN) :: A + REAL, INTENT(IN) :: B + END FUNCTION TEST_MODULE_FUNCTION + END INTERFACE +END MODULE TEST_MODULE diff --git a/Tests/Fortran/test_module_main.f90 b/Tests/Fortran/test_module_main.f90 new file mode 100644 index 000000000..6ac97fa91 --- /dev/null +++ b/Tests/Fortran/test_module_main.f90 @@ -0,0 +1,4 @@ +PROGRAM MAINF90 + USE TEST_MODULE + PRINT *,'Sum is',TEST_MODULE_FUNCTION(1., 2.) +END PROGRAM MAINF90 diff --git a/Tests/Fortran/test_preprocess.F90 b/Tests/Fortran/test_preprocess.F90 new file mode 100644 index 000000000..e4f1fbe76 --- /dev/null +++ b/Tests/Fortran/test_preprocess.F90 @@ -0,0 +1,51 @@ +MODULE Available +! no conent +END MODULE + +PROGRAM PPTEST +! value of InPPFalseBranch ; values of SkipToEnd +! 0 <empty> +#ifndef FOO + ! 1 ; <0> + USE NotAvailable +# ifndef FOO + ! 2 ; <0,0> + USE NotAvailable +# else + ! 2 ; <0,0> + USE NotAvailable +# endif + ! 1 ; <0> +# ifdef FOO + ! 2 ; <0,1> + USE NotAvailable +# else + ! 2 ; <0,1> + USE NotAvailable +# endif + ! 1 ; <0> +#else + ! 0 ; <0> + USE Available +# ifndef FOO + ! 1 ; <0,0> + USE NotAvailable +# else + ! 0 ; <0,0> + USE Available +# endif + ! 0 ; <0> +# ifdef FOO + ! 0 ; <0,1> + USE Available +# else + ! 1 ; <0,1> + USE NotAvailable +# endif + ! 0 ; <0> +#endif +! 0 ; <empty> + +#include "test_preprocess.h" + +END PROGRAM diff --git a/Tests/Fortran/test_use_in_comment_fixedform.f b/Tests/Fortran/test_use_in_comment_fixedform.f new file mode 100644 index 000000000..39f486bf9 --- /dev/null +++ b/Tests/Fortran/test_use_in_comment_fixedform.f @@ -0,0 +1,7 @@ + PROGRAM foo +! USE bar +! use bar +! Use bar + + WRITE(*,*) 'Hello, Fortran world.' + END PROGRAM diff --git a/Tests/Fortran/test_use_in_comment_freeform.f90 b/Tests/Fortran/test_use_in_comment_freeform.f90 new file mode 100644 index 000000000..c992a041b --- /dev/null +++ b/Tests/Fortran/test_use_in_comment_freeform.f90 @@ -0,0 +1,7 @@ +PROGRAM foo +! USE bar +! use bar +! Use bar + + WRITE(*,*) 'Hello, Fortran world.' +END PROGRAM diff --git a/Tests/Fortran/testf.f b/Tests/Fortran/testf.f new file mode 100644 index 000000000..abf6c6df7 --- /dev/null +++ b/Tests/Fortran/testf.f @@ -0,0 +1,7 @@ + PROGRAM TESTF + + CALL HELLO() + CALL WORLD() + + END + diff --git a/Tests/Fortran/world.f b/Tests/Fortran/world.f new file mode 100644 index 000000000..0487dffe4 --- /dev/null +++ b/Tests/Fortran/world.f @@ -0,0 +1,6 @@ + SUBROUTINE WORLD + + PRINT *, 'World!' + + END + diff --git a/Tests/Fortran/world_gnu.def b/Tests/Fortran/world_gnu.def new file mode 100644 index 000000000..161779877 --- /dev/null +++ b/Tests/Fortran/world_gnu.def @@ -0,0 +1,2 @@ +EXPORTS + world_ diff --git a/Tests/Fortran/world_icl.def b/Tests/Fortran/world_icl.def new file mode 100644 index 000000000..ead7710cd --- /dev/null +++ b/Tests/Fortran/world_icl.def @@ -0,0 +1,2 @@ +EXPORTS + WORLD diff --git a/Tests/FortranC/CMakeLists.txt b/Tests/FortranC/CMakeLists.txt new file mode 100644 index 000000000..f33558397 --- /dev/null +++ b/Tests/FortranC/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 2.8) +project(FortranC C Fortran) + +# Skip this test for compilers not known to be compatible. +if(NOT ("${CMAKE_C_COMPILER_ID}" STREQUAL "${CMAKE_Fortran_COMPILER_ID}" OR + "${CMAKE_C_COMPILER_ID}-${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(MSVC-Intel)$")) + message(STATUS "${CMAKE_C_COMPILER_ID} C and ${CMAKE_Fortran_COMPILER_ID} Fortran not known to be compatible!") + return() +endif() + +# Wipe out all FortranCInterface information to ensure it re-runs. +file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/CMakeFiles/FortranCInterface) + +if(FortranC_TEST_FLAGS) + # Test whether FortranCInterface checks see C flags. + set(ENV{TEST_OPT_CC} "--test-opt-cc=1") + set(CMAKE_C_FLAGS "$ENV{TEST_OPT_CC} ${CMAKE_C_FLAGS}") + + # Test whether FortranCInterface checks see Fortran flags. + set(ENV{TEST_OPT_FC} "--test-opt-fc=1") + set(CMAKE_Fortran_FLAGS "$ENV{TEST_OPT_FC} ${CMAKE_Fortran_FLAGS}") +endif() + +include(FortranCInterface) +FortranCInterface_VERIFY() diff --git a/Tests/FortranC/Flags.cmake.in b/Tests/FortranC/Flags.cmake.in new file mode 100644 index 000000000..0b82f0ead --- /dev/null +++ b/Tests/FortranC/Flags.cmake.in @@ -0,0 +1,28 @@ +set(src "@CMAKE_CURRENT_SOURCE_DIR@/FortranC") +set(bld "@CMAKE_CURRENT_BINARY_DIR@/FortranC/Flags") + +# Create wrapper scripts for the compilers that check for expected +# flags, remove them, and invoke the real compiler. +set(ID "CC") +set(COMMAND "@CMAKE_C_COMPILER@") +configure_file("${src}/test_opt.sh.in" "${bld}/cc.sh" @ONLY) +set(ID "FC") +set(COMMAND "@CMAKE_Fortran_COMPILER@") +configure_file("${src}/test_opt.sh.in" "${bld}/fc.sh" @ONLY) +set(ID) +set(COMMAND) + +execute_process( + WORKING_DIRECTORY "${bld}" + COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_TEST_GENERATOR@" + "-DFortranC_TEST_FLAGS=1" + "-DCMAKE_C_COMPILER=${bld}/cc.sh" + "-DCMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@" + "-DCMAKE_Fortran_COMPILER=${bld}/fc.sh" + "-DCMAKE_Fortran_FLAGS:STRING=@CMAKE_Fortran_FLAGS@" + RESULT_VARIABLE result + ) + +if(NOT "${result}" STREQUAL "0") + message(FATAL_ERROR "Configuration failed: ${result}") +endif() diff --git a/Tests/FortranC/test_opt.sh.in b/Tests/FortranC/test_opt.sh.in new file mode 100755 index 000000000..f3d93dcf1 --- /dev/null +++ b/Tests/FortranC/test_opt.sh.in @@ -0,0 +1,18 @@ +#!/bin/sh + +TEST_OPT_@ID@_FOUND=0 +ARGS="" +for a in "$@"; do + if [ "x${TEST_OPT_@ID@}" != "x" -a "x${TEST_OPT_@ID@}" = "x$a" ]; then + TEST_OPT_@ID@_FOUND=1 + else + ARGS="$ARGS \"$a\"" + fi +done + +if [ "x${TEST_OPT_@ID@}" != "x" -a "x${TEST_OPT_@ID@_FOUND}" != "x1" ]; then + echo "Not given option '${TEST_OPT_@ID@}' as expected!" + exit 1 +fi + +eval "\"@COMMAND@\"" "$ARGS" diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt new file mode 100644 index 000000000..d57a8b295 --- /dev/null +++ b/Tests/FortranOnly/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required (VERSION 2.8) +project(FortranOnly Fortran) +message("CTEST_FULL_OUTPUT ") + +# create a library with hello and world functions +add_library(FortranOnlylib hello.f world.f) +set_property(TARGET FortranOnlylib PROPERTY Fortran_FORMAT FIXED) +set_property(SOURCE world.f PROPERTY Fortran_FORMAT FREE) + +# create an executable that calls hello and world +add_executable(FortranOnly testf.f) +target_link_libraries(FortranOnly FortranOnlylib) + +# create a custom command that runs FortranOnly and puts +# the output into the file testfhello.txt +add_custom_command(OUTPUT ${FortranOnly_BINARY_DIR}/testfhello.txt + COMMAND ${FortranOnly_BINARY_DIR}/${CMAKE_CFG_INTDIR}/FortranOnly + > testfhello.txt) +# create a second executable FortranOnly2 that has +# testfhello.txt has an source file so that it will +# run the above custom command. +add_executable(FortranOnly2 testfhello.txt testf.f) +target_link_libraries(FortranOnly2 FortranOnlylib) +# create a custom target to check the content of testfhello.txt +# by running the cmake script checktestf2.cmake +add_custom_target(checktestf2 ALL + COMMAND ${CMAKE_COMMAND} + -P ${FortranOnly_SOURCE_DIR}/checktestf2.cmake) + +# create a custom target that runs FortranOnly exectuable and creates +# a file out.txt that should have hello world in it. +add_custom_target(sayhello ALL + COMMAND ${FortranOnly_BINARY_DIR}/${CMAKE_CFG_INTDIR}/FortranOnly > out.txt +) +# make sure stuff is built in the right order +add_dependencies(checktestf2 FortranOnly2) +add_dependencies(sayhello FortranOnly) +add_dependencies(FortranOnly2 FortranOnly) + +# add a custom target that checkes that out.txt has the correct +# content +add_custom_target(checksayhello ALL + COMMAND ${CMAKE_COMMAND} -P ${FortranOnly_SOURCE_DIR}/checksayhello.cmake + ) +add_dependencies(checksayhello sayhello) diff --git a/Tests/FortranOnly/checksayhello.cmake b/Tests/FortranOnly/checksayhello.cmake new file mode 100644 index 000000000..5352290ab --- /dev/null +++ b/Tests/FortranOnly/checksayhello.cmake @@ -0,0 +1,7 @@ +file(READ out.txt IN) +message("${IN}") +if(IN MATCHES Hello AND IN MATCHES World) + message("Passed") +else() + message(FATAL_ERROR "Hello world not found") +endif() diff --git a/Tests/FortranOnly/checktestf2.cmake b/Tests/FortranOnly/checktestf2.cmake new file mode 100644 index 000000000..f0e6be329 --- /dev/null +++ b/Tests/FortranOnly/checktestf2.cmake @@ -0,0 +1,8 @@ +file(READ testfhello.txt IN) +message("${IN}") +if(IN MATCHES Hello AND IN MATCHES World) + message("Passed") +else() + message(FATAL_ERROR "Hello world not found") +endif() +file(WRITE testfhello2.txt ${IN}) diff --git a/Tests/FortranOnly/hello.f b/Tests/FortranOnly/hello.f new file mode 100644 index 000000000..63e64080d --- /dev/null +++ b/Tests/FortranOnly/hello.f @@ -0,0 +1,5 @@ + SUBROUTINE HELLO + + PRINT *, 'Hello' + + END diff --git a/Tests/FortranOnly/testf.f b/Tests/FortranOnly/testf.f new file mode 100644 index 000000000..490918108 --- /dev/null +++ b/Tests/FortranOnly/testf.f @@ -0,0 +1,6 @@ + PROGRAM TESTF + + CALL HELLO() + CALL WORLD() + + END diff --git a/Tests/FortranOnly/world.f b/Tests/FortranOnly/world.f new file mode 100644 index 000000000..342b24431 --- /dev/null +++ b/Tests/FortranOnly/world.f @@ -0,0 +1,4 @@ +! Free-format ".f" file to test Fortran_FORMAT property +SUBROUTINE WORLD + PRINT *, 'World!' +END diff --git a/Tests/Framework/CMakeLists.txt b/Tests/Framework/CMakeLists.txt new file mode 100644 index 000000000..29f983810 --- /dev/null +++ b/Tests/Framework/CMakeLists.txt @@ -0,0 +1,80 @@ +cmake_minimum_required (VERSION 2.6) +project(Framework) + +add_library(foo SHARED + foo.cxx + foo.h + foo2.h + fooExtensionlessResource + fooPublic.h + fooPublicExtensionlessHeader + fooPrivate.h + fooPrivateExtensionlessHeader + fooNeither.h + fooBoth.h + test.lua + fooDeepPublic.h +) +set_property(SOURCE fooDeepPublic.h + PROPERTY MACOSX_PACKAGE_LOCATION Headers/Deep + ) +set(foo_ver ver4) + +set_target_properties(foo PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION ${foo_ver} + PRIVATE_HEADER "fooPrivate.h;fooBoth.h;fooPrivateExtensionlessHeader" + PUBLIC_HEADER "foo.h;foo2.h;fooPublic.h;fooBoth.h;fooPublicExtensionlessHeader" + RESOURCE "fooExtensionlessResource;test.lua" + INSTALL_NAME_DIR "@executable_path/../../../Library/Frameworks" + DEBUG_POSTFIX -d +) +# fooBoth.h is listed as both public and private... (private wins...) +# fooNeither.h is listed as neither public nor private... + +add_executable(bar bar.cxx) +target_link_libraries(bar foo) +install(TARGETS foo bar + RUNTIME DESTINATION Applications/CMakeTestsFramework/bin + FRAMEWORK DESTINATION Library/Frameworks + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + + # These are ignored on the Mac... and things are automatically placed in + # their appropriate Framework sub-folder at build time. (And then the built + # framework is copied recursively when it is installed.) + PRIVATE_HEADER DESTINATION share/foo-${foo_ver}/PrivateHeaders + PUBLIC_HEADER DESTINATION include/foo-${foo_ver} + RESOURCE DESTINATION share/foo-${foo_ver}/Resources + # But they are required to be present so that installing a framework on other + # other platforms will install the pieces of the framework without having to + # duplicate install rules for the pieces of the framework. +) + +# Make a static library and apply the framework properties to it to verify +# that everything still builds correctly, but it will not actually produce +# a framework... The framework properties only apply when the library type +# is SHARED. +# +add_library(fooStatic STATIC + foo.cxx + foo.h + foo2.h + fooExtensionlessResource + fooPublic.h + fooPublicExtensionlessHeader + fooPrivate.h + fooPrivateExtensionlessHeader + fooNeither.h + fooBoth.h + test.lua + fooDeepPublic.h +) +set_target_properties(fooStatic PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION none +) +add_executable(barStatic bar.cxx) +target_link_libraries(barStatic fooStatic) + +include(CPack) diff --git a/Tests/Framework/bar.cxx b/Tests/Framework/bar.cxx new file mode 100644 index 000000000..37c132a0f --- /dev/null +++ b/Tests/Framework/bar.cxx @@ -0,0 +1,6 @@ +void foo(); +int main() +{ + foo(); + return 0; +} diff --git a/Tests/Framework/foo.cxx b/Tests/Framework/foo.cxx new file mode 100644 index 000000000..b249ce348 --- /dev/null +++ b/Tests/Framework/foo.cxx @@ -0,0 +1,10 @@ +#include <stdio.h> +#if defined(_WIN32) && defined(foo_EXPORTS) +# define CM_TEST_LIB_EXPORT __declspec( dllexport ) +#else +# define CM_TEST_LIB_EXPORT +#endif +CM_TEST_LIB_EXPORT void foo() +{ + printf("foo\n"); +} diff --git a/Tests/Framework/foo.h b/Tests/Framework/foo.h new file mode 100644 index 000000000..d959c813f --- /dev/null +++ b/Tests/Framework/foo.h @@ -0,0 +1 @@ +fooh diff --git a/Tests/Framework/foo2.h b/Tests/Framework/foo2.h new file mode 100644 index 000000000..2431d7980 --- /dev/null +++ b/Tests/Framework/foo2.h @@ -0,0 +1 @@ +foo2h diff --git a/Tests/Framework/fooBoth.h b/Tests/Framework/fooBoth.h new file mode 100644 index 000000000..5a0f33095 --- /dev/null +++ b/Tests/Framework/fooBoth.h @@ -0,0 +1 @@ +fooBothh diff --git a/Tests/Framework/fooDeepPublic.h b/Tests/Framework/fooDeepPublic.h new file mode 100644 index 000000000..3fc410878 --- /dev/null +++ b/Tests/Framework/fooDeepPublic.h @@ -0,0 +1 @@ +fooDeepPublic diff --git a/Tests/Framework/fooExtensionlessResource b/Tests/Framework/fooExtensionlessResource new file mode 100644 index 000000000..5122750ee --- /dev/null +++ b/Tests/Framework/fooExtensionlessResource @@ -0,0 +1 @@ +fooExtensionlessResource diff --git a/Tests/Framework/fooNeither.h b/Tests/Framework/fooNeither.h new file mode 100644 index 000000000..04736a1b1 --- /dev/null +++ b/Tests/Framework/fooNeither.h @@ -0,0 +1 @@ +fooNeitherh diff --git a/Tests/Framework/fooPrivate.h b/Tests/Framework/fooPrivate.h new file mode 100644 index 000000000..dc8cb34dc --- /dev/null +++ b/Tests/Framework/fooPrivate.h @@ -0,0 +1 @@ +fooPrivateh diff --git a/Tests/Framework/fooPrivateExtensionlessHeader b/Tests/Framework/fooPrivateExtensionlessHeader new file mode 100644 index 000000000..ac97b929e --- /dev/null +++ b/Tests/Framework/fooPrivateExtensionlessHeader @@ -0,0 +1 @@ +fooPrivateExtensionlessHeader diff --git a/Tests/Framework/fooPublic.h b/Tests/Framework/fooPublic.h new file mode 100644 index 000000000..f0469de6f --- /dev/null +++ b/Tests/Framework/fooPublic.h @@ -0,0 +1 @@ +fooPublich diff --git a/Tests/Framework/fooPublicExtensionlessHeader b/Tests/Framework/fooPublicExtensionlessHeader new file mode 100644 index 000000000..972d9898d --- /dev/null +++ b/Tests/Framework/fooPublicExtensionlessHeader @@ -0,0 +1 @@ +fooPublicExtensionlessHeader diff --git a/Tests/Framework/test.lua b/Tests/Framework/test.lua new file mode 100644 index 000000000..ce5c3eb84 --- /dev/null +++ b/Tests/Framework/test.lua @@ -0,0 +1 @@ +test.lua diff --git a/Tests/FunctionTest/CMakeLists.txt b/Tests/FunctionTest/CMakeLists.txt new file mode 100644 index 000000000..5d4f42d4a --- /dev/null +++ b/Tests/FunctionTest/CMakeLists.txt @@ -0,0 +1,176 @@ +# a simple C only test case +cmake_minimum_required (VERSION 2.6) +PROJECT (FunctionTest) + +FUNCTION(FAILED testname) + MESSAGE(SEND_ERROR "${testname} failed ${ARGN}") +ENDFUNCTION(FAILED) + +FUNCTION(PASS testname) + MESSAGE("${testname} passed ${ARGN}") +ENDFUNCTION(PASS) + + +# test scope +SET(COUNT 3) +FUNCTION(scope_test) + SET(COUNT 4) +ENDFUNCTION(scope_test) +scope_test() +IF(COUNT EQUAL "3") + PASS("scope") +ELSE(COUNT EQUAL "3") + FAILED("COUNT Got: ${COUNT}") +ENDIF(COUNT EQUAL "3") + +# test ARGC +FUNCTION(weird_name) + IF("${ARGC}" EQUAL "3") + PASS("ARGC") + ELSE("${ARGC}" EQUAL "3") + FAILED("ARGC" "Got: ${ARGC}") + ENDIF("${ARGC}" EQUAL "3") +ENDFUNCTION(weird_name) +WeIrD_nAmE(a1 a2 a3) + +# test ARGN +FUNCTION(test_argn_function argument) + IF("${ARGN}" EQUAL "3") + PASS("ARGN") + ELSE("${ARGN}" EQUAL "3") + FAILED("ARGN" "Got: ${ARGN}") + ENDIF("${ARGN}" EQUAL "3") +ENDFUNCTION(test_argn_function) +Test_Argn_Function(ignored 3) + +# test argument naming and raise scope +function(track_find_variable cache_variable is_changed) + set("${is_changed}" changed PARENT_SCOPE) +endfunction(track_find_variable) +track_find_variable(testvar is_changed) +if ("${is_changed}" STREQUAL changed) + pass("same argument name test") +else ("${is_changed}" STREQUAL changed) + pass("same argument name test") +endif ("${is_changed}" STREQUAL changed) + +include("Util.cmake") +tester() +if (tester_res STREQUAL "${CMAKE_CURRENT_LIST_FILE}") + pass("CMAKE_CURRENT_LIST_FILE test") +else (tester_res STREQUAL "${CMAKE_CURRENT_LIST_FILE}") + pass("CMAKE_CURRENT_LIST_FILE test") +endif (tester_res STREQUAL "${CMAKE_CURRENT_LIST_FILE}") + + + +# test recursion and return via set(... PARENT_SCOPE) +function (factorial argument result) + if (argument LESS 2) + set (lresult 1) + else (argument LESS 2) + math (EXPR temp "${argument} - 1") + factorial (${temp} tresult) + math (EXPR lresult "${argument}*${tresult}") + endif (argument LESS 2) + set ("${result}" "${lresult}" PARENT_SCOPE) +endfunction (factorial) + +factorial (5 fresult) +if (fresult EQUAL 120) + pass("factorial") +else (fresult EQUAL 120) + failed ("factorial, computed ${fresult} instead of 120") +endif (fresult EQUAL 120) + + + +# case test +FUNCTION(strange_function m) + SET("${m}" strange_function PARENT_SCOPE) +ENDFUNCTION(strange_function m) + +STRANGE_FUNCTION(var) +set(second_var "second_var") +IF("${var}" STREQUAL "strange_function" AND "${second_var}" STREQUAL "second_var") + PASS("Case Test" "(${var} ${second_var})") +ELSE("${var}" STREQUAL "strange_function" AND "${second_var}" STREQUAL "second_var") + FAILED("Case test" "(${var} ${second_var})") +ENDIF("${var}" STREQUAL "strange_function" AND "${second_var}" STREQUAL "second_var") + +# test backing up command +FUNCTION(ADD_EXECUTABLE exec) + _ADD_EXECUTABLE(mini${exec} ${ARGN}) +ENDFUNCTION(ADD_EXECUTABLE) + +# var undef case +FUNCTION(undef_var m) + SET("${m}" PARENT_SCOPE) +ENDFUNCTION(undef_var) + +SET(FUNCTION_UNDEFINED 1) +undef_var(FUNCTION_UNDEFINED) +IF(DEFINED FUNCTION_UNDEFINED) + FAILED("Function Undefine Test" "(${FUNCTION_UNDEFINED})") +ELSE(DEFINED FUNCTION_UNDEFINED) + PASS("Function Undefine Test" "(${FUNCTION_UNDEFINED})") +ENDIF(DEFINED FUNCTION_UNDEFINED) + +# Subdirectory scope raise. +SET(SUBDIR_UNDEFINED 1) +ADD_SUBDIRECTORY(SubDirScope) +IF(DEFINED SUBDIR_UNDEFINED) + FAILED("Subdir Undefine Test" "(${SUBDIR_UNDEFINED})") +ELSE(DEFINED SUBDIR_UNDEFINED) + PASS("Subdir Undefine Test" "(${SUBDIR_UNDEFINED})") +ENDIF(DEFINED SUBDIR_UNDEFINED) +IF(DEFINED SUBDIR_DEFINED) + PASS("Subdir Define Test" "(${SUBDIR_DEFINED})") +ELSE(DEFINED SUBDIR_DEFINED) + FAILED("Subdir Define Test" "(${SUBDIR_DEFINED})") +ENDIF(DEFINED SUBDIR_DEFINED) + +# Test function-scoped directory. +FUNCTION(ADD_SUBDIR2 dir) + ADD_SUBDIRECTORY("${dir}" "${dir}2") + # The parent scope sets in the subdir should be visible here. + IF(DEFINED SUBDIR_UNDEFINED) + FAILED("Subdir Function Undefine Test 1" "(${SUBDIR_UNDEFINED})") + ELSE(DEFINED SUBDIR_UNDEFINED) + PASS("Subdir Function Undefine Test 1" "(${SUBDIR_UNDEFINED})") + ENDIF(DEFINED SUBDIR_UNDEFINED) + IF(DEFINED SUBDIR_DEFINED) + PASS("Subdir Function Define Test 1" "(${SUBDIR_DEFINED})") + ELSE(DEFINED SUBDIR_DEFINED) + FAILED("Subdir Function Define Test 1" "(${SUBDIR_DEFINED})") + ENDIF(DEFINED SUBDIR_DEFINED) +ENDFUNCTION(ADD_SUBDIR2) + +# Reset test variables. +SET(SUBDIR_UNDEFINED 1) +SET(SUBDIR_DEFINED) + +# Run test function. +ADD_SUBDIR2(SubDirScope) + +# The parent scope sets in the subdir should not be visible here. +IF(DEFINED SUBDIR_UNDEFINED) + PASS("Subdir Function Undefine Test 2" "(${SUBDIR_UNDEFINED})") +ELSE(DEFINED SUBDIR_UNDEFINED) + FAILED("Subdir Function Undefine Test 2" "(${SUBDIR_UNDEFINED})") +ENDIF(DEFINED SUBDIR_UNDEFINED) +IF(DEFINED SUBDIR_DEFINED) + FAILED("Subdir Function Define Test 2" "(${SUBDIR_DEFINED})") +ELSE(DEFINED SUBDIR_DEFINED) + PASS("Subdir Function Define Test 2" "(${SUBDIR_DEFINED})") +ENDIF(DEFINED SUBDIR_DEFINED) + +ADD_EXECUTABLE(FunctionTest functionTest.c) + +# Use the PROJECT_LABEL property: in IDEs, the project label should appear +# in the UI rather than the target name. If this were a good test of the +# property rather than just a smoke test, it would verify that the label +# actually appears in the UI of the IDE... Or at least that the text appears +# somewhere in the generated project files. +SET_PROPERTY(TARGET miniFunctionTest + PROPERTY PROJECT_LABEL "Test de Fonctionnement") diff --git a/Tests/FunctionTest/SubDirScope/CMakeLists.txt b/Tests/FunctionTest/SubDirScope/CMakeLists.txt new file mode 100644 index 000000000..4a53d2c0a --- /dev/null +++ b/Tests/FunctionTest/SubDirScope/CMakeLists.txt @@ -0,0 +1,14 @@ +SET(SUBDIR_DEFINED 1 PARENT_SCOPE) +SET(SUBDIR_UNDEFINED PARENT_SCOPE) + +# The above sets should not affect the current scope. +IF(DEFINED SUBDIR_UNDEFINED) + PASS("SubdirScope Undefine Test" "(${SUBDIR_UNDEFINED})") +ELSE(DEFINED SUBDIR_UNDEFINED) + FAILED("SubdirScope Undefine Test" "(${SUBDIR_UNDEFINED})") +ENDIF(DEFINED SUBDIR_UNDEFINED) +IF(DEFINED SUBDIR_DEFINED) + FAILED("SubdirScope Define Test" "(${SUBDIR_DEFINED})") +ELSE(DEFINED SUBDIR_DEFINED) + PASS("SubdirScope Define Test" "(${SUBDIR_DEFINED})") +ENDIF(DEFINED SUBDIR_DEFINED) diff --git a/Tests/FunctionTest/Util.cmake b/Tests/FunctionTest/Util.cmake new file mode 100644 index 000000000..f0c73b5da --- /dev/null +++ b/Tests/FunctionTest/Util.cmake @@ -0,0 +1,3 @@ +function(tester) + set (tester_res "${CMAKE_CURRENT_LIST_FILE}" PARENT_SCOPE) +endfunction(tester) diff --git a/Tests/FunctionTest/functionTest.c b/Tests/FunctionTest/functionTest.c new file mode 100644 index 000000000..e0ced6afd --- /dev/null +++ b/Tests/FunctionTest/functionTest.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char* argv[]) +{ + printf("Running command: %s with %d arguments\n", argv[0], argc); + return 0; +} diff --git a/Tests/IPO/CMakeLists.txt b/Tests/IPO/CMakeLists.txt new file mode 100644 index 000000000..595e4f50d --- /dev/null +++ b/Tests/IPO/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 2.8) +project(IPO NONE) + +SET_PROPERTY(DIRECTORY PROPERTY INTERPROCEDURAL_OPTIMIZATION 1) + +add_subdirectory(../COnly COnly) +add_subdirectory(../CxxOnly CxxOnly) diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt new file mode 100644 index 000000000..60f5e5e6f --- /dev/null +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -0,0 +1,49 @@ +cmake_minimum_required (VERSION 2.6) +project(IncludeDirectories) + +file(WRITE ${CMAKE_BINARY_DIR}/Flags/Flags.h +"//Flags.h +") +file(WRITE ${CMAKE_BINARY_DIR}/IncDir/IncDir.h +"//IncDir.h +") +file(WRITE ${CMAKE_BINARY_DIR}/SrcProp/SrcProp.h +"//SrcProp.h +") +file(WRITE ${CMAKE_BINARY_DIR}/TarProp/TarProp.h +"//TarProp.h +") + +# default to testing with full path +# some compilers can not handle the escape for directories +# with spaces in them. +set(USE_FULLPATH TRUE) +if(WATCOM OR MSVC60) + set(USE_FULLPATH FALSE) +endif() +if(USE_FULLPATH) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \"-I${CMAKE_BINARY_DIR}/Flags\"") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -IFlags") +endif() + +include_directories(${CMAKE_BINARY_DIR}/IncDir) +if(USE_FULLPATH) + set_source_files_properties(main.cpp PROPERTIES COMPILE_FLAGS + "\"-I${CMAKE_BINARY_DIR}/SrcProp\"") +else() + set_source_files_properties(main.cpp PROPERTIES COMPILE_FLAGS + "-ISrcProp") +endif() + +add_executable(IncludeDirectories main.cpp) + +if(USE_FULLPATH) + set_target_properties(IncludeDirectories + PROPERTIES COMPILE_FLAGS "\"-I${CMAKE_BINARY_DIR}/TarProp\"") +else() + set_target_properties(IncludeDirectories + PROPERTIES COMPILE_FLAGS "-ITarProp") +endif() + +add_subdirectory(TargetIncludeDirectories) diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt new file mode 100644 index 000000000..334b8be62 --- /dev/null +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt @@ -0,0 +1,24 @@ + +cmake_minimum_required(VERSION 2.8) + +project(TargetIncludeDirectories) + +macro(create_header _name) + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_name}") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_name}/${_name}.h" "//${_name}.h\n") +endmacro() + +create_header(bar) +create_header(bat) +create_header(foo) +create_header(baz) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include_directories("${CMAKE_CURRENT_BINARY_DIR}/bar") + +add_executable(TargetIncludeDirectories main.cpp) +set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/bat") +set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/foo") + +include_directories("${CMAKE_CURRENT_BINARY_DIR}/baz") diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp new file mode 100644 index 000000000..8aa35320f --- /dev/null +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp @@ -0,0 +1,10 @@ + +#include "bar.h" +#include "bat.h" +#include "foo.h" +#include "baz.h" + +int main(int, char**) +{ + return 0; +} diff --git a/Tests/IncludeDirectories/main.cpp b/Tests/IncludeDirectories/main.cpp new file mode 100644 index 000000000..a59d27c39 --- /dev/null +++ b/Tests/IncludeDirectories/main.cpp @@ -0,0 +1,9 @@ +#include "Flags.h" +#include "IncDir.h" +#include "SrcProp.h" +#include "TarProp.h" + +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/JCTest/CMakeLists.txt b/Tests/JCTest/CMakeLists.txt new file mode 100644 index 000000000..a0f590e57 --- /dev/null +++ b/Tests/JCTest/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 2.6) +project(TestTime) +enable_testing() +add_executable(TestTime TestTime.cxx) + +foreach(f 1 2 3 4 5 6 7 8 9 10 11 12 12 14 15 16 17 18 19 +20 21 22 23 24 25 26 27 28 29 30) + add_test(TestTime${f} TestTime 50000000) +endforeach(f) diff --git a/Tests/JCTest/TestTime.cxx b/Tests/JCTest/TestTime.cxx new file mode 100644 index 000000000..5768ab522 --- /dev/null +++ b/Tests/JCTest/TestTime.cxx @@ -0,0 +1,12 @@ +#include <stdio.h> +#include <stdlib.h> + +int main(int ac, char** av) +{ + float d = 10.0; + for(int i =0; i < atoi(av[1]); i++) + { + d *= .2; + } + printf("%f", d); +} diff --git a/Tests/Java/A.java b/Tests/Java/A.java new file mode 100644 index 000000000..e34b7046a --- /dev/null +++ b/Tests/Java/A.java @@ -0,0 +1,11 @@ +class A +{ + public A() + { + } + + public void printName() + { + System.out.println("A"); + } +} diff --git a/Tests/Java/CMakeLists.txt b/Tests/Java/CMakeLists.txt new file mode 100644 index 000000000..6a69a2464 --- /dev/null +++ b/Tests/Java/CMakeLists.txt @@ -0,0 +1,9 @@ +project(hello Java) + +cmake_minimum_required (VERSION 2.6) +set(CMAKE_VERBOSE_MAKEFILE 1) + +find_package(Java COMPONENTS Development) +include (UseJava) + +add_jar(hello A.java HelloWorld.java) diff --git a/Tests/Java/HelloWorld.java b/Tests/Java/HelloWorld.java new file mode 100644 index 000000000..54246ec26 --- /dev/null +++ b/Tests/Java/HelloWorld.java @@ -0,0 +1,11 @@ +class HelloWorld +{ + public static void main(String args[]) + { + A a; + a = new A(); + a.printName(); + System.out.println("Hello World!"); + } +} + diff --git a/Tests/Jump/CMakeLists.txt b/Tests/Jump/CMakeLists.txt new file mode 100644 index 000000000..4bdafd09b --- /dev/null +++ b/Tests/Jump/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(Jump) + +SET(CMAKE_IGNORE_DEPENDENCIES_ORDERING 1) +ADD_SUBDIRECTORY(Executable) +ADD_SUBDIRECTORY(Library) diff --git a/Tests/Jump/Executable/CMakeLists.txt b/Tests/Jump/Executable/CMakeLists.txt new file mode 100644 index 000000000..7658b7e31 --- /dev/null +++ b/Tests/Jump/Executable/CMakeLists.txt @@ -0,0 +1,6 @@ +IF(NOT LIBRARY_OUTPUT_PATH) + LINK_DIRECTORIES(${Jump_BINARY_DIR}/Library/Static + ${Jump_BINARY_DIR}/Library/Shared) +ENDIF(NOT LIBRARY_OUTPUT_PATH) +ADD_EXECUTABLE(jumpExecutable jumpExecutable.cxx) +TARGET_LINK_LIBRARIES(jumpExecutable jumpStatic jumpShared) diff --git a/Tests/Jump/Executable/jumpExecutable.cxx b/Tests/Jump/Executable/jumpExecutable.cxx new file mode 100644 index 000000000..7a050c702 --- /dev/null +++ b/Tests/Jump/Executable/jumpExecutable.cxx @@ -0,0 +1,12 @@ +#ifdef _WIN32 +# define JUMP_IMPORT __declspec(dllimport) +#else +# define JUMP_IMPORT extern +#endif + +extern int jumpStatic(); +JUMP_IMPORT int jumpShared(); +int main() +{ + return jumpShared() && jumpShared(); +} diff --git a/Tests/Jump/Library/CMakeLists.txt b/Tests/Jump/Library/CMakeLists.txt new file mode 100644 index 000000000..2f78c501c --- /dev/null +++ b/Tests/Jump/Library/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_SUBDIRECTORY(Static) +ADD_SUBDIRECTORY(Shared) diff --git a/Tests/Jump/Library/Shared/CMakeLists.txt b/Tests/Jump/Library/Shared/CMakeLists.txt new file mode 100644 index 000000000..44405770f --- /dev/null +++ b/Tests/Jump/Library/Shared/CMakeLists.txt @@ -0,0 +1,26 @@ +ADD_LIBRARY(jumpShared SHARED jumpShared.cxx) + +IF(WIN32 OR CYGWIN) + SET(SHARED_MUST_BE_IN_EXE_DIR 1) +ENDIF() + +IF(APPLE) + SET(SHARED_MUST_BE_IN_EXE_DIR 1) +ENDIF(APPLE) + +IF(SHARED_MUST_BE_IN_EXE_DIR) + SET(LIB_NAME + ${CMAKE_SHARED_LIBRARY_PREFIX}jumpShared${CMAKE_SHARED_LIBRARY_SUFFIX}) + SET(EXE_DIR ${Jump_BINARY_DIR}/Executable) + IF(EXECUTABLE_OUTPUT_PATH) + SET(EXE_DIR ${EXECUTABLE_OUTPUT_PATH}) + ENDIF(EXECUTABLE_OUTPUT_PATH) + SET(LIB_DIR ${Jump_BINARY_DIR}/Library/Shared) + IF(LIBRARY_OUTPUT_PATH) + SET(LIB_DIR ${LIBRARY_OUTPUT_PATH}) + ENDIF(LIBRARY_OUTPUT_PATH) + ADD_CUSTOM_COMMAND(TARGET jumpShared + POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy + ${LIB_DIR}/${CMAKE_CFG_INTDIR}/${LIB_NAME} + ${EXE_DIR}/${CMAKE_CFG_INTDIR}/${LIB_NAME}) +ENDIF(SHARED_MUST_BE_IN_EXE_DIR) diff --git a/Tests/Jump/Library/Shared/jumpShared.cxx b/Tests/Jump/Library/Shared/jumpShared.cxx new file mode 100644 index 000000000..f500058cc --- /dev/null +++ b/Tests/Jump/Library/Shared/jumpShared.cxx @@ -0,0 +1,7 @@ +#ifdef _WIN32 +# define JUMP_EXPORT __declspec(dllexport) +#else +# define JUMP_EXPORT +#endif + +JUMP_EXPORT int jumpShared() { return 0; } diff --git a/Tests/Jump/Library/Static/CMakeLists.txt b/Tests/Jump/Library/Static/CMakeLists.txt new file mode 100644 index 000000000..23e70c0b1 --- /dev/null +++ b/Tests/Jump/Library/Static/CMakeLists.txt @@ -0,0 +1 @@ +ADD_LIBRARY(jumpStatic STATIC jumpStatic.cxx) diff --git a/Tests/Jump/Library/Static/jumpStatic.cxx b/Tests/Jump/Library/Static/jumpStatic.cxx new file mode 100644 index 000000000..1f92eb998 --- /dev/null +++ b/Tests/Jump/Library/Static/jumpStatic.cxx @@ -0,0 +1 @@ +int jumpStatic() { return 0; } diff --git a/Tests/KDE4StableBranchTest/test_kde4.sh.in b/Tests/KDE4StableBranchTest/test_kde4.sh.in new file mode 100755 index 000000000..81badcd79 --- /dev/null +++ b/Tests/KDE4StableBranchTest/test_kde4.sh.in @@ -0,0 +1,62 @@ +#!/bin/sh + +# This shell script tests whether cmake is able to build the latest +# stable KDE4 release, or at least some part of it. +# It downloads automoc from KDE svn, builds and installs it, then it +# downloads phonon from KDE svn, builds and installs it, and finally +# it downloads kdelibs (currently from the 4.3 branch), and builds +# a (small) part of it, i.e. libkdecore and one unit test depending on it. +# +# <neundorf AT kde.org> + +CMAKE="@CMAKE_CMAKE_COMMAND@" +BASEDIR="@TEST_KDE4_BASE_DIR@" +INSTALLDIR="$BASEDIR/install" +QMAKE="@QT_QMAKE_EXECUTABLE@" + +cd "$BASEDIR" || exit -1 +echo "Removing old install dir " $INSTALLDIR + +rm -rf install || exit -1 +rm -rf build-automoc || exit -1 +rm -rf build-phonon || exit -1 +rm -rf build-kdelibs || exit -1 + + + +# build and install automoc +cd "$BASEDIR" || exit -1 +svn co svn://anonsvn.kde.org/home/kde/tags/kdesupport-for-4.3/kdesupport/automoc || exit -1 + +mkdir -p build-automoc || exit -1 + +cd build-automoc || exit -1 +"$CMAKE" -DCMAKE_INSTALL_PREFIX="$INSTALLDIR" -DQT_QMAKE_EXECUTABLE:STRING="$QMAKE" ../automoc || exit -1 +"$CMAKE" --build . || exit -1 +"$CMAKE" -P cmake_install.cmake || exit -1 + +export CMAKE_PREFIX_PATH="$INSTALLDIR:$CMAKE_PREFIX_PATH" + + +# build and install phonon +cd "$BASEDIR" || exit -1 +svn co svn://anonsvn.kde.org/home/kde/tags/kdesupport-for-4.3/kdesupport/phonon || exit -1 + +mkdir -p build-phonon || exit -1 + +cd build-phonon || exit -1 +"$CMAKE" -DCMAKE_INSTALL_PREFIX="$INSTALLDIR" -DQT_QMAKE_EXECUTABLE:STRING="$QMAKE" -DWITH_GLIB2=FALSE -DWITH_GObject=FALSE -DWITH_GStreamer=FALSE -DWITH_GStreamerPlugins=FALSE -DWITH_OpenGL=FALSE -DWITH_XCB=FALSE -DWITH_Xine=FALSE ../phonon || exit -1 +"$CMAKE" --build . || exit -1 +"$CMAKE" -P cmake_install.cmake || exit -1 + + +# finally build kdelibs/kdecore +cd "$BASEDIR" || exit -1 + +svn co svn://anonsvn.kde.org/home/kde/branches/KDE/4.3/kdelibs/ || exit -1 +mkdir -p build-kdelibs || exit -1 +cd build-kdelibs || exit -1 +# trick cmake into not searching strigi and not searching sharedmimeinfo +"$CMAKE" -DCMAKE_INSTALL_PREFIX="$INSTALLDIR" -DQT_QMAKE_EXECUTABLE:STRING="$QMAKE" -DSTRIGI_FOUND=TRUE -DSTRIGI_INCLUDE_DIR=/usr/include -DSTRIGI_STREAMANALYZER_LIBRARY=-lc -DSTRIGI_STREAMS_LIBRARY=-lc -DSTRIGI_STRIGIQTDBUSCLIENT_LIBRARY=-lc -DSTRIGI_NEEDS_SIGNED_CHAR=TRUE -DSTRIGI_NEEDS_CHAR=FALSE -DUPDATE_MIME_DATABASE_EXECUTABLE=/bin/sh ../kdelibs || exit -1 +make -C kdecore/tests kurltest || exit -1 + diff --git a/Tests/LibName/CMakeLists.txt b/Tests/LibName/CMakeLists.txt new file mode 100644 index 000000000..07499a14d --- /dev/null +++ b/Tests/LibName/CMakeLists.txt @@ -0,0 +1,26 @@ +project(LibName) +# this is a test to make sure that relative path +# LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH work +set(LIBRARY_OUTPUT_PATH lib) +set(EXECUTABLE_OUTPUT_PATH lib) + +add_library(bar SHARED bar.c) + +add_library(foo SHARED foo.c) +target_link_libraries(foo bar) + +add_executable(foobar foobar.c) +target_link_libraries(foobar foo) +IF(UNIX) + target_link_libraries(foobar -L/usr/local/lib) +ENDIF(UNIX) + + +# check with lib version + +add_library(verFoo SHARED foo.c) +target_link_libraries(verFoo bar) +set_target_properties(verFoo PROPERTIES VERSION 3.1.4 SOVERSION 3) + +add_executable(verFoobar foobar.c) +target_link_libraries(verFoobar verFoo) diff --git a/Tests/LibName/bar.c b/Tests/LibName/bar.c new file mode 100644 index 000000000..960718038 --- /dev/null +++ b/Tests/LibName/bar.c @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + +extern void foo() +{ +} diff --git a/Tests/LibName/foo.c b/Tests/LibName/foo.c new file mode 100644 index 000000000..a68970405 --- /dev/null +++ b/Tests/LibName/foo.c @@ -0,0 +1,11 @@ +#ifdef _WIN32 +__declspec(dllimport) +#endif +extern void foo(); +#ifdef _WIN32 +__declspec(dllexport) +#endif + void bar() +{ + foo(); +} diff --git a/Tests/LibName/foobar.c b/Tests/LibName/foobar.c new file mode 100644 index 000000000..73b4b4156 --- /dev/null +++ b/Tests/LibName/foobar.c @@ -0,0 +1,10 @@ +#ifdef _WIN32 +__declspec(dllimport) +#endif +extern void bar(); + +int main() +{ + bar(); + return 0; +} diff --git a/Tests/LinkDirectory/CMakeLists.txt b/Tests/LinkDirectory/CMakeLists.txt new file mode 100644 index 000000000..7356b27d2 --- /dev/null +++ b/Tests/LinkDirectory/CMakeLists.txt @@ -0,0 +1,47 @@ +cmake_minimum_required(VERSION 2.8) +project(LinkDirectory C) + +# Put the subproject source tree in our build tree so it can refer to +# link directories relative to its source. +if(NOT "${LinkDirectory_SOURCE_DIR}" STREQUAL "${LinkDirectory_BINARY_DIR}") + file(COPY External/ DESTINATION External PATTERN CVS EXCLUDE) +endif() + +# Build a library into the subproject source tree. +add_library(mylibA STATIC mylibA.c) +set_property(TARGET mylibA PROPERTY + ARCHIVE_OUTPUT_DIRECTORY "${LinkDirectory_BINARY_DIR}/External/lib") +get_property(mylibA TARGET mylibA PROPERTY LOCATION) + +# Build a library into our build tree relative to the subproject build tree. +add_library(mylibB STATIC mylibB.c) +set_property(TARGET mylibB PROPERTY + ARCHIVE_OUTPUT_DIRECTORY "${LinkDirectory_BINARY_DIR}/lib") +get_property(mylibB TARGET mylibB PROPERTY LOCATION) + +# Create a custom target to drive the subproject build. +include(ExternalProject) +ExternalProject_Add(ExternalTarget + SOURCE_DIR "${LinkDirectory_BINARY_DIR}/External" + BINARY_DIR "${LinkDirectory_BINARY_DIR}/External-build" + CMAKE_ARGS "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${LinkDirectory_BINARY_DIR}/bin" + PREFIX "${LinkDirectory_BINARY_DIR}/External-build/root" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" + ) + +# Add a step to wipe out the subproject executable after our libraries +# change. This is needed because the subproject cannot depend on them +# directly because it does not know the full paths to the libraries. +# (The purpose of this test is to check that link_directories works.) +ExternalProject_Add_Step(ExternalTarget cleanup + COMMAND ${CMAKE_COMMAND} -E remove_directory ${LinkDirectory_BINARY_DIR}/bin + DEPENDEES download + DEPENDERS configure + DEPENDS ${mylibA} ${mylibB} + "${LinkDirectory_BINARY_DIR}/External/CMakeLists.txt" + "${LinkDirectory_BINARY_DIR}/External/myexe.c" + ) + +# Make the subproject build after our targets. +add_dependencies(ExternalTarget mylibA mylibB) diff --git a/Tests/LinkDirectory/External/CMakeLists.txt b/Tests/LinkDirectory/External/CMakeLists.txt new file mode 100644 index 000000000..f7c840f9a --- /dev/null +++ b/Tests/LinkDirectory/External/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 2.8) +project(LinkDirectoryExternal C) + +# Test CMP0015 OLD behavior: -L../lib +cmake_policy(SET CMP0015 OLD) +link_directories(../lib) + +# Test CMP0015 NEW behavior: -L${CMAKE_CURRENT_SOURCE_DIR}/lib +cmake_policy(SET CMP0015 NEW) +link_directories(lib) + +add_executable(myexe myexe.c) +set_property(TARGET myexe PROPERTY OUTPUT_NAME LinkDirectory) +target_link_libraries(myexe mylibA mylibB) diff --git a/Tests/LinkDirectory/External/myexe.c b/Tests/LinkDirectory/External/myexe.c new file mode 100644 index 000000000..6ef1ebe59 --- /dev/null +++ b/Tests/LinkDirectory/External/myexe.c @@ -0,0 +1,3 @@ +extern int mylibA(void); +extern int mylibB(void); +int main(void) { return mylibA() + mylibB(); } diff --git a/Tests/LinkDirectory/mylibA.c b/Tests/LinkDirectory/mylibA.c new file mode 100644 index 000000000..890a0890e --- /dev/null +++ b/Tests/LinkDirectory/mylibA.c @@ -0,0 +1 @@ +int mylibA(void) { return 0; } diff --git a/Tests/LinkDirectory/mylibB.c b/Tests/LinkDirectory/mylibB.c new file mode 100644 index 000000000..090cc6ce5 --- /dev/null +++ b/Tests/LinkDirectory/mylibB.c @@ -0,0 +1 @@ +int mylibB(void) { return 0; } diff --git a/Tests/LinkFlags/CMakeLists.txt b/Tests/LinkFlags/CMakeLists.txt new file mode 100644 index 000000000..e06020c25 --- /dev/null +++ b/Tests/LinkFlags/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 2.8) +project(LinkFlags C) + +string(TOUPPER "${TEST_CONFIG}" TEST_CONFIG_UPPER) +set(obj "${CMAKE_C_OUTPUT_EXTENSION}") +if(BORLAND) + set(pre -) +endif() + +add_library(LinkFlags_lib STATIC LinkFlagsLib.c) +set_property(TARGET LinkFlags_lib PROPERTY STATIC_LIBRARY_FLAGS ${pre}BADFLAG${obj}) + +add_library(LinkFlags_dll SHARED LinkFlagsLib.c) +set_property(TARGET LinkFlags_dll PROPERTY LINK_FLAGS ${pre}BADFLAG${obj}) + +add_executable(LinkFlags_exe LinkFlagsExe.c) +set_property(TARGET LinkFlags_exe PROPERTY LINK_FLAGS ${pre}BADFLAG${obj}) + +add_library(LinkFlags_lib_config STATIC LinkFlagsLib.c) +set_property(TARGET LinkFlags_lib_config PROPERTY STATIC_LIBRARY_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG_${TEST_CONFIG}${obj}) + +add_library(LinkFlags_dll_config SHARED LinkFlagsLib.c) +set_property(TARGET LinkFlags_dll_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG_${TEST_CONFIG}${obj}) + +add_executable(LinkFlags_exe_config LinkFlagsExe.c) +set_property(TARGET LinkFlags_exe_config PROPERTY LINK_FLAGS_${TEST_CONFIG_UPPER} ${pre}BADFLAG_${TEST_CONFIG}${obj}) + +add_executable(LinkFlags LinkFlags.c) diff --git a/Tests/LinkFlags/LinkFlags.c b/Tests/LinkFlags/LinkFlags.c new file mode 100644 index 000000000..78f2de106 --- /dev/null +++ b/Tests/LinkFlags/LinkFlags.c @@ -0,0 +1 @@ +int main(void) { return 0; } diff --git a/Tests/LinkFlags/LinkFlagsExe.c b/Tests/LinkFlags/LinkFlagsExe.c new file mode 100644 index 000000000..123587a1f --- /dev/null +++ b/Tests/LinkFlags/LinkFlagsExe.c @@ -0,0 +1,6 @@ +int main(void) { return 0; } + +/* Intel compiler does not reject bad flags or objects! */ +#if defined(__INTEL_COMPILER) +# error BADFLAG +#endif diff --git a/Tests/LinkFlags/LinkFlagsLib.c b/Tests/LinkFlags/LinkFlagsLib.c new file mode 100644 index 000000000..9d8d08819 --- /dev/null +++ b/Tests/LinkFlags/LinkFlagsLib.c @@ -0,0 +1,6 @@ +int flags_lib(void) { return 0; } + +/* Intel compiler does not reject bad flags or objects! */ +#if defined(__INTEL_COMPILER) +# error BADFLAG +#endif diff --git a/Tests/LinkLanguage/CMakeLists.txt b/Tests/LinkLanguage/CMakeLists.txt new file mode 100644 index 000000000..b4e53925d --- /dev/null +++ b/Tests/LinkLanguage/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.7.20090708) +project(LinkLanguage C CXX) + +add_library(foo STATIC foo.cxx) +add_executable(LinkLanguage LinkLanguage.c) + +# Export the target now to compute its link interface and implementation. +# This tests that the link info is recomputed after the library is linked. +export(TARGETS LinkLanguage FILE LinkLanguageTargets.cmake) + +target_link_libraries(LinkLanguage foo) + +# CMake should now automatically choose CXX for linking, so we need +# not set the property: +#set_property(TARGET LinkLanguage PROPERTY LINKER_LANGUAGE CXX) diff --git a/Tests/LinkLanguage/LinkLanguage.c b/Tests/LinkLanguage/LinkLanguage.c new file mode 100644 index 000000000..cf1557cab --- /dev/null +++ b/Tests/LinkLanguage/LinkLanguage.c @@ -0,0 +1,6 @@ +extern int foo(void); +int main() +{ + return foo(); +} + diff --git a/Tests/LinkLanguage/foo.cxx b/Tests/LinkLanguage/foo.cxx new file mode 100644 index 000000000..5321c2dc0 --- /dev/null +++ b/Tests/LinkLanguage/foo.cxx @@ -0,0 +1,6 @@ +extern "C" int foo(void) +{ + // Reference C++ standard library symbols. + delete new int; + return 0; +} diff --git a/Tests/LinkLine/CMakeLists.txt b/Tests/LinkLine/CMakeLists.txt new file mode 100644 index 000000000..c8f0ecf63 --- /dev/null +++ b/Tests/LinkLine/CMakeLists.txt @@ -0,0 +1,12 @@ +PROJECT( LinkLine ) + +# Makes sure that the library order as specified by the user are +# unchanged by dependency analysis, etc. libOne and libTwo are +# dependent on each other. The link line should be -lOne -lTwo -lOne. + +ADD_LIBRARY( One One.c ) +ADD_LIBRARY( Two Two.c ) + +LINK_LIBRARIES( One Two ) +ADD_EXECUTABLE( LinkLine Exec.c ) +LINK_LIBRARIES( One ) diff --git a/Tests/LinkLine/Exec.c b/Tests/LinkLine/Exec.c new file mode 100644 index 000000000..807a7a8cc --- /dev/null +++ b/Tests/LinkLine/Exec.c @@ -0,0 +1,9 @@ +void OneFunc(); +void TwoFunc(); + +int main() +{ + OneFunc(); + TwoFunc(); + return 0; +} diff --git a/Tests/LinkLine/One.c b/Tests/LinkLine/One.c new file mode 100644 index 000000000..167f07d0d --- /dev/null +++ b/Tests/LinkLine/One.c @@ -0,0 +1,10 @@ +void TwoFunc(); + +void OneFunc() +{ + static int i = 0; + ++i; + if( i==1 ) { + TwoFunc(); + } +} diff --git a/Tests/LinkLine/Two.c b/Tests/LinkLine/Two.c new file mode 100644 index 000000000..0db73a882 --- /dev/null +++ b/Tests/LinkLine/Two.c @@ -0,0 +1,10 @@ +void OneFunc(); + +void TwoFunc() +{ + static int i = 0; + ++i; + if( i==1 ) { + OneFunc(); + } +} diff --git a/Tests/LinkLineOrder/CMakeLists.txt b/Tests/LinkLineOrder/CMakeLists.txt new file mode 100644 index 000000000..21a502217 --- /dev/null +++ b/Tests/LinkLineOrder/CMakeLists.txt @@ -0,0 +1,36 @@ +PROJECT( LinkLineOrder ) + +# This tests ensures that the order of libraries are preserved when +# they don't have dependency information, even if they are deep in the +# dependency tree. + +# NoDepC depends on NoDepA which depends on NoDepB. NoDepE and NoDepF +# are dependent on each other (recursive dependency). However, CMake +# has no information about these libraries except for the order they +# are specified in One. We must make sure we don't lose that. + +ADD_LIBRARY( NoDepA NoDepA.c ) +ADD_LIBRARY( NoDepB NoDepB.c ) +ADD_LIBRARY( NoDepC NoDepC.c ) +ADD_LIBRARY( NoDepE NoDepE.c ) +ADD_LIBRARY( NoDepF NoDepF.c ) + +ADD_LIBRARY( One One.c ) +TARGET_LINK_LIBRARIES( One NoDepC NoDepA NoDepB NoDepE NoDepF NoDepE ) + +ADD_EXECUTABLE( Exec1 Exec1.c ) +TARGET_LINK_LIBRARIES( Exec1 One ) + + +# Similar situation as One, except at a different level of the +# dependency tree. This makes sure that the order is presevered +# everywhere in the graph. +ADD_LIBRARY( NoDepX NoDepX.c ) +ADD_LIBRARY( NoDepY NoDepY.c ) +ADD_LIBRARY( NoDepZ NoDepZ.c ) + +ADD_LIBRARY( Two Two.c ) +TARGET_LINK_LIBRARIES( Two One NoDepZ NoDepX NoDepY ) + +ADD_EXECUTABLE( Exec2 Exec2.c ) +TARGET_LINK_LIBRARIES( Exec2 Two ) diff --git a/Tests/LinkLineOrder/Exec1.c b/Tests/LinkLineOrder/Exec1.c new file mode 100644 index 000000000..9bbf0f68f --- /dev/null +++ b/Tests/LinkLineOrder/Exec1.c @@ -0,0 +1,8 @@ +/* Directly depends on One */ +void OneFunc(); + +int main() +{ + OneFunc(); + return 0; +} diff --git a/Tests/LinkLineOrder/Exec2.c b/Tests/LinkLineOrder/Exec2.c new file mode 100644 index 000000000..91b85758e --- /dev/null +++ b/Tests/LinkLineOrder/Exec2.c @@ -0,0 +1,8 @@ +/* Directly depends on Two */ +void TwoFunc(); + +int main() +{ + TwoFunc(); + return 0; +} diff --git a/Tests/LinkLineOrder/NoDepA.c b/Tests/LinkLineOrder/NoDepA.c new file mode 100644 index 000000000..76f97bc8c --- /dev/null +++ b/Tests/LinkLineOrder/NoDepA.c @@ -0,0 +1,7 @@ +/* depends on NoDepB */ +void NoDepB_func(); + +void NoDepA_func() +{ + NoDepB_func(); +} diff --git a/Tests/LinkLineOrder/NoDepB.c b/Tests/LinkLineOrder/NoDepB.c new file mode 100644 index 000000000..fa89ae9ee --- /dev/null +++ b/Tests/LinkLineOrder/NoDepB.c @@ -0,0 +1,4 @@ +/* No dependencies */ +void NoDepB_func() +{ +} diff --git a/Tests/LinkLineOrder/NoDepC.c b/Tests/LinkLineOrder/NoDepC.c new file mode 100644 index 000000000..f05d962b7 --- /dev/null +++ b/Tests/LinkLineOrder/NoDepC.c @@ -0,0 +1,7 @@ +/* depends on NoDepA */ +void NoDepA_func(); + +void NoDepC_func() +{ + NoDepA_func(); +} diff --git a/Tests/LinkLineOrder/NoDepE.c b/Tests/LinkLineOrder/NoDepE.c new file mode 100644 index 000000000..e1ba74996 --- /dev/null +++ b/Tests/LinkLineOrder/NoDepE.c @@ -0,0 +1,11 @@ +/* depends on NoDepF */ +void NoDepF_func(); + +void NoDepE_func() +{ + static int firstcall = 1; + if( firstcall ) { + firstcall = 0; + NoDepF_func(); + } +} diff --git a/Tests/LinkLineOrder/NoDepF.c b/Tests/LinkLineOrder/NoDepF.c new file mode 100644 index 000000000..8311cb868 --- /dev/null +++ b/Tests/LinkLineOrder/NoDepF.c @@ -0,0 +1,11 @@ +/* depends on NoDepE */ +void NoDepE_func(); + +void NoDepF_func() +{ + static int firstcall = 1; + if( firstcall ) { + firstcall = 0; + NoDepE_func(); + } +} diff --git a/Tests/LinkLineOrder/NoDepX.c b/Tests/LinkLineOrder/NoDepX.c new file mode 100644 index 000000000..c895dd11b --- /dev/null +++ b/Tests/LinkLineOrder/NoDepX.c @@ -0,0 +1,7 @@ +/* depends on NoDepY*/ +void NoDepY_func(); + +void NoDepX_func() +{ + NoDepY_func(); +} diff --git a/Tests/LinkLineOrder/NoDepY.c b/Tests/LinkLineOrder/NoDepY.c new file mode 100644 index 000000000..1e6a4aec3 --- /dev/null +++ b/Tests/LinkLineOrder/NoDepY.c @@ -0,0 +1,4 @@ +/* No dependencies */ +void NoDepY_func() +{ +} diff --git a/Tests/LinkLineOrder/NoDepZ.c b/Tests/LinkLineOrder/NoDepZ.c new file mode 100644 index 000000000..045e5705a --- /dev/null +++ b/Tests/LinkLineOrder/NoDepZ.c @@ -0,0 +1,7 @@ +/* depends on NoDepX */ +void NoDepX_func(); + +void NoDepZ_func() +{ + NoDepX_func(); +} diff --git a/Tests/LinkLineOrder/One.c b/Tests/LinkLineOrder/One.c new file mode 100644 index 000000000..b23b1ece9 --- /dev/null +++ b/Tests/LinkLineOrder/One.c @@ -0,0 +1,10 @@ +/* depends on NoDepC and NoDepE (and hence on NoDepA, NoDepB and */ +/* NoDepF) */ +void NoDepC_func(); +void NoDepE_func(); + +void OneFunc() +{ + NoDepC_func(); + NoDepE_func(); +} diff --git a/Tests/LinkLineOrder/Two.c b/Tests/LinkLineOrder/Two.c new file mode 100644 index 000000000..6bffaa866 --- /dev/null +++ b/Tests/LinkLineOrder/Two.c @@ -0,0 +1,8 @@ +void OneFunc(); +void NoDepZ_func(); + +void TwoFunc() +{ + OneFunc(); + NoDepZ_func(); +} diff --git a/Tests/LinkStatic/CMakeLists.txt b/Tests/LinkStatic/CMakeLists.txt new file mode 100644 index 000000000..2062c4345 --- /dev/null +++ b/Tests/LinkStatic/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 2.8.4.20110303 FATAL_ERROR) +project(LinkStatic C) + +if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU)$") + message(FATAL_ERROR "This test works only with the GNU compiler!") +endif() + +find_library(MATH_LIBRARY NAMES libm.a) +if(MATH_LIBRARY) + get_filename_component(MATH_LIB_DIR ${MATH_LIBRARY} PATH) + link_directories(${MATH_LIB_DIR}) + # Name the library both with a full path and as "-lm" to + # activate the link type switching code for both cases. + # If the second one links shared then the link will fail. + set(MATH_LIBRARIES ${MATH_LIBRARY} -lm) +else() + message(FATAL_ERROR "Cannot find libm.a needed for this test") +endif() + +add_executable(LinkStatic LinkStatic.c) +target_link_libraries(LinkStatic ${MATH_LIBRARIES}) + +# Enable static linking. +set(LinkStatic_FLAG "-static" CACHE STRING "Flag to link statically") +set_property(TARGET LinkStatic PROPERTY LINK_FLAGS "${LinkStatic_FLAG}") +set_property(TARGET LinkStatic PROPERTY LINK_SEARCH_START_STATIC 1) +#set_property(TARGET LinkStatic PROPERTY LINK_SEARCH_END_STATIC 1) # insufficient diff --git a/Tests/LinkStatic/LinkStatic.c b/Tests/LinkStatic/LinkStatic.c new file mode 100644 index 000000000..360097744 --- /dev/null +++ b/Tests/LinkStatic/LinkStatic.c @@ -0,0 +1,5 @@ +#include <math.h> +int main(void) +{ + return (int)sin(0); +} diff --git a/Tests/LoadCommand/CMakeCommands/CMakeLists.txt b/Tests/LoadCommand/CMakeCommands/CMakeLists.txt new file mode 100644 index 000000000..5cdbc59bf --- /dev/null +++ b/Tests/LoadCommand/CMakeCommands/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CMAKE_LOADED_COMMANDS) + +IF (MUDSLIDE_TYPE MATCHES MUCHO) + ADD_DEFINITIONS(-DMUCHO_MUDSLIDE) +ENDIF (MUDSLIDE_TYPE MATCHES MUCHO) + +INCLUDE_DIRECTORIES(${CMAKE_ROOT}/include ${CMAKE_ROOT}/Source) + +ADD_LIBRARY(cmCMAKE_TEST_COMMAND MODULE cmTestCommand.c) + +IF(WATCOM) + TARGET_LINK_LIBRARIES(cmCMAKE_TEST_COMMAND clbsdll.lib) +ENDIF(WATCOM) diff --git a/Tests/LoadCommand/CMakeCommands/cmTestCommand.c b/Tests/LoadCommand/CMakeCommands/cmTestCommand.c new file mode 100644 index 000000000..6b4f48f7b --- /dev/null +++ b/Tests/LoadCommand/CMakeCommands/cmTestCommand.c @@ -0,0 +1,219 @@ +#include "cmCPluginAPI.h" +#include <string.h> +#include <stdlib.h> +#include <stdio.h> + +typedef struct +{ + char *LibraryName; + int Argc; + char** Argv; +} cmVTKWrapTclData; + +/* do almost everything in the initial pass */ +static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[]) +{ + char* file; + char* str; + char *srcs; + const char* cstr; + char buffer[1024]; + void *source_file; + char *args[2]; + char *ccArgs[4]; + char *ccDep[1]; + char *ccOut[1]; + cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf; + + cmVTKWrapTclData *cdata = + (cmVTKWrapTclData *)malloc(sizeof(cmVTKWrapTclData)); + cdata->LibraryName = "BOO"; + cdata->Argc = argc; + cdata->Argv = argv; + info->CAPI->SetClientData(info,cdata); + + /* Now check and see if the value has been stored in the cache */ + /* already, if so use that value and don't look for the program */ + if(!info->CAPI->IsOn(mf,"TEST_COMMAND_TEST1")) + { + info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO"); + return 1; + } + + info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO"); + cdata->LibraryName = "HOO"; + + info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE", "ON", + "Test cache variable", + CM_CACHE_BOOL); + info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE1", "", + "Test cache variable 1", + CM_CACHE_PATH); + info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE2", "", + "Test cache variable 2", + CM_CACHE_FILEPATH); + info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE3", "", + "Test cache variable 3", + CM_CACHE_STRING); + info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE4", "", + "Test cache variable 4", + CM_CACHE_INTERNAL); + info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE5", "", + "Test cache variable 5", + CM_CACHE_STATIC); + + + file = info->CAPI->ExpandVariablesInString(mf, "${CMAKE_COMMAND}", 0, 0); + + str = info->CAPI->GetFilenameWithoutExtension(file); + info->CAPI->DisplaySatus(mf, str); + info->CAPI->Free(str); + str = info->CAPI->GetFilenamePath(file); + info->CAPI->DisplaySatus(mf, str); + info->CAPI->Free(str); + str = info->CAPI->Capitalized("cmake"); + info->CAPI->DisplaySatus(mf, str); + info->CAPI->Free(str); + + info->CAPI->DisplaySatus(mf, info->CAPI->GetProjectName(mf)); + info->CAPI->DisplaySatus(mf, info->CAPI->GetHomeDirectory(mf)); + info->CAPI->DisplaySatus(mf, info->CAPI->GetHomeOutputDirectory(mf)); + info->CAPI->DisplaySatus(mf, info->CAPI->GetStartDirectory(mf)); + info->CAPI->DisplaySatus(mf, info->CAPI->GetStartOutputDirectory(mf)); + info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentDirectory(mf)); + info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentOutputDirectory(mf)); + sprintf(buffer, "Cache version: %d.%d, CMake version: %d.%d", + info->CAPI->GetCacheMajorVersion(mf), + info->CAPI->GetCacheMinorVersion(mf), + info->CAPI->GetMajorVersion(mf), + info->CAPI->GetMinorVersion(mf)); + info->CAPI->DisplaySatus(mf, buffer); + if ( info->CAPI->CommandExists(mf, "SET") ) + { + info->CAPI->DisplaySatus(mf, "Command SET exists"); + } + if ( info->CAPI->CommandExists(mf, "SET_FOO_BAR") ) + { + info->CAPI->SetError(mf, "Command SET_FOO_BAR should not exists"); + return 0; + } + info->CAPI->AddDefineFlag(mf, "-DADDED_DEFINITION"); + + source_file = info->CAPI->CreateNewSourceFile(mf); + cstr = info->CAPI->SourceFileGetSourceName(source_file); + sprintf(buffer, "Shold be empty (source file name): [%s]", cstr); + info->CAPI->DisplaySatus(mf, buffer); + cstr = info->CAPI->SourceFileGetFullPath(source_file); + sprintf(buffer, "Should be empty (source file full path): [%s]", cstr); + info->CAPI->DisplaySatus(mf, buffer); + info->CAPI->DefineSourceFileProperty(mf,"SOME_PROPERTY","unused old prop", + "This property is no longer used", + 0); + if ( info->CAPI->SourceFileGetPropertyAsBool(source_file, "SOME_PROPERTY") ) + { + info->CAPI->SetError(mf, "Property SOME_PROPERTY should not be defined"); + return 0; + } + info->CAPI->DefineSourceFileProperty(mf,"SOME_PROPERTY2","nice prop", + "This property is for testing.", + 0); + info->CAPI->SourceFileSetProperty(source_file, "SOME_PROPERTY2", "HERE"); + cstr = info->CAPI->SourceFileGetProperty(source_file, "ABSTRACT"); + sprintf(buffer, "Should be 0 (source file abstract property): [%p]", cstr); + info->CAPI->DisplaySatus(mf, buffer); + + info->CAPI->DestroySourceFile(source_file); + + srcs = argv[2]; + info->CAPI->AddExecutable(mf,"LoadedCommand",1, &srcs, 0); + + /* add customs commands to generate the source file */ + ccArgs[0] = "-E"; + ccArgs[1] = "copy"; + ccArgs[2] = argv[0]; + ccArgs[3] = argv[1]; + ccDep[0] = ccArgs[2]; + ccOut[0] = ccArgs[3]; + info->CAPI->AddCustomCommand(mf, "LoadedCommand.cxx.in", + file, + 4, ccArgs, + 1, ccDep, + 1, ccOut, + "LoadedCommand"); + + + ccArgs[2] = argv[1]; + ccArgs[3] = argv[2]; + ccDep[0] = ccArgs[2]; + ccOut[0] = ccArgs[3]; + info->CAPI->AddCustomCommandToOutput(mf, ccOut[0], + file, + 4, ccArgs, + ccDep[0], + 0, 0); + + + ccArgs[1] = "echo"; + ccArgs[2] = "Build has finished"; + info->CAPI->AddCustomCommandToTarget(mf, "LoadedCommand", + file, + 3, ccArgs, + CM_POST_BUILD); + + info->CAPI->Free(file); + + args[0] = "TEST_EXEC"; + args[1] = "TRUE"; + + /* code coverage */ + if (info->CAPI->GetTotalArgumentSize(2,args) != 13) + { + return 0; + } + info->CAPI->ExecuteCommand(mf,"SET",2,args); + + /* make sure we can find the source file */ + if (!info->CAPI->GetSource(mf,argv[1])) + { + info->CAPI->SetError(mf, "Source file could not be found!"); + return 0; + } + + return 1; +} + +static void CCONV FinalPass(void *inf, void *mf) +{ + cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf; + /* get our client data from initial pass */ + cmVTKWrapTclData *cdata = + (cmVTKWrapTclData *)info->CAPI->GetClientData(info); + if (strcmp(info->CAPI->GetDefinition(mf, "TEST_DEF"),"HOO") || + strcmp(cdata->LibraryName,"HOO")) + { + fprintf(stderr,"*** Failed LOADED COMMAND Final Pass\n"); + } +} +static void CCONV Destructor(void *inf) +{ + cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf; + /* get our client data from initial pass */ + cmVTKWrapTclData *cdata = + (cmVTKWrapTclData *)info->CAPI->GetClientData(info); + free(cdata); +} + +#ifdef MUCHO_MUDSLIDE +void CM_PLUGIN_EXPORT CCONV CMAKE_TEST_COMMANDInit(cmLoadedCommandInfo *info) +{ + info->InitialPass = InitialPass; + info->FinalPass = FinalPass; + info->Destructor = Destructor; + info->m_Inherited = 0; + info->Name = "CMAKE_TEST_COMMAND"; +} +#endif + + + + diff --git a/Tests/LoadCommand/CMakeLists.txt b/Tests/LoadCommand/CMakeLists.txt new file mode 100644 index 000000000..846cbb084 --- /dev/null +++ b/Tests/LoadCommand/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(LoadCommand) + +# set a definition +SET (TEST_COMMAND_TEST1 1) + +INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake) +CHECK_TYPE_SIZE(char SIZEOF_CHAR) +CHECK_TYPE_SIZE(short SIZEOF_SHORT) + +INCLUDE (CheckFunctionExists) +CHECK_FUNCTION_EXISTS(printf HAVE_PRINTF) +CHECK_FUNCTION_EXISTS(vsblabla HAVE_VSBLABLA) + +CONFIGURE_FILE(${LoadCommand_SOURCE_DIR}/LoadedCommand.h.in + ${LoadCommand_BINARY_DIR}/LoadedCommand.h) + +INCLUDE_DIRECTORIES(${LoadCommand_BINARY_DIR}) + +# try to compile the command +# make sure it is not already loaded +IF(COMMAND CMAKE_TEST_COMMAND) +ELSE(COMMAND CMAKE_TEST_COMMAND) + TRY_COMPILE(COMPILE_OK + ${LoadCommand_BINARY_DIR}/CMakeCommands + ${LoadCommand_SOURCE_DIR}/CMakeCommands + CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO + OUTPUT_VARIABLE OUTPUT ) +# do another TRY_COMPILE to get around make +# problem on hp + TRY_COMPILE(COMPILE_OK + ${LoadCommand_BINARY_DIR}/CMakeCommands + ${LoadCommand_SOURCE_DIR}/CMakeCommands + CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO + OUTPUT_VARIABLE OUTPUT ) +ENDIF(COMMAND CMAKE_TEST_COMMAND) + +MESSAGE("Output from try compile: ${OUTPUT}") + +# if the compile was OK, try loading the command +IF (COMPILE_OK) + LOAD_COMMAND(CMAKE_TEST_COMMAND + ${LoadCommand_BINARY_DIR}/CMakeCommands + ${LoadCommand_BINARY_DIR}/CMakeCommands/Debug + ${LoadCommand_BINARY_DIR}/CMakeCommands/Development + ) + # if the command loaded, execute the command + IF (COMMAND CMAKE_TEST_COMMAND) + CMAKE_TEST_COMMAND( + "${LoadCommand_SOURCE_DIR}/LoadedCommand.cxx.in" + "${LoadCommand_BINARY_DIR}/LoadedCommand2.cxx.in" + "${LoadCommand_BINARY_DIR}/LoadedCommand3.cxx" + ) + ENDIF (COMMAND CMAKE_TEST_COMMAND) +ELSE (COMPILE_OK) + MESSAGE("failed to compile CMAKE_LOADED_COMMANDS") +ENDIF (COMPILE_OK) + +# TEST_DEF is set by the loaded command cmTestCommand.c +IF (TEST_DEF AND SOME_CACHE_VARIABLE AND TEST_EXEC) + ADD_DEFINITIONS(-DCMAKE_IS_FUN) +ENDIF (TEST_DEF AND SOME_CACHE_VARIABLE AND TEST_EXEC) + diff --git a/Tests/LoadCommand/LoadedCommand.cxx.in b/Tests/LoadCommand/LoadedCommand.cxx.in new file mode 100644 index 000000000..c58bcf153 --- /dev/null +++ b/Tests/LoadCommand/LoadedCommand.cxx.in @@ -0,0 +1,41 @@ +#include "LoadedCommand.h" +#include <stdio.h> + +int testSizeOf(int s1, int s2) +{ + return s1 - s2; +} + +int main () +{ + int ret = 0; +#ifdef HAVE_VSBLABLA + printf("Should not be able to find vsblabla\n"); + ret = 1; +#endif + +#if !defined( HAVE_PRINTF ) + printf("Should be able to find printf\n"); + ret= 1; +#endif + +#if !defined( ADDED_DEFINITION ) + printf("Should have ADDED_DEFINITION defined\n"); + ret= 1; +#endif +#if !defined(CMAKE_IS_FUN) + printf("Loaded Command was not built with CMAKE_IS_FUN: failed.\n"); + ret = 1; +#endif + if(testSizeOf(SIZEOF_CHAR, sizeof(char))) + { + printf("Size of char is broken.\n"); + ret = 1; + } + if(testSizeOf(SIZEOF_SHORT, sizeof(short))) + { + printf("Size of short is broken.\n"); + ret = 1; + } + return ret; +} diff --git a/Tests/LoadCommand/LoadedCommand.h.in b/Tests/LoadCommand/LoadedCommand.h.in new file mode 100644 index 000000000..7516a66e5 --- /dev/null +++ b/Tests/LoadCommand/LoadedCommand.h.in @@ -0,0 +1,7 @@ +/* Check for size of types */ +#cmakedefine SIZEOF_CHAR ${SIZEOF_CHAR} +#cmakedefine SIZEOF_SHORT ${SIZEOF_SHORT} + +/* Check for functions */ +#cmakedefine HAVE_PRINTF +#cmakedefine HAVE_VSBLABLA diff --git a/Tests/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt b/Tests/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt new file mode 100644 index 000000000..953d05c99 --- /dev/null +++ b/Tests/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CMAKE_LOADED_COMMANDS) + +IF (MUDSLIDE_TYPE MATCHES MUCHO) + ADD_DEFINITIONS(-DMUCHO_MUDSLIDE) +ENDIF (MUDSLIDE_TYPE MATCHES MUCHO) + +IF(WATCOM) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") +ENDIF(WATCOM) +INCLUDE_DIRECTORIES(${CMAKE_ROOT}/include ${CMAKE_ROOT}/Source) + +ADD_LIBRARY(cmCMAKE_TEST_COMMAND MODULE cmTestCommand.c) + +IF(WATCOM) + TARGET_LINK_LIBRARIES(cmCMAKE_TEST_COMMAND clbsdll.lib) +ENDIF(WATCOM) diff --git a/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c b/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c new file mode 100644 index 000000000..6b4f48f7b --- /dev/null +++ b/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c @@ -0,0 +1,219 @@ +#include "cmCPluginAPI.h" +#include <string.h> +#include <stdlib.h> +#include <stdio.h> + +typedef struct +{ + char *LibraryName; + int Argc; + char** Argv; +} cmVTKWrapTclData; + +/* do almost everything in the initial pass */ +static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[]) +{ + char* file; + char* str; + char *srcs; + const char* cstr; + char buffer[1024]; + void *source_file; + char *args[2]; + char *ccArgs[4]; + char *ccDep[1]; + char *ccOut[1]; + cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf; + + cmVTKWrapTclData *cdata = + (cmVTKWrapTclData *)malloc(sizeof(cmVTKWrapTclData)); + cdata->LibraryName = "BOO"; + cdata->Argc = argc; + cdata->Argv = argv; + info->CAPI->SetClientData(info,cdata); + + /* Now check and see if the value has been stored in the cache */ + /* already, if so use that value and don't look for the program */ + if(!info->CAPI->IsOn(mf,"TEST_COMMAND_TEST1")) + { + info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO"); + return 1; + } + + info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO"); + cdata->LibraryName = "HOO"; + + info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE", "ON", + "Test cache variable", + CM_CACHE_BOOL); + info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE1", "", + "Test cache variable 1", + CM_CACHE_PATH); + info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE2", "", + "Test cache variable 2", + CM_CACHE_FILEPATH); + info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE3", "", + "Test cache variable 3", + CM_CACHE_STRING); + info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE4", "", + "Test cache variable 4", + CM_CACHE_INTERNAL); + info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE5", "", + "Test cache variable 5", + CM_CACHE_STATIC); + + + file = info->CAPI->ExpandVariablesInString(mf, "${CMAKE_COMMAND}", 0, 0); + + str = info->CAPI->GetFilenameWithoutExtension(file); + info->CAPI->DisplaySatus(mf, str); + info->CAPI->Free(str); + str = info->CAPI->GetFilenamePath(file); + info->CAPI->DisplaySatus(mf, str); + info->CAPI->Free(str); + str = info->CAPI->Capitalized("cmake"); + info->CAPI->DisplaySatus(mf, str); + info->CAPI->Free(str); + + info->CAPI->DisplaySatus(mf, info->CAPI->GetProjectName(mf)); + info->CAPI->DisplaySatus(mf, info->CAPI->GetHomeDirectory(mf)); + info->CAPI->DisplaySatus(mf, info->CAPI->GetHomeOutputDirectory(mf)); + info->CAPI->DisplaySatus(mf, info->CAPI->GetStartDirectory(mf)); + info->CAPI->DisplaySatus(mf, info->CAPI->GetStartOutputDirectory(mf)); + info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentDirectory(mf)); + info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentOutputDirectory(mf)); + sprintf(buffer, "Cache version: %d.%d, CMake version: %d.%d", + info->CAPI->GetCacheMajorVersion(mf), + info->CAPI->GetCacheMinorVersion(mf), + info->CAPI->GetMajorVersion(mf), + info->CAPI->GetMinorVersion(mf)); + info->CAPI->DisplaySatus(mf, buffer); + if ( info->CAPI->CommandExists(mf, "SET") ) + { + info->CAPI->DisplaySatus(mf, "Command SET exists"); + } + if ( info->CAPI->CommandExists(mf, "SET_FOO_BAR") ) + { + info->CAPI->SetError(mf, "Command SET_FOO_BAR should not exists"); + return 0; + } + info->CAPI->AddDefineFlag(mf, "-DADDED_DEFINITION"); + + source_file = info->CAPI->CreateNewSourceFile(mf); + cstr = info->CAPI->SourceFileGetSourceName(source_file); + sprintf(buffer, "Shold be empty (source file name): [%s]", cstr); + info->CAPI->DisplaySatus(mf, buffer); + cstr = info->CAPI->SourceFileGetFullPath(source_file); + sprintf(buffer, "Should be empty (source file full path): [%s]", cstr); + info->CAPI->DisplaySatus(mf, buffer); + info->CAPI->DefineSourceFileProperty(mf,"SOME_PROPERTY","unused old prop", + "This property is no longer used", + 0); + if ( info->CAPI->SourceFileGetPropertyAsBool(source_file, "SOME_PROPERTY") ) + { + info->CAPI->SetError(mf, "Property SOME_PROPERTY should not be defined"); + return 0; + } + info->CAPI->DefineSourceFileProperty(mf,"SOME_PROPERTY2","nice prop", + "This property is for testing.", + 0); + info->CAPI->SourceFileSetProperty(source_file, "SOME_PROPERTY2", "HERE"); + cstr = info->CAPI->SourceFileGetProperty(source_file, "ABSTRACT"); + sprintf(buffer, "Should be 0 (source file abstract property): [%p]", cstr); + info->CAPI->DisplaySatus(mf, buffer); + + info->CAPI->DestroySourceFile(source_file); + + srcs = argv[2]; + info->CAPI->AddExecutable(mf,"LoadedCommand",1, &srcs, 0); + + /* add customs commands to generate the source file */ + ccArgs[0] = "-E"; + ccArgs[1] = "copy"; + ccArgs[2] = argv[0]; + ccArgs[3] = argv[1]; + ccDep[0] = ccArgs[2]; + ccOut[0] = ccArgs[3]; + info->CAPI->AddCustomCommand(mf, "LoadedCommand.cxx.in", + file, + 4, ccArgs, + 1, ccDep, + 1, ccOut, + "LoadedCommand"); + + + ccArgs[2] = argv[1]; + ccArgs[3] = argv[2]; + ccDep[0] = ccArgs[2]; + ccOut[0] = ccArgs[3]; + info->CAPI->AddCustomCommandToOutput(mf, ccOut[0], + file, + 4, ccArgs, + ccDep[0], + 0, 0); + + + ccArgs[1] = "echo"; + ccArgs[2] = "Build has finished"; + info->CAPI->AddCustomCommandToTarget(mf, "LoadedCommand", + file, + 3, ccArgs, + CM_POST_BUILD); + + info->CAPI->Free(file); + + args[0] = "TEST_EXEC"; + args[1] = "TRUE"; + + /* code coverage */ + if (info->CAPI->GetTotalArgumentSize(2,args) != 13) + { + return 0; + } + info->CAPI->ExecuteCommand(mf,"SET",2,args); + + /* make sure we can find the source file */ + if (!info->CAPI->GetSource(mf,argv[1])) + { + info->CAPI->SetError(mf, "Source file could not be found!"); + return 0; + } + + return 1; +} + +static void CCONV FinalPass(void *inf, void *mf) +{ + cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf; + /* get our client data from initial pass */ + cmVTKWrapTclData *cdata = + (cmVTKWrapTclData *)info->CAPI->GetClientData(info); + if (strcmp(info->CAPI->GetDefinition(mf, "TEST_DEF"),"HOO") || + strcmp(cdata->LibraryName,"HOO")) + { + fprintf(stderr,"*** Failed LOADED COMMAND Final Pass\n"); + } +} +static void CCONV Destructor(void *inf) +{ + cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf; + /* get our client data from initial pass */ + cmVTKWrapTclData *cdata = + (cmVTKWrapTclData *)info->CAPI->GetClientData(info); + free(cdata); +} + +#ifdef MUCHO_MUDSLIDE +void CM_PLUGIN_EXPORT CCONV CMAKE_TEST_COMMANDInit(cmLoadedCommandInfo *info) +{ + info->InitialPass = InitialPass; + info->FinalPass = FinalPass; + info->Destructor = Destructor; + info->m_Inherited = 0; + info->Name = "CMAKE_TEST_COMMAND"; +} +#endif + + + + diff --git a/Tests/LoadCommandOneConfig/CMakeLists.txt b/Tests/LoadCommandOneConfig/CMakeLists.txt new file mode 100644 index 000000000..e99105a74 --- /dev/null +++ b/Tests/LoadCommandOneConfig/CMakeLists.txt @@ -0,0 +1,69 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(LoadCommand) + +# set a definition +SET (TEST_COMMAND_TEST1 1) + +INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake) +CHECK_TYPE_SIZE(char SIZEOF_CHAR) +CHECK_TYPE_SIZE(short SIZEOF_SHORT) + +INCLUDE (CheckFunctionExists) +CHECK_FUNCTION_EXISTS(printf HAVE_PRINTF) +CHECK_FUNCTION_EXISTS(vsblabla HAVE_VSBLABLA) + +INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake) +CHECK_INCLUDE_FILE("sys/prctl.h" HAVE_SYS_PRCTL_H) + +INCLUDE (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake) +CHECK_LIBRARY_EXISTS(m ceil "" HAVE_LIBM) + +CONFIGURE_FILE(${LoadCommand_SOURCE_DIR}/LoadedCommand.h.in + ${LoadCommand_BINARY_DIR}/LoadedCommand.h) + +INCLUDE_DIRECTORIES(${LoadCommand_BINARY_DIR}) + +# try to compile the command +# make sure it is not already loaded +IF(COMMAND CMAKE_TEST_COMMAND) +ELSE(COMMAND CMAKE_TEST_COMMAND) + TRY_COMPILE(COMPILE_OK + ${LoadCommand_BINARY_DIR}/CMakeCommands + ${LoadCommand_SOURCE_DIR}/CMakeCommands + CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO + OUTPUT_VARIABLE OUTPUT ) +# do another TRY_COMPILE to get around make +# problem on hp + TRY_COMPILE(COMPILE_OK + ${LoadCommand_BINARY_DIR}/CMakeCommands + ${LoadCommand_SOURCE_DIR}/CMakeCommands + CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO + OUTPUT_VARIABLE OUTPUT ) +ENDIF(COMMAND CMAKE_TEST_COMMAND) + +MESSAGE("Output from try compile: ${OUTPUT}") + +# if the compile was OK, try loading the command +IF (COMPILE_OK) + LOAD_COMMAND(CMAKE_TEST_COMMAND + ${LoadCommand_BINARY_DIR}/CMakeCommands + ${LoadCommand_BINARY_DIR}/CMakeCommands/Debug + ${LoadCommand_BINARY_DIR}/CMakeCommands/Development + ) + # if the command loaded, execute the command + IF (COMMAND CMAKE_TEST_COMMAND) + CMAKE_TEST_COMMAND( + "${LoadCommand_SOURCE_DIR}/LoadedCommand.cxx.in" + "${LoadCommand_BINARY_DIR}/LoadedCommand2.cxx.in" + "${LoadCommand_BINARY_DIR}/LoadedCommand3.cxx" + ) + ENDIF (COMMAND CMAKE_TEST_COMMAND) +ELSE (COMPILE_OK) + MESSAGE("failed to compile CMAKE_LOADED_COMMANDS") +ENDIF (COMPILE_OK) + +# TEST_DEF is set by the loaded command cmTestCommand.c +IF (TEST_DEF AND SOME_CACHE_VARIABLE AND TEST_EXEC) + ADD_DEFINITIONS(-DCMAKE_IS_FUN) +ENDIF (TEST_DEF AND SOME_CACHE_VARIABLE AND TEST_EXEC) + diff --git a/Tests/LoadCommandOneConfig/LoadedCommand.cxx.in b/Tests/LoadCommandOneConfig/LoadedCommand.cxx.in new file mode 100644 index 000000000..c58bcf153 --- /dev/null +++ b/Tests/LoadCommandOneConfig/LoadedCommand.cxx.in @@ -0,0 +1,41 @@ +#include "LoadedCommand.h" +#include <stdio.h> + +int testSizeOf(int s1, int s2) +{ + return s1 - s2; +} + +int main () +{ + int ret = 0; +#ifdef HAVE_VSBLABLA + printf("Should not be able to find vsblabla\n"); + ret = 1; +#endif + +#if !defined( HAVE_PRINTF ) + printf("Should be able to find printf\n"); + ret= 1; +#endif + +#if !defined( ADDED_DEFINITION ) + printf("Should have ADDED_DEFINITION defined\n"); + ret= 1; +#endif +#if !defined(CMAKE_IS_FUN) + printf("Loaded Command was not built with CMAKE_IS_FUN: failed.\n"); + ret = 1; +#endif + if(testSizeOf(SIZEOF_CHAR, sizeof(char))) + { + printf("Size of char is broken.\n"); + ret = 1; + } + if(testSizeOf(SIZEOF_SHORT, sizeof(short))) + { + printf("Size of short is broken.\n"); + ret = 1; + } + return ret; +} diff --git a/Tests/LoadCommandOneConfig/LoadedCommand.h.in b/Tests/LoadCommandOneConfig/LoadedCommand.h.in new file mode 100644 index 000000000..7a0a15d4d --- /dev/null +++ b/Tests/LoadCommandOneConfig/LoadedCommand.h.in @@ -0,0 +1,13 @@ +/* Check for size of types */ +#cmakedefine SIZEOF_CHAR ${SIZEOF_CHAR} +#cmakedefine SIZEOF_SHORT ${SIZEOF_SHORT} + +/* Check for functions */ +#cmakedefine HAVE_PRINTF +#cmakedefine HAVE_VSBLABLA + +/* Check for headers */ +#cmakedefine HAVE_SYS_PRCTL_H + +/* Check for libraries */ +#cmakedefine HAVE_LIBM diff --git a/Tests/MFC/CMakeLists.txt b/Tests/MFC/CMakeLists.txt new file mode 100644 index 000000000..62ff749fe --- /dev/null +++ b/Tests/MFC/CMakeLists.txt @@ -0,0 +1,61 @@ +cmake_minimum_required(VERSION 2.8) +project(mfc_driver) + +include(CTest) +include(ExternalProject) + + +set(CMAKE_MFC_FLAG_VALUE "2") +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.SharedMfcDll.txt + @ONLY + ) + +ExternalProject_Add(mfcShared + URL ${CMAKE_CURRENT_SOURCE_DIR}/mfc1 + PATCH_COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.SharedMfcDll.txt + <SOURCE_DIR>/CMakeLists.txt + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + ) + + +set(CMAKE_MFC_FLAG_VALUE "1") +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.StaticMfcLib.txt + @ONLY + ) + +ExternalProject_Add(mfcStatic + URL ${CMAKE_CURRENT_SOURCE_DIR}/mfc1 + PATCH_COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.StaticMfcLib.txt + <SOURCE_DIR>/CMakeLists.txt + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + ) + + +set(binary_dir "${CMAKE_CURRENT_BINARY_DIR}") +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/ValidateBuild.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/ValidateBuild.cmake + @ONLY + ) +add_test( + NAME validate + COMMAND ${CMAKE_COMMAND} + -P "${CMAKE_CURRENT_BINARY_DIR}/ValidateBuild.cmake" + ) + + +add_test( + NAME environment + COMMAND ${CMAKE_COMMAND} -E environment + ) + + +message(STATUS "===== environment =====") +execute_process(COMMAND ${CMAKE_COMMAND} -E environment) +message(STATUS "===== /environment =====") diff --git a/Tests/MFC/CMakeLists.txt.in b/Tests/MFC/CMakeLists.txt.in new file mode 100644 index 000000000..e6bfabd33 --- /dev/null +++ b/Tests/MFC/CMakeLists.txt.in @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 2.8) +project(mfc1) + +macro(replace_flags var these those) + if("${${var}}" MATCHES "${these}") + string(REGEX REPLACE "${these}" "${those}" ${var} "${${var}}") + #message(STATUS "info: ${var} changed to '${${var}}'") + endif() + message(STATUS "info: ${var}='${${var}}'") +endmacro() + +macro(msvc_link_to_static_crt) + if(MSVC) + set(has_correct_flag 0) + foreach(lang C CXX) + foreach(suffix "" _DEBUG _MINSIZEREL _RELEASE _RELWITHDEBINFO) + replace_flags("CMAKE_${lang}_FLAGS${suffix}" "/MD" "/MT") + if(CMAKE_${lang}_FLAGS${suffix} MATCHES "/MT") + set(has_correct_flag 1) + endif() + endforeach() + endforeach() + if(NOT has_correct_flag) + message(FATAL_ERROR "no CMAKE_*_FLAGS var contains /MT") + endif() + endif() +endmacro() + +set(files + ChildFrm.cpp + ChildFrm.h + MainFrm.cpp + MainFrm.h + mfc1.cpp + mfc1.h + mfc1.rc + mfc1Doc.cpp + mfc1Doc.h + mfc1View.cpp + mfc1View.h + Resource.h + stdafx.cpp + stdafx.h +) + +set(CMAKE_MFC_FLAG "@CMAKE_MFC_FLAG_VALUE@") + +if("${CMAKE_MFC_FLAG}" STREQUAL "1") + msvc_link_to_static_crt() +else() + # VS generators add this automatically based on the CMAKE_MFC_FLAG value, + # but generators matching "Make" require: + add_definitions(-D_AFXDLL) +endif() + +add_executable(mfc1 WIN32 ${files}) +install(TARGETS mfc1 DESTINATION bin) + +if("${CMAKE_MFC_FLAG}" STREQUAL "2") + set(CMAKE_INSTALL_MFC_LIBRARIES ON) + include(InstallRequiredSystemLibraries) +endif() diff --git a/Tests/MFC/ValidateBuild.cmake.in b/Tests/MFC/ValidateBuild.cmake.in new file mode 100644 index 000000000..ed923f5e7 --- /dev/null +++ b/Tests/MFC/ValidateBuild.cmake.in @@ -0,0 +1,68 @@ +# +# This code validates that the install trees of the shared and static builds +# of "mfc1" have the expected contents: +# +set(binary_dir "@binary_dir@") +message("binary_dir='${binary_dir}'") + +# There should be exactly one file in the static install tree "bin" directory +# and it should be named "mfc1.exe" +# +message(STATUS "===== mfcStatic install tree =====") +file(GLOB_RECURSE files "${binary_dir}/mfcStatic-prefix/bin/*.*") +message(STATUS "mfcStatic files='${files}'") +list(LENGTH files len) +if(NOT len EQUAL 1) + message(FATAL_ERROR + "len='${len}' is not '1' (count of static 'bin' files)") +endif() +get_filename_component(name "${files}" NAME) +string(TOLOWER "${name}" name) +if(NOT "${name}" STREQUAL "mfc1.exe") + message(FATAL_ERROR "unexpected mfcStatic file name '${name}'") +endif() + +# There should be at least 3 files in the shared install tree "bin" +# directory: mfc1.exe, the main MFC dll and the C runtime dll. With more +# recent versions of VS, there will also be an MFC language dll and a +# manifest file. +# +message(STATUS "===== mfcShared install tree =====") +file(GLOB_RECURSE files "${binary_dir}/mfcShared-prefix/bin/*.*") +message(STATUS "mfcShared files='${files}'") +list(LENGTH files len) + +set(msvc6 "@MSVC60@") +if("${msvc6}" STREQUAL "1") + set(expected_minimum_file_count 1) +else() + set(expected_minimum_file_count 3) +endif() + +if(len LESS ${expected_minimum_file_count}) + message(FATAL_ERROR + "len='${len}' is less than '${expected_minimum_file_count}' (count of shared 'bin' files)") +endif() +foreach(f ${files}) + message(STATUS "file '${f}'") + get_filename_component(ext "${f}" EXT) + string(TOLOWER "${ext}" ext) + + if("${ext}" MATCHES "\\.exe$") + message(STATUS " exe file") + get_filename_component(name "${f}" NAME) + string(TOLOWER "${name}" name) + if(NOT "${name}" STREQUAL "mfc1.exe") + message(FATAL_ERROR "unexpected mfcShared .exe file name '${name}'") + endif() + elseif("${ext}" MATCHES "\\.dll$") + message(STATUS " dll file") + elseif("${ext}" MATCHES "\\.manifest$") + message(STATUS " manifest file") + else() + message(STATUS " unknown file") + message(FATAL_ERROR "unexpected mfcShared ${ext} file name '${f}'") + endif() +endforeach() + +message(STATUS "All mfc1 build validation tests pass.") diff --git a/Tests/MFC/mfc1/.gitattributes b/Tests/MFC/mfc1/.gitattributes new file mode 100644 index 000000000..59be5dcfb --- /dev/null +++ b/Tests/MFC/mfc1/.gitattributes @@ -0,0 +1,6 @@ +.gitattributes export-ignore + +*.sln -crlf +*.vcproj -crlf + +* -whitespace diff --git a/Tests/MFC/mfc1/ChildFrm.cpp b/Tests/MFC/mfc1/ChildFrm.cpp new file mode 100644 index 000000000..b04c4f231 --- /dev/null +++ b/Tests/MFC/mfc1/ChildFrm.cpp @@ -0,0 +1,59 @@ +// ChildFrm.cpp : implementation of the CChildFrame class +// +#include "stdafx.h" +#include "mfc1.h" + +#include "ChildFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CChildFrame + +IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd) + +BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd) +END_MESSAGE_MAP() + + +// CChildFrame construction/destruction + +CChildFrame::CChildFrame() +{ + // TODO: add member initialization code here +} + +CChildFrame::~CChildFrame() +{ +} + + +BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs + if( !CMDIChildWnd::PreCreateWindow(cs) ) + return FALSE; + + return TRUE; +} + + +// CChildFrame diagnostics + +#ifdef _DEBUG +void CChildFrame::AssertValid() const +{ + CMDIChildWnd::AssertValid(); +} + +void CChildFrame::Dump(CDumpContext& dc) const +{ + CMDIChildWnd::Dump(dc); +} + +#endif //_DEBUG + + +// CChildFrame message handlers diff --git a/Tests/MFC/mfc1/ChildFrm.h b/Tests/MFC/mfc1/ChildFrm.h new file mode 100644 index 000000000..34b80f126 --- /dev/null +++ b/Tests/MFC/mfc1/ChildFrm.h @@ -0,0 +1,34 @@ +// ChildFrm.h : interface of the CChildFrame class +// + + +#pragma once + + +class CChildFrame : public CMDIChildWnd +{ + DECLARE_DYNCREATE(CChildFrame) +public: + CChildFrame(); + +// Attributes +public: + +// Operations +public: + +// Overrides + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + +// Implementation +public: + virtual ~CChildFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +// Generated message map functions +protected: + DECLARE_MESSAGE_MAP() +}; diff --git a/Tests/MFC/mfc1/MainFrm.cpp b/Tests/MFC/mfc1/MainFrm.cpp new file mode 100644 index 000000000..44554bf4c --- /dev/null +++ b/Tests/MFC/mfc1/MainFrm.cpp @@ -0,0 +1,98 @@ +// MainFrm.cpp : implementation of the CMainFrame class +// + +#include "stdafx.h" +#include "mfc1.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CMainFrame + +IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) + ON_WM_CREATE() +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // status line indicator + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + + +// CMainFrame construction/destruction + +CMainFrame::CMainFrame() +{ + // TODO: add member initialization code here +} + +CMainFrame::~CMainFrame() +{ +} + + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP + | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) + { + TRACE0("Failed to create toolbar\n"); + return -1; // fail to create + } + + if (!m_wndStatusBar.Create(this) || + !m_wndStatusBar.SetIndicators(indicators, + sizeof(indicators)/sizeof(UINT))) + { + TRACE0("Failed to create status bar\n"); + return -1; // fail to create + } + // TODO: Delete these three lines if you don't want the toolbar to be dockable + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(&m_wndToolBar); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CMDIFrameWnd::PreCreateWindow(cs) ) + return FALSE; + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return TRUE; +} + + +// CMainFrame diagnostics + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CMDIFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CMDIFrameWnd::Dump(dc); +} + +#endif //_DEBUG + + +// CMainFrame message handlers diff --git a/Tests/MFC/mfc1/MainFrm.h b/Tests/MFC/mfc1/MainFrm.h new file mode 100644 index 000000000..1039ac5ee --- /dev/null +++ b/Tests/MFC/mfc1/MainFrm.h @@ -0,0 +1,38 @@ +// MainFrm.h : interface of the CMainFrame class +// + + +#pragma once +class CMainFrame : public CMDIFrameWnd +{ + DECLARE_DYNAMIC(CMainFrame) +public: + CMainFrame(); + +// Attributes +public: + +// Operations +public: + +// Overrides +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + +// Implementation +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // control bar embedded members + CStatusBar m_wndStatusBar; + CToolBar m_wndToolBar; + +// Generated message map functions +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + DECLARE_MESSAGE_MAP() +}; diff --git a/Tests/MFC/mfc1/ReadMe.txt b/Tests/MFC/mfc1/ReadMe.txt new file mode 100644 index 000000000..d84608e71 --- /dev/null +++ b/Tests/MFC/mfc1/ReadMe.txt @@ -0,0 +1,135 @@ +================================================================================ + MICROSOFT FOUNDATION CLASS LIBRARY : mfc1 Project Overview +=============================================================================== + +The application wizard has created this mfc1 application for +you. This application not only demonstrates the basics of using the Microsoft +Foundation Classes but is also a starting point for writing your application. + +This file contains a summary of what you will find in each of the files that +make up your mfc1 application. + +mfc1.vcproj + This is the main project file for VC++ projects generated using an application wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + application wizard. + +mfc1.h + This is the main header file for the application. It includes other + project specific headers (including Resource.h) and declares the + Cmfc1App application class. + +mfc1.cpp + This is the main application source file that contains the application + class Cmfc1App. + +mfc1.rc + This is a listing of all of the Microsoft Windows resources that the + program uses. It includes the icons, bitmaps, and cursors that are stored + in the RES subdirectory. This file can be directly edited in Microsoft + Visual C++. Your project resources are in 1033. + +res\mfc1.ico + This is an icon file, which is used as the application's icon. This + icon is included by the main resource file mfc1.rc. + +res\mfc1.rc2 + This file contains resources that are not edited by Microsoft + Visual C++. You should place all resources not editable by + the resource editor in this file. +mfc1.reg + This is an example .reg file that shows you the kind of registration + settings the framework will set for you. You can use this as a .reg + file to go along with your application or just delete it and rely + on the default RegisterShellFileTypes registration. +///////////////////////////////////////////////////////////////////////////// + +For the main frame window: + The project includes a standard MFC interface. +MainFrm.h, MainFrm.cpp + These files contain the frame class CMainFrame, which is derived from + CMDIFrameWnd and controls all MDI frame features. +res\Toolbar.bmp + This bitmap file is used to create tiled images for the toolbar. + The initial toolbar and status bar are constructed in the CMainFrame + class. Edit this toolbar bitmap using the resource editor, and + update the IDR_MAINFRAME TOOLBAR array in mfc1.rc to add + toolbar buttons. +///////////////////////////////////////////////////////////////////////////// + +For the child frame window: + +ChildFrm.h, ChildFrm.cpp + These files define and implement the CChildFrame class, which + supports the child windows in an MDI application. + +///////////////////////////////////////////////////////////////////////////// + +The application wizard creates one document type and one view: + +mfc1Doc.h, mfc1Doc.cpp - the document + These files contain your Cmfc1Doc class. Edit these files to + add your special document data and to implement file saving and loading + (via Cmfc1Doc::Serialize). + The Document will have the following strings: + File extension: mf1 + File type ID: mfc1.Document + Main frame caption: mfc1 + Doc type name: mfc1 + Filter name: mfc1 Files (*.mf1) + File new short name: mfc1 + File type long name: mfc1.Document +mfc1View.h, mfc1View.cpp - the view of the document + These files contain your Cmfc1View class. + Cmfc1View objects are used to view Cmfc1Doc objects. +res\mfc1Doc.ico + This is an icon file, which is used as the icon for MDI child windows + for the Cmfc1Doc class. This icon is included by the main + resource file mfc1.rc. +///////////////////////////////////////////////////////////////////////////// + +Other Features: + +ActiveX Controls + The application includes support to use ActiveX controls. + +Printing and Print Preview support + The application wizard has generated code to handle the print, print setup, and print preview + commands by calling member functions in the CView class from the MFC library. +///////////////////////////////////////////////////////////////////////////// + +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named mfc1.pch and a precompiled types file named StdAfx.obj. + +Resource.h + This is the standard header file, which defines new resource IDs. + Microsoft Visual C++ reads and updates this file. + +mfc1.manifest + Application manifest files are used by Windows XP to describe an applications + dependency on specific versions of Side-by-Side assemblies. The loader uses this + information to load the appropriate assembly from the assembly cache or private + from the application. The Application manifest maybe included for redistribution + as an external .manifest file that is installed in the same folder as the application + executable or it may be included in the executable in the form of a resource. +///////////////////////////////////////////////////////////////////////////// + +Other notes: + +The application wizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + +If your application uses MFC in a shared DLL, and your application is in a +language other than the operating system's current language, you will need +to copy the corresponding localized resources MFC70XXX.DLL from the Microsoft +Visual C++ CD-ROM under the Win\System directory to your computer's system or +system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the +language abbreviation. For example, MFC70DEU.DLL contains resources +translated to German.) If you don't do this, some of the UI elements of +your application will remain in the language of the operating system. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Tests/MFC/mfc1/Resource.h b/Tests/MFC/mfc1/Resource.h new file mode 100644 index 000000000..0a9c13f57 --- /dev/null +++ b/Tests/MFC/mfc1/Resource.h @@ -0,0 +1,20 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by mfc1.rc +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_MAINFRAME 128 +#define IDR_mfc1TYPE 129 +#define IDR_MANIFEST CREATEPROCESS_MANIFEST_RESOURCE_ID + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 32771 +#endif +#endif diff --git a/Tests/MFC/mfc1/mfc1.cpp b/Tests/MFC/mfc1/mfc1.cpp new file mode 100644 index 000000000..9530cd2b9 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.cpp @@ -0,0 +1,144 @@ +// mfc1.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "mfc1.h" +#include "MainFrm.h" + +#include "ChildFrm.h" +#include "mfc1Doc.h" +#include "mfc1View.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cmfc1App + +BEGIN_MESSAGE_MAP(Cmfc1App, CWinApp) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + // Standard file based document commands + ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) + // Standard print setup command + ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) +END_MESSAGE_MAP() + + +// Cmfc1App construction + +Cmfc1App::Cmfc1App() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + + +// The one and only Cmfc1App object + +Cmfc1App theApp; + +// Cmfc1App initialization + +BOOL Cmfc1App::InitInstance() +{ + // InitCommonControls() is required on Windows XP if an application + // manifest specifies use of ComCtl32.dll version 6 or later to enable + // visual styles. Otherwise, any window creation will fail. + InitCommonControls(); + + CWinApp::InitInstance(); + + // Initialize OLE libraries + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + AfxEnableControlContainer(); + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need + // Change the registry key under which our settings are stored + // TODO: You should modify this string to be something appropriate + // such as the name of your company or organization + SetRegistryKey(_T("Local AppWizard-Generated Applications")); + LoadStdProfileSettings(4); // Load standard INI file options (including MRU) + // Register the application's document templates. Document templates + // serve as the connection between documents, frame windows and views + CMultiDocTemplate* pDocTemplate; + pDocTemplate = new CMultiDocTemplate(IDR_mfc1TYPE, + RUNTIME_CLASS(Cmfc1Doc), + RUNTIME_CLASS(CChildFrame), // custom MDI child frame + RUNTIME_CLASS(Cmfc1View)); + if (!pDocTemplate) + return FALSE; + AddDocTemplate(pDocTemplate); + // create main MDI Frame window + CMainFrame* pMainFrame = new CMainFrame; + if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) + return FALSE; + m_pMainWnd = pMainFrame; + // call DragAcceptFiles only if there's a suffix + // In an MDI app, this should occur immediately after setting m_pMainWnd + // Enable drag/drop open + m_pMainWnd->DragAcceptFiles(); + // Enable DDE Execute open + EnableShellOpen(); + RegisterShellFileTypes(TRUE); + // Parse command line for standard shell commands, DDE, file open + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + // Dispatch commands specified on the command line. Will return FALSE if + // app was launched with /RegServer, /Register, /Unregserver or /Unregister. + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + // The main window has been initialized, so show and update it + pMainFrame->ShowWindow(m_nCmdShow); + pMainFrame->UpdateWindow(); + return TRUE; +} + + + +// CAboutDlg dialog used for App About + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialog Data + enum { IDD = IDD_ABOUTBOX }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + +// Implementation +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) +END_MESSAGE_MAP() + +// App command to run the dialog +void Cmfc1App::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + + +// Cmfc1App message handlers diff --git a/Tests/MFC/mfc1/mfc1.h b/Tests/MFC/mfc1/mfc1.h new file mode 100644 index 000000000..c273601f8 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.h @@ -0,0 +1,31 @@ +// mfc1.h : main header file for the mfc1 application +// +#pragma once + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + + +// Cmfc1App: +// See mfc1.cpp for the implementation of this class +// + +class Cmfc1App : public CWinApp +{ +public: + Cmfc1App(); + + +// Overrides +public: + virtual BOOL InitInstance(); + +// Implementation + afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() +}; + +extern Cmfc1App theApp; diff --git a/Tests/MFC/mfc1/mfc1.rc b/Tests/MFC/mfc1/mfc1.rc new file mode 100644 index 000000000..346c5fb77 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.rc @@ -0,0 +1,393 @@ +//Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// + +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +#ifdef APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#include ""res\\mfc1.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#include ""afxprint.rc"" // printing/print preview resources\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(1252) +IDR_MAINFRAME ICON "res\\mfc1.ico" +IDR_mfc1TYPE ICON "res\\mfc1Doc.ico" +#endif +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_MAINFRAME TOOLBAR 16, 15 +BEGIN + BUTTON ID_FILE_NEW + BUTTON ID_FILE_OPEN + BUTTON ID_FILE_SAVE + SEPARATOR + BUTTON ID_EDIT_CUT + BUTTON ID_EDIT_COPY + BUTTON ID_EDIT_PASTE + SEPARATOR + BUTTON ID_FILE_PRINT + BUTTON ID_APP_ABOUT +END + + + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(1252) +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINFRAME MENU +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New\tCtrl+N", ID_FILE_NEW + MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN + MENUITEM SEPARATOR + MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP + MENUITEM SEPARATOR + MENUITEM "Recent File", ID_FILE_MRU_FILE1,GRAYED + MENUITEM SEPARATOR + MENUITEM "&Close", ID_FILE_CLOSE + MENUITEM "E&xit", ID_APP_EXIT + END + POPUP "&View" + BEGIN + MENUITEM "&Toolbar", ID_VIEW_TOOLBAR + MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR + END + POPUP "&Help" + BEGIN + MENUITEM "&About mfc1...", ID_APP_ABOUT + END +END +IDR_mfc1TYPE MENU +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New\tCtrl+N", ID_FILE_NEW + MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN + MENUITEM "&Close", ID_FILE_CLOSE + MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE + MENUITEM "Save &As...", ID_FILE_SAVE_AS + MENUITEM SEPARATOR + MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT + MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW + MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP + MENUITEM SEPARATOR + MENUITEM "Recent File", ID_FILE_MRU_FILE1,GRAYED + MENUITEM SEPARATOR + MENUITEM "E&xit", ID_APP_EXIT + END + POPUP "&Edit" + BEGIN + MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO + MENUITEM SEPARATOR + MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT + MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY + MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE + END + POPUP "&View" + BEGIN + MENUITEM "&Toolbar", ID_VIEW_TOOLBAR + MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR + END + POPUP "&Window" + BEGIN + MENUITEM "&New Window", ID_WINDOW_NEW + MENUITEM "&Cascade", ID_WINDOW_CASCADE + MENUITEM "&Tile", ID_WINDOW_TILE_HORZ + MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE + END + POPUP "&Help" + BEGIN + MENUITEM "&About mfc1...", ID_APP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_MAINFRAME ACCELERATORS +BEGIN + "N", ID_FILE_NEW, VIRTKEY,CONTROL + "O", ID_FILE_OPEN, VIRTKEY,CONTROL + "S", ID_FILE_SAVE, VIRTKEY,CONTROL + "P", ID_FILE_PRINT, VIRTKEY,CONTROL + "Z", ID_EDIT_UNDO, VIRTKEY,CONTROL + "X", ID_EDIT_CUT, VIRTKEY,CONTROL + "C", ID_EDIT_COPY, VIRTKEY,CONTROL + "V", ID_EDIT_PASTE, VIRTKEY,CONTROL + VK_BACK, ID_EDIT_UNDO, VIRTKEY,ALT + VK_DELETE, ID_EDIT_CUT, VIRTKEY,SHIFT + VK_INSERT, ID_EDIT_COPY, VIRTKEY,CONTROL + VK_INSERT, ID_EDIT_PASTE, VIRTKEY,SHIFT + VK_F6, ID_NEXT_PANE, VIRTKEY + VK_F6, ID_PREV_PANE, VIRTKEY,SHIFT +END + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +#if _MSC_VER < 1300 +#define DS_SHELLFONT_FLAG 0 +#else +#define DS_SHELLFONT_FLAG DS_SHELLFONT +#endif + +IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55 +CAPTION "About mfc1" +STYLE DS_MODALFRAME | DS_SHELLFONT_FLAG | WS_POPUP | WS_CAPTION | WS_SYSMENU +FONT 8, "MS Shell Dlg" +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT "mfc1 Version 1.0",IDC_STATIC,40,10,119,8, + SS_NOPREFIX + LTEXT "Copyright (C) 2011",IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,178,7,50,16,WS_GROUP +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "TODO: <Company name>" + VALUE "FileDescription", "TODO: <File description>" + VALUE "FileVersion", "1.0.0.1" + VALUE "InternalName", "mfc1.exe" + VALUE "LegalCopyright", "TODO: (c) <Company name>. All rights reserved." + VALUE "OriginalFilename","mfc1.exe" + VALUE "ProductName", "TODO: <Product name>" + VALUE "ProductVersion", "1.0.0.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 228 + TOPMARGIN, 7 + BOTTOMMARGIN, 48 + END +END +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN +// Non-mac-targeting apps remove the two extra substrings + IDR_MAINFRAME "mfc1" + // has a file suffix - shell file type too + IDR_mfc1TYPE "\nmfc1\nmfc1\nmfc1 Files (*.mf1)\n.mf1\nmfc1.Document\nmfc1.Document" +END +STRINGTABLE +BEGIN + AFX_IDS_APP_TITLE "mfc1" + AFX_IDS_IDLEMESSAGE "Ready" +END +STRINGTABLE +BEGIN + ID_INDICATOR_EXT "EXT" + ID_INDICATOR_CAPS "CAP" + ID_INDICATOR_NUM "NUM" + ID_INDICATOR_SCRL "SCRL" + ID_INDICATOR_OVR "OVR" + ID_INDICATOR_REC "REC" +END +STRINGTABLE +BEGIN + ID_FILE_NEW "Create a new document\nNew" + ID_FILE_OPEN "Open an existing document\nOpen" + ID_FILE_CLOSE "Close the active document\nClose" + ID_FILE_SAVE "Save the active document\nSave" + ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" + ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" + ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" + ID_FILE_PRINT "Print the active document\nPrint" + ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" + ID_APP_ABOUT "Display program information, version number and copyright\nAbout" + ID_APP_EXIT "Quit the application; prompts to save documents\nExit" + ID_FILE_MRU_FILE1 "Open this document" + ID_FILE_MRU_FILE2 "Open this document" + ID_FILE_MRU_FILE3 "Open this document" + ID_FILE_MRU_FILE4 "Open this document" + ID_FILE_MRU_FILE5 "Open this document" + ID_FILE_MRU_FILE6 "Open this document" + ID_FILE_MRU_FILE7 "Open this document" + ID_FILE_MRU_FILE8 "Open this document" + ID_FILE_MRU_FILE9 "Open this document" + ID_FILE_MRU_FILE10 "Open this document" + ID_FILE_MRU_FILE11 "Open this document" + ID_FILE_MRU_FILE12 "Open this document" + ID_FILE_MRU_FILE13 "Open this document" + ID_FILE_MRU_FILE14 "Open this document" + ID_FILE_MRU_FILE15 "Open this document" + ID_FILE_MRU_FILE16 "Open this document" + ID_NEXT_PANE "Switch to the next window pane\nNext Pane" + ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" + ID_WINDOW_NEW "Open another window for the active document\nNew Window" + ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" + ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows" + ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows" + ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows" + ID_WINDOW_SPLIT "Split the active window into panes\nSplit" + ID_EDIT_CLEAR "Erase the selection\nErase" + ID_EDIT_CLEAR_ALL "Erase everything\nErase All" + ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" + ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" + ID_EDIT_FIND "Find the specified text\nFind" + ID_EDIT_PASTE "Insert Clipboard contents\nPaste" + ID_EDIT_REPEAT "Repeat the last action\nRepeat" + ID_EDIT_REPLACE "Replace specific text with different text\nReplace" + ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" + ID_EDIT_UNDO "Undo the last action\nUndo" + ID_EDIT_REDO "Redo the previously undone action\nRedo" + ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" + ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" +END + +STRINGTABLE +BEGIN + AFX_IDS_SCSIZE "Change the window size" + AFX_IDS_SCMOVE "Change the window position" + AFX_IDS_SCMINIMIZE "Reduce the window to an icon" + AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" + AFX_IDS_SCNEXTWINDOW "Switch to the next document window" + AFX_IDS_SCPREVWINDOW "Switch to the previous document window" + AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" + AFX_IDS_SCRESTORE "Restore the window to normal size" + AFX_IDS_SCTASKLIST "Activate Task List" + AFX_IDS_MDICHILD "Activate this window" + AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" +END + +#endif + +#ifdef _UNICODE +IDR_MANIFEST RT_MANIFEST "res\\mfc1.manifest" +#endif + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(1252) +#include "res\\mfc1.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#include "afxprint.rc" // printing/print preview resources +#endif +#endif // not APSTUDIO_INVOKED diff --git a/Tests/MFC/mfc1/mfc1.reg b/Tests/MFC/mfc1/mfc1.reg new file mode 100644 index 000000000..9f3a86ffb --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.reg @@ -0,0 +1,13 @@ +REGEDIT +; This .REG file may be used by your SETUP program. +; If a SETUP program is not available, the entries below will be +; registered in your InitInstance automatically with a call to +; CWinApp::RegisterShellFileTypes and COleObjectFactory::UpdateRegistryAll. + +HKEY_CLASSES_ROOT\.mf1 = mfc1.Document +HKEY_CLASSES_ROOT\mfc1.Document\shell\open\command = mfc1.EXE %1 +HKEY_CLASSES_ROOT\mfc1.Document\shell\open\ddeexec = [open("%1")] +HKEY_CLASSES_ROOT\mfc1.Document\shell\open\ddeexec\application = mfc1 + ; note: the application is optional + ; (it defaults to the app name in "command") +HKEY_CLASSES_ROOT\mfc1.Document = mfc1.Document diff --git a/Tests/MFC/mfc1/mfc1.sln b/Tests/MFC/mfc1/mfc1.sln new file mode 100644 index 000000000..78bbe56f2 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mfc1", "mfc1.vcproj", "{06C08100-1145-4104-AEC3-6BC8C608B819}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {06C08100-1145-4104-AEC3-6BC8C608B819}.Debug.ActiveCfg = Debug|Win32
+ {06C08100-1145-4104-AEC3-6BC8C608B819}.Debug.Build.0 = Debug|Win32
+ {06C08100-1145-4104-AEC3-6BC8C608B819}.Release.ActiveCfg = Release|Win32
+ {06C08100-1145-4104-AEC3-6BC8C608B819}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Tests/MFC/mfc1/mfc1.vcproj b/Tests/MFC/mfc1/mfc1.vcproj new file mode 100644 index 000000000..6df86e564 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.vcproj @@ -0,0 +1,216 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="mfc1"
+ ProjectGUID="{06C08100-1145-4104-AEC3-6BC8C608B819}"
+ Keyword="MFCProj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ UseOfMFC="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ TreatWChar_tAsBuiltInType="TRUE"
+ UsePrecompiledHeader="3"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ SubSystem="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="FALSE"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"
+ AdditionalIncludeDirectories="$(IntDir)"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ UseOfMFC="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG"
+ MinimalRebuild="FALSE"
+ RuntimeLibrary="2"
+ TreatWChar_tAsBuiltInType="TRUE"
+ UsePrecompiledHeader="3"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="FALSE"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ AdditionalIncludeDirectories="$(IntDir)"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath=".\ChildFrm.cpp">
+ </File>
+ <File
+ RelativePath=".\MainFrm.cpp">
+ </File>
+ <File
+ RelativePath=".\mfc1.cpp">
+ </File>
+ <File
+ RelativePath=".\mfc1Doc.cpp">
+ </File>
+ <File
+ RelativePath=".\mfc1View.cpp">
+ </File>
+ <File
+ RelativePath=".\stdafx.cpp">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath=".\ChildFrm.h">
+ </File>
+ <File
+ RelativePath=".\MainFrm.h">
+ </File>
+ <File
+ RelativePath=".\mfc1.h">
+ </File>
+ <File
+ RelativePath=".\mfc1Doc.h">
+ </File>
+ <File
+ RelativePath=".\mfc1View.h">
+ </File>
+ <File
+ RelativePath=".\Resource.h">
+ </File>
+ <File
+ RelativePath=".\stdafx.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ <File
+ RelativePath=".\res\mfc1.ico">
+ </File>
+ <File
+ RelativePath=".\mfc1.rc">
+ </File>
+ <File
+ RelativePath=".\res\mfc1.rc2">
+ </File>
+ <File
+ RelativePath=".\res\mfc1Doc.ico">
+ </File>
+ <File
+ RelativePath=".\res\Toolbar.bmp">
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\res\mfc1.manifest">
+ </File>
+ <File
+ RelativePath=".\mfc1.reg">
+ </File>
+ <File
+ RelativePath=".\ReadMe.txt">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Tests/MFC/mfc1/mfc1Doc.cpp b/Tests/MFC/mfc1/mfc1Doc.cpp new file mode 100644 index 000000000..8767052ed --- /dev/null +++ b/Tests/MFC/mfc1/mfc1Doc.cpp @@ -0,0 +1,78 @@ +// mfc1Doc.cpp : implementation of the Cmfc1Doc class +// + +#include "stdafx.h" +#include "mfc1.h" + +#include "mfc1Doc.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cmfc1Doc + +IMPLEMENT_DYNCREATE(Cmfc1Doc, CDocument) + +BEGIN_MESSAGE_MAP(Cmfc1Doc, CDocument) +END_MESSAGE_MAP() + + +// Cmfc1Doc construction/destruction + +Cmfc1Doc::Cmfc1Doc() +{ + // TODO: add one-time construction code here + +} + +Cmfc1Doc::~Cmfc1Doc() +{ +} + +BOOL Cmfc1Doc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: add reinitialization code here + // (SDI documents will reuse this document) + + return TRUE; +} + + + + +// Cmfc1Doc serialization + +void Cmfc1Doc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: add storing code here + } + else + { + // TODO: add loading code here + } +} + + +// Cmfc1Doc diagnostics + +#ifdef _DEBUG +void Cmfc1Doc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void Cmfc1Doc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + + +// Cmfc1Doc commands diff --git a/Tests/MFC/mfc1/mfc1Doc.h b/Tests/MFC/mfc1/mfc1Doc.h new file mode 100644 index 000000000..92d8e3541 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1Doc.h @@ -0,0 +1,37 @@ +// mfc1Doc.h : interface of the Cmfc1Doc class +// + + +#pragma once + +class Cmfc1Doc : public CDocument +{ +protected: // create from serialization only + Cmfc1Doc(); + DECLARE_DYNCREATE(Cmfc1Doc) + +// Attributes +public: + +// Operations +public: + +// Overrides + public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); + +// Implementation +public: + virtual ~Cmfc1Doc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generated message map functions +protected: + DECLARE_MESSAGE_MAP() +}; diff --git a/Tests/MFC/mfc1/mfc1View.cpp b/Tests/MFC/mfc1/mfc1View.cpp new file mode 100644 index 000000000..06c765230 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1View.cpp @@ -0,0 +1,99 @@ +// mfc1View.cpp : implementation of the Cmfc1View class +// + +#include "stdafx.h" +#include "mfc1.h" + +#include "mfc1Doc.h" +#include "mfc1View.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cmfc1View + +IMPLEMENT_DYNCREATE(Cmfc1View, CView) + +BEGIN_MESSAGE_MAP(Cmfc1View, CView) + // Standard printing commands + ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) +END_MESSAGE_MAP() + +// Cmfc1View construction/destruction + +Cmfc1View::Cmfc1View() +{ + // TODO: add construction code here + +} + +Cmfc1View::~Cmfc1View() +{ +} + +BOOL Cmfc1View::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return CView::PreCreateWindow(cs); +} + +// Cmfc1View drawing + +void Cmfc1View::OnDraw(CDC* /*pDC*/) +{ + Cmfc1Doc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + if (!pDoc) + return; + + // TODO: add draw code for native data here +} + + +// Cmfc1View printing + +BOOL Cmfc1View::OnPreparePrinting(CPrintInfo* pInfo) +{ + // default preparation + return DoPreparePrinting(pInfo); +} + +void Cmfc1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: add extra initialization before printing +} + +void Cmfc1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: add cleanup after printing +} + + +// Cmfc1View diagnostics + +#ifdef _DEBUG +void Cmfc1View::AssertValid() const +{ + CView::AssertValid(); +} + +void Cmfc1View::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +Cmfc1Doc* Cmfc1View::GetDocument() const // non-debug version is inline +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(Cmfc1Doc))); + return (Cmfc1Doc*)m_pDocument; +} +#endif //_DEBUG + + +// Cmfc1View message handlers diff --git a/Tests/MFC/mfc1/mfc1View.h b/Tests/MFC/mfc1/mfc1View.h new file mode 100644 index 000000000..42446536b --- /dev/null +++ b/Tests/MFC/mfc1/mfc1View.h @@ -0,0 +1,48 @@ +// mfc1View.h : interface of the Cmfc1View class +// + + +#pragma once + + +class Cmfc1View : public CView +{ +protected: // create from serialization only + Cmfc1View(); + DECLARE_DYNCREATE(Cmfc1View) + +// Attributes +public: + Cmfc1Doc* GetDocument() const; + +// Operations +public: + +// Overrides + public: + virtual void OnDraw(CDC* pDC); // overridden to draw this view +virtual BOOL PreCreateWindow(CREATESTRUCT& cs); +protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + +// Implementation +public: + virtual ~Cmfc1View(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generated message map functions +protected: + DECLARE_MESSAGE_MAP() +}; + +#ifndef _DEBUG // debug version in mfc1View.cpp +inline Cmfc1Doc* Cmfc1View::GetDocument() const + { return reinterpret_cast<Cmfc1Doc*>(m_pDocument); } +#endif diff --git a/Tests/MFC/mfc1/res/Toolbar.bmp b/Tests/MFC/mfc1/res/Toolbar.bmp Binary files differnew file mode 100644 index 000000000..d501723c1 --- /dev/null +++ b/Tests/MFC/mfc1/res/Toolbar.bmp diff --git a/Tests/MFC/mfc1/res/mfc1.ico b/Tests/MFC/mfc1/res/mfc1.ico Binary files differnew file mode 100644 index 000000000..8a84ca3d3 --- /dev/null +++ b/Tests/MFC/mfc1/res/mfc1.ico diff --git a/Tests/MFC/mfc1/res/mfc1.manifest b/Tests/MFC/mfc1/res/mfc1.manifest new file mode 100644 index 000000000..b15d2f2f2 --- /dev/null +++ b/Tests/MFC/mfc1/res/mfc1.manifest @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> +<assemblyIdentity + version="1.0.0.0" + processorArchitecture="X86" + name="Microsoft.Windows.mfc1" + type="win32" +/> +<description>Your app description here</description> +<dependency> + <dependentAssembly> + <assemblyIdentity + type="win32" + name="Microsoft.Windows.Common-Controls" + version="6.0.0.0" + processorArchitecture="X86" + publicKeyToken="6595b64144ccf1df" + language="*" + /> + </dependentAssembly> +</dependency> +</assembly> diff --git a/Tests/MFC/mfc1/res/mfc1.rc2 b/Tests/MFC/mfc1/res/mfc1.rc2 new file mode 100644 index 000000000..62a3ab0d6 --- /dev/null +++ b/Tests/MFC/mfc1/res/mfc1.rc2 @@ -0,0 +1,13 @@ +// +// mfc1.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/Tests/MFC/mfc1/res/mfc1Doc.ico b/Tests/MFC/mfc1/res/mfc1Doc.ico Binary files differnew file mode 100644 index 000000000..2a1f1ae6e --- /dev/null +++ b/Tests/MFC/mfc1/res/mfc1Doc.ico diff --git a/Tests/MFC/mfc1/stdafx.cpp b/Tests/MFC/mfc1/stdafx.cpp new file mode 100644 index 000000000..67fd1b539 --- /dev/null +++ b/Tests/MFC/mfc1/stdafx.cpp @@ -0,0 +1,5 @@ +// stdafx.cpp : source file that includes just the standard includes +// mfc1.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" diff --git a/Tests/MFC/mfc1/stdafx.h b/Tests/MFC/mfc1/stdafx.h new file mode 100644 index 000000000..35a678dcd --- /dev/null +++ b/Tests/MFC/mfc1/stdafx.h @@ -0,0 +1,56 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently + +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#endif + +// See http://msdn.microsoft.com/en-us/library/6sehtctf.aspx for more info +// on WINVER and _WIN32_WINNT + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. +#if _MSC_VER < 1600 +#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. +#else +#define WINVER 0x0501 // Target Windows XP and later with VS 10 and later +#endif +#endif + +#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. +#if _MSC_VER < 1600 +#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. +#else +#define _WIN32_WINNT 0x0501 // Target Windows XP and later with VS 10 and later +#endif +#endif + +#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. +#if _MSC_VER < 1600 +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif +#endif + +#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. +#if _MSC_VER < 1600 +#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. +#endif +#endif + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit + +// turns off MFC's hiding of some common and often safely ignored warning messages +#define _AFX_ALL_WARNINGS + +#include <afxwin.h> // MFC core and standard components +#include <afxext.h> // MFC extensions +#include <afxdisp.h> // MFC Automation classes + +#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include <afxcmn.h> // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT diff --git a/Tests/MFC/try_compile/CMakeLists.txt b/Tests/MFC/try_compile/CMakeLists.txt new file mode 100644 index 000000000..8e5d746f6 --- /dev/null +++ b/Tests/MFC/try_compile/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8) +project(try_compile_mfc) + +set(files + stdafx.cpp + stdafx.h +) + +set(CMAKE_MFC_FLAG "2") + +# VS generators add this automatically based on the CMAKE_MFC_FLAG value, +# but generators matching "Make" require: +add_definitions(-D_AFXDLL) + +add_executable(simplest_possible_mfc_exe WIN32 ${files}) diff --git a/Tests/MacroTest/CMakeLists.txt b/Tests/MacroTest/CMakeLists.txt new file mode 100644 index 000000000..ef673fd85 --- /dev/null +++ b/Tests/MacroTest/CMakeLists.txt @@ -0,0 +1,91 @@ +# a simple C only test case +cmake_minimum_required (VERSION 2.6) +PROJECT (MacroTest) + +MACRO(FAILED testname) + MESSAGE(SEND_ERROR "${testname} failed ${ARGN}") +ENDMACRO(FAILED) + +MACRO(PASS testname) + MESSAGE("${testname} passed ${ARGN}") +ENDMACRO(PASS) + +# test ARGC +MACRO(weird_name) + IF("${ARGC}" EQUAL "3") + PASS("ARGC") + ELSE("${ARGC}" EQUAL "3") + FAILED("ARGC" "Got: ${ARGC}") + ENDIF("${ARGC}" EQUAL "3") +ENDMACRO(weird_name) +WeIrD_nAmE(a1 a2 a3) + +# test ARGN +MACRO(test_argn_macro argument) + IF("${ARGN}" EQUAL "3") + PASS("ARGN") + ELSE("${ARGN}" EQUAL "3") + FAILED("ARGN" "Got: ${ARGN}") + ENDIF("${ARGN}" EQUAL "3") +ENDMACRO(test_argn_macro) +Test_Argn_Macro(ignored 3) + +# case test +MACRO(strange_macro m) + SET("${m}" strange_macro) +ENDMACRO(strange_macro m) +STRANGE_MACRO(var) +set(second_var "second_var") +IF("${var}" STREQUAL "strange_macro" AND "${second_var}" STREQUAL "second_var") + PASS("Case Test" "(${var} ${second_var})") +ELSE("${var}" STREQUAL "strange_macro" AND "${second_var}" STREQUAL "second_var") + FAILED("Case test" "(${var} ${second_var})") +ENDIF("${var}" STREQUAL "strange_macro" AND "${second_var}" STREQUAL "second_var") + +# test backing up command +MACRO(ADD_EXECUTABLE exec) + _ADD_EXECUTABLE("mini${exec}" ${ARGN}) +ENDMACRO(ADD_EXECUTABLE) + +INCLUDE(CheckCSourceCompiles) +Check_C_Source_Compiles( +" +#include <stdio.h> +#ifdef __CLASSIC_C__ +int main(){ + int ac; + char*av[]; +#else +int main(int ac, char*av[]){ +#endif + if(ac > 1000){return *av[0];} + return 0; +}" +SOME_CHECK) +IF(SOME_CHECK) + MESSAGE("CheckCSourceCompiles works") +ELSE(SOME_CHECK) + MESSAGE(FATAL_ERROR "CheckCSourceCompiles does not work") +ENDIF(SOME_CHECK) + +INCLUDE(CheckCXXSourceCompiles) +Check_CXX_Source_Compiles( +" +#include <stdio.h> +int main(int ac, char*av[]){ + if(ac > 1000){return *av[0];} + return 0; +}" +SOME_CHECK) +IF(SOME_CHECK) + MESSAGE("CheckCXXSourceCompiles works") +ELSE(SOME_CHECK) + MESSAGE(FATAL_ERROR "CheckCXXSourceCompiles does not work") +ENDIF(SOME_CHECK) + +ADD_EXECUTABLE(MacroTest macroTest.c) + +MACRO(GET_CURRENT_FILE var) + SET(${var} ${CMAKE_CURRENT_LIST_FILE}) +ENDMACRO(GET_CURRENT_FILE) +INCLUDE(context.cmake) diff --git a/Tests/MacroTest/context.cmake b/Tests/MacroTest/context.cmake new file mode 100644 index 000000000..f4d7035fb --- /dev/null +++ b/Tests/MacroTest/context.cmake @@ -0,0 +1,10 @@ +GET_CURRENT_FILE(current_file) +IF(NOT "${current_file}" STREQUAL "${CMAKE_CURRENT_LIST_FILE}") + MESSAGE(FATAL_ERROR + "Macro file context is broken. Expected:\n" + " ${CMAKE_CURRENT_LIST_FILE}\n" + "but got:\n" + " ${current_file}\n" + "from the macro." + ) +ENDIF(NOT "${current_file}" STREQUAL "${CMAKE_CURRENT_LIST_FILE}") diff --git a/Tests/MacroTest/macroTest.c b/Tests/MacroTest/macroTest.c new file mode 100644 index 000000000..e0ced6afd --- /dev/null +++ b/Tests/MacroTest/macroTest.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char* argv[]) +{ + printf("Running command: %s with %d arguments\n", argv[0], argc); + return 0; +} diff --git a/Tests/MakeClean/CMakeLists.txt b/Tests/MakeClean/CMakeLists.txt new file mode 100644 index 000000000..97d3554bd --- /dev/null +++ b/Tests/MakeClean/CMakeLists.txt @@ -0,0 +1,57 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(MakeClean) + +# Build the to-clean project. +TRY_COMPILE(TOCLEAN_BUILT + ${MakeClean_BINARY_DIR}/ToClean + ${MakeClean_SOURCE_DIR}/ToClean + ToClean + OUTPUT_VARIABLE OUTPUT + ) +IF(TOCLEAN_BUILT) + MESSAGE( + "Building ToClean succeeded with the following output:\n" + "[${OUTPUT}]" + ) +ELSE(TOCLEAN_BUILT) + MESSAGE(FATAL_ERROR + "Building ToClean failed with the following output:\n" + "[${OUTPUT}]" + ) +ENDIF(TOCLEAN_BUILT) + +# Get the set of files to check from the ToClean project. +INCLUDE(${MakeClean_BINARY_DIR}/ToClean/ToCleanFiles.cmake) + +# Check for the existence of the files. +FOREACH(f ${TOCLEAN_FILES}) + IF(EXISTS "${f}") + ELSE(EXISTS "${f}") + MESSAGE(FATAL_ERROR "File \"${f}\" does not exist!") + ENDIF(EXISTS "${f}") +ENDFOREACH(f) + +# Configure an executable to check that all the files are missing. +SET(CHECK_FILES) +FOREACH(f ${TOCLEAN_FILES}) + SET(CHECK_FILES "${CHECK_FILES} \"${f}\",\n") +ENDFOREACH(f) +CONFIGURE_FILE(${MakeClean_SOURCE_DIR}/check_clean.c.in + ${MakeClean_BINARY_DIR}/check_clean.c @ONLY IMMEDIATE) +ADD_EXECUTABLE(check_clean ${MakeClean_BINARY_DIR}/check_clean.c) + +# After the executable builds, clean the files. +ADD_CUSTOM_COMMAND( + TARGET check_clean + POST_BUILD + COMMAND ${CMAKE_CTEST_COMMAND} + ARGS --build-and-test + ${MakeClean_SOURCE_DIR}/ToClean + ${MakeClean_BINARY_DIR}/ToClean + --build-generator ${CMAKE_GENERATOR} + --build-project ToClean + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-noclean + --build-target clean + COMMENT "Clean the ToClean Project" + ) diff --git a/Tests/MakeClean/ToClean/CMakeLists.txt b/Tests/MakeClean/ToClean/CMakeLists.txt new file mode 100644 index 000000000..50facadb7 --- /dev/null +++ b/Tests/MakeClean/ToClean/CMakeLists.txt @@ -0,0 +1,31 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(ToClean) + +# Build a simple project. +ADD_EXECUTABLE(toclean toclean.cxx) + +# List some build-time-generated files. +GET_TARGET_PROPERTY(TOCLEAN_FILES toclean LOCATION) +SET(TOCLEAN_FILES ${TOCLEAN_FILES} + "${ToClean_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") + +# Create a file that must be registered for cleaning. +FILE(WRITE "${ToClean_BINARY_DIR}/Registered.txt" + "File registered for cleaning.\n") +SET_DIRECTORY_PROPERTIES(PROPERTIES + ADDITIONAL_MAKE_CLEAN_FILES "${ToClean_BINARY_DIR}/Registered.txt") +SET(TOCLEAN_FILES ${TOCLEAN_FILES} "${ToClean_BINARY_DIR}/Registered.txt") + +# Create a custom command whose output should be cleaned. +ADD_CUSTOM_COMMAND(OUTPUT ${ToClean_BINARY_DIR}/generated.txt + DEPENDS ${ToClean_SOURCE_DIR}/toclean.cxx + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${ToClean_SOURCE_DIR}/toclean.cxx + ${ToClean_BINARY_DIR}/generated.txt + ) +ADD_CUSTOM_TARGET(generate ALL DEPENDS ${ToClean_BINARY_DIR}/generated.txt) +SET(TOCLEAN_FILES ${TOCLEAN_FILES} "${ToClean_BINARY_DIR}/generated.txt") + +# Configure a file listing these build-time-generated files. +CONFIGURE_FILE(${ToClean_SOURCE_DIR}/ToCleanFiles.cmake.in + ${ToClean_BINARY_DIR}/ToCleanFiles.cmake @ONLY IMMEDIATE) diff --git a/Tests/MakeClean/ToClean/ToCleanFiles.cmake.in b/Tests/MakeClean/ToClean/ToCleanFiles.cmake.in new file mode 100644 index 000000000..10d11c37a --- /dev/null +++ b/Tests/MakeClean/ToClean/ToCleanFiles.cmake.in @@ -0,0 +1 @@ +SET(TOCLEAN_FILES "@TOCLEAN_FILES@") diff --git a/Tests/MakeClean/ToClean/toclean.cxx b/Tests/MakeClean/ToClean/toclean.cxx new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/MakeClean/ToClean/toclean.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/MakeClean/check_clean.c.in b/Tests/MakeClean/check_clean.c.in new file mode 100644 index 000000000..5bc4ab880 --- /dev/null +++ b/Tests/MakeClean/check_clean.c.in @@ -0,0 +1,26 @@ +#include <stdio.h> + +int main() +{ + /* The list of files to check. */ + const char* files[] = + { + @CHECK_FILES@ + 0 + }; + + /* No file should exist. */ + const char** f = files; + int result = 0; + for(; *f; ++f) + { + FILE* pf = fopen(*f, "rb"); + if(pf) + { + fclose(pf); + fprintf(stderr, "File \"%s\" exists!", *f); + result = 1; + } + } + return result; +} diff --git a/Tests/MathTest/CMakeLists.txt b/Tests/MathTest/CMakeLists.txt new file mode 100644 index 000000000..d1e5b1acd --- /dev/null +++ b/Tests/MathTest/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(MathTest) + + +# Expression test + +SET(expressions + "5 * ( 3 + 4)" + "(1 | 2 | 4 | 8) & 16" + "1 +(3*4) + 10 >> 2" + "10000 / 20 / 4" + "10000 / (20 / 4)" + ) + +SET(FILE_EXPRESSIONS "") +FOREACH(expression + ${expressions}) + MATH(EXPR expr "${expression}") + SET(FILE_EXPRESSIONS "${FILE_EXPRESSIONS}TEST_EXPRESSION(${expression}, ${expr})\n") +ENDFOREACH(expression) + +CONFIGURE_FILE( + "${CMAKE_CURRENT_SOURCE_DIR}/MathTestTests.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/MathTestTests.h" + @ONLY) + +INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}") +ADD_EXECUTABLE(MathTest MathTestExec.cxx) + diff --git a/Tests/MathTest/MathTestExec.cxx b/Tests/MathTest/MathTestExec.cxx new file mode 100644 index 000000000..5b94602a6 --- /dev/null +++ b/Tests/MathTest/MathTestExec.cxx @@ -0,0 +1,26 @@ +#include <stdio.h> + +#define TEST_EXPRESSION(x, y) \ + if ( (x) != (y) ) \ + { \ + printf("Problem with EXPR: Expression: \"%s\" in C returns %d while in CMake returns: %d\n", \ + #x, (x), (y)); \ + res ++; \ + } + +int main(int argc, char* argv[]) +{ + if ( argc > 1 ) + { + printf("Usage: %s\n", argv[0]); + return 1; + } + int res = 0; +#include "MathTestTests.h" + if ( res != 0 ) + { + printf("%s: %d math tests failed\n", argv[0], res); + return 1; + } + return 0; +} diff --git a/Tests/MathTest/MathTestTests.h.in b/Tests/MathTest/MathTestTests.h.in new file mode 100644 index 000000000..39c6861d7 --- /dev/null +++ b/Tests/MathTest/MathTestTests.h.in @@ -0,0 +1 @@ +@FILE_EXPRESSIONS@ diff --git a/Tests/MissingSourceFile/CMakeLists.txt b/Tests/MissingSourceFile/CMakeLists.txt new file mode 100644 index 000000000..a7206c897 --- /dev/null +++ b/Tests/MissingSourceFile/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(MissingSourceFile C) +add_executable(MissingSourceFile DoesNotExist/MissingSourceFile.c) diff --git a/Tests/Module/CheckTypeSize/CMakeLists.txt b/Tests/Module/CheckTypeSize/CMakeLists.txt new file mode 100644 index 000000000..45e9f6757 --- /dev/null +++ b/Tests/Module/CheckTypeSize/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 2.8.1 FATAL_ERROR) +project(CheckTypeSize C) + +include(CheckTypeSize) +check_type_size("void*" SIZEOF_DATA_PTR) +check_type_size(char SIZEOF_CHAR) +check_type_size(short SIZEOF_SHORT) +check_type_size(int SIZEOF_INT) +check_type_size(long SIZEOF_LONG) +check_type_size("long long" SIZEOF_LONG_LONG) +check_type_size(__int64 SIZEOF___INT64) +check_type_size(size_t SIZEOF_SIZE_T) +check_type_size(ssize_t SIZEOF_SSIZE_T) + +configure_file(config.h.in config.h) +include_directories(${CheckTypeSize_BINARY_DIR}) + +add_executable(CheckTypeSize CheckTypeSize.c) diff --git a/Tests/Module/CheckTypeSize/CheckTypeSize.c b/Tests/Module/CheckTypeSize/CheckTypeSize.c new file mode 100644 index 000000000..602c83494 --- /dev/null +++ b/Tests/Module/CheckTypeSize/CheckTypeSize.c @@ -0,0 +1,122 @@ +#include "config.h" + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef HAVE_STDDEF_H +# include <stddef.h> +#endif + +#include <stdio.h> + +#define CHECK(t,m) do { \ + if(sizeof(t) != m) \ + { \ + printf(#m ": expected %d, got %d (line %d)\n", \ + (int)sizeof(t), (int)m, __LINE__); \ + result = 1; \ + } \ + } while(0) + +#define NODEF(m) do { \ + printf(#m": not defined (line %d)\n", __LINE__); \ + result = 1; \ + } while(0) + +int main() +{ + int result = 0; + + /* void* */ +#if !defined(HAVE_SIZEOF_DATA_PTR) + NODEF(HAVE_SIZEOF_DATA_PTR); +#endif +#if defined(SIZEOF_DATA_PTR) + CHECK(void*, SIZEOF_DATA_PTR); +#else + NODEF(SIZEOF_DATA_PTR); +#endif + + /* char */ +#if !defined(HAVE_SIZEOF_CHAR) + NODEF(HAVE_SIZEOF_CHAR); +#endif +#if defined(SIZEOF_CHAR) + CHECK(char, SIZEOF_CHAR); +#else + NODEF(SIZEOF_CHAR); +#endif + + /* short */ +#if !defined(HAVE_SIZEOF_SHORT) + NODEF(HAVE_SIZEOF_SHORT); +#endif +#if defined(SIZEOF_SHORT) + CHECK(short, SIZEOF_SHORT); +#else + NODEF(SIZEOF_SHORT); +#endif + + /* int */ +#if !defined(HAVE_SIZEOF_INT) + NODEF(HAVE_SIZEOF_INT); +#endif +#if defined(SIZEOF_INT) + CHECK(int, SIZEOF_INT); +#else + NODEF(SIZEOF_INT); +#endif + + /* long */ +#if !defined(HAVE_SIZEOF_LONG) + NODEF(HAVE_SIZEOF_LONG); +#endif +#if defined(SIZEOF_LONG) + CHECK(long, SIZEOF_LONG); +#else + NODEF(SIZEOF_LONG); +#endif + + /* long long */ +#if defined(SIZEOF_LONG_LONG) + CHECK(long long, SIZEOF_LONG_LONG); +# if !defined(HAVE_SIZEOF_LONG_LONG) + NODEF(HAVE_SIZEOF_LONG_LONG); +# endif +#endif + + /* __int64 */ +#if defined(SIZEOF___INT64) + CHECK(__int64, SIZEOF___INT64); +# if !defined(HAVE_SIZEOF___INT64) + NODEF(HAVE_SIZEOF___INT64); +# endif +#elif defined(HAVE_SIZEOF___INT64) + NODEF(SIZEOF___INT64); +#endif + + /* size_t */ +#if !defined(HAVE_SIZEOF_SIZE_T) + NODEF(HAVE_SIZEOF_SIZE_T); +#endif +#if defined(SIZEOF_SIZE_T) + CHECK(size_t, SIZEOF_SIZE_T); +#else + NODEF(SIZEOF_SIZE_T); +#endif + + /* ssize_t */ +#if defined(SIZEOF_SSIZE_T) + CHECK(ssize_t, SIZEOF_SSIZE_T); +# if !defined(HAVE_SIZEOF_SSIZE_T) + NODEF(HAVE_SIZEOF_SSIZE_T); +# endif +#elif defined(HAVE_SIZEOF_SSIZE_T) + NODEF(SIZEOF_SSIZE_T); +#endif + + return result; +} diff --git a/Tests/Module/CheckTypeSize/config.h.in b/Tests/Module/CheckTypeSize/config.h.in new file mode 100644 index 000000000..b5bfbf6e5 --- /dev/null +++ b/Tests/Module/CheckTypeSize/config.h.in @@ -0,0 +1,39 @@ +#cmakedefine HAVE_SYS_TYPES_H +#cmakedefine HAVE_STDINT_H +#cmakedefine HAVE_STDDEF_H + +/* void* */ +#cmakedefine HAVE_SIZEOF_DATA_PTR +@SIZEOF_DATA_PTR_CODE@ + +/* char */ +#cmakedefine HAVE_SIZEOF_CHAR +@SIZEOF_CHAR_CODE@ + +/* short */ +#cmakedefine HAVE_SIZEOF_SHORT +@SIZEOF_SHORT_CODE@ + +/* int */ +#cmakedefine HAVE_SIZEOF_INT +@SIZEOF_INT_CODE@ + +/* long */ +#cmakedefine HAVE_SIZEOF_LONG +@SIZEOF_LONG_CODE@ + +/* long long */ +#cmakedefine HAVE_SIZEOF_LONG_LONG +@SIZEOF_LONG_LONG_CODE@ + +/* __int64 */ +#cmakedefine HAVE_SIZEOF___INT64 +@SIZEOF___INT64_CODE@ + +/* size_t */ +#cmakedefine HAVE_SIZEOF_SIZE_T +@SIZEOF_SIZE_T_CODE@ + +/* ssize_t */ +#cmakedefine HAVE_SIZEOF_SSIZE_T +@SIZEOF_SSIZE_T_CODE@ diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt new file mode 100644 index 000000000..4a5b1cb5a --- /dev/null +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -0,0 +1,184 @@ +cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR) + +project(GenerateExportHeader) + +# Prevent timeout on Watcom by not running the tests. +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom) + file(WRITE + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + "int main() { return 0; } + " + ) + + add_executable( + GenerateExportHeader + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + ) + return() +endif() + +include(CheckCXXCompilerFlag) + +set( CMAKE_INCLUDE_CURRENT_DIR ON ) + +macro(TEST_FAIL value msg) + if (${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +macro(TEST_PASS value msg) + if (NOT ${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +check_cxx_compiler_flag(-Werror HAS_WERROR_FLAG) + +if(HAS_WERROR_FLAG) + set(ERROR_FLAG "-Werror") +else() + # MSVC + # And intel on windows? + # http://software.intel.com/en-us/articles/how-to-handle-warnings-message-in-compiler/?wapkw=%28compiler+warning+message%29 + check_cxx_compiler_flag("/WX" HAS_WX_FLAG) + if(HAS_WX_FLAG) + set(ERROR_FLAG "/WX") + else() + # Sun CC + # http://www.acsu.buffalo.edu/~charngda/sunstudio.html + check_cxx_compiler_flag("-errwarn=%all" HAS_ERRWARN_ALL) + if (HAS_ERRWARN_ALL) + set(ERROR_FLAG "-errwarn=%all") + else() + endif() + endif() +endif() + +set(DEPS + libshared + libstatic + lib_shared_and_static +) + +foreach(DEP ${DEPS}) + try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/${DEP}_build + ${CMAKE_CURRENT_SOURCE_DIR}/${DEP} + ${DEP} + OUTPUT_VARIABLE Out + ) + if (NOT Result) + message("OUTPUT: ${Out}") + endif() +endforeach() + +# The _do_build macro is called from a child scope, where +# the current source and binary dir are different. Save them here +# for use in the macro. +set(TEST_TOP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(TEST_TOP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + + +# We seem to get race conditions is writing this stuff to the same file at least on MinGW +# So to write to separate source and build directories, we use a count to differentiate. +set (COUNT 0) +macro(_do_build Include Library LibrarySource Source) + + math(EXPR COUNT "${COUNT} + 1" ) + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/src.cpp" "#include \"${Include}\"\n" + "int main() { ${Source}; }\n" + ) + + if ("${Library}" STREQUAL "static_variant") + set(CONDITIONAL_STATIC_DEFINE "add_definitions(-DLIBSHARED_AND_STATIC_STATIC_DEFINE)\n") + endif() + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt" + "cmake_minimum_required(VERSION 2.8)\n" + + "project(compiletest)\n" + + "set(CMAKE_INCLUDE_CURRENT_DIR ON)\n" + + "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"\${CMAKE_CURRENT_BINARY_DIR}\")\n" + + "include(GenerateExportHeader)\n" + + "add_compiler_export_flags()\n" + + "if(NOT \"${ERROR_FLAG}\" STREQUAL \"\")\n" + " add_definitions(${ERROR_FLAG})\n" + "endif()\n" + + "include(\"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build/Targets.cmake\")\n" + + "include_directories(\"${TEST_TOP_SOURCE_DIR}/${LibrarySource}\"\n" + " \"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build\")\n" + + "${CONDITIONAL_STATIC_DEFINE}" + + "add_executable(compiletest src.cpp)\n" + "target_link_libraries(compiletest ${Library})\n" + ) + + try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/fail${COUNT} + ${CMAKE_CURRENT_BINARY_DIR}/test${COUNT} + compiletest + OUTPUT_VARIABLE Out + ) +endmacro() + +macro(build_fail Include Library LibrarySource Source Message) + _do_build(${Include} ${Library} ${LibrarySource} "${Source}") + test_fail(Result ${Message}) +endmacro() + +macro(build_pass Include Library LibrarySource Source Message) + _do_build(${Include} ${Library} ${LibrarySource} "${Source}") + test_pass(Result ${Message}) +endmacro() + +include(GenerateExportHeader) + +add_compiler_export_flags() + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + +message("#### COMPILER_HAS_DEPRECATED: " ${COMPILER_HAS_DEPRECATED}) +message("#### COMPILER_HAS_HIDDEN_VISIBILITY: " ${COMPILER_HAS_HIDDEN_VISIBILITY}) +message("#### WIN32: " ${WIN32}) +message("#### HAS_WERROR_FLAG: " ${HAS_WERROR_FLAG}) + +set(link_libraries) +macro(macro_add_test_library name) + add_subdirectory(${name}) + include_directories(${name} + ${${name}_BINARY_DIR} # For the export header. + ) + list(APPEND link_libraries ${name}) + add_subdirectory(${name}test) +endmacro() + +macro_add_test_library(libshared) +macro_add_test_library(libstatic) +add_subdirectory(lib_shared_and_static) +add_subdirectory(lib_shared_and_statictest) + +add_subdirectory(override_symbol) +add_subdirectory(nodeprecated) +add_subdirectory(prefix) + +if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) + # We deliberately call deprecated methods, and test for that elsewhere. + # No need to clutter the test output with warnings. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") +endif() + +if(MSVC AND COMPILER_HAS_DEPRECATED) + add_definitions(/wd4996) +endif() + +add_executable(GenerateExportHeader exportheader_test.cpp) + +target_link_libraries(GenerateExportHeader ${link_libraries}) diff --git a/Tests/Module/GenerateExportHeader/exportheader_test.cpp b/Tests/Module/GenerateExportHeader/exportheader_test.cpp new file mode 100644 index 000000000..55c3c1ad6 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/exportheader_test.cpp @@ -0,0 +1,82 @@ + +#include "libshared.h" + +#include "libstatic.h" + +// #define BUILD_FAIL + +#ifndef BUILD_FAIL +#define DOES_NOT_BUILD(function) +#else +#define DOES_NOT_BUILD(function) function +#endif + +int main() +{ + { + Libshared l; + l.libshared(); + l.libshared_exported(); + l.libshared_deprecated(); + l.libshared_not_exported(); + + DOES_NOT_BUILD(l.libshared_excluded();) + } + + { + LibsharedNotExported l; + DOES_NOT_BUILD(l.libshared();) + l.libshared_exported(); + l.libshared_deprecated(); + DOES_NOT_BUILD(l.libshared_not_exported();) + DOES_NOT_BUILD(l.libshared_excluded();) + } + + { + LibsharedExcluded l; + DOES_NOT_BUILD(l.libshared();) + l.libshared_exported(); + l.libshared_deprecated(); + DOES_NOT_BUILD(l.libshared_not_exported();) + DOES_NOT_BUILD(l.libshared_excluded();) + } + + libshared_exported(); + libshared_deprecated(); + DOES_NOT_BUILD(libshared_not_exported();) + DOES_NOT_BUILD(libshared_excluded();) + + { + Libstatic l; + l.libstatic(); + l.libstatic_exported(); + l.libstatic_deprecated(); + l.libstatic_not_exported(); + l.libstatic_excluded(); + } + + { + LibstaticNotExported l; + l.libstatic(); + l.libstatic_exported(); + l.libstatic_deprecated(); + l.libstatic_not_exported(); + l.libstatic_excluded(); + } + + { + LibstaticExcluded l; + l.libstatic(); + l.libstatic_exported(); + l.libstatic_deprecated(); + l.libstatic_not_exported(); + l.libstatic_excluded(); + } + + libstatic_exported(); + libstatic_deprecated(); + libstatic_not_exported(); + libstatic_excluded(); + + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt new file mode 100644 index 000000000..be0387fd5 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt @@ -0,0 +1,23 @@ + +cmake_minimum_required(VERSION 2.8) + +project(lib_shared_and_static) + +include(GenerateExportHeader) + +add_compiler_export_flags() + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(lib_SRCS + libshared_and_static.cpp +) + +add_library(shared_variant SHARED ${lib_SRCS}) +add_library(static_variant ${lib_SRCS}) + +generate_export_header(shared_variant BASE_NAME libshared_and_static) + +set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) + +export(TARGETS shared_variant static_variant FILE Targets.cmake) diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp new file mode 100644 index 000000000..1e0727362 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp @@ -0,0 +1,91 @@ + +#include "libshared_and_static.h" + +int LibsharedAndStatic::libshared_and_static() const +{ + return 0; +} + +int LibsharedAndStatic::libshared_and_static_exported() const +{ + return 0; +} + +int LibsharedAndStatic::libshared_and_static_deprecated() const +{ + return 0; +} + +int LibsharedAndStatic::libshared_and_static_not_exported() const { + return 0; +} + +int LibsharedAndStatic::libshared_and_static_excluded() const { + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static() const +{ + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_exported() const +{ + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_deprecated() const +{ + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_not_exported() const { + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_excluded() const { + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static() const +{ + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_exported() const +{ + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_deprecated() const +{ + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_not_exported() const { + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_excluded() const { + return 0; +} + +int libshared_and_static() { + return 0; +} + +int libshared_and_static_exported() { + return 0; +} + +int libshared_and_static_deprecated() { + return 0; +} + +int libshared_and_static_not_exported() { + return 0; +} + +int libshared_and_static_excluded() { + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h new file mode 100644 index 000000000..049bfe9c4 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h @@ -0,0 +1,54 @@ + +#ifndef SHARED_AND_STATIC_H +#define SHARED_AND_STATIC_H + +#include "libshared_and_static_export.h" + +class LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic { +public: + int libshared_and_static() const; + + int libshared_and_static_exported() const; + + int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + + int libshared_and_static_not_exported() const; + + int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; +}; + +class LibsharedAndStaticNotExported { +public: + int libshared_and_static() const; + + int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; + + int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + + int libshared_and_static_not_exported() const; + + int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; +}; + +class LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded { +public: + int libshared_and_static() const; + + int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; + + int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + + int libshared_and_static_not_exported() const; + + int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; +}; + +LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported(); + +LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated(); + +int libshared_and_static_not_exported(); + +int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded(); + +#endif diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt new file mode 100644 index 000000000..207534d6e --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt @@ -0,0 +1,33 @@ + +macro(shared_variant_build_pass Source Message) + build_pass("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +macro(shared_variant_build_fail Source Message) + build_fail("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +macro(static_variant_build_pass Source Message) + build_pass("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +macro(static_variant_build_fail Source Message) + build_fail("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +static_variant_build_pass("return libshared_and_static_exported();" "Failed to build static variant") +shared_variant_build_pass("return libshared_and_static_exported();" "Failed to build shared variant") +# if (COMPILER_HAS_DEPRECATED) +# shared_variant_build_fail("return libshared_and_static_deprecated();" "Built shared deprecated variant") +# static_variant_build_fail("return libshared_and_static_deprecated();" "Built static deprecated variant") +# else() +# shared_variant_build_pass("return libshared_and_static_deprecated();" "Built shared deprecated variant") +# static_variant_build_pass("return libshared_and_static_deprecated();" "Built static deprecated variant") +# endif() +static_variant_build_pass("return libshared_and_static_not_exported();" "Failed to build static not exported variant") + +if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY) + shared_variant_build_fail("return libshared_and_static_not_exported();" "Built shared not exported variant") +else() + shared_variant_build_pass("return libshared_and_static_not_exported();" "Built shared not exported variant") +endif() diff --git a/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt new file mode 100644 index 000000000..e20adb1a7 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt @@ -0,0 +1,16 @@ + +cmake_minimum_required(VERSION 2.8) + +project(libshared) + +include(GenerateExportHeader) + +add_compiler_export_flags() + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_library(libshared SHARED libshared.cpp) + +generate_export_header(libshared) + +export(TARGETS libshared FILE Targets.cmake) diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.cpp b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp new file mode 100644 index 000000000..d4041b36d --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp @@ -0,0 +1,91 @@ + +#include "libshared.h" + +int Libshared::libshared() const +{ + return 0; +} + +int Libshared::libshared_exported() const +{ + return 0; +} + +int Libshared::libshared_deprecated() const +{ + return 0; +} + +int Libshared::libshared_not_exported() const { + return 0; +} + +int Libshared::libshared_excluded() const { + return 0; +} + +int LibsharedNotExported::libshared() const +{ + return 0; +} + +int LibsharedNotExported::libshared_exported() const +{ + return 0; +} + +int LibsharedNotExported::libshared_deprecated() const +{ + return 0; +} + +int LibsharedNotExported::libshared_not_exported() const { + return 0; +} + +int LibsharedNotExported::libshared_excluded() const { + return 0; +} + +int LibsharedExcluded::libshared() const +{ + return 0; +} + +int LibsharedExcluded::libshared_exported() const +{ + return 0; +} + +int LibsharedExcluded::libshared_deprecated() const +{ + return 0; +} + +int LibsharedExcluded::libshared_not_exported() const { + return 0; +} + +int LibsharedExcluded::libshared_excluded() const { + return 0; +} + +int libshared() { + return 0; +} + +int libshared_exported() { + return 0; +} + +int libshared_deprecated() { + return 0; +} + +int libshared_not_exported() { + return 0; +} + +int libshared_excluded() { + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.h b/Tests/Module/GenerateExportHeader/libshared/libshared.h new file mode 100644 index 000000000..3d9bbff4f --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libshared/libshared.h @@ -0,0 +1,54 @@ + +#ifndef LIBSHARED_H +#define LIBSHARED_H + +#include "libshared_export.h" + +class LIBSHARED_EXPORT Libshared { +public: + int libshared() const; + + int libshared_exported() const; + + int LIBSHARED_DEPRECATED libshared_deprecated() const; + + int libshared_not_exported() const; + + int LIBSHARED_NO_EXPORT libshared_excluded() const; +}; + +class LibsharedNotExported { +public: + int libshared() const; + + int LIBSHARED_EXPORT libshared_exported() const; + + int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const; + + int libshared_not_exported() const; + + int LIBSHARED_NO_EXPORT libshared_excluded() const; +}; + +class LIBSHARED_NO_EXPORT LibsharedExcluded { +public: + int libshared() const; + + int LIBSHARED_EXPORT libshared_exported() const; + + int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const; + + int libshared_not_exported() const; + + int LIBSHARED_NO_EXPORT libshared_excluded() const; +}; + +LIBSHARED_EXPORT int libshared_exported(); + +LIBSHARED_DEPRECATED_EXPORT int libshared_deprecated(); + +int libshared_not_exported(); + +int LIBSHARED_NO_EXPORT libshared_excluded(); + +#endif diff --git a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt new file mode 100644 index 000000000..a5804fcfb --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt @@ -0,0 +1,44 @@ + +macro(shared_build_pass Source Message) + build_pass("libshared.h" "libshared" "libshared" "${Source}" ${Message}) +endmacro() + +macro(shared_build_fail Source Message) + build_fail("libshared.h" "libshared" "libshared" "${Source}" ${Message}) +endmacro() + +shared_build_pass("Libshared l; return l.libshared_exported();" "Failed to build exported") + +# if (COMPILER_HAS_DEPRECATED) +# shared_build_fail("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") +# else() +# shared_build_pass("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") +# endif() +if (COMPILER_HAS_HIDDEN_VISIBILITY) + shared_build_fail("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") +else() + # There is no MSVC equivalent to hiding symbols. + shared_build_pass("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This is possible on MSVC.") +endif() + +if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY) + shared_build_fail("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method. This should not be possible.") + shared_build_fail("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method. This should not be possible.") + shared_build_fail("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method. This should not be possible.") + shared_build_fail("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method. This should not be possible.") + shared_build_fail("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method. This should not be possible.") + shared_build_fail("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") + + shared_build_fail("return libshared_excluded();" "Built use of excluded function. This should not be possible.") + shared_build_fail("return libshared_not_exported();" "Built use of not-exported function. This should not be possible.") +else() + shared_build_pass("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method.") + shared_build_pass("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method.") + shared_build_pass("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method.") + shared_build_pass("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method.") + shared_build_pass("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method.") + shared_build_pass("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method.") + + shared_build_pass("return libshared_excluded();" "Built use of excluded function.") + shared_build_pass("return libshared_not_exported();" "Built use of not-exported function.") +endif() diff --git a/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt new file mode 100644 index 000000000..b2db3ea74 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt @@ -0,0 +1,18 @@ + +cmake_minimum_required(VERSION 2.8) + +project(libstatic) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include(GenerateExportHeader) + +add_compiler_export_flags() + +# Show that the export header has no effect on a static library. + +add_library(libstatic STATIC libstatic.cpp) + +generate_export_header(libstatic) + +export(TARGETS libstatic FILE Targets.cmake) diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp new file mode 100644 index 000000000..0710c3e9e --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp @@ -0,0 +1,87 @@ + +#include "libstatic.h" + +int Libstatic::libstatic() const +{ + return 0; +} + +int Libstatic::libstatic_exported() const +{ + return 0; +} + +int Libstatic::libstatic_deprecated() const +{ + return 0; +} + +int Libstatic::libstatic_not_exported() const { + return 0; +} + +int Libstatic::libstatic_excluded() const { + return 0; +} + +int LibstaticNotExported::libstatic() const +{ + return 0; +} + +int LibstaticNotExported::libstatic_exported() const +{ + return 0; +} + +int LibstaticNotExported::libstatic_deprecated() const +{ + return 0; +} + +int LibstaticNotExported::libstatic_not_exported() const { + return 0; +} + +int LibstaticNotExported::libstatic_excluded() const { + return 0; +} + +int LibstaticExcluded::libstatic() const +{ + return 0; +} + +int LibstaticExcluded::libstatic_exported() const +{ + return 0; +} + +int LibstaticExcluded::libstatic_deprecated() const +{ + return 0; +} + +int LibstaticExcluded::libstatic_not_exported() const { + return 0; +} + +int LibstaticExcluded::libstatic_excluded() const { + return 0; +} + +int libstatic_exported() { + return 0; +} + +int libstatic_deprecated() { + return 0; +} + +int libstatic_not_exported() { + return 0; +} + +int libstatic_excluded() { + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.h b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h new file mode 100644 index 000000000..cc7a35b4e --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h @@ -0,0 +1,54 @@ + +#ifndef LIBSTATIC_H +#define LIBSTATIC_H + +#include "libstatic_export.h" + +class LIBSTATIC_EXPORT Libstatic { +public: + int libstatic() const; + + int libstatic_exported() const; + + int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + + int libstatic_not_exported() const; + + int LIBSTATIC_NO_EXPORT libstatic_excluded() const; +}; + +class LibstaticNotExported { +public: + int libstatic() const; + + int LIBSTATIC_EXPORT libstatic_exported() const; + + int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + + int libstatic_not_exported() const; + + int LIBSTATIC_NO_EXPORT libstatic_excluded() const; +}; + +class LIBSTATIC_NO_EXPORT LibstaticExcluded { +public: + int libstatic() const; + + int LIBSTATIC_EXPORT libstatic_exported() const; + + int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + + int libstatic_not_exported() const; + + int LIBSTATIC_NO_EXPORT libstatic_excluded() const; +}; + +LIBSTATIC_EXPORT int libstatic_exported(); + +LIBSTATIC_DEPRECATED_EXPORT int libstatic_deprecated(); + +int libstatic_not_exported(); + +int LIBSTATIC_NO_EXPORT libstatic_excluded(); + +#endif diff --git a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt new file mode 100644 index 000000000..eb6bb874c --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt @@ -0,0 +1,18 @@ + +macro(static_build_pass Source Message) + build_pass("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message}) +endmacro() + +macro(static_build_fail Source Message) + build_fail("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message}) +endmacro() + +static_build_pass("Libstatic l; return l.libstatic_exported();" "Failed to build exported.") + +# if (COMPILER_HAS_DEPRECATED) +# static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") +# static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") +# else() +# static_build_pass("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") +# static_build_pass("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") +# endif() diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt new file mode 100644 index 000000000..aeeb13a85 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 2.8) + +project(nodeprecated) + +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined) + +configure_file(CMakeLists.txt.in ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined/CMakeLists.txt) +set(DEFINE_NO_DEPRECATED DEFINE_NO_DEPRECATED) +configure_file(CMakeLists.txt.in ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined/CMakeLists.txt) + +try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined_build + ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined + nodeprecated_test + OUTPUT_VARIABLE Out +) + +test_pass(Result "Failed to build without no-deprecated define") + +try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined_build + ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined + nodeprecated_test + OUTPUT_VARIABLE Out +) + +test_fail(Result "Built even with no-deprecated define")
\ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in new file mode 100644 index 000000000..d8dc482f3 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8) + +project(nodeprecated_test) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include(GenerateExportHeader) + +add_library(nodeprecatedlib SHARED someclass.cpp) + +generate_export_header(nodeprecatedlib @DEFINE_NO_DEPRECATED@) + +add_executable(nodeprecatedconsumer main.cpp) + +target_link_libraries(nodeprecatedconsumer nodeprecatedlib) diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp b/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp new file mode 100644 index 000000000..eec46d3f2 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp @@ -0,0 +1,9 @@ + +#include "someclass.h" + +int main(int, char**) +{ + SomeClass sc; + sc.someMethod(); + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp new file mode 100644 index 000000000..a3f41111c --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp @@ -0,0 +1,9 @@ + +#include "someclass.h" + +#ifndef NODEPRECATEDLIB_NO_DEPRECATED +void SomeClass::someMethod() const +{ + +} +#endif diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h new file mode 100644 index 000000000..312a177f1 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h @@ -0,0 +1,10 @@ + +#include "nodeprecatedlib_export.h" + +class NODEPRECATEDLIB_EXPORT SomeClass +{ +public: +#ifndef NODEPRECATEDLIB_NO_DEPRECATED + void someMethod() const; +#endif +}; diff --git a/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt new file mode 100644 index 000000000..aeeef20ee --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt @@ -0,0 +1,11 @@ +project(override_symbol) + +add_library(somelib SHARED someclass.cpp) + +set_target_properties(somelib PROPERTIES DEFINE_SYMBOL SOMELIB_MAKEDLL) + +generate_export_header(somelib) + +add_executable(consumer main.cpp) + +target_link_libraries(consumer somelib) diff --git a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp new file mode 100644 index 000000000..eec46d3f2 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp @@ -0,0 +1,9 @@ + +#include "someclass.h" + +int main(int, char**) +{ + SomeClass sc; + sc.someMethod(); + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp new file mode 100644 index 000000000..427ec297c --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp @@ -0,0 +1,7 @@ + +#include "someclass.h" + +void SomeClass::someMethod() const +{ + +} diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.h b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h new file mode 100644 index 000000000..ae5e84454 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h @@ -0,0 +1,8 @@ + +#include "somelib_export.h" + +class SOMELIB_EXPORT SomeClass +{ +public: + void someMethod() const; +}; diff --git a/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt b/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt new file mode 100644 index 000000000..bd64df283 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt @@ -0,0 +1,15 @@ +project(use_prefix) + +set(use_prefix_lib_SRCS + useprefixclass.cpp +) + +add_library(use_prefix_lib SHARED useprefixclass.cpp) + +generate_export_header(use_prefix_lib + PREFIX_NAME MYPREFIX_ +) + +add_executable(use_prefix main.cpp) + +target_link_libraries(use_prefix use_prefix_lib)
\ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/prefix/main.cpp b/Tests/Module/GenerateExportHeader/prefix/main.cpp new file mode 100644 index 000000000..507f6fd15 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/prefix/main.cpp @@ -0,0 +1,8 @@ + +#include "useprefixclass.h" + +int main(int argc, char **argv) +{ + UsePrefixClass upc; + return upc.someMethod(); +} diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp new file mode 100644 index 000000000..1fd2cb2b4 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp @@ -0,0 +1,7 @@ + +#include "useprefixclass.h" + +int UsePrefixClass::someMethod() const +{ + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h new file mode 100644 index 000000000..f5e31b507 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h @@ -0,0 +1,13 @@ + +#ifndef USEPREFIXCLASS_H +#define USEPREFIXCLASS_H + +#include "use_prefix_lib_export.h" + +class MYPREFIX_USE_PREFIX_LIB_EXPORT UsePrefixClass +{ +public: + int someMethod() const; +}; + +#endif diff --git a/Tests/ModuleDefinition/CMakeLists.txt b/Tests/ModuleDefinition/CMakeLists.txt new file mode 100644 index 000000000..a30f64363 --- /dev/null +++ b/Tests/ModuleDefinition/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 2.6) +project(ModuleDefinition C) + +# Test .def file source recognition for DLLs. +add_library(example_dll SHARED example_dll.c example_dll.def) + +# Test generated .def file. +add_custom_command(OUTPUT example_dll_gen.def + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/example_dll_gen.def.in + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/example_dll_gen.def.in + ${CMAKE_CURRENT_BINARY_DIR}/example_dll_gen.def + ) +add_library(example_dll_gen SHARED example_dll_gen.c example_dll_gen.def) + +# Test /DEF:<file> flag recognition for VS. +if(MSVC OR "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") + add_library(example_dll_2 SHARED example_dll_2.c) + set_property(TARGET example_dll_2 PROPERTY LINK_FLAGS + /DEF:"${ModuleDefinition_SOURCE_DIR}/example_dll_2.def") + set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS EXAMPLE_DLL_2) + set(example_dll_2 example_dll_2) +endif() + +# Test .def file source recognition for EXEs. +add_executable(example_exe example_exe.c example_exe.def) +set_property(TARGET example_exe PROPERTY ENABLE_EXPORTS 1) +target_link_libraries(example_exe example_dll example_dll_gen ${example_dll_2}) + +# Test linking to the executable. +add_library(example_mod_1 MODULE example_mod_1.c) +target_link_libraries(example_mod_1 example_exe example_dll ${example_dll_2}) diff --git a/Tests/ModuleDefinition/example_dll.c b/Tests/ModuleDefinition/example_dll.c new file mode 100644 index 000000000..88b3904a7 --- /dev/null +++ b/Tests/ModuleDefinition/example_dll.c @@ -0,0 +1 @@ +int example_dll_function(void) { return 0; } diff --git a/Tests/ModuleDefinition/example_dll.def b/Tests/ModuleDefinition/example_dll.def new file mode 100644 index 000000000..df64fb3c1 --- /dev/null +++ b/Tests/ModuleDefinition/example_dll.def @@ -0,0 +1,2 @@ +EXPORTS +example_dll_function diff --git a/Tests/ModuleDefinition/example_dll_2.c b/Tests/ModuleDefinition/example_dll_2.c new file mode 100644 index 000000000..9d79acdd3 --- /dev/null +++ b/Tests/ModuleDefinition/example_dll_2.c @@ -0,0 +1 @@ +int example_dll_2_function(void) { return 0; } diff --git a/Tests/ModuleDefinition/example_dll_2.def b/Tests/ModuleDefinition/example_dll_2.def new file mode 100644 index 000000000..8eba7f9cd --- /dev/null +++ b/Tests/ModuleDefinition/example_dll_2.def @@ -0,0 +1,2 @@ +EXPORTS +example_dll_2_function diff --git a/Tests/ModuleDefinition/example_dll_gen.c b/Tests/ModuleDefinition/example_dll_gen.c new file mode 100644 index 000000000..be5d1eed7 --- /dev/null +++ b/Tests/ModuleDefinition/example_dll_gen.c @@ -0,0 +1 @@ +int example_dll_gen_function(void) { return 0; } diff --git a/Tests/ModuleDefinition/example_dll_gen.def.in b/Tests/ModuleDefinition/example_dll_gen.def.in new file mode 100644 index 000000000..c489dbc83 --- /dev/null +++ b/Tests/ModuleDefinition/example_dll_gen.def.in @@ -0,0 +1,2 @@ +EXPORTS +example_dll_gen_function diff --git a/Tests/ModuleDefinition/example_exe.c b/Tests/ModuleDefinition/example_exe.c new file mode 100644 index 000000000..253ae8b70 --- /dev/null +++ b/Tests/ModuleDefinition/example_exe.c @@ -0,0 +1,16 @@ +extern int __declspec(dllimport) example_dll_function(void); +extern int __declspec(dllimport) example_dll_gen_function(void); +#ifdef EXAMPLE_DLL_2 +extern int __declspec(dllimport) example_dll_2_function(void); +#endif +int example_exe_function(void) { return 0; } +int main(void) +{ + return + example_dll_function() + + example_dll_gen_function() + +#ifdef EXAMPLE_DLL_2 + example_dll_2_function() + +#endif + example_exe_function(); +} diff --git a/Tests/ModuleDefinition/example_exe.def b/Tests/ModuleDefinition/example_exe.def new file mode 100644 index 000000000..2a0df1f84 --- /dev/null +++ b/Tests/ModuleDefinition/example_exe.def @@ -0,0 +1,2 @@ +EXPORTS +example_exe_function diff --git a/Tests/ModuleDefinition/example_mod_1.c b/Tests/ModuleDefinition/example_mod_1.c new file mode 100644 index 000000000..4e2f9ba1f --- /dev/null +++ b/Tests/ModuleDefinition/example_mod_1.c @@ -0,0 +1,21 @@ +#ifdef __WATCOMC__ +# define MODULE_CCONV __cdecl +#else +# define MODULE_CCONV +#endif + +int __declspec(dllimport) example_exe_function(void); +int __declspec(dllimport) example_dll_function(void); +#ifdef EXAMPLE_DLL_2 +int __declspec(dllimport) example_dll_2_function(void); +#endif + +__declspec(dllexport) int MODULE_CCONV example_mod_1_function(int n) +{ + return + example_dll_function() + +#ifdef EXAMPLE_DLL_2 + example_dll_2_function() + +#endif + example_exe_function() + n; +} diff --git a/Tests/MumpsCoverage/.gitattributes b/Tests/MumpsCoverage/.gitattributes new file mode 100644 index 000000000..b6806125d --- /dev/null +++ b/Tests/MumpsCoverage/.gitattributes @@ -0,0 +1,2 @@ +*.cmcov -crlf -whitespace +*.mcov -crlf -whitespace diff --git a/Tests/MumpsCoverage/Accounts_ReceivableTest.cmcov b/Tests/MumpsCoverage/Accounts_ReceivableTest.cmcov new file mode 100644 index 000000000..c3b3342ab --- /dev/null +++ b/Tests/MumpsCoverage/Accounts_ReceivableTest.cmcov @@ -0,0 +1,304 @@ +Routine,Line,RtnLine,Code
+DDIOL,1,0,"DDIOL ;SFISC/MKO-THE LOADER ;1:53 PM 12 Sep 1995"
+,2,0," ;;22.0;VA FileMan;;Mar 30, 1999"
+,3,0," ;Per VHA Directive 10-93-142, this routine should not be modified."
+,4,0," ;"
+,5,0,"EN(A,G,FMT) ;Write the text contained in local array A or global array G"
+,6,0," ;If one string passed, use format FMT"
+,7,0," N %,Y,DINAKED"
+,8,0," S DINAKED=$$LGR^%ZOSV"
+,9,0," ;"
+,10,0," S:'$D(A) A="""""
+,11,0," I $G(A)="""",$D(A)<9,$G(FMT)="""",$G(G)'?1""^""1A.7AN,$G(G)'?1""^""1A.7AN1""("".E1"")"" Q"
+,12,0," ;"
+,13,0," G:$D(DDS) SM"
+,14,0," G:$D(DIQUIET) LD"
+,15,0," ;"
+,16,0," N F,I,S"
+,17,0," I $D(A)=1,$G(G)="""" D"
+,18,0," . S F=$S($G(FMT)]"""":FMT,1:""!"")"
+,19,0," . W @F,A"
+,20,0," ;"
+,21,0," E I $D(A)>9 S I=0 F S I=$O(A(I)) Q:I'=+$P(I,""E"") D"
+,22,0," . S F=$G(A(I,""F""),""!"") S:F="""" F=""?0"""
+,23,0," . W @F,$G(A(I))"
+,24,0," ;"
+,25,0," E S I=0 F S I=$O(@G@(I)) Q:I'=+$P(I,""E"") D"
+,26,0," . S S=$G(@G@(I,0),$G(@G@(I)))"
+,27,0," . S F=$G(@G@(I,""F""),""!"") S:F="""" F=""?0"""
+,28,0," . W @F,S"
+,29,0," ;"
+,30,0," I DINAKED]"""" S DINAKED=$S(DINAKED["""""""""""":$O(@DINAKED),1:$D(@DINAKED))"
+,31,0," Q"
+,32,0," ;"
+,33,0,"LD ;Load text into ^TMP"
+,34,0," N I,N,T"
+,35,0," S T=$S($G(DDIOLFLG)[""H"":""DIHELP"",1:""DIMSG"")"
+,36,0," S N=$O(^TMP(T,$J,"" ""),-1)"
+,37,0," ;"
+,38,0," I $D(A)=1,$G(G)="""" D"
+,39,0," . D LD1(A,$S($G(FMT)]"""":FMT,1:""!""))"
+,40,0," ;"
+,41,0," E I $D(A)>9 S I=0 F S I=$O(A(I)) Q:I'=+$P(I,""E"") D"
+,42,0," . D LD1($G(A(I)),$G(A(I,""F""),""!""))"
+,43,0," ;"
+,44,0," E S I=0 F S I=$O(@G@(I)) Q:I'=+$P(I,""E"") D"
+,45,0," . D LD1($G(@G@(I),$G(@G@(I,0))),$G(@G@(I,""F""),""!""))"
+,46,0," ;"
+,47,0," K:'N @T S:N @T=N"
+,48,0," I DINAKED]"""" S DINAKED=$S(DINAKED["""""""""""":$O(@DINAKED),1:$D(@DINAKED))"
+,49,0," Q"
+,50,0," ;"
+,51,0,"LD1(S,F) ;Load string S, with format F"
+,52,0," ;In: N and T"
+,53,0," N C,J,L"
+,54,0," S:S[$C(7) S=$TR(S,$C(7),"""")"
+,55,0," F J=1:1:$L(F,""!"")-1 S N=N+1,^TMP(T,$J,N)="""""
+,56,0," S:'N N=1"
+,57,0," S:F[""?"" @(""C=""_$P(F,""?"",2))"
+,58,0," S L=$G(^TMP(T,$J,N))"
+,59,0," S ^TMP(T,$J,N)=L_$J("""",$G(C)-$L(L))_S"
+,60,0," Q"
+,61,0," ;"
+,62,0,"SM ;Print text in ScreenMan's Command Area"
+,63,0," I $D(DDSID),$D(DTOUT)!$D(DUOUT) G SMQ"
+,64,0," N DDIOL"
+,65,0," S DDIOL=1"
+,66,0," ;"
+,67,0," I $D(A)=1&($G(G)="""")!($D(A)>9) D"
+,68,0," . D MSG^DDSMSG(.A,"""",$G(FMT))"
+,69,0," E I $D(@G@(+$O(@G@(0)),0))#2 D"
+,70,0," . D WP^DDSMSG(G)"
+,71,0," E D HLP^DDSMSG(G)"
+,72,0," ;"
+,73,0,"SMQ I DINAKED]"""" S DINAKED=$S(DINAKED["""""""""""":$O(@DINAKED),1:$D(@DINAKED))"
+,74,0," Q"
+Totals for DDIOL,,0,
+XINDEX,1,0,"XINDEX ;ISC/REL,GFT,GRK,RWF - INDEX & CROSS-REFERENCE ;08/04/08 13:19"
+,2,1," ;;7.3;TOOLKIT;**20,27,48,61,66,68,110,121,128**;Apr 25, 1995;Build 1"
+,3,0," ; Per VHA Directive 2004-038, this routine should not be modified."
+,4,1," G ^XINDX6"
+,5,107216,"SEP F I=1:1 S CH=$E(LIN,I) D QUOTE:CH=Q Q:"" ""[CH"
+,6,107216," S ARG=$E(LIN,1,I-1) S:CH="" "" I=I+1 S LIN=$E(LIN,I,999) Q"
+,7,36371,"QUOTE F I=I+1:1 S CH=$E(LIN,I) Q:CH=""""!(CH=Q)"
+,8,36371," Q:CH]"""" S ERR=6 G ^XINDX1"
+,9,0,"ALIVE ;enter here from taskman"
+,10,1," D SETUP^XINDX7 ;Get ready to process"
+,11,468,"A2 S RTN=$O(^UTILITY($J,RTN)) G ^XINDX5:RTN="""""
+,12,467," S INDLC=(RTN?1""|""1.4L.NP) D LOAD:'INDLC"
+,13,467," I $D(ZTQUEUED),$$S^%ZTLOAD S RTN=""~"",IND(""QUIT"")=1,ZTSTOP=1 G A2"
+,14,467," I 'INDDS,INDLC W !!?10,""Data Dictionaries"",! S INDDS=1"
+,15,467," D BEG"
+,16,467," G A2"
+,17,0," ;"
+,18,467,"LOAD S X=RTN,XCNP=0,DIF=""^UTILITY(""_$J_"",1,RTN,0,"" X ^%ZOSF(""TEST"") Q:'$T X ^%ZOSF(""LOAD"") S ^UTILITY($J,1,RTN,0,0)=XCNP-1"
+,19,467," I $D(^UTILITY($J,1,RTN,0,0)) S ^UTILITY($J,1,RTN,""RSUM"")=""B""_$$SUMB^XPDRSUM($NA(^UTILITY($J,1,RTN,0)))"
+,20,467," Q"
+,21,0,"BEG ;"
+,22,467," S %=INDLC*5 W:$X+10+%>IOM ! W RTN,$J("""",10+%-$L(RTN))"
+,23,467," S (IND(""DO""),IND(""SZT""),IND(""SZC""),LABO)=0,LC=$G(^UTILITY($J,1,RTN,0,0))"
+,24,467," I LC="""" W !,"">>>Routine '"",RTN,""' not found <<<"",! Q"
+,25,467," S TXT="""",LAB=$P(^UTILITY($J,1,RTN,0,1,0),"" "") I RTN'=$P(LAB,""("") D E^XINDX1(17)"
+,26,467," I 'INDLC,LAB[""("" D E^XINDX1(55) S LAB=$P(LAB,""("")"
+,27,0," ;if M routine(not compiled template or DD) and has more than 2 lines, check lines 1 & 2"
+,28,467," I 'INDLC,LC>2 D"
+,29,467," . N LABO S LABO=1"
+,30,467," . S LIN=$G(^UTILITY($J,1,RTN,0,1,0)),TXT=1"
+,31,0," . ;check 1st line (site/dev - ) patch 128"
+,32,467," . I $P(LIN,"";"",2,4)'?.E1""/"".E.1""-"".E D E^XINDX1(62)"
+,33,467," . S LIN=$G(^UTILITY($J,1,RTN,0,2,0)),TXT=2"
+,34,0," . ;check 2nd line (;;nn.nn[TV]nn;package;.anything)"
+,35,467," . I $P(LIN,"";"",3,99)'?1.2N1"".""1.2N.1(1""T"",1""V"").2N1"";""1A.AP1"";"".E D E^XINDX1(44) ;patch 121"
+,36,467," . I $L(INP(11)) X INP(11) ;Version number check"
+,37,467," . I $L(INP(12)) X INP(12) ;Patch number check"
+,38,467,"B5 F TXT=1:1:LC S LIN=^UTILITY($J,1,RTN,0,TXT,0),LN=$L(LIN),IND(""SZT"")=IND(""SZT"")+LN+2 D LN,ST ;Process Line"
+,39,467," S LAB="""",LABO=0,TXT=0,^UTILITY($J,1,RTN,0)=IND(""SZT"")_""^""_LC_""^""_IND(""SZC"")"
+,40,467," I IND(""SZT"")>INP(""MAX""),'INDLC S ERR=35,ERR(1)=IND(""SZT"") D ^XINDX1"
+,41,467," I IND(""SZT"")-IND(""SZC"")>INP(""CMAX""),'INDLC S ERR=58,ERR(1)=IND(""SZT"")-IND(""SZC"") D ^XINDX1"
+,42,467," D POSTRTN"
+,43,467," Q"
+,44,0," ;Proccess one line, LN = Length, LIN = Line."
+,45,44620,"LN K V S (ARG,GRB,IND(""COM""),IND(""DOL""),IND(""F""))="""",X=$P(LIN,"" "")"
+,46,44620," I '$L(X) S LABO=LABO+1 G CD"
+,47,5073," S (IND(""COM""),LAB)=$P(X,""(""),ARG=$P($P(X,""("",2),"")""),LABO=0,IND(""PP"")=X?1.8E1""("".E1"")"""
+,48,5073," D:$L(ARG) NE^XINDX3 ;Process formal parameters as New list."
+,49,5073," I 'INDLC,'$$VT^XINDX2(LAB) D E^XINDX1($S(LAB=$$CASE^XINDX52(LAB):37,1:55)) ;Check for bad labels"
+,50,5073," I $D(^UTILITY($J,1,RTN,""T"",LAB)) D E^XINDX1(15) G CD ;DUP label"
+,51,5073," S ^UTILITY($J,1,RTN,""T"",LAB)="""""
+,52,44620,"CD I LN>245 D:'(LN=246&($E(RTN,1,3)=""|dd"")) E^XINDX1(19) ;patch 119"
+,53,44620," D:LIN'?1.ANP E^XINDX1(18)"
+,54,44620," S LIN=$P(LIN,"" "",2,999),IND(""LCC"")=1"
+,55,44620," I LIN="""" D E^XINDX1(42) Q ;Blank line ;p110"
+,56,44620," S I=0 ;Watch the scope of I, counts dots"
+,57,44620," I "" .""[$E(LIN) D S X=$L($E(LIN,1,I),""."")-1,LIN=$E(LIN,I,999)"
+,58,10770," . F I=1:1:245 Q:"". ""'[$E(LIN,I)"
+,59,10770," . Q"
+,60,0," ;check dots against Do level IND(""DO""), IND(""DOL"")=dot level"
+,61,44620," D:'I&$G(IND(""DO1"")) E^XINDX1(51) S IND(""DO1"")=0 S:'I IND(""DO"")=0"
+,62,44620," I I D:X>IND(""DO"") E^XINDX1(51) S (IND(""DO""),IND(""DOL""))=X"
+,63,0," ;Count Comment lines, skip ;; lines"
+,64,44620," I $E(LIN)="";"",$E(LIN,2)'="";"" S IND(""SZC"")=IND(""SZC"")+$L(LIN) ;p110"
+,65,0," ;Process commands on line."
+,66,116081,"EE I LIN="""" D ^XINDX2 Q"
+,67,71461," S COM=$E(LIN),GK="""",ARG="""""
+,68,71461," I COM="";"" S LIN="""" G EE ;p110"
+,69,54870," I COM="" "" S ERR=$S(LIN?1."" "":13,1:0),LIN=$S(ERR:"""",1:$E(LIN,2,999)) D:ERR ^XINDX1 G EE"
+,70,53608," D SEP"
+,71,53608," S CM=$P(ARG,"":"",1),POST=$P(ARG,"":"",2,999),IND(""COM"")=IND(""COM"")_$C(9)_COM,ERR=48"
+,72,53608," D:ARG["":""&(POST']"""") ^XINDX1 S:POST]"""" GRB=GRB_$C(9)_POST,IND(""COM"")=IND(""COM"")_"":"""
+,73,0," ;SAC now allows lowercase commands"
+,74,53608," I CM?.E1L.E S CM=$$CASE^XINDX52(CM),COM=$E(CM) ;I IND(""LCC"") S IND(""LCC"")=0 D E^XINDX1(47)"
+,75,53608," I CM="""" D E^XINDX1(21) G EE ;Missing command"
+,76,53608," S CX=$G(IND(""CMD"",CM)) I CX="""" D G:CX="""" EE"
+,77,0," . I $E(CM)=""Z"" S CX=""^Z"" Q ;Proccess Z commands"
+,78,0," . D E^XINDX1(1) S LIN="""" Q"
+,79,53608," S CX=$P(CX,""^"",2,9)"
+,80,53608," D SEP I '$L(LIN),CH="" "" D E^XINDX1(13) ;trailing space"
+,81,53608," I ARG="""",""CGJMORSUWX""[COM S ERR=49 G ^XINDX1"
+,82,53608," I CX>0 D E^XINDX1(CX) S CX="""""
+,83,53608," D:$L(CX) @CX S:ARG'="""" GRB=GRB_$C(9)_ARG G EE"
+,84,0,"B S ERR=25 G ^XINDX1"
+,85,0,"C S ERR=29 G ^XINDX1"
+,86,0,"D G DG1^XINDX4"
+,87,0,"E Q:ARG="""" S ERR=7 G ^XINDX1"
+,88,1559,"F G:ARG]"""" FR^XINDX4 S IND(""F"")=1 Q"
+,89,1932,"G G DG^XINDX4"
+,90,11,"H Q:ARG'="""" S ERR=32 G ^XINDX1"
+,91,0,"J S ERR=36,ARG="""" G ^XINDX1"
+,92,2218,"K S ERR=$S(ARG?1""("".E:22,ARG?."" "":23,1:0) D:ERR ^XINDX1"
+,93,2218," G KL^XINDX3"
+,94,259,"L G LO^XINDX4"
+,95,30,"M G S^XINDX3"
+,96,1721,"N G NE^XINDX3"
+,97,0,"O S ERR=34 D ^XINDX1,O^XINDX3 Q"
+,98,7762,"Q Q:ARG="""" G Q^XINDX4"
+,99,85,"R S RDTIME=0 G RD^XINDX3"
+,100,17549,"S G S^XINDX3"
+,101,0,"TR Q ;What to process. p110"
+,102,72,"U S ARG=$P(ARG,"":"") Q"
+,103,0,"V S ARG="""",ERR=20 G ^XINDX1"
+,104,4584,"W G WR^XINDX4"
+,105,220,"X G XE^XINDX4"
+,106,0,"Z S ERR=2 D ^XINDX1 G ZC^XINDX4"
+,107,0," ;"
+,108,0," ;Save off items from line."
+,109,44620,"ST S R=LAB_$S(LABO:""+""_LABO,1:"""")"
+,110,0," ;Local variable, Global, Marked Items, Naked global, Internal ref, eXternal ref., Tag ref."
+,111,44620," S LOC="""" F S LOC=$O(V(LOC)),S="""" Q:LOC="""" F S S=$O(V(LOC,S)) Q:S="""" D SET"
+,112,44620," S ^UTILITY($J,1,RTN,""COM"",TXT)=IND(""COM"")"
+,113,44620," Q"
+,114,0," ;"
+,115,85079,"SET I V(LOC,S)]"""" F %=""!"",""~"" I V(LOC,S)[%,$G(^UTILITY($J,1,RTN,LOC,S))'[% S ^(S)=$G(^(S))_%"
+,116,85079," S %=0"
+,117,86891,"SE2 S ARG=$G(^UTILITY($J,1,RTN,LOC,S,%)) I $L(ARG)>230 S %=%+1 G SE2"
+,118,85079," S ^UTILITY($J,1,RTN,LOC,S,%)=ARG_R_V(LOC,S)_"","""
+,119,85079," Q"
+,120,0," ;"
+,121,0,"POSTRTN ;Do more overall checking"
+,122,467," N V,E,T,T1,T2"
+,123,467," S T="""" ;Check for missing Labels"
+,124,467," F S T=$O(^UTILITY($J,1,RTN,""I"",T)),T2=T Q:T="""" S T1=$G(^(T,0)) D"
+,125,2091," . Q:$E(T2,1,2)=""@("""
+,126,2044," . S:$E(T2,1,2)=""$$"" T2=$E(T2,3,99)"
+,127,2044," . I T2]"""",'$D(^UTILITY($J,1,RTN,""T"",$P(T2,""+"",1))) D"
+,128,0," . . F I=1:1:$L(T1,"","")-1 S LAB=$P(T1,"","",I),LABO=+$P(LAB,""+"",2),LAB=$P(LAB,""+""),E=14,E(1)=T D E^XINDX1(.E)"
+,129,0," . . Q"
+,130,2044," . Q"
+,131,467," S LAB="""",LABO=0 ;Check for valid label names"
+,132,467," I 'INDLC F S LAB=$O(^UTILITY($J,1,RTN,""T"",LAB)) Q:LAB="""" D"
+,133,5073," . I '$$VA^XINDX2(LAB) D E^XINDX1(55) Q"
+,134,5073," . D:'$$VT^XINDX2(LAB) E^XINDX1(37)"
+,135,5073," . Q"
+,136,467," S LAB="""",LABO=0 ;Check for valid variable names."
+,137,467," F S LAB=$O(^UTILITY($J,1,RTN,""L"",LAB)) Q:LAB="""" D"
+,138,15909," . D VLNF^XINDX3($P(LAB,""(""))"
+,139,15909," . Q"
+,140,467," Q"
+,141,0," ;"
+,142,0,"QUICK ;Quick, Just get a routine an print the results"
+,143,0," D QUICK^XINDX6()"
+,144,0," Q"
+Totals for XINDEX,,2446443,
+XINDX1,1,0,"XINDX1 ;ISC/REL,GRK,RWF - ERROR ROUTINE ;08/05/08 13:59"
+,2,2," ;;7.3;TOOLKIT;**20,61,66,68,110,121,128**;Apr 25, 1995;Build 1"
+,3,0," ; Per VHA Directive 2004-038, this routine should not be modified."
+,4,2," G A"
+,5,0,"E(ERR) ;"
+,6,75,"A N %,%1 ;TXT is the line of the error."
+,7,75," S ERTX=LAB_$S(LABO:""+""_LABO,1:"""")_$C(9),%1=$T(ERROR+ERR),ERTX=ERTX_$S(ERR:$P(%1,"";"",4,9),1:ERR) ;p110"
+,8,75," I ERTX[""|"" F %=1:1 S ERTX=$P(ERTX,""|"")_$S($D(ERR(%)):ERR(%),1:""??"")_$P(ERTX,""|"",%+1,99) Q:ERTX'[""|"""
+,9,75,"B I $P(%1,"";"",3)]"""" D Q:%1]"""" ;Don't flag kernel doing kernel."
+,10,0," . S %1=$P(%1,"";"",3)"
+,11,0," . F Q:RTN[$P(%1,"","") S %1=$P(%1,"","",2,99) ;quit if RTN[%1 or null."
+,12,0," . Q"
+,13,75," I ERR=17,$E(RTN)'=""%"",$E(LAB)=""%"" Q ;Don't flag %RTN w/o %."
+,14,0," ;Global is Error Line,tab,error tag,tab,error text"
+,15,75," S %=$G(^UTILITY($J,1,RTN,""E"",0))+1,^(0)=%,^(%)=TXT_$C(9)_ERTX"
+,16,75," Q"
+,17,0," ;"
+,18,0," ;F = Fatal, S = Standard, W = Warning, I = Info"
+,19,0,"ERROR ;"
+,20,0,"1 ;;;F - UNDEFINED COMMAND (rest of line not checked)."
+,21,0,"2 ;;;F - Non-standard (Undefined) 'Z' command."
+,22,0,"3 ;;XTRMON;F - Undefined Function."
+,23,0,"4 ;;;F - Undefined Special Variable."
+,24,0,"5 ;;;F - Unmatched Parenthesis."
+,25,0,"6 ;;;F - Unmatched Quotation Marks."
+,26,0,"7 ;;;F - ELSE Command followed by only one space."
+,27,0,"8 ;;;F - FOR Command did not contain '='."
+,28,0,"9 ;;;I - QUIT Command followed by only one space."
+,29,0,"10 ;;;F - Unrecognized argument in SET command."
+,30,0,"11 ;;;W - Invalid local variable name."
+,31,0,"12 ;;;W - Invalid global variable name."
+,32,0,"13 ;;;W - Blank(s) at end of line."
+,33,0,"14 ;;;F - Call to missing label '|' in this routine."
+,34,0,"15 ;;;W - Duplicate label. (M57)"
+,35,0,"16 ;;;F - Error in pattern code."
+,36,0,"17 ;;;W - First line label NOT routine name."
+,37,0,"18 ;;;W - Line contains a CONTROL (non-graphic) character."
+,38,0,"19 ;;;S - Line is longer than 245 bytes."
+,39,0,"20 ;;;S - View command used."
+,40,0,"21 ;;;F - General Syntax Error."
+,41,0,"22 ;;;S - Exclusive Kill."
+,42,0,"23 ;;;S - Unargumented Kill."
+,43,0,"24 ;;;S - Kill of an unsubscripted global."
+,44,0,"25 ;;;S - Break command used."
+,45,0,"26 ;;;S - Exclusive or Unargumented NEW command."
+,46,0,"27 ;;;S - $View function used."
+,47,0,"28 ;;ZOSV,ZIS,ZT;S - Non-standard $Z special variable used."
+,48,0,"29 ;;ZIS,ZTM;S - 'Close' command should be invoked through 'D ^%ZISC'."
+,49,0,"30 ;;;S - LABEL+OFFSET syntax."
+,50,0,"31 ;;ZOSV,ZIS,ZT;S - Non-standard $Z function used."
+,51,0,"32 ;;;S - 'HALT' command should be invoked through 'G ^XUSCLEAN'."
+,52,0,"33 ;;;S - Read command doesn't have a timeout."
+,53,0,"34 ;;ZIS;S - 'OPEN' command should be invoked through ^%ZIS."
+,54,0,"35 ;;;S - Routine exceeds SACC maximum size of 20000 (|)."
+,55,0,"36 ;;ZTM;S - Should use 'TASKMAN' instead of 'JOB' command."
+,56,0,"37 ;;;F - Label is not valid."
+,57,0,"38 ;;;F - Call to this |"
+,58,0,"39 ;;ZIS,XUS,XUP;S - Kill of a protected variable (|)."
+,59,0,"40 ;;;S - Space where a command should be."
+,60,0,"41 ;;;I - Star or pound READ used."
+,61,0,"42 ;;;W - Null line (no commands or comment)."
+,62,0,"43 ;;;F - Invalid or wrong number of arguments to a function."
+,63,0,"44 ;;;S - 2nd line of routine violates the SAC."
+,64,0,"45 ;;ZT,ZIS,XUTM,XTER;S - Set to a '%' global."
+,65,0,"46 ;;;F - Quoted string not followed by a separator."
+,66,0,"47 ;;;S - Lowercase command(s) used in line."
+,67,0,"48 ;;;F - Missing argument to a command post-conditional."
+,68,0,"49 ;;;F - Command missing an argument."
+,69,0,"50 ;;ZTM;S - Extended reference."
+,70,0,"51 ;;;F - Block structure mismatch."
+,71,0,"52 ;;;F - Reference to routine '^|'. That isn't in this UCI."
+,72,0,"53 ;;;F - Bad Number."
+,73,0,"54 ;;XG;S - Access to SSVN's restricted to Kernel."
+,74,0,"55 ;;;S - Violates VA programming standards."
+,75,0,"56 ;;;S - Patch number '|' missing from second line."
+,76,0,"57 ;;;S - Lower/Mixed case Variable name used."
+,77,0,"58 ;;;S - Routine code exceeds SACC maximum size of 15000 (|)."
+,78,0,"59 ;;;F - Bad WRITE syntax."
+,79,0,"60 ;;;S - Lock missing Timeout."
+,80,0,"61 ;;;S - Non-Incremental Lock."
+,81,0,"62 ;;;S - First line of routine violates the SAC."
+,82,0,"63 ;;;F - GO or DO mismatch from block structure (M45)."
+Totals for XINDX1,,529,
diff --git a/Tests/MumpsCoverage/Accounts_ReceivableTest.mcov b/Tests/MumpsCoverage/Accounts_ReceivableTest.mcov new file mode 100644 index 000000000..3c585f556 --- /dev/null +++ b/Tests/MumpsCoverage/Accounts_ReceivableTest.mcov @@ -0,0 +1,1445 @@ +%GO Global Output Utility +GT.M 17-APR-2012 17:18:27 ZWR +^ZZCOVERAGE("%RSEL","SRC")="1:0:0:0" +^ZZCOVERAGE("%RSEL","SRC",1)="1:0:0:0" +^ZZCOVERAGE("%RSEL","SRC",2)="1:0:0:0" +^ZZCOVERAGE("%RSEL","SRC",3)="1:0:0:0" +^ZZCOVERAGE("%RSEL","SRC",4)="1:0:0:0" +^ZZCOVERAGE("%RSEL","SRC",5)="1:0:0:0" +^ZZCOVERAGE("%RSEL","SRC",6)="1:0:0:0" +^ZZCOVERAGE("%RSEL","SRC",7)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init")="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",1)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",3)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",4)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",5)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",6)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",7)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",8)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",8,"FOR_LOOP",1)=1 +^ZZCOVERAGE("%RSEL","init",9)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",10)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",11)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",12)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",13)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",14)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",15)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",16)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",17)="1:0:0:0" +^ZZCOVERAGE("%RSEL","init",17,"FOR_LOOP",1)=2 +^ZZCOVERAGE("%RSEL","init",18)="2:0:0:0" +^ZZCOVERAGE("%RSEL","init",19)="2:0:0:0" +^ZZCOVERAGE("%RSEL","init",20)="2:0:0:0" +^ZZCOVERAGE("%RSEL","init",40)="1:0:0:0" +^ZZCOVERAGE("%RSEL","main")="1:32001:84004:116005" +^ZZCOVERAGE("%RSEL","main",1)="1:0:0:0" +^ZZCOVERAGE("%RSEL","main",2)="1:0:0:0" +^ZZCOVERAGE("%RSEL","main",3)="1:0:0:0" +^ZZCOVERAGE("%RSEL","main",3,"FOR_LOOP",1)=468 +^ZZCOVERAGE("%RSEL","main",4)="468:0:24003:24003" +^ZZCOVERAGE("%RSEL","main",5)="468:0:0:0" +^ZZCOVERAGE("%RSEL","main",6)="468:32001:48001:80002" +^ZZCOVERAGE("%RSEL","main",7)="467:0:12000:12000" +^ZZCOVERAGE("%RSEL","main",8)="467:0:0:0" +^ZZCOVERAGE("%RSEL","main",9)="467:0:0:0" +^ZZCOVERAGE("%RSEL","main",10)="467:0:0:0" +^ZZCOVERAGE("%RSEL","main",11)="1:0:0:0" +^ZZCOVERAGE("%RSEL","main",12)="1:0:0:0" +^ZZCOVERAGE("%RSEL","main",13)="1:0:0:0" +^ZZCOVERAGE("%RSEL","main",14)="1:0:0:0" +^ZZCOVERAGE("%RSEL","next")="1403:12001:20002:32003" +^ZZCOVERAGE("%RSEL","next",0)="1403:0:0:0" +^ZZCOVERAGE("%RSEL","next",1)="1403:12001:20002:32003" +^ZZCOVERAGE("%RSEL","next",1,"FOR_LOOP",1)=1403 +^ZZCOVERAGE("%RSEL","next",2)="1403:0:0:0" +^ZZCOVERAGE("%RSEL","save")="467:0:4001:4001" +^ZZCOVERAGE("%RSEL","save",1)="467:0:0:0" +^ZZCOVERAGE("%RSEL","save",5)="467:0:0:0" +^ZZCOVERAGE("%RSEL","save",6)="467:0:0:0" +^ZZCOVERAGE("%RSEL","save",7)="467:0:0:0" +^ZZCOVERAGE("%RSEL","save",8)="467:0:4001:4001" +^ZZCOVERAGE("%RSEL","save",9)="467:0:0:0" +^ZZCOVERAGE("%RSEL","search")="934:0:16001:16001" +^ZZCOVERAGE("%RSEL","search",0)="934:0:4000:4000" +^ZZCOVERAGE("%RSEL","search",1)="934:0:0:0" +^ZZCOVERAGE("%RSEL","search",2)="934:0:4001:4001" +^ZZCOVERAGE("%RSEL","search",2,"FOR_LOOP",1)=1868 +^ZZCOVERAGE("%RSEL","search",3)="934:0:8000:8000" +^ZZCOVERAGE("%RSEL","search",4)="934:0:0:0" +^ZZCOVERAGE("%RSEL","search",5)="934:0:0:0" +^ZZCOVERAGE("%RSEL","start")="468:0:4001:4001" +^ZZCOVERAGE("%RSEL","start",0)="468:0:0:0" +^ZZCOVERAGE("%RSEL","start",1)="468:0:0:0" +^ZZCOVERAGE("%RSEL","start",2)="468:0:0:0" +^ZZCOVERAGE("%RSEL","start",2,"FOR_LOOP",1)=936 +^ZZCOVERAGE("%RSEL","start",3)="468:0:0:0" +^ZZCOVERAGE("%RSEL","work")="467:20002:24001:44003" +^ZZCOVERAGE("%RSEL","work",1)="467:0:0:0" +^ZZCOVERAGE("%RSEL","work",2)="467:0:0:0" +^ZZCOVERAGE("%RSEL","work",3)="467:0:4000:4000" +^ZZCOVERAGE("%RSEL","work",4)="467:0:0:0" +^ZZCOVERAGE("%RSEL","work",6)="467:4000:12000:16000" +^ZZCOVERAGE("%RSEL","work",6,"FOR_LOOP",1)=3421 +^ZZCOVERAGE("%RSEL","work",7)="467:0:0:0" +^ZZCOVERAGE("%RSEL","work",8)="467:4001:0:4001" +^ZZCOVERAGE("%RSEL","work",9)="467:0:0:0" +^ZZCOVERAGE("%RSEL","work",10)="467:0:0:0" +^ZZCOVERAGE("%RSEL","work",11)="467:0:0:0" +^ZZCOVERAGE("%RSEL","work",12)="467:4000:0:4000" +^ZZCOVERAGE("%RSEL","work",13)="467:0:4000:4000" +^ZZCOVERAGE("%RSEL","work",14)="467:0:0:0" +^ZZCOVERAGE("%RSEL","work",15)="467:4001:4001:8002" +^ZZCOVERAGE("%RSEL","work",15,"FOR_LOOP",1)=934 +^ZZCOVERAGE("%RSEL","work",16)="467:0:0:0" +^ZZCOVERAGE("%ZIS","%ZIS")="2:0:0:0" +^ZZCOVERAGE("%ZIS","%ZIS",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS","%ZIS",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS","A",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS","A",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS","CLEAN")="3:0:0:0" +^ZZCOVERAGE("%ZIS","CLEAN",1)="3:0:0:0" +^ZZCOVERAGE("%ZIS","CLEAN",2)="3:0:0:0" +^ZZCOVERAGE("%ZIS","CLEAN",3)="3:0:0:0" +^ZZCOVERAGE("%ZIS","CLEAN",4)="3:0:0:0" +^ZZCOVERAGE("%ZIS","GETHOME")="2:0:0:0" +^ZZCOVERAGE("%ZIS","GETHOME",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS","GETHOME",1)="1:0:0:0" +^ZZCOVERAGE("%ZIS","GETHOME",3)="1:0:0:0" +^ZZCOVERAGE("%ZIS","GETHOME",4)="1:0:0:0" +^ZZCOVERAGE("%ZIS","GETHOME",5)="1:0:0:0" +^ZZCOVERAGE("%ZIS","GETHOME",6)="1:0:0:0" +^ZZCOVERAGE("%ZIS","GETHOME",7)="1:0:0:0" +^ZZCOVERAGE("%ZIS","HOME")="1:0:0:0" +^ZZCOVERAGE("%ZIS","HOME",1)="1:0:0:0" +^ZZCOVERAGE("%ZIS","HOME",2)="1:0:0:0" +^ZZCOVERAGE("%ZIS","INIT",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS","INIT",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS","INIT",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS","INIT",5)="2:0:0:0" +^ZZCOVERAGE("%ZIS","INIT",6)="2:0:0:0" +^ZZCOVERAGE("%ZIS","INIT",8)="2:0:0:0" +^ZZCOVERAGE("%ZIS","INIT",10)="2:0:0:0" +^ZZCOVERAGE("%ZIS","INIT",11)="2:0:0:0" +^ZZCOVERAGE("%ZIS","INIT",12)="2:0:0:0" +^ZZCOVERAGE("%ZIS","INIT",13)="2:0:0:0" +^ZZCOVERAGE("%ZIS","INIT",15)="2:0:0:0" +^ZZCOVERAGE("%ZIS","K2",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS","K2",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS","K2",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS","K2",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS","VIRTUAL")="2:0:0:0" +^ZZCOVERAGE("%ZIS","VIRTUAL",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS","VIRTUAL",4,"FOR_LOOP",1)=6 +^ZZCOVERAGE("%ZIS","VIRTUAL",5)="2:0:0:0" +^ZZCOVERAGE("%ZIS","VIRTUAL",7)="2:0:0:0" +^ZZCOVERAGE("%ZIS","VTLKUP")="4:0:0:0" +^ZZCOVERAGE("%ZIS","VTLKUP",0)="4:0:0:0" +^ZZCOVERAGE("%ZIS","VTLKUP",0,"FOR_LOOP",1)=8 +^ZZCOVERAGE("%ZIS","VTLKUP",1)="4:0:0:0" +^ZZCOVERAGE("%ZIS1","EX2",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","EX2",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","EXIT",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","EXIT",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","EXIT",5)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","EXIT",6)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","EXIT",7)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","EXIT",8)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","EXIT",9)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","G",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","IOP")="1:0:0:0" +^ZZCOVERAGE("%ZIS1","IOP",1)="1:0:0:0" +^ZZCOVERAGE("%ZIS1","K2")="2:0:0:0" +^ZZCOVERAGE("%ZIS1","K2",1)="4:0:0:0" +^ZZCOVERAGE("%ZIS1","K2",2)="4:0:0:0" +^ZZCOVERAGE("%ZIS1","K2",3)="4:0:0:0" +^ZZCOVERAGE("%ZIS1","K2",4)="4:0:0:0" +^ZZCOVERAGE("%ZIS1","KIL",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","KIL",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","KIL",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","L1",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","L1",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","L1",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","L1",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","L1",5)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","L1",6)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","L1",7)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","L1",8)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","L1",9)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","L1",10)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","L1",11)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","L1",12)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","LKUP")="2:0:0:0" +^ZZCOVERAGE("%ZIS1","LKUP",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","LKUP",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","LKUP",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","MAIN",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","R")="1:0:0:0" +^ZZCOVERAGE("%ZIS1","R",0)="1:0:0:0" +^ZZCOVERAGE("%ZIS1","R",1)="1:0:0:0" +^ZZCOVERAGE("%ZIS1","R",2)="1:0:0:0" +^ZZCOVERAGE("%ZIS1","RD",0)="1:0:0:0" +^ZZCOVERAGE("%ZIS1","RD",1)="1:0:0:0" +^ZZCOVERAGE("%ZIS1","RD",2)="1:0:0:0" +^ZZCOVERAGE("%ZIS1","RD",3)="1:0:0:0" +^ZZCOVERAGE("%ZIS1","RD",4)="1:0:0:0" +^ZZCOVERAGE("%ZIS1","RD",5)="1:0:0:0" +^ZZCOVERAGE("%ZIS1","SBR")="1:0:0:0" +^ZZCOVERAGE("%ZIS1","SBR",1)="1:0:0:0" +^ZZCOVERAGE("%ZIS1","SBR",2)="1:0:0:0" +^ZZCOVERAGE("%ZIS1","SBR",3)="1:0:0:0" +^ZZCOVERAGE("%ZIS1","SETQ")="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETQ",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETQ",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETQ",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETQ",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETQ",5)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETVAR",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETVAR",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETVAR",5)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETVAR",7)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETVAR",8)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETVAR",9)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETVAR",10)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETVAR",11)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETVAR",12)="2:0:0:0" +^ZZCOVERAGE("%ZIS1","SETVAR",13)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","CHECK",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","CHECK",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","CHECK",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","CHECK",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","CHECK",5)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","CHECK",6)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","IOPAR")="4:0:0:0" +^ZZCOVERAGE("%ZIS2","IOPAR",0)="4:0:0:0" +^ZZCOVERAGE("%ZIS2","IOPAR",1)="4:0:0:0" +^ZZCOVERAGE("%ZIS2","L2")="2:0:0:0" +^ZZCOVERAGE("%ZIS2","L2",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","OCPU",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","OOS",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","OOS",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","OTHCPU")="2:0:0:0" +^ZZCOVERAGE("%ZIS2","OTHCPU",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","OTHCPU",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","OTHCPU",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","OTHCPU",2,"FOR_LOOP",1)=4 +^ZZCOVERAGE("%ZIS2","OTHCPU",3)="4:0:0:0" +^ZZCOVERAGE("%ZIS2","OTHCPU",4)="4:0:0:0" +^ZZCOVERAGE("%ZIS2","OTHCPU",5)="4:0:0:0" +^ZZCOVERAGE("%ZIS2","OTHCPU",15)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","PTIME",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","QUECHK")="2:0:0:0" +^ZZCOVERAGE("%ZIS2","QUECHK",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","QUECHK",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","QUECHK",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","QUECHK",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","QUECHK",9)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","QUECHK",13)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","SLAVE",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","T2",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","T2",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","TMPVAR",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","TMPVAR",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","TMPVAR",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","TMPVAR",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","TMPVAR",10)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","TMPVAR",11)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","TMPVAR",12)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","TMPVAR",15)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","TMPVAR",16)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","TMPVAR",18)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","VTRM",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS2","VTRM",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","%ZIS3",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","%ZIS3",5)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","%ZIS3",6)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","%ZIS3",8)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","%ZIS3",9)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","%ZIS3",11)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","ALTP",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","ASKMAR",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","ASKMAR",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","MARGN")="2:0:0:0" +^ZZCOVERAGE("%ZIS3","MARGN",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","MARGN",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","MARGN",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","MARGN",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","Q",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","Q",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","Q",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","SETPAR")="2:0:0:0" +^ZZCOVERAGE("%ZIS3","SETPAR",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","SETPAR",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","ST")="2:0:0:0" +^ZZCOVERAGE("%ZIS3","ST",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","ST",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","ST",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","ST",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","STP",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","STP",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","STP",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","STP",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","TRM",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","TRM",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","TRM",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","TRM",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","TRM",5)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","W")="2:0:0:0" +^ZZCOVERAGE("%ZIS3","W",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","W",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS3","W",2)="1:0:0:0" +^ZZCOVERAGE("%ZIS3","W",3)="1:0:0:0" +^ZZCOVERAGE("%ZIS4","O")="2:0:0:0" +^ZZCOVERAGE("%ZIS4","O",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","O",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","O1")="2:0:0:0" +^ZZCOVERAGE("%ZIS4","O1",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","O1",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","O1",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","O1",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","OPAR",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","OPAR",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","OPAR",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","OPAR",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","OPAR",4)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","OPAR",5)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","OPAR",9)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","OPAR",10)="2:0:0:0" +^ZZCOVERAGE("%ZIS4","OPAR",12)="2:0:0:0" +^ZZCOVERAGE("%ZIS6","ANSBAK",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS6","ANSBAK",2)="2:0:0:0" +^ZZCOVERAGE("%ZIS6","ANSBAK",3)="2:0:0:0" +^ZZCOVERAGE("%ZIS6","OXECUTE",1)="2:0:0:0" +^ZZCOVERAGE("%ZIS6","QUIT",0)="2:0:0:0" +^ZZCOVERAGE("%ZIS6","QUIT",1)="2:0:0:0" +^ZZCOVERAGE("%ZISC","C0")="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",1)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",3)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",5)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",6)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",8)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",9)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",10)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",13)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",16)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",17)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",21)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",26)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",27)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",29)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",32)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",33)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",34)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",37)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",41)="1:0:0:0" +^ZZCOVERAGE("%ZISC","C0",43)="1:0:0:0" +^ZZCOVERAGE("%ZISC","CIOS")="1:0:0:0" +^ZZCOVERAGE("%ZISC","CIOS",0)="1:0:0:0" +^ZZCOVERAGE("%ZISC","CIOS",1)="1:0:0:0" +^ZZCOVERAGE("%ZISC","CIOS",2)="1:0:0:0" +^ZZCOVERAGE("%ZISC","CIOS",3)="1:0:0:0" +^ZZCOVERAGE("%ZISC","CIOS",4)="1:0:0:0" +^ZZCOVERAGE("%ZISC","CIOS",5)="1:0:0:0" +^ZZCOVERAGE("%ZISC","CIOS",6)="1:0:0:0" +^ZZCOVERAGE("%ZISC","CIOS",7)="1:0:0:0" +^ZZCOVERAGE("%ZISC","CIOS",8)="1:0:0:0" +^ZZCOVERAGE("%ZISC","CLOSPP")="1:0:0:0" +^ZZCOVERAGE("%ZISC","CLOSPP",0)="1:0:0:0" +^ZZCOVERAGE("%ZISC","CLOSPP",1)="1:0:0:0" +^ZZCOVERAGE("%ZISC","CLOSPP",2)="1:0:0:0" +^ZZCOVERAGE("%ZISC","END",0)="1:0:0:0" +^ZZCOVERAGE("%ZISC","END",2)="1:0:0:0" +^ZZCOVERAGE("%ZISC","END",4)="1:0:0:0" +^ZZCOVERAGE("%ZISC","FF")="1:0:0:0" +^ZZCOVERAGE("%ZISC","FF",0)="1:0:0:0" +^ZZCOVERAGE("%ZISC","FF",1)="1:0:0:0" +^ZZCOVERAGE("%ZISC","FF",2)="1:0:0:0" +^ZZCOVERAGE("%ZISC","RM")="1:0:0:0" +^ZZCOVERAGE("%ZISC","RM",0)="1:0:0:0" +^ZZCOVERAGE("%ZISC","RM",1)="1:0:0:0" +^ZZCOVERAGE("%ZISC","S1",0)="1:0:0:0" +^ZZCOVERAGE("%ZISC","S1",1)="1:0:0:0" +^ZZCOVERAGE("%ZISC","SETIO",2)="1:0:0:0" +^ZZCOVERAGE("%ZISC","SETIO",4)="1:0:0:0" +^ZZCOVERAGE("%ZISC","SETIO",5)="1:0:0:0" +^ZZCOVERAGE("%ZISC","SETIO",6)="1:0:0:0" +^ZZCOVERAGE("%ZISC","SETIO",7)="1:0:0:0" +^ZZCOVERAGE("%ZISC","SETIO",8)="1:0:0:0" +^ZZCOVERAGE("%ZISC","SETIO",9)="1:0:0:0" +^ZZCOVERAGE("%ZISC","SETIO",10)="1:0:0:0" +^ZZCOVERAGE("%ZISC","SETIO",12)="1:0:0:0" +^ZZCOVERAGE("%ZISC","SUBTYPE")="1:0:0:0" +^ZZCOVERAGE("%ZISC","SUBTYPE",1)="1:0:0:0" +^ZZCOVERAGE("%ZISC","SUBTYPE",2)="1:0:0:0" +^ZZCOVERAGE("%ZISC","SUBTYPE",3)="1:0:0:0" +^ZZCOVERAGE("%ZISUTL","LINEPORT")="1:0:0:0" +^ZZCOVERAGE("%ZISUTL","LINEPORT",0)="1:0:0:0" +^ZZCOVERAGE("%ZISUTL","LINEPORT",2)="1:0:0:0" +^ZZCOVERAGE("%ZISUTL","LINEPORT",3)="1:0:0:0" +^ZZCOVERAGE("%ZISUTL","LINEPORT",4)="1:0:0:0" +^ZZCOVERAGE("%ZISUTL","LINEPORT",5)="1:0:0:0" +^ZZCOVERAGE("%ZISUTL","LINEPORT",6)="1:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTIEN")="3:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTIEN",0)="3:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTIEN",1)="3:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTNAM")="3:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTNAM",0)="3:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTNAM",1)="3:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTNAM",2)="3:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTNAM",3)="3:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTNAM",5)="3:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTNAM",6)="3:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTSUB")="2:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTSUB",0)="2:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTSUB",1)="2:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTSUB",2)="2:0:0:0" +^ZZCOVERAGE("%ZISUTL","LNPRTSUB",3)="2:0:0:0" +^ZZCOVERAGE("%ZISUTL","SYMBOL")="2:0:0:0" +^ZZCOVERAGE("%ZISUTL","SYMBOL",0)="2:0:0:0" +^ZZCOVERAGE("%ZISUTL","SYMBOL",1)="2:0:0:0" +^ZZCOVERAGE("%ZISUTL","SYMBOL",3)="2:0:0:0" +^ZZCOVERAGE("%ZISUTL","SYMBOL",4)="2:0:0:0" +^ZZCOVERAGE("%ZISUTL","SYMBOL",5)="2:0:0:0" +^ZZCOVERAGE("%ZISUTL","SYMBOL",5,"FOR_LOOP",1)=40 +^ZZCOVERAGE("%ZISUTL","SYMBOL",6)="40:0:0:0" +^ZZCOVERAGE("%ZISUTL","SYMBOL",10)="2:0:0:0" +^ZZCOVERAGE("%ZOSV","GETENV")="2:0:0:0" +^ZZCOVERAGE("%ZOSV","GETENV",1)="2:0:0:0" +^ZZCOVERAGE("%ZOSV","GETENV",2)="2:0:0:0" +^ZZCOVERAGE("%ZOSV","GETENV",3)="2:0:0:0" +^ZZCOVERAGE("%ZOSV","LGR")="2:0:0:0" +^ZZCOVERAGE("%ZOSV","LGR",0)="2:0:0:0" +^ZZCOVERAGE("%ZOSV","LGR",1)="2:0:0:0" +^ZZCOVERAGE("%ZOSV","PRI")="1:0:0:0" +^ZZCOVERAGE("%ZOSV","PRI",0)="1:0:0:0" +^ZZCOVERAGE("%ZOSV","PRI",3)="1:0:0:0" +^ZZCOVERAGE("%ZOSV","RETURN")="2:0:4000:4000" +^ZZCOVERAGE("%ZOSV","RETURN",0)="2:0:0:0" +^ZZCOVERAGE("%ZOSV","RETURN",2)="2:0:0:0" +^ZZCOVERAGE("%ZOSV","RETURN",3)="2:0:0:0" +^ZZCOVERAGE("%ZOSV","RETURN",4)="2:0:4000:4000" +^ZZCOVERAGE("%ZOSV","RETURN",5)="2:0:0:0" +^ZZCOVERAGE("%ZOSV","RETURN",7)="2:0:0:0" +^ZZCOVERAGE("%ZOSV","TEMP")="2:0:0:0" +^ZZCOVERAGE("%ZOSV","TEMP",0)="2:0:0:0" +^ZZCOVERAGE("%ZOSV","TEMP",2)="2:0:0:0" +^ZZCOVERAGE("%ZOSV2","LOAD")="467:1000060:340019:1340079" +^ZZCOVERAGE("%ZOSV2","LOAD",0)="467:0:0:0" +^ZZCOVERAGE("%ZOSV2","LOAD",1)="467:0:8001:8001" +^ZZCOVERAGE("%ZOSV2","LOAD",2)="467:1000060:320018:1320078" +^ZZCOVERAGE("%ZOSV2","LOAD",2,"FOR_LOOP",1)=45087 +^ZZCOVERAGE("%ZOSV2","LOAD",3)="467:0:12000:12000" +^ZZCOVERAGE("DIALOG","EZBLD")="2:0:4000:4000" +^ZZCOVERAGE("DIALOG","EZBLD",0)="2:0:0:0" +^ZZCOVERAGE("DIALOG","EZBLD",2)="2:0:0:0" +^ZZCOVERAGE("DIALOG","EZBLD",3)="2:0:0:0" +^ZZCOVERAGE("DIALOG","EZBLD",4)="2:0:0:0" +^ZZCOVERAGE("DIALOG","EZBLD",5)="2:0:0:0" +^ZZCOVERAGE("DIALOG","EZBLD",6)="2:0:0:0" +^ZZCOVERAGE("DIALOG","EZBLD",7)="2:0:0:0" +^ZZCOVERAGE("DIALOG","EZBLD",8)="2:0:0:0" +^ZZCOVERAGE("DIALOG","EZBLD",9)="2:0:0:0" +^ZZCOVERAGE("DIALOG","PARAM")="2:0:0:0" +^ZZCOVERAGE("DIALOG","PARAM",0)="4:0:0:0" +^ZZCOVERAGE("DIALOG","PARAM",1)="2:0:0:0" +^ZZCOVERAGE("DIALOG","PARAM",2)="2:0:0:0" +^ZZCOVERAGE("DIALOG","PARAM",3)="2:0:0:0" +^ZZCOVERAGE("DIALOG","Q1",0)="2:0:0:0" +^ZZCOVERAGE("DIALOG","Q2")="2:0:0:0" +^ZZCOVERAGE("DIALOG","Q2",0)="2:0:0:0" +^ZZCOVERAGE("DIALOG","QEZ",0)="2:0:4000:4000" +^ZZCOVERAGE("DIALOG","QEZ",1)="2:0:0:0" +^ZZCOVERAGE("DIALOG","QP",0)="2:0:0:0" +^ZZCOVERAGE("DIC","A1",0)="2:0:0:0" +^ZZCOVERAGE("DIC","ASK",0)="2:0:0:0" +^ZZCOVERAGE("DIC","ASK",1)="2:0:0:0" +^ZZCOVERAGE("DIC","ASK",2)="2:0:0:0" +^ZZCOVERAGE("DIC","ASK",3)="2:0:0:0" +^ZZCOVERAGE("DIC","ASK",4)="2:0:0:0" +^ZZCOVERAGE("DIC","DIC")="2:0:0:0" +^ZZCOVERAGE("DIC","DIC",3)="2:0:0:0" +^ZZCOVERAGE("DIC","DIC",4)="2:0:0:0" +^ZZCOVERAGE("DIC","DIC",5)="2:0:0:0" +^ZZCOVERAGE("DIC","DIC",6)="2:0:0:0" +^ZZCOVERAGE("DIC","EN",0)="2:0:0:0" +^ZZCOVERAGE("DIC","EN",1)="2:0:0:0" +^ZZCOVERAGE("DIC","EN",2)="2:0:0:0" +^ZZCOVERAGE("DIC","EN",3)="2:0:0:0" +^ZZCOVERAGE("DIC","EN",4)="2:0:0:0" +^ZZCOVERAGE("DIC","EN",5)="2:0:0:0" +^ZZCOVERAGE("DIC","EN",6)="2:0:0:0" +^ZZCOVERAGE("DIC","EN",7)="2:0:0:0" +^ZZCOVERAGE("DIC","EN",8)="2:0:0:0" +^ZZCOVERAGE("DIC","EN",9)="2:0:0:0" +^ZZCOVERAGE("DIC","RTN",0)="2:0:0:0" +^ZZCOVERAGE("DIC","RTN",3)="2:0:0:0" +^ZZCOVERAGE("DIC","RTN",6)="2:0:0:0" +^ZZCOVERAGE("DIC","X",1)="2:0:0:0" +^ZZCOVERAGE("DIC","X",4)="2:0:0:0" +^ZZCOVERAGE("DIC","X",5)="2:0:0:0" +^ZZCOVERAGE("DIC","X",6)="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE")="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE",0)="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE",1)="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE",2)="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE",3)="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE",4)="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE",7)="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE",8)="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE",11)="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE",12)="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE",13)="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE",14)="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE",15)="2:0:0:0" +^ZZCOVERAGE("DIC0","GETFILE",16)="2:0:0:0" +^ZZCOVERAGE("DIC0","INIT")="2:0:0:0" +^ZZCOVERAGE("DIC0","INIT",1)="2:0:0:0" +^ZZCOVERAGE("DIC0","INIT",2)="2:0:0:0" +^ZZCOVERAGE("DIC0","INIT",3)="2:0:0:0" +^ZZCOVERAGE("DIC0","INIT",4)="2:0:0:0" +^ZZCOVERAGE("DIC0","INIT",5)="2:0:0:0" +^ZZCOVERAGE("DIC0","INIT",6)="2:0:0:0" +^ZZCOVERAGE("DIC0","INIT",7)="2:0:0:0" +^ZZCOVERAGE("DIC0","INIT",8)="2:0:0:0" +^ZZCOVERAGE("DIC0","SETIEN")="2:0:0:0" +^ZZCOVERAGE("DIC0","SETIEN",0)="2:0:0:0" +^ZZCOVERAGE("DIC0","SETIEN",1)="2:0:0:0" +^ZZCOVERAGE("DIC0","SETIEN",2)="2:0:0:0" +^ZZCOVERAGE("DIC0","SETIEN",3)="2:0:0:0" +^ZZCOVERAGE("DIC0","SETIEN",4)="2:0:0:0" +^ZZCOVERAGE("DIC0","SETIEN",5)="2:0:0:0" +^ZZCOVERAGE("DIC0","SETIEN",5,"FOR_LOOP",1)=2 +^ZZCOVERAGE("DIC0","SETIEN",6)="2:0:0:0" +^ZZCOVERAGE("DIC0","SETIEN",7)="2:0:0:0" +^ZZCOVERAGE("DIC1","B",0)="2:0:0:0" +^ZZCOVERAGE("DIC1","DIC1")="2:0:0:0" +^ZZCOVERAGE("DIC1","DIC1",3)="2:0:0:0" +^ZZCOVERAGE("DIC1","DIC1",4)="2:0:0:0" +^ZZCOVERAGE("DIC1","DIC1",5)="2:0:0:0" +^ZZCOVERAGE("DIC1","DO")="4:0:0:0" +^ZZCOVERAGE("DIC1","DO",1)="4:0:0:0" +^ZZCOVERAGE("DIC1","DO",2)="2:0:0:0" +^ZZCOVERAGE("DIC1","DO2",0)="2:0:0:0" +^ZZCOVERAGE("DIC1","DO2",1)="2:0:0:0" +^ZZCOVERAGE("DIC1","DO2",2)="2:0:0:0" +^ZZCOVERAGE("DIC1","DO2",3)="2:0:0:0" +^ZZCOVERAGE("DIC1","GETFA")="4:0:0:0" +^ZZCOVERAGE("DIC1","GETFA",0)="4:0:0:0" +^ZZCOVERAGE("DIC1","GETFA",2)="4:0:0:0" +^ZZCOVERAGE("DIC1","P",1)="2:0:0:0" +^ZZCOVERAGE("DIC1","P",2)="2:0:0:0" +^ZZCOVERAGE("DIC1","PROMPT",1)="2:0:0:0" +^ZZCOVERAGE("DIC1","PROMPT",2)="2:0:0:0" +^ZZCOVERAGE("DIC1","W",0)="2:0:0:0" +^ZZCOVERAGE("DIC1","W",0,"FOR_LOOP",1)=4 +^ZZCOVERAGE("DIC1","W",1)="3:0:0:0" +^ZZCOVERAGE("DIC1","W",2)="3:0:0:0" +^ZZCOVERAGE("DIC1","W",3)="2:0:0:0" +^ZZCOVERAGE("DIC1","W",4)="2:0:0:0" +^ZZCOVERAGE("DIC1","W",5)="2:0:0:0" +^ZZCOVERAGE("DIC1","W",6)="2:0:0:0" +^ZZCOVERAGE("DIC1","WOV")="1:0:0:0" +^ZZCOVERAGE("DIC1","WOV",0)="1:0:0:0" +^ZZCOVERAGE("DIC1","WOV",1)="1:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT")="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",0)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",1)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",2)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",3)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",3,"FOR_LOOP",1)=2 +^ZZCOVERAGE("DIC11","GETPRMT",4)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",8)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",9)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",10)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",11)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",12)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",13)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",14)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",15)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",16)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",17)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",18)="2:0:0:0" +^ZZCOVERAGE("DIC11","GETPRMT",19)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",0)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",1)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",2)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",3)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",4)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",6)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",8)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",9)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",11)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",12)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",13)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",14)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",15)="2:0:0:0" +^ZZCOVERAGE("DIC11","PR1",16)="2:0:0:0" +^ZZCOVERAGE("DIC11","PROMPT")="2:0:0:0" +^ZZCOVERAGE("DIC11","PROMPT",0)="2:0:0:0" +^ZZCOVERAGE("DIC11","PROMPT",1)="2:0:0:0" +^ZZCOVERAGE("DIC11","PROMPT",1,"FOR_LOOP",1)=2 +^ZZCOVERAGE("DIC11","PROMPT",2)="2:0:0:0" +^ZZCOVERAGE("DIC11","PROMPT",3)="2:0:0:0" +^ZZCOVERAGE("DIC11","PROMPT",5)="2:0:0:0" +^ZZCOVERAGE("DIC2","PGM")="4:0:0:0" +^ZZCOVERAGE("DIC2","PGM",0)="4:0:0:0" +^ZZCOVERAGE("DIC2","PGM",1)="4:0:0:0" +^ZZCOVERAGE("DIC2","PGM",2)="4:0:0:0" +^ZZCOVERAGE("DIC2","Q")="2:0:0:0" +^ZZCOVERAGE("DIC2","Q",0)="2:0:0:0" +^ZZCOVERAGE("DIC2","Q",1)="2:0:0:0" +^ZZCOVERAGE("DIC2","Q",2)="2:0:0:0" +^ZZCOVERAGE("DICL","DINDEX")="2:0:0:0" +^ZZCOVERAGE("DICL","DINDEX",0)="2:0:0:0" +^ZZCOVERAGE("DICL","DINDEX",1)="2:0:0:0" +^ZZCOVERAGE("DICL","DINDEX",2)="2:0:0:0" +^ZZCOVERAGE("DICL","DINDEX",5)="2:0:0:0" +^ZZCOVERAGE("DICL","DINDEX",6)="2:0:0:0" +^ZZCOVERAGE("DICUIX","I1",2)="2:0:0:0" +^ZZCOVERAGE("DICUIX","I1",3)="2:0:0:0" +^ZZCOVERAGE("DICUIX","I1",4)="2:0:0:0" +^ZZCOVERAGE("DICUIX","I1",5)="2:0:0:0" +^ZZCOVERAGE("DICUIX","INDEX")="2:0:0:0" +^ZZCOVERAGE("DICUIX","INDEX",0)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X1",2)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X1",8)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X1",9)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",2)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",3)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",4)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",5)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",8)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",11)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",12)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",13)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",14)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",15)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",15,"FOR_LOOP",1)=2 +^ZZCOVERAGE("DICUIX","X2",16)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",17)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",18)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",19)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",20)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",21)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",22)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",23)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",24)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",25)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",26)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",27)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",28)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",29)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",30)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",31)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",32)="2:0:0:0" +^ZZCOVERAGE("DICUIX","X2",33)="2:0:0:0" +^ZZCOVERAGE("DICUIX","XREF")="2:0:0:0" +^ZZCOVERAGE("DICUIX","XREF",0)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G1",2)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G1",3)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G1",4)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G2",2)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G2",3)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G3",2)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G30",1)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G4",2)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G4",3)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G4",4)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G4",5)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G4",6)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G4",7)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G5",2)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G5",3)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","G5",7)="2:0:0:0" +^ZZCOVERAGE("DICUIX1","GET")="2:0:0:0" +^ZZCOVERAGE("DICUIX1","GET",0)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C1",0)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C1",1)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C2",0)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C2",1)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C3",0)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C3",1)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C3",2)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C3",5)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",0)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",1)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",2)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",3)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",4)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",5)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",6)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",7)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",8)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",9)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",10)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",11)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",12)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",17)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",18)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",23)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C4",24)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C5",0)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C5",1)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C6",0)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C6",18)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C6",19)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C6",20)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C7",0)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","C7",7)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON1")="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON1",1)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON1",2)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON1",3)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON1",4)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON1",5)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON1",6)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON1",7)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON2")="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON2",1)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON2",2)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON2",3)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON2",4)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON2",5)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON2",6)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON2",7)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON2",8)="2:0:0:0" +^ZZCOVERAGE("DICUIX2","COMMON2",9)="2:0:0:0" +^ZZCOVERAGE("DIEFU","IENX",1)="2:0:0:0" +^ZZCOVERAGE("DIEFU","IENX",2)="2:0:0:0" +^ZZCOVERAGE("DIEFU","IENX",3)="2:0:0:0" +^ZZCOVERAGE("DIEFU","IENX",3,"FOR_LOOP",1)=4 +^ZZCOVERAGE("DIEFU","IENX",4)="2:0:0:0" +^ZZCOVERAGE("DIEFU","IENX",5)="2:0:0:0" +^ZZCOVERAGE("DILF","CREF")="4:0:0:0" +^ZZCOVERAGE("DILF","CREF",0)="4:0:0:0" +^ZZCOVERAGE("DILF","IENS")="2:0:0:0" +^ZZCOVERAGE("DILF","IENS",0)="2:0:0:0" +^ZZCOVERAGE("DILF","IENS",1)="2:0:0:0" +^ZZCOVERAGE("DILF","OREF")="2:0:0:0" +^ZZCOVERAGE("DILF","OREF",0)="2:0:0:0" +^ZZCOVERAGE("DILIBF","FNO")="2:0:0:0" +^ZZCOVERAGE("DILIBF","FNO",0)="2:0:0:0" +^ZZCOVERAGE("DILIBF","FNO",1)="2:0:0:0" +^ZZCOVERAGE("DILIBF","FNO",2)="2:0:0:0" +^ZZCOVERAGE("DIQGU","ENCREF",0)="4:0:0:0" +^ZZCOVERAGE("DIQGU","ENOREF",0)="2:0:0:0" +^ZZCOVERAGE("DIQGU","OR2")="2:0:0:0" +^ZZCOVERAGE("DIQGU","OR2",0)="2:0:0:0" +^ZZCOVERAGE("XINDEX","A2",0)="468:0:4000:4000" +^ZZCOVERAGE("XINDEX","A2",1)="467:0:0:0" +^ZZCOVERAGE("XINDEX","A2",2)="467:0:0:0" +^ZZCOVERAGE("XINDEX","A2",3)="467:4000:0:4000" +^ZZCOVERAGE("XINDEX","A2",4)="467:0:4000:4000" +^ZZCOVERAGE("XINDEX","A2",5)="467:0:0:0" +^ZZCOVERAGE("XINDEX","ALIVE",1)="1:0:0:0" +^ZZCOVERAGE("XINDEX","B5",0)="467:188012:220012:408024" +^ZZCOVERAGE("XINDEX","B5",0,"FOR_LOOP",1)=44620 +^ZZCOVERAGE("XINDEX","B5",1)="467:20000:8000:28000" +^ZZCOVERAGE("XINDEX","B5",2)="467:4000:0:4000" +^ZZCOVERAGE("XINDEX","B5",3)="467:0:0:0" +^ZZCOVERAGE("XINDEX","B5",4)="467:4000:0:4000" +^ZZCOVERAGE("XINDEX","B5",5)="467:0:0:0" +^ZZCOVERAGE("XINDEX","BEG")="467:2460149:2872194:5332343" +^ZZCOVERAGE("XINDEX","BEG",1)="467:8000:0:8000" +^ZZCOVERAGE("XINDEX","BEG",2)="467:4000:0:4000" +^ZZCOVERAGE("XINDEX","BEG",3)="467:0:4000:4000" +^ZZCOVERAGE("XINDEX","BEG",4)="467:0:4000:4000" +^ZZCOVERAGE("XINDEX","BEG",5)="467:4001:0:4001" +^ZZCOVERAGE("XINDEX","BEG",7)="467:0:0:0" +^ZZCOVERAGE("XINDEX","BEG",8)="467:0:0:0" +^ZZCOVERAGE("XINDEX","BEG",9)="467:0:0:0" +^ZZCOVERAGE("XINDEX","BEG",11)="467:4000:0:4000" +^ZZCOVERAGE("XINDEX","BEG",12)="467:0:4000:4000" +^ZZCOVERAGE("XINDEX","BEG",14)="467:0:0:0" +^ZZCOVERAGE("XINDEX","BEG",15)="467:0:0:0" +^ZZCOVERAGE("XINDEX","BEG",16)="467:0:0:0" +^ZZCOVERAGE("XINDEX","CD",0)="44620:32001:36002:68003" +^ZZCOVERAGE("XINDEX","CD",1)="44620:40002:60004:100006" +^ZZCOVERAGE("XINDEX","CD",2)="44620:40001:60002:100003" +^ZZCOVERAGE("XINDEX","CD",3)="44620:36002:44004:80006" +^ZZCOVERAGE("XINDEX","CD",4)="44620:28000:40002:68002" +^ZZCOVERAGE("XINDEX","CD",5)="44620:28002:52001:80003" +^ZZCOVERAGE("XINDEX","CD",6)="10770:28003:20000:48003" +^ZZCOVERAGE("XINDEX","CD",6,"FOR_LOOP",1)=57531 +^ZZCOVERAGE("XINDEX","CD",7)="10770:24004:16000:40004" +^ZZCOVERAGE("XINDEX","CD",9)="44620:60005:40004:100009" +^ZZCOVERAGE("XINDEX","CD",10)="44620:44003:48005:92008" +^ZZCOVERAGE("XINDEX","CD",12)="44620:52004:44002:96006" +^ZZCOVERAGE("XINDEX","EE",0)="116081:148007:200014:348021" +^ZZCOVERAGE("XINDEX","EE",1)="71461:44004:44002:88006" +^ZZCOVERAGE("XINDEX","EE",2)="71461:100007:80003:180010" +^ZZCOVERAGE("XINDEX","EE",3)="54870:44001:48001:92002" +^ZZCOVERAGE("XINDEX","EE",4)="53608:88008:100009:188017" +^ZZCOVERAGE("XINDEX","EE",5)="53608:72006:68004:140010" +^ZZCOVERAGE("XINDEX","EE",6)="53608:76005:72004:148009" +^ZZCOVERAGE("XINDEX","EE",8)="53608:60003:64005:124008" +^ZZCOVERAGE("XINDEX","EE",9)="53608:48003:72003:120006" +^ZZCOVERAGE("XINDEX","EE",10)="53608:52002:96008:148010" +^ZZCOVERAGE("XINDEX","EE",13)="53608:52003:44001:96004" +^ZZCOVERAGE("XINDEX","EE",14)="53608:96007:112006:208013" +^ZZCOVERAGE("XINDEX","EE",15)="53608:24001:52004:76005" +^ZZCOVERAGE("XINDEX","EE",16)="53608:52005:88007:140012" +^ZZCOVERAGE("XINDEX","EE",17)="53608:128008:208017:336025" +^ZZCOVERAGE("XINDEX","F")="1559:4000:4001:8001" +^ZZCOVERAGE("XINDEX","F",0)="1559:4000:0:4000" +^ZZCOVERAGE("XINDEX","G")="1932:56003:96009:152012" +^ZZCOVERAGE("XINDEX","G",0)="1932:4000:8002:12002" +^ZZCOVERAGE("XINDEX","H")="11:0:0:0" +^ZZCOVERAGE("XINDEX","H",0)="11:0:0:0" +^ZZCOVERAGE("XINDEX","K")="2218:40001:24002:64003" +^ZZCOVERAGE("XINDEX","K",0)="2218:4000:4000:8000" +^ZZCOVERAGE("XINDEX","K",1)="2218:0:4001:4001" +^ZZCOVERAGE("XINDEX","L")="259:4001:4000:8001" +^ZZCOVERAGE("XINDEX","L",0)="259:0:0:0" +^ZZCOVERAGE("XINDEX","LN",0)="44620:68005:104005:172010" +^ZZCOVERAGE("XINDEX","LN",1)="44620:40001:64004:104005" +^ZZCOVERAGE("XINDEX","LN",2)="5073:12000:4001:16001" +^ZZCOVERAGE("XINDEX","LN",3)="5073:4000:8000:12000" +^ZZCOVERAGE("XINDEX","LN",4)="5073:20001:0:20001" +^ZZCOVERAGE("XINDEX","LN",5)="5073:20003:12002:32005" +^ZZCOVERAGE("XINDEX","LN",6)="5073:12002:16000:28002" +^ZZCOVERAGE("XINDEX","LOAD")="467:88003:196019:284022" +^ZZCOVERAGE("XINDEX","LOAD",0)="467:88003:196019:284022" +^ZZCOVERAGE("XINDEX","LOAD",1)="467:0:0:0" +^ZZCOVERAGE("XINDEX","LOAD",2)="467:0:0:0" +^ZZCOVERAGE("XINDEX","M")="30:4000:0:4000" +^ZZCOVERAGE("XINDEX","M",0)="30:0:0:0" +^ZZCOVERAGE("XINDEX","N")="1721:88005:80004:168009" +^ZZCOVERAGE("XINDEX","N",0)="1721:4000:0:4000" +^ZZCOVERAGE("XINDEX","POSTRTN")="467:108009:96003:204012" +^ZZCOVERAGE("XINDEX","POSTRTN",1)="467:0:0:0" +^ZZCOVERAGE("XINDEX","POSTRTN",2)="467:0:0:0" +^ZZCOVERAGE("XINDEX","POSTRTN",3)="467:12000:8000:20000" +^ZZCOVERAGE("XINDEX","POSTRTN",3,"FOR_LOOP",1)=2558 +^ZZCOVERAGE("XINDEX","POSTRTN",4)="2091:0:0:0" +^ZZCOVERAGE("XINDEX","POSTRTN",5)="2044:4000:0:4000" +^ZZCOVERAGE("XINDEX","POSTRTN",6)="2044:4000:0:4000" +^ZZCOVERAGE("XINDEX","POSTRTN",9)="2044:0:0:0" +^ZZCOVERAGE("XINDEX","POSTRTN",10)="467:0:4000:4000" +^ZZCOVERAGE("XINDEX","POSTRTN",11)="467:12002:16001:28003" +^ZZCOVERAGE("XINDEX","POSTRTN",11,"FOR_LOOP",1)=5540 +^ZZCOVERAGE("XINDEX","POSTRTN",12)="5073:0:4000:4000" +^ZZCOVERAGE("XINDEX","POSTRTN",13)="5073:8000:4000:12000" +^ZZCOVERAGE("XINDEX","POSTRTN",14)="5073:0:0:0" +^ZZCOVERAGE("XINDEX","POSTRTN",15)="467:0:0:0" +^ZZCOVERAGE("XINDEX","POSTRTN",16)="467:28001:20001:48002" +^ZZCOVERAGE("XINDEX","POSTRTN",16,"FOR_LOOP",1)=16376 +^ZZCOVERAGE("XINDEX","POSTRTN",17)="15909:40006:40001:80007" +^ZZCOVERAGE("XINDEX","POSTRTN",18)="15909:0:0:0" +^ZZCOVERAGE("XINDEX","POSTRTN",19)="467:0:0:0" +^ZZCOVERAGE("XINDEX","Q")="7762:12000:20001:32001" +^ZZCOVERAGE("XINDEX","Q",0)="7762:4000:16001:20001" +^ZZCOVERAGE("XINDEX","QUOTE")="36371:188012:232009:420021" +^ZZCOVERAGE("XINDEX","QUOTE",0)="36371:156010:192008:348018" +^ZZCOVERAGE("XINDEX","QUOTE",0,"FOR_LOOP",1)=323268 +^ZZCOVERAGE("XINDEX","QUOTE",1)="36371:20002:20001:40003" +^ZZCOVERAGE("XINDEX","R")="85:0:8001:8001" +^ZZCOVERAGE("XINDEX","R",0)="85:0:0:0" +^ZZCOVERAGE("XINDEX","S")="17549:716055:988057:1704112" +^ZZCOVERAGE("XINDEX","S",0)="17549:28003:28003:56006" +^ZZCOVERAGE("XINDEX","SE2",0)="86891:176010:272017:448027" +^ZZCOVERAGE("XINDEX","SE2",1)="85079:264015:376016:640031" +^ZZCOVERAGE("XINDEX","SE2",2)="85079:72005:112010:184015" +^ZZCOVERAGE("XINDEX","SEP")="107216:736054:648038:1384092" +^ZZCOVERAGE("XINDEX","SEP",0)="107216:580045:440030:1020075" +^ZZCOVERAGE("XINDEX","SEP",0,"FOR_LOOP",1)=1019212 +^ZZCOVERAGE("XINDEX","SEP",1)="107216:120007:144005:264012" +^ZZCOVERAGE("XINDEX","SET")="85079:772044:1124063:1896107" +^ZZCOVERAGE("XINDEX","SET",0)="85079:176007:168008:344015" +^ZZCOVERAGE("XINDEX","SET",0,"FOR_LOOP",1)=74812 +^ZZCOVERAGE("XINDEX","SET",1)="85079:64005:144010:208015" +^ZZCOVERAGE("XINDEX","ST",0)="44620:68001:56004:124005" +^ZZCOVERAGE("XINDEX","ST",2)="44620:260012:376038:636050" +^ZZCOVERAGE("XINDEX","ST",2,"FOR_LOOP",1)=85813 +^ZZCOVERAGE("XINDEX","ST",2,"FOR_LOOP",2)=126272 +^ZZCOVERAGE("XINDEX","ST",3)="44620:224014:184014:408028" +^ZZCOVERAGE("XINDEX","ST",4)="44620:0:0:0" +^ZZCOVERAGE("XINDEX","U")="72:0:0:0" +^ZZCOVERAGE("XINDEX","U",0)="72:0:0:0" +^ZZCOVERAGE("XINDEX","W")="4584:156009:200014:356023" +^ZZCOVERAGE("XINDEX","W",0)="4584:0:16001:16001" +^ZZCOVERAGE("XINDEX","X")="220:0:0:0" +^ZZCOVERAGE("XINDEX","X",0)="220:0:0:0" +^ZZCOVERAGE("XINDEX","XINDEX")="1:32002:36000:68002" +^ZZCOVERAGE("XINDEX","XINDEX",3)="1:0:0:0" +^ZZCOVERAGE("XINDX1","A",0)="75:0:4000:4000" +^ZZCOVERAGE("XINDX1","A",1)="75:0:0:0" +^ZZCOVERAGE("XINDX1","A",2)="75:0:0:0" +^ZZCOVERAGE("XINDX1","B",0)="75:0:0:0" +^ZZCOVERAGE("XINDX1","B",4)="75:0:0:0" +^ZZCOVERAGE("XINDX1","B",6)="75:0:0:0" +^ZZCOVERAGE("XINDX1","B",7)="75:0:0:0" +^ZZCOVERAGE("XINDX1","E")="73:0:4000:4000" +^ZZCOVERAGE("XINDX1","E",0)="73:0:0:0" +^ZZCOVERAGE("XINDX1","XINDX1")="2:0:0:0" +^ZZCOVERAGE("XINDX1","XINDX1",3)="2:0:0:0" +^ZZCOVERAGE("XINDX10","ASK")="1:0:0:0" +^ZZCOVERAGE("XINDX10","ASK",1)="1:0:0:0" +^ZZCOVERAGE("XINDX10","ASK",2)="1:0:0:0" +^ZZCOVERAGE("XINDX10","ASK",3)="1:0:0:0" +^ZZCOVERAGE("XINDX10","ASK",8)="1:0:0:0" +^ZZCOVERAGE("XINDX2","%")="44620:132010:232014:364024" +^ZZCOVERAGE("XINDX2","%",0)="44620:96008:92005:188013" +^ZZCOVERAGE("XINDX2","%",0,"FOR_LOOP",1)=62810 +^ZZCOVERAGE("XINDX2","%",1)="44620:16001:68003:84004" +^ZZCOVERAGE("XINDX2","ARG")="329774:1516089:2124136:3640225" +^ZZCOVERAGE("XINDX2","ARG",1)="330498:328020:360021:688041" +^ZZCOVERAGE("XINDX2","ARG",2)="262221:228015:296022:524037" +^ZZCOVERAGE("XINDX2","ARG",3)="226556:260020:468034:728054" +^ZZCOVERAGE("XINDX2","ARG",4)="126854:104004:160011:264015" +^ZZCOVERAGE("XINDX2","ARG",5)="117750:136007:148011:284018" +^ZZCOVERAGE("XINDX2","ARG",6)="88629:60001:96003:156004" +^ZZCOVERAGE("XINDX2","ARG",7)="88424:80005:100006:180011" +^ZZCOVERAGE("XINDX2","ARG",8)="86550:72002:108007:180009" +^ZZCOVERAGE("XINDX2","ARGG")="18715:288018:352019:640037" +^ZZCOVERAGE("XINDX2","ARGG",0)="18715:76007:84005:160012" +^ZZCOVERAGE("XINDX2","ARGG",0,"FOR_LOOP",1)=49672 +^ZZCOVERAGE("XINDX2","ARGS")="44410:464031:676031:1140062" +^ZZCOVERAGE("XINDX2","ARGS",1)="63125:620038:844037:1464075" +^ZZCOVERAGE("XINDX2","ARGS",1,"FOR_LOOP",1)=291597 +^ZZCOVERAGE("XINDX2","ARGS",2)="63125:24001:60004:84005" +^ZZCOVERAGE("XINDX2","DN")="44410:208011:284017:492028" +^ZZCOVERAGE("XINDX2","DN",0)="44410:44003:108008:152011" +^ZZCOVERAGE("XINDX2","DN",1)="44410:152008:144006:296014" +^ZZCOVERAGE("XINDX2","EXT",1)="1970:4000:8001:12001" +^ZZCOVERAGE("XINDX2","EXT",2)="1970:0:0:0" +^ZZCOVERAGE("XINDX2","EXT",3)="1970:8001:12001:20002" +^ZZCOVERAGE("XINDX2","EXT",4)="1970:0:4000:4000" +^ZZCOVERAGE("XINDX2","FLUSH")="94:0:0:0" +^ZZCOVERAGE("XINDX2","FLUSH",0)="94:0:0:0" +^ZZCOVERAGE("XINDX2","FLUSH",1)="94:0:0:0" +^ZZCOVERAGE("XINDX2","FLUSH",1,"FOR_LOOP",1)=415 +^ZZCOVERAGE("XINDX2","FLUSH",2)="94:0:0:0" +^ZZCOVERAGE("XINDX2","FNC")="12:0:0:0" +^ZZCOVERAGE("XINDX2","FNC",0)="12:0:0:0" +^ZZCOVERAGE("XINDX2","FNC",1)="12:0:0:0" +^ZZCOVERAGE("XINDX2","FNC",2)="12:0:0:0" +^ZZCOVERAGE("XINDX2","FNC",3)="12:0:0:0" +^ZZCOVERAGE("XINDX2","FNC",4)="12:0:0:0" +^ZZCOVERAGE("XINDX2","FUN")="29121:340019:424027:764046" +^ZZCOVERAGE("XINDX2","FUN",0)="29121:36004:40002:76006" +^ZZCOVERAGE("XINDX2","FUN",1)="23452:48002:72003:120005" +^ZZCOVERAGE("XINDX2","FUN",2)="23452:20000:44003:64003" +^ZZCOVERAGE("XINDX2","FUN",3)="23393:96004:56005:152009" +^ZZCOVERAGE("XINDX2","FUN",3,"FOR_LOOP",1)=147754 +^ZZCOVERAGE("XINDX2","FUN",4)="23393:48003:56005:104008" +^ZZCOVERAGE("XINDX2","FUN",5)="23393:60004:92005:152009" +^ZZCOVERAGE("XINDX2","GLO",0)="9104:28002:28001:56003" +^ZZCOVERAGE("XINDX2","GLO",1)="9104:12001:20001:32002" +^ZZCOVERAGE("XINDX2","GLO",2)="9104:16000:28001:44001" +^ZZCOVERAGE("XINDX2","GLO",3)="9104:36002:80004:116006" +^ZZCOVERAGE("XINDX2","GLO",4)="9104:8000:4000:12000" +^ZZCOVERAGE("XINDX2","INC")="322910:416022:652029:1068051" +^ZZCOVERAGE("XINDX2","INC",0)="365505:320019:472020:792039" +^ZZCOVERAGE("XINDX2","INC2")="42595:104006:148008:252014" +^ZZCOVERAGE("XINDX2","INC2",0)="42595:48001:40003:88004" +^ZZCOVERAGE("XINDX2","LOC")="99702:576031:736052:1312083" +^ZZCOVERAGE("XINDX2","LOC",0)="99702:144010:156013:300023" +^ZZCOVERAGE("XINDX2","LOC",1)="99702:124004:148011:272015" +^ZZCOVERAGE("XINDX2","LOC",2)="99702:212011:272014:484025" +^ZZCOVERAGE("XINDX2","LOC",3)="99702:52005:96006:148011" +^ZZCOVERAGE("XINDX2","NAK",0)="996:0:0:0" +^ZZCOVERAGE("XINDX2","NAK",1)="996:0:0:0" +^ZZCOVERAGE("XINDX2","PAT")="205:4000:0:4000" +^ZZCOVERAGE("XINDX2","PAT",0)="205:0:0:0" +^ZZCOVERAGE("XINDX2","PAT",1)="205:4000:0:4000" +^ZZCOVERAGE("XINDX2","PAT",1,"FOR_LOOP",1)=457 +^ZZCOVERAGE("XINDX2","PAT",2)="205:0:0:0" +^ZZCOVERAGE("XINDX2","PATCODE")="457:4000:4000:8000" +^ZZCOVERAGE("XINDX2","PATCODE",0)="457:0:4000:4000" +^ZZCOVERAGE("XINDX2","PATCODE",1)="358:4000:0:4000" +^ZZCOVERAGE("XINDX2","PATCODE",1,"FOR_LOOP",1)=791 +^ZZCOVERAGE("XINDX2","PATCODE",2)="358:0:0:0" +^ZZCOVERAGE("XINDX2","PATCODE",3)="358:0:0:0" +^ZZCOVERAGE("XINDX2","PATCODE",4)="358:0:0:0" +^ZZCOVERAGE("XINDX2","PATQ")="99:4000:4000:8000" +^ZZCOVERAGE("XINDX2","PATQ",0)="99:0:4000:4000" +^ZZCOVERAGE("XINDX2","PATQ",0,"FOR_LOOP",1)=247 +^ZZCOVERAGE("XINDX2","PATQ",1)="99:4000:0:4000" +^ZZCOVERAGE("XINDX2","PATQ",2)="99:0:0:0" +^ZZCOVERAGE("XINDX2","PEEK")="112687:168013:248022:416035" +^ZZCOVERAGE("XINDX2","PEEK",0)="112687:120009:164010:284019" +^ZZCOVERAGE("XINDX2","PEEKDN")="17373:56002:40000:96002" +^ZZCOVERAGE("XINDX2","PEEKDN",0)="17373:48002:32000:80002" +^ZZCOVERAGE("XINDX2","REPCNT")="457:0:0:0" +^ZZCOVERAGE("XINDX2","REPCNT",0)="457:0:0:0" +^ZZCOVERAGE("XINDX2","REPCNT",0,"FOR_LOOP",1)=1004 +^ZZCOVERAGE("XINDX2","REPCNT",1)="457:0:0:0" +^ZZCOVERAGE("XINDX2","REPCNT",2)="457:0:0:0" +^ZZCOVERAGE("XINDX2","SPV",1)="3699:0:8001:8001" +^ZZCOVERAGE("XINDX2","SPV",2)="3699:0:0:0" +^ZZCOVERAGE("XINDX2","ST")="110835:464030:648049:1112079" +^ZZCOVERAGE("XINDX2","ST",0)="110835:192009:248021:440030" +^ZZCOVERAGE("XINDX2","ST",1)="110835:100008:156011:256019" +^ZZCOVERAGE("XINDX2","ST",2)="110835:76005:116005:192010" +^ZZCOVERAGE("XINDX2","TEXT",0)="59:0:0:0" +^ZZCOVERAGE("XINDX2","TEXT",1)="59:0:0:0" +^ZZCOVERAGE("XINDX2","TEXT",2)="59:0:0:0" +^ZZCOVERAGE("XINDX2","TEXT",3)="59:0:0:0" +^ZZCOVERAGE("XINDX2","UP")="44410:116012:180012:296024" +^ZZCOVERAGE("XINDX2","UP",1)="44410:112012:116006:228018" +^ZZCOVERAGE("XINDX2","VA")="5073:16001:20000:36001" +^ZZCOVERAGE("XINDX2","VA",0)="5073:4000:12000:16000" +^ZZCOVERAGE("XINDX2","VA",1)="5073:8000:4000:12000" +^ZZCOVERAGE("XINDX2","VT")="10205:4001:24002:28003" +^ZZCOVERAGE("XINDX2","VT",0)="10205:0:8000:8000" +^ZZCOVERAGE("XINDX2","VT",1)="10205:0:4000:4000" +^ZZCOVERAGE("XINDX3","A",0)="8136:36001:12001:48002" +^ZZCOVERAGE("XINDX3","ASM")="312:12001:0:12001" +^ZZCOVERAGE("XINDX3","ASM",0)="312:0:0:0" +^ZZCOVERAGE("XINDX3","ASM",1)="312:8001:0:8001" +^ZZCOVERAGE("XINDX3","ASM",1,"FOR_LOOP",1)=2110 +^ZZCOVERAGE("XINDX3","ASM",2)="312:0:0:0" +^ZZCOVERAGE("XINDX3","DN")="498:4000:4000:8000" +^ZZCOVERAGE("XINDX3","DN",0)="498:0:4000:4000" +^ZZCOVERAGE("XINDX3","DN",1)="498:4000:0:4000" +^ZZCOVERAGE("XINDX3","FL")="63250:152007:260014:412021" +^ZZCOVERAGE("XINDX3","FL",1)="63250:72000:144009:216009" +^ZZCOVERAGE("XINDX3","FL",2)="63250:64006:80004:144010" +^ZZCOVERAGE("XINDX3","INC")="145482:224018:308026:532044" +^ZZCOVERAGE("XINDX3","INC",0)="145482:188015:196015:384030" +^ZZCOVERAGE("XINDX3","KL",1)="2218:0:4000:4000" +^ZZCOVERAGE("XINDX3","KL1")="28:0:0:0" +^ZZCOVERAGE("XINDX3","KL1",0)="28:0:0:0" +^ZZCOVERAGE("XINDX3","KL2")="724:4000:28000:32000" +^ZZCOVERAGE("XINDX3","KL2",0)="724:0:0:0" +^ZZCOVERAGE("XINDX3","KL2",1)="724:0:4000:4000" +^ZZCOVERAGE("XINDX3","KL2",2)="724:0:0:0" +^ZZCOVERAGE("XINDX3","KL3")="3320:12002:36002:48004" +^ZZCOVERAGE("XINDX3","KL3",0)="3320:4000:8000:12000" +^ZZCOVERAGE("XINDX3","KL3",1)="3320:4001:4000:8001" +^ZZCOVERAGE("XINDX3","KL5",0)="3320:0:20002:20002" +^ZZCOVERAGE("XINDX3","MULT")="498:8001:4000:12001" +^ZZCOVERAGE("XINDX3","MULT",0)="498:4001:0:4001" +^ZZCOVERAGE("XINDX3","MULT",1)="498:4000:4000:8000" +^ZZCOVERAGE("XINDX3","MULT",1,"FOR_LOOP",1)=2401 +^ZZCOVERAGE("XINDX3","MULT",2)="498:0:0:0" +^ZZCOVERAGE("XINDX3","N2",0)="23604:68004:36003:104007" +^ZZCOVERAGE("XINDX3","N2",3)="11802:16002:4000:20002" +^ZZCOVERAGE("XINDX3","N2",4)="187:0:0:0" +^ZZCOVERAGE("XINDX3","N2",5)="187:0:0:0" +^ZZCOVERAGE("XINDX3","N2",6)="11628:12001:20002:32003" +^ZZCOVERAGE("XINDX3","N2",7)="11628:12000:8000:20000" +^ZZCOVERAGE("XINDX3","NE")="779:32002:16001:48003" +^ZZCOVERAGE("XINDX3","NE",1)="2500:4000:4000:8000" +^ZZCOVERAGE("XINDX3","NE",2)="2500:4000:20000:24000" +^ZZCOVERAGE("XINDX3","PEEK")="498:0:0:0" +^ZZCOVERAGE("XINDX3","PEEK",0)="498:0:0:0" +^ZZCOVERAGE("XINDX3","PEEKDN")="39:0:0:0" +^ZZCOVERAGE("XINDX3","PEEKDN",0)="39:0:0:0" +^ZZCOVERAGE("XINDX3","RD",0)="85:0:0:0" +^ZZCOVERAGE("XINDX3","RD1",0)="278:0:4001:4001" +^ZZCOVERAGE("XINDX3","RD1",3)="193:0:4000:4000" +^ZZCOVERAGE("XINDX3","RD1",4)="85:0:0:0" +^ZZCOVERAGE("XINDX3","RD1",5)="85:0:0:0" +^ZZCOVERAGE("XINDX3","RD2")="85:0:4000:4000" +^ZZCOVERAGE("XINDX3","RD2",0)="255:0:0:0" +^ZZCOVERAGE("XINDX3","RD2",1)="170:0:0:0" +^ZZCOVERAGE("XINDX3","RD2",2)="170:0:4000:4000" +^ZZCOVERAGE("XINDX3","RD2",3)="85:0:0:0" +^ZZCOVERAGE("XINDX3","RD3")="108:0:0:0" +^ZZCOVERAGE("XINDX3","RD3",0)="161:0:0:0" +^ZZCOVERAGE("XINDX3","RD3",1)="37:0:0:0" +^ZZCOVERAGE("XINDX3","RD3",2)="37:0:0:0" +^ZZCOVERAGE("XINDX3","S",1)="17579:48005:56003:104008" +^ZZCOVERAGE("XINDX3","S2",0)="110559:164008:220011:384019" +^ZZCOVERAGE("XINDX3","S2",1)="92980:64007:96005:160012" +^ZZCOVERAGE("XINDX3","S2",2)="92980:52004:100005:152009" +^ZZCOVERAGE("XINDX3","S2",3)="87238:60005:68003:128008" +^ZZCOVERAGE("XINDX3","S2",4)="63916:68007:68004:136011" +^ZZCOVERAGE("XINDX3","S2",5)="846:0:0:0" +^ZZCOVERAGE("XINDX3","S2",6)="846:0:4000:4000" +^ZZCOVERAGE("XINDX3","S2",10)="63916:56004:60003:116007" +^ZZCOVERAGE("XINDX3","S2",11)="62481:40002:60003:100005" +^ZZCOVERAGE("XINDX3","S2",12)="62313:56003:56005:112008" +^ZZCOVERAGE("XINDX3","S2",13)="61815:76007:152010:228017" +^ZZCOVERAGE("XINDX3","UP")="498:8000:4000:12000" +^ZZCOVERAGE("XINDX3","UP",1)="498:8000:4000:12000" +^ZZCOVERAGE("XINDX3","VLN",1)="15909:32002:16001:48003" +^ZZCOVERAGE("XINDX3","VLN",2)="15909:44002:28003:72005" +^ZZCOVERAGE("XINDX3","VLNF")="15909:120006:60005:180011" +^ZZCOVERAGE("XINDX3","VLNF",0)="15909:32002:12001:44003" +^ZZCOVERAGE("XINDX4","CNG")="2186:0:24001:24001" +^ZZCOVERAGE("XINDX4","CNG",0)="2186:0:0:0" +^ZZCOVERAGE("XINDX4","CNG",2)="2186:0:8001:8001" +^ZZCOVERAGE("XINDX4","CNG",2,"FOR_LOOP",1)=2202 +^ZZCOVERAGE("XINDX4","CNG",3)="2186:0:12000:12000" +^ZZCOVERAGE("XINDX4","DG",0)="8937:20003:16000:36003" +^ZZCOVERAGE("XINDX4","DG",1)="8937:12000:16001:28001" +^ZZCOVERAGE("XINDX4","DG",2)="8937:8001:20002:28003" +^ZZCOVERAGE("XINDX4","DG",3)="8937:16000:12000:28000" +^ZZCOVERAGE("XINDX4","DG",4)="8937:4000:12001:16001" +^ZZCOVERAGE("XINDX4","DG",5)="8937:0:12002:12002" +^ZZCOVERAGE("XINDX4","DG",6)="8937:12001:12000:24001" +^ZZCOVERAGE("XINDX4","DG",7)="8937:12000:20003:32003" +^ZZCOVERAGE("XINDX4","DG",8)="8937:24001:4001:28002" +^ZZCOVERAGE("XINDX4","DG",9)="8937:4000:12001:16001" +^ZZCOVERAGE("XINDX4","DG",10)="8937:16001:28001:44002" +^ZZCOVERAGE("XINDX4","DG",11)="8937:8000:12000:20000" +^ZZCOVERAGE("XINDX4","DG",12)="8937:4000:16002:20002" +^ZZCOVERAGE("XINDX4","DG",13)="8937:8000:12002:20002" +^ZZCOVERAGE("XINDX4","DG",14)="8937:0:4000:4000" +^ZZCOVERAGE("XINDX4","DG",15)="8937:36002:32002:68004" +^ZZCOVERAGE("XINDX4","DG",16)="8937:8001:4001:12002" +^ZZCOVERAGE("XINDX4","DG",17)="8387:12002:4000:16002" +^ZZCOVERAGE("XINDX4","DG1")="8449:168011:180013:348024" +^ZZCOVERAGE("XINDX4","DG1",0)="8449:12001:16001:28002" +^ZZCOVERAGE("XINDX4","FR",0)="525:0:4001:4001" +^ZZCOVERAGE("XINDX4","FR",1)="525:0:0:0" +^ZZCOVERAGE("XINDX4","FR",2)="525:0:0:0" +^ZZCOVERAGE("XINDX4","INSIDE")="2202:4001:32001:36002" +^ZZCOVERAGE("XINDX4","INSIDE",0)="2202:0:16000:16000" +^ZZCOVERAGE("XINDX4","INSIDE",1)="2202:0:4000:4000" +^ZZCOVERAGE("XINDX4","INSIDE",2)="2202:4001:4000:8001" +^ZZCOVERAGE("XINDX4","LO",1)="259:0:0:0" +^ZZCOVERAGE("XINDX4","LO",2)="259:0:0:0" +^ZZCOVERAGE("XINDX4","LO",3)="259:0:0:0" +^ZZCOVERAGE("XINDX4","LO",4)="259:0:4000:4000" +^ZZCOVERAGE("XINDX4","LO",4,"FOR_LOOP",1)=260 +^ZZCOVERAGE("XINDX4","LO",5)="260:0:0:0" +^ZZCOVERAGE("XINDX4","LO",6)="260:0:0:0" +^ZZCOVERAGE("XINDX4","LO",7)="260:0:0:0" +^ZZCOVERAGE("XINDX4","LO",8)="89:0:0:0" +^ZZCOVERAGE("XINDX4","LO",9)="89:0:0:0" +^ZZCOVERAGE("XINDX4","LO",10)="89:4001:0:4001" +^ZZCOVERAGE("XINDX4","LO",12)="259:0:0:0" +^ZZCOVERAGE("XINDX4","LO",13)="259:0:0:0" +^ZZCOVERAGE("XINDX4","LOOP")="14735:44003:108008:152011" +^ZZCOVERAGE("XINDX4","LOOP",0)="14735:28002:72005:100007" +^ZZCOVERAGE("XINDX4","LOOP",0,"FOR_LOOP",1)=68121 +^ZZCOVERAGE("XINDX4","LOOP",1)="14735:4000:32003:36003" +^ZZCOVERAGE("XINDX4","PAREN")="2638:24000:36004:60004" +^ZZCOVERAGE("XINDX4","PAREN",0)="2638:4000:8000:12000" +^ZZCOVERAGE("XINDX4","PAREN",1)="2638:20000:16001:36001" +^ZZCOVERAGE("XINDX4","PAREN",1,"FOR_LOOP",1)=50171 +^ZZCOVERAGE("XINDX4","PAREN",2)="2638:0:8002:8002" +^ZZCOVERAGE("XINDX4","PAREN",3)="2638:0:0:0" +^ZZCOVERAGE("XINDX4","PRUNE")="2186:8001:16001:24002" +^ZZCOVERAGE("XINDX4","PRUNE",0)="2186:8001:4000:12001" +^ZZCOVERAGE("XINDX4","PRUNE",1)="2186:0:8001:8001" +^ZZCOVERAGE("XINDX4","PRUNE",1,"FOR_LOOP",1)=2186 +^ZZCOVERAGE("XINDX4","PRUNE",2)="2186:0:4000:4000" +^ZZCOVERAGE("XINDX4","PRUNE",2,"FOR_LOOP",1)=2187 +^ZZCOVERAGE("XINDX4","PRUNE",3)="2186:0:0:0" +^ZZCOVERAGE("XINDX4","Q",1)="747:8000:0:8000" +^ZZCOVERAGE("XINDX4","Q",2)="747:0:0:0" +^ZZCOVERAGE("XINDX4","QUOTE")="2402:28002:28000:56002" +^ZZCOVERAGE("XINDX4","QUOTE",0)="2402:20002:20000:40002" +^ZZCOVERAGE("XINDX4","QUOTE",0,"FOR_LOOP",1)=23674 +^ZZCOVERAGE("XINDX4","QUOTE",1)="2402:0:0:0" +^ZZCOVERAGE("XINDX4","QUOTE",2)="2402:8000:4000:12000" +^ZZCOVERAGE("XINDX4","ST")="8937:24000:16002:40002" +^ZZCOVERAGE("XINDX4","ST",0)="8937:12000:8000:20000" +^ZZCOVERAGE("XINDX4","ST",1)="8937:8000:8002:16002" +^ZZCOVERAGE("XINDX4","WR",0)="4584:12001:12000:24001" +^ZZCOVERAGE("XINDX4","WR",1)="4584:0:8000:8000" +^ZZCOVERAGE("XINDX4","WR",2)="4584:72004:56006:128010" +^ZZCOVERAGE("XINDX4","WR",2,"FOR_LOOP",1)=27607 +^ZZCOVERAGE("XINDX4","WR",3)="23023:8002:32003:40005" +^ZZCOVERAGE("XINDX4","WR",4)="20835:12000:32001:44001" +^ZZCOVERAGE("XINDX4","WR",5)="20835:24002:8001:32003" +^ZZCOVERAGE("XINDX4","WR",6)="20835:24000:36002:60002" +^ZZCOVERAGE("XINDX4","WR",7)="20835:0:0:0" +^ZZCOVERAGE("XINDX4","WR",8)="4584:4000:0:4000" +^ZZCOVERAGE("XINDX4","XE",0)="220:0:0:0" +^ZZCOVERAGE("XINDX4","XE",1)="220:0:0:0" +^ZZCOVERAGE("XINDX5","A",0)="468:0:4000:4000" +^ZZCOVERAGE("XINDX5","A",1)="467:28002:24000:52002" +^ZZCOVERAGE("XINDX5","A",1,"FOR_LOOP",1)=4011 +^ZZCOVERAGE("XINDX5","A",2)="467:0:0:0" +^ZZCOVERAGE("XINDX5","AA")="3544:48004:68006:116010" +^ZZCOVERAGE("XINDX5","AA",0)="3544:8002:16003:24005" +^ZZCOVERAGE("XINDX5","AA",1)="1902:0:4000:4000" +^ZZCOVERAGE("XINDX5","AA",2)="1902:4001:0:4001" +^ZZCOVERAGE("XINDX5","AA",3)="1902:12001:4001:16002" +^ZZCOVERAGE("XINDX5","AA",4)="1902:12000:32002:44002" +^ZZCOVERAGE("XINDX5","AA",5)="1902:0:0:0" +^ZZCOVERAGE("XINDX5","AA",6)="1209:0:0:0" +^ZZCOVERAGE("XINDX5","AA",7)="1209:8000:4000:12000" +^ZZCOVERAGE("XINDX5","AA",8)="1209:0:0:0" +^ZZCOVERAGE("XINDX5","AA",9)="1642:0:4000:4000" +^ZZCOVERAGE("XINDX5","AA",10)="1594:0:0:0" +^ZZCOVERAGE("XINDX5","AA",11)="1594:4000:4000:8000" +^ZZCOVERAGE("XINDX5","AA",12)="1642:0:0:0" +^ZZCOVERAGE("XINDX5","B",0)="1:0:0:0" +^ZZCOVERAGE("XINDX5","CLEAN",1)="1:0:0:0" +^ZZCOVERAGE("XINDX5","CLEAN",2)="1:0:0:0" +^ZZCOVERAGE("XINDX5","CLEAN",3)="1:0:0:0" +^ZZCOVERAGE("XINDX5","END",0)="1:0:0:0" +^ZZCOVERAGE("XINDX5","END",1)="1:0:0:0" +^ZZCOVERAGE("XINDX5","END",2)="1:0:0:0" +^ZZCOVERAGE("XINDX5","END",3)="1:0:0:0" +^ZZCOVERAGE("XINDX5","VTAG")="4320:12000:16001:28001" +^ZZCOVERAGE("XINDX5","VTAG",0)="4320:12000:8001:20001" +^ZZCOVERAGE("XINDX5","VTAG",1)="4320:0:4000:4000" +^ZZCOVERAGE("XINDX5","XINDX5",3)="1:0:0:0" +^ZZCOVERAGE("XINDX5","XINDX5",4)="1:0:0:0" +^ZZCOVERAGE("XINDX5","XINDX5",5)="1:0:0:0" +^ZZCOVERAGE("XINDX5","XINDX5",7)="1:0:0:0" +^ZZCOVERAGE("XINDX51","B")="1:0:4001:4001" +^ZZCOVERAGE("XINDX51","B",0)="1:0:0:0" +^ZZCOVERAGE("XINDX51","B",1)="1:0:0:0" +^ZZCOVERAGE("XINDX51","B",3)="1:0:4001:4001" +^ZZCOVERAGE("XINDX51","B",3,"FOR_LOOP",1)=468 +^ZZCOVERAGE("XINDX51","B",4)="1:0:0:0" +^ZZCOVERAGE("XINDX51","B",6)="1:0:0:0" +^ZZCOVERAGE("XINDX51","BHDR")="60:0:4000:4000" +^ZZCOVERAGE("XINDX51","BHDR",0)="60:0:4000:4000" +^ZZCOVERAGE("XINDX51","BHDR",1)="60:0:0:0" +^ZZCOVERAGE("XINDX51","END",0)="1:0:0:0" +^ZZCOVERAGE("XINDX51","HD")="60:0:0:0" +^ZZCOVERAGE("XINDX51","HD",0)="60:0:0:0" +^ZZCOVERAGE("XINDX51","HD",1)="60:0:0:0" +^ZZCOVERAGE("XINDX51","HD1")="1:0:0:0" +^ZZCOVERAGE("XINDX51","HD1",0)="1:0:0:0" +^ZZCOVERAGE("XINDX51","HD1",1)="1:0:0:0" +^ZZCOVERAGE("XINDX51","HD2")="60:4000:0:4000" +^ZZCOVERAGE("XINDX51","HD2",0)="60:4000:0:4000" +^ZZCOVERAGE("XINDX51","HD2",1)="60:0:0:0" +^ZZCOVERAGE("XINDX51","WAIT")="1:0:0:0" +^ZZCOVERAGE("XINDX51","WAIT",0)="1:0:0:0" +^ZZCOVERAGE("XINDX51","WAIT",1)="1:0:0:0" +^ZZCOVERAGE("XINDX51","WAIT",2)="1:0:0:0" +^ZZCOVERAGE("XINDX51","WERR")="60:0:0:0" +^ZZCOVERAGE("XINDX51","WERR",0)="60:0:0:0" +^ZZCOVERAGE("XINDX51","WERR",1)="60:0:0:0" +^ZZCOVERAGE("XINDX51","WERR",2)="60:0:0:0" +^ZZCOVERAGE("XINDX51","WERR",2,"FOR_LOOP",1)=135 +^ZZCOVERAGE("XINDX51","WERR",3)="75:0:0:0" +^ZZCOVERAGE("XINDX51","WERR",4)="75:0:0:0" +^ZZCOVERAGE("XINDX51","WERR",5)="75:0:0:0" +^ZZCOVERAGE("XINDX51","WERR",6)="75:0:0:0" +^ZZCOVERAGE("XINDX51","WERR",7)="60:0:0:0" +^ZZCOVERAGE("XINDX51","WORL")="70:0:0:0" +^ZZCOVERAGE("XINDX51","WORL",0)="70:0:0:0" +^ZZCOVERAGE("XINDX51","WORL",1)="70:0:0:0" +^ZZCOVERAGE("XINDX51","WORL",2)="70:0:0:0" +^ZZCOVERAGE("XINDX51","WORL",3)="70:0:0:0" +^ZZCOVERAGE("XINDX51","WORL",3,"FOR_LOOP",1)=76 +^ZZCOVERAGE("XINDX51","WORL",4)="70:0:0:0" +^ZZCOVERAGE("XINDX52","CASE")="2:0:0:0" +^ZZCOVERAGE("XINDX52","CASE",0)="2:0:0:0" +^ZZCOVERAGE("XINDX52","CASE",1)="2:0:0:0" +^ZZCOVERAGE("XINDX6","ANS")="2:0:0:0" +^ZZCOVERAGE("XINDX6","ANS",0)="2:0:0:0" +^ZZCOVERAGE("XINDX6","ANS",1)="2:0:0:0" +^ZZCOVERAGE("XINDX6","ANS",1,"FOR_LOOP",1)=2 +^ZZCOVERAGE("XINDX6","ANS",2)="2:0:0:0" +^ZZCOVERAGE("XINDX6","ASKRTN")="1:4000:0:4000" +^ZZCOVERAGE("XINDX6","ASKRTN",1)="1:0:0:0" +^ZZCOVERAGE("XINDX6","ASKRTN",1,"FOR_LOOP",1)=468 +^ZZCOVERAGE("XINDX6","ASKRTN",2)="1:4000:0:4000" +^ZZCOVERAGE("XINDX6","ASKRTN",2,"FOR_LOOP",1)=468 +^ZZCOVERAGE("XINDX6","ASKRTN",3)="1:0:0:0" +^ZZCOVERAGE("XINDX6","DEVICE",0)="1:0:0:0" +^ZZCOVERAGE("XINDX6","DEVICE",2)="1:0:0:0" +^ZZCOVERAGE("XINDX6","DEVICE",3)="1:0:0:0" +^ZZCOVERAGE("XINDX6","L7",0)="1:0:0:0" +^ZZCOVERAGE("XINDX6","L7",1)="1:0:0:0" +^ZZCOVERAGE("XINDX6","NY")="1:0:0:0" +^ZZCOVERAGE("XINDX6","NY",0)="1:0:0:0" +^ZZCOVERAGE("XINDX6","PARAM")="1:0:0:0" +^ZZCOVERAGE("XINDX6","PARAM",1)="1:0:0:0" +^ZZCOVERAGE("XINDX6","PARAM",2)="1:0:0:0" +^ZZCOVERAGE("XINDX6","PARAM",2,"FOR_LOOP",1)=10 +^ZZCOVERAGE("XINDX6","PARAM",3)="1:0:0:0" +^ZZCOVERAGE("XINDX6","PARAM",4)="1:0:0:0" +^ZZCOVERAGE("XINDX6","PARAM",5)="1:0:0:0" +^ZZCOVERAGE("XINDX6","PARAM",6)="1:0:0:0" +^ZZCOVERAGE("XINDX6","PARAM",7)="1:0:0:0" +^ZZCOVERAGE("XINDX6","RD")="2:0:0:0" +^ZZCOVERAGE("XINDX6","RD",0)="2:0:0:0" +^ZZCOVERAGE("XINDX6","XINDX6",5)="1:0:0:0" +^ZZCOVERAGE("XINDX6","XINDX6",6)="1:0:0:0" +^ZZCOVERAGE("XINDX6","XINDX6",7)="1:0:0:0" +^ZZCOVERAGE("XINDX6","XINDX6",8)="1:0:0:0" +^ZZCOVERAGE("XINDX6","XINDX6",9)="1:0:0:0" +^ZZCOVERAGE("XINDX6","XINDX6",10)="1:0:0:0" +^ZZCOVERAGE("XINDX6","XINDX6",11)="1:0:0:0" +^ZZCOVERAGE("XINDX6","XINDX6",12)="1:0:0:0" +^ZZCOVERAGE("XINDX6","XINDX6",13)="1:0:0:0" +^ZZCOVERAGE("XINDX6","YN")="1:0:0:0" +^ZZCOVERAGE("XINDX6","YN",0)="1:0:0:0" +^ZZCOVERAGE("XINDX7","BUILD")="1:0:0:0" +^ZZCOVERAGE("XINDX7","BUILD",0)="1:0:0:0" +^ZZCOVERAGE("XINDX7","BUILD",1)="1:0:0:0" +^ZZCOVERAGE("XINDX7","BUILD",1,"FOR_LOOP",1)=10 +^ZZCOVERAGE("XINDX7","BUILD",2)="9:0:0:0" +^ZZCOVERAGE("XINDX7","BUILD",3)="6:0:0:0" +^ZZCOVERAGE("XINDX7","BUILD",3,"FOR_LOOP",1)=85 +^ZZCOVERAGE("XINDX7","BUILD",4)="79:0:0:0" +^ZZCOVERAGE("XINDX7","BUILD",5)="79:0:0:0" +^ZZCOVERAGE("XINDX7","BUILD",6)="6:0:0:0" +^ZZCOVERAGE("XINDX7","BUILD",7)="1:0:0:0" +^ZZCOVERAGE("XINDX7","HDR")="2:0:0:0" +^ZZCOVERAGE("XINDX7","HDR",0)="2:0:0:0" +^ZZCOVERAGE("XINDX7","HDR",1)="2:0:0:0" +^ZZCOVERAGE("XINDX7","HDR",2)="1:0:0:0" +^ZZCOVERAGE("XINDX7","HDR",3)="1:0:0:0" +^ZZCOVERAGE("XINDX7","HDR",4)="1:0:0:0" +^ZZCOVERAGE("XINDX7","HDR",5)="1:0:0:0" +^ZZCOVERAGE("XINDX7","HDR",6)="2:0:0:0" +^ZZCOVERAGE("XINDX7","HDR",7)="2:0:0:0" +^ZZCOVERAGE("XINDX7","SETUP")="1:0:0:0" +^ZZCOVERAGE("XINDX7","SETUP",1)="1:0:0:0" +^ZZCOVERAGE("XINDX7","SETUP",2)="1:0:0:0" +^ZZCOVERAGE("XINDX7","SETUP",3)="1:0:0:0" +^ZZCOVERAGE("XINDX7","SETUP",4)="1:0:0:0" +^ZZCOVERAGE("XINDX7","SETUP",6)="1:0:0:0" +^ZZCOVERAGE("XINDX7","SETUP",7)="1:0:0:0" +^ZZCOVERAGE("XINDX7","SETUP",7,"FOR_LOOP",1)=468 +^ZZCOVERAGE("XINDX7","SETUP",8)="1:0:0:0" +^ZZCOVERAGE("XINDX7","SETUP",9)="1:0:0:0" +^ZZCOVERAGE("XINDX7","SETUP",10)="1:0:0:0" +^ZZCOVERAGE("XINDX9","ADD")="406841:436032:684041:1120073" +^ZZCOVERAGE("XINDX9","ADD",0)="598820:552042:692040:1244082" +^ZZCOVERAGE("XINDX9","AR")="197699:748039:1052073:1800112" +^ZZCOVERAGE("XINDX9","AR",0)="197699:708036:936061:1644097" +^ZZCOVERAGE("XINDX9","CASE")="23461:28003:92005:120008" +^ZZCOVERAGE("XINDX9","CASE",0)="23461:12002:48003:60005" +^ZZCOVERAGE("XINDX9","CASE",1)="23461:12001:28000:40001" +^ZZCOVERAGE("XINDX9","DN")="45002:204010:248016:452026" +^ZZCOVERAGE("XINDX9","DN",0)="45002:176008:196011:372019" +^ZZCOVERAGE("XINDX9","DN",1)="45002:16001:24003:40004" +^ZZCOVERAGE("XINDX9","EXT",1)="1970:4000:12001:16001" +^ZZCOVERAGE("XINDX9","FNC")="29146:96005:104009:200014" +^ZZCOVERAGE("XINDX9","FNC",0)="29146:28001:20003:48004" +^ZZCOVERAGE("XINDX9","FNC",1)="29146:44002:72005:116007" +^ZZCOVERAGE("XINDX9","FNC",2)="12:0:0:0" +^ZZCOVERAGE("XINDX9","FNC",3)="12:0:0:0" +^ZZCOVERAGE("XINDX9","FUNC")="29134:284015:400024:684039" +^ZZCOVERAGE("XINDX9","FUNC",1)="29134:112005:120007:232012" +^ZZCOVERAGE("XINDX9","FUNC",2)="23461:48003:72004:120007" +^ZZCOVERAGE("XINDX9","FUNC",3)="23461:20000:32001:52001" +^ZZCOVERAGE("XINDX9","FX",0)="23461:68004:116009:184013" +^ZZCOVERAGE("XINDX9","GVAR")="29134:96004:180015:276019" +^ZZCOVERAGE("XINDX9","GVAR",0)="29134:28000:44003:72003" +^ZZCOVERAGE("XINDX9","GVAR",1)="29134:32001:72005:104006" +^ZZCOVERAGE("XINDX9","GVAR",2)="29134:16000:24002:40002" +^ZZCOVERAGE("XINDX9","INC")="29134:64003:64007:128010" +^ZZCOVERAGE("XINDX9","INC",0)="29134:20001:12001:32002" +^ZZCOVERAGE("XINDX9","INC",1)="29134:32002:40004:72006" +^ZZCOVERAGE("XINDX9","NEW")="287703:532032:660032:1192064" +^ZZCOVERAGE("XINDX9","NEW",0)="287703:200012:244014:444026" +^ZZCOVERAGE("XINDX9","NEW",1)="287703:220014:248008:468022" +^ZZCOVERAGE("XINDX9","NUM")="45379:292023:340026:632049" +^ZZCOVERAGE("XINDX9","NUM",0)="45379:92006:84006:176012" +^ZZCOVERAGE("XINDX9","NUM",0,"FOR_LOOP",1)=71145 +^ZZCOVERAGE("XINDX9","NUM",1)="45379:40005:48002:88007" +^ZZCOVERAGE("XINDX9","NUM",2)="45379:40004:56005:96009" +^ZZCOVERAGE("XINDX9","NUM",3)="45379:76003:88008:164011" +^ZZCOVERAGE("XINDX9","NUM",4)="45379:24003:40003:64006" +^ZZCOVERAGE("XINDX9","PA2",0)="518346:544028:668032:1212060" +^ZZCOVERAGE("XINDX9","PA2",1)="472665:532043:620035:1152078" +^ZZCOVERAGE("XINDX9","PA2",2)="317803:264019:292021:556040" +^ZZCOVERAGE("XINDX9","PA2",3)="317803:200013:324018:524031" +^ZZCOVERAGE("XINDX9","PA2",4)="307072:348020:492025:840045" +^ZZCOVERAGE("XINDX9","PA2",5)="197397:160015:296011:456026" +^ZZCOVERAGE("XINDX9","PA2",6)="152018:120016:132005:252021" +^ZZCOVERAGE("XINDX9","PA2",7)="152018:116009:112008:228017" +^ZZCOVERAGE("XINDX9","PA2",8)="151813:96008:168010:264018" +^ZZCOVERAGE("XINDX9","PA2",9)="151813:100008:172009:272017" +^ZZCOVERAGE("XINDX9","PA2",10)="151813:220008:324022:544030" +^ZZCOVERAGE("XINDX9","PA2",11)="151813:168011:152010:320021" +^ZZCOVERAGE("XINDX9","PA2",12)="151813:128009:148012:276021" +^ZZCOVERAGE("XINDX9","PA2",13)="151813:136005:104009:240014" +^ZZCOVERAGE("XINDX9","PARSE")="45681:3356226:4340257:7696483" +^ZZCOVERAGE("XINDX9","PARSE",0)="45681:104007:108007:212014" +^ZZCOVERAGE("XINDX9","PAT")="205:0:0:0" +^ZZCOVERAGE("XINDX9","PAT",0)="205:0:0:0" +^ZZCOVERAGE("XINDX9","PAT",1)="205:0:0:0" +^ZZCOVERAGE("XINDX9","PAT",1,"FOR_LOOP",1)=1185 +^ZZCOVERAGE("XINDX9","PAT",2)="205:0:0:0" +^ZZCOVERAGE("XINDX9","PAT",3)="205:0:0:0" +^ZZCOVERAGE("XINDX9","PAT",4)="205:0:0:0" +^ZZCOVERAGE("XINDX9","PATC")="28:0:0:0" +^ZZCOVERAGE("XINDX9","PATC",0)="28:0:0:0" +^ZZCOVERAGE("XINDX9","PATQ")="99:0:8000:8000" +^ZZCOVERAGE("XINDX9","PATQ",0)="99:0:0:0" +^ZZCOVERAGE("XINDX9","PATQ",0,"FOR_LOOP",1)=247 +^ZZCOVERAGE("XINDX9","PATQ",1)="99:0:0:0" +^ZZCOVERAGE("XINDX9","PATQ",2)="99:0:8000:8000" +^ZZCOVERAGE("XINDX9","PATU")="15:0:0:0" +^ZZCOVERAGE("XINDX9","PATU",0)="15:0:0:0" +^ZZCOVERAGE("XINDX9","PEND",0)="45681:68001:140014:208015" +^ZZCOVERAGE("XINDX9","PEND",1)="45681:36004:52005:88009" +^ZZCOVERAGE("XINDX9","QUOTE")="35724:244013:304019:548032" +^ZZCOVERAGE("XINDX9","QUOTE",0)="36272:172010:140009:312019" +^ZZCOVERAGE("XINDX9","QUOTE",0,"FOR_LOOP",1)=323021 +^ZZCOVERAGE("XINDX9","QUOTE",1)="36272:28001:72004:100005" +^ZZCOVERAGE("XINDX9","QUOTE",2)="35724:28001:24003:52004" +^ZZCOVERAGE("XINDX9","QUOTE",3)="35724:16001:52002:68003" +^ZZCOVERAGE("XINDX9","SPV",0)="3703:4000:12000:16000" +^ZZCOVERAGE("XINDX9","SPV",1)="3703:8001:4000:12001" +^ZZCOVERAGE("XINDX9","SPV",2)="3703:8001:4000:12001" +^ZZCOVERAGE("XINDX9","SPV",3)="3703:4000:8001:12001" +^ZZCOVERAGE("XINDX9","STR")="287703:560037:724043:1284080" +^ZZCOVERAGE("XINDX9","STR",0)="287703:300018:312020:612038" +^ZZCOVERAGE("XINDX9","SUM")="213322:612034:916052:1528086" +^ZZCOVERAGE("XINDX9","SUM",0)="213322:160009:208011:368020" +^ZZCOVERAGE("XINDX9","SUM",1)="213322:212007:280018:492025" +^ZZCOVERAGE("XINDX9","SUM",2)="213322:136012:268012:404024" +^ZZCOVERAGE("XINDX9","UP")="45002:396026:440029:836055" +^ZZCOVERAGE("XINDX9","UP",0)="45002:24003:44001:68004" +^ZZCOVERAGE("XINDX9","UP",1)="45002:180008:192016:372024" +^ZZCOVERAGE("XINDX9","UP",2)="45002:136010:128005:264015" +^ZZCOVERAGE("XINDX9","UP",3)="45002:40003:52003:92006" +^ZZCOVERAGE("XINDX9","VAR")="138809:828044:1004072:1832116" +^ZZCOVERAGE("XINDX9","VAR",0)="138809:376018:336017:712035" +^ZZCOVERAGE("XINDX9","VAR",0,"FOR_LOOP",1)=462128 +^ZZCOVERAGE("XINDX9","VAR",1)="138809:292018:376034:668052" +^ZZCOVERAGE("XINDX9","VAR",2)="138809:116003:144008:260011" +^ZZCOVERAGE("XINDX9","XINDX9")="45681:296016:320021:616037" +^ZZCOVERAGE("XINDX9","XINDX9",3)="45681:52003:128006:180009" +^ZZCOVERAGE("XINDX9","XINDX9",4)="45681:164006:112008:276014" +^ZZCOVERAGE("XINDX9","XINDX9",4,"FOR_LOOP",1)=128269 +^ZZCOVERAGE("XINDX9","XINDX9",5)="45681:48004:52005:100009" +^ZZCOVERAGE("XLFDT","DT")="1:0:0:0" +^ZZCOVERAGE("XLFDT","DT",0)="1:0:0:0" +^ZZCOVERAGE("XLFDT","DT",1)="1:0:0:0" +^ZZCOVERAGE("XLFDT","HR")="3:0:0:0" +^ZZCOVERAGE("XLFDT","HR",0)="3:0:0:0" +^ZZCOVERAGE("XLFDT","HR",1)="3:0:0:0" +^ZZCOVERAGE("XLFDT","HTE")="1:0:0:0" +^ZZCOVERAGE("XLFDT","HTE",0)="1:0:0:0" +^ZZCOVERAGE("XLFDT","HTE",1)="1:0:0:0" +^ZZCOVERAGE("XLFDT","HTE",2)="1:0:0:0" +^ZZCOVERAGE("XLFDT","HTE",3)="1:0:0:0" +^ZZCOVERAGE("XLFDT","HTFM")="2:0:0:0" +^ZZCOVERAGE("XLFDT","HTFM",0)="2:0:0:0" +^ZZCOVERAGE("XLFDT","HTFM",1)="2:0:0:0" +^ZZCOVERAGE("XLFDT","HTFM",2)="2:0:0:0" +^ZZCOVERAGE("XLFDT","HTFM",3)="2:0:0:0" +^ZZCOVERAGE("XLFDT","HTFM",4)="2:0:0:0" +^ZZCOVERAGE("XLFDT","HTFM",5)="2:0:0:0" +^ZZCOVERAGE("XLFDT","T2",0)="1:0:0:0" +^ZZCOVERAGE("XLFDT","T2",1)="1:0:0:0" +^ZZCOVERAGE("XLFDT","YMD")="2:0:0:0" +^ZZCOVERAGE("XLFDT","YMD",1)="2:0:0:0" +^ZZCOVERAGE("XLFDT","YMD",2)="2:0:0:0" +^ZZCOVERAGE("XLFDT","YMD",3)="2:0:0:0" +^ZZCOVERAGE("XLFDT","YMD",4)="2:0:0:0" +^ZZCOVERAGE("XLFDT","YMD",5)="2:0:0:0" +^ZZCOVERAGE("XLFDT1","F1",1)="1:0:0:0" +^ZZCOVERAGE("XLFDT1","FMT")="1:0:0:0" +^ZZCOVERAGE("XLFDT1","FMT",1)="1:0:0:0" +^ZZCOVERAGE("XLFDT1","FMT",2)="1:0:0:0" +^ZZCOVERAGE("XLFDT1","M")="1:0:0:0" +^ZZCOVERAGE("XLFDT1","M",0)="1:0:0:0" +^ZZCOVERAGE("XLFDT1","TM",1)="1:0:0:0" +^ZZCOVERAGE("XLFDT1","TM",2)="1:0:0:0" +^ZZCOVERAGE("XLFDT1","TM",3)="1:0:0:0" +^ZZCOVERAGE("XLFDT1","TM",7)="1:0:0:0" +^ZZCOVERAGE("XPDRSUM","SUMB")="467:1808124:180014:1988138" +^ZZCOVERAGE("XPDRSUM","SUMB",0)="467:8000:0:8000" +^ZZCOVERAGE("XPDRSUM","SUMB",2)="467:0:0:0" +^ZZCOVERAGE("XPDRSUM","SUMB",3)="467:1796124:180014:1976138" +^ZZCOVERAGE("XPDRSUM","SUMB",3,"FOR_LOOP",1)=44620 +^ZZCOVERAGE("XPDRSUM","SUMB",3,"FOR_LOOP",2)=1566704 +^ZZCOVERAGE("XPDRSUM","SUMB",4)="467:0:0:0" +^ZZCOVERAGE("XTRUTL1","BUILD")="1:0:0:0" +^ZZCOVERAGE("XTRUTL1","BUILD",0)="1:0:0:0" +^ZZCOVERAGE("XTRUTL1","BUILD",1)="1:0:0:0" +^ZZCOVERAGE("XTRUTL1","BUILD",2)="1:0:0:0" +^ZZCOVERAGE("XTRUTL1","BUILD",3)="1:0:0:0" + + diff --git a/Tests/MumpsCoverage/DartConfiguration.cache.tcl.in b/Tests/MumpsCoverage/DartConfiguration.cache.tcl.in new file mode 100644 index 000000000..a1c6b17f6 --- /dev/null +++ b/Tests/MumpsCoverage/DartConfiguration.cache.tcl.in @@ -0,0 +1,8 @@ +# This file is configured by CMake automatically as DartConfiguration.tcl +# If you choose not to use CMake, this file may be hand configured, by +# filling in the required variables. + + +# Configuration directories and files +SourceDirectory: ${CMake_SOURCE_DIR}/Testing/MumpsCoverage +BuildDirectory: ${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage diff --git a/Tests/MumpsCoverage/DartConfiguration.tcl.in b/Tests/MumpsCoverage/DartConfiguration.tcl.in new file mode 100644 index 000000000..2d7eaa521 --- /dev/null +++ b/Tests/MumpsCoverage/DartConfiguration.tcl.in @@ -0,0 +1,8 @@ +# This file is configured by CMake automatically as DartConfiguration.tcl +# If you choose not to use CMake, this file may be hand configured, by +# filling in the required variables. + + +# Configuration directories and files +SourceDirectory: ${CMake_SOURCE_DIR}/Testing/MumpsCoverage +BuildDirectory: ${CMake_BINARY_DIR}/Testing/MumpsCoverage diff --git a/Tests/MumpsCoverage/VistA-FOIA/Packages/Toolkit/Routines/XINDEX.m b/Tests/MumpsCoverage/VistA-FOIA/Packages/Toolkit/Routines/XINDEX.m new file mode 100644 index 000000000..b04522151 --- /dev/null +++ b/Tests/MumpsCoverage/VistA-FOIA/Packages/Toolkit/Routines/XINDEX.m @@ -0,0 +1,144 @@ +XINDEX ;ISC/REL,GFT,GRK,RWF - INDEX & CROSS-REFERENCE ;08/04/08 13:19 + ;;7.3;TOOLKIT;**20,27,48,61,66,68,110,121,128**;Apr 25, 1995;Build 1 + ; Per VHA Directive 2004-038, this routine should not be modified. + G ^XINDX6 +SEP F I=1:1 S CH=$E(LIN,I) D QUOTE:CH=Q Q:" "[CH + S ARG=$E(LIN,1,I-1) S:CH=" " I=I+1 S LIN=$E(LIN,I,999) Q +QUOTE F I=I+1:1 S CH=$E(LIN,I) Q:CH=""!(CH=Q) + Q:CH]"" S ERR=6 G ^XINDX1 +ALIVE ;enter here from taskman + D SETUP^XINDX7 ;Get ready to process +A2 S RTN=$O(^UTILITY($J,RTN)) G ^XINDX5:RTN="" + S INDLC=(RTN?1"|"1.4L.NP) D LOAD:'INDLC + I $D(ZTQUEUED),$$S^%ZTLOAD S RTN="~",IND("QUIT")=1,ZTSTOP=1 G A2 + I 'INDDS,INDLC W !!?10,"Data Dictionaries",! S INDDS=1 + D BEG + G A2 + ; +LOAD S X=RTN,XCNP=0,DIF="^UTILITY("_$J_",1,RTN,0," X ^%ZOSF("TEST") Q:'$T X ^%ZOSF("LOAD") S ^UTILITY($J,1,RTN,0,0)=XCNP-1 + I $D(^UTILITY($J,1,RTN,0,0)) S ^UTILITY($J,1,RTN,"RSUM")="B"_$$SUMB^XPDRSUM($NA(^UTILITY($J,1,RTN,0))) + Q +BEG ; + S %=INDLC*5 W:$X+10+%>IOM ! W RTN,$J("",10+%-$L(RTN)) + S (IND("DO"),IND("SZT"),IND("SZC"),LABO)=0,LC=$G(^UTILITY($J,1,RTN,0,0)) + I LC="" W !,">>>Routine '",RTN,"' not found <<<",! Q + S TXT="",LAB=$P(^UTILITY($J,1,RTN,0,1,0)," ") I RTN'=$P(LAB,"(") D E^XINDX1(17) + I 'INDLC,LAB["(" D E^XINDX1(55) S LAB=$P(LAB,"(") + ;if M routine(not compiled template or DD) and has more than 2 lines, check lines 1 & 2 + I 'INDLC,LC>2 D + . N LABO S LABO=1 + . S LIN=$G(^UTILITY($J,1,RTN,0,1,0)),TXT=1 + . ;check 1st line (site/dev - ) patch 128 + . I $P(LIN,";",2,4)'?.E1"/".E.1"-".E D E^XINDX1(62) + . S LIN=$G(^UTILITY($J,1,RTN,0,2,0)),TXT=2 + . ;check 2nd line (;;nn.nn[TV]nn;package;.anything) + . I $P(LIN,";",3,99)'?1.2N1"."1.2N.1(1"T",1"V").2N1";"1A.AP1";".E D E^XINDX1(44) ;patch 121 + . I $L(INP(11)) X INP(11) ;Version number check + . I $L(INP(12)) X INP(12) ;Patch number check +B5 F TXT=1:1:LC S LIN=^UTILITY($J,1,RTN,0,TXT,0),LN=$L(LIN),IND("SZT")=IND("SZT")+LN+2 D LN,ST ;Process Line + S LAB="",LABO=0,TXT=0,^UTILITY($J,1,RTN,0)=IND("SZT")_"^"_LC_"^"_IND("SZC") + I IND("SZT")>INP("MAX"),'INDLC S ERR=35,ERR(1)=IND("SZT") D ^XINDX1 + I IND("SZT")-IND("SZC")>INP("CMAX"),'INDLC S ERR=58,ERR(1)=IND("SZT")-IND("SZC") D ^XINDX1 + D POSTRTN + Q + ;Proccess one line, LN = Length, LIN = Line. +LN K V S (ARG,GRB,IND("COM"),IND("DOL"),IND("F"))="",X=$P(LIN," ") + I '$L(X) S LABO=LABO+1 G CD + S (IND("COM"),LAB)=$P(X,"("),ARG=$P($P(X,"(",2),")"),LABO=0,IND("PP")=X?1.8E1"(".E1")" + D:$L(ARG) NE^XINDX3 ;Process formal parameters as New list. + I 'INDLC,'$$VT^XINDX2(LAB) D E^XINDX1($S(LAB=$$CASE^XINDX52(LAB):37,1:55)) ;Check for bad labels + I $D(^UTILITY($J,1,RTN,"T",LAB)) D E^XINDX1(15) G CD ;DUP label + S ^UTILITY($J,1,RTN,"T",LAB)="" +CD I LN>245 D:'(LN=246&($E(RTN,1,3)="|dd")) E^XINDX1(19) ;patch 119 + D:LIN'?1.ANP E^XINDX1(18) + S LIN=$P(LIN," ",2,999),IND("LCC")=1 + I LIN="" D E^XINDX1(42) Q ;Blank line ;p110 + S I=0 ;Watch the scope of I, counts dots + I " ."[$E(LIN) D S X=$L($E(LIN,1,I),".")-1,LIN=$E(LIN,I,999) + . F I=1:1:245 Q:". "'[$E(LIN,I) + . Q + ;check dots against Do level IND("DO"), IND("DOL")=dot level + D:'I&$G(IND("DO1")) E^XINDX1(51) S IND("DO1")=0 S:'I IND("DO")=0 + I I D:X>IND("DO") E^XINDX1(51) S (IND("DO"),IND("DOL"))=X + ;Count Comment lines, skip ;; lines + I $E(LIN)=";",$E(LIN,2)'=";" S IND("SZC")=IND("SZC")+$L(LIN) ;p110 + ;Process commands on line. +EE I LIN="" D ^XINDX2 Q + S COM=$E(LIN),GK="",ARG="" + I COM=";" S LIN="" G EE ;p110 + I COM=" " S ERR=$S(LIN?1." ":13,1:0),LIN=$S(ERR:"",1:$E(LIN,2,999)) D:ERR ^XINDX1 G EE + D SEP + S CM=$P(ARG,":",1),POST=$P(ARG,":",2,999),IND("COM")=IND("COM")_$C(9)_COM,ERR=48 + D:ARG[":"&(POST']"") ^XINDX1 S:POST]"" GRB=GRB_$C(9)_POST,IND("COM")=IND("COM")_":" + ;SAC now allows lowercase commands + I CM?.E1L.E S CM=$$CASE^XINDX52(CM),COM=$E(CM) ;I IND("LCC") S IND("LCC")=0 D E^XINDX1(47) + I CM="" D E^XINDX1(21) G EE ;Missing command + S CX=$G(IND("CMD",CM)) I CX="" D G:CX="" EE + . I $E(CM)="Z" S CX="^Z" Q ;Proccess Z commands + . D E^XINDX1(1) S LIN="" Q + S CX=$P(CX,"^",2,9) + D SEP I '$L(LIN),CH=" " D E^XINDX1(13) ;trailing space + I ARG="","CGJMORSUWX"[COM S ERR=49 G ^XINDX1 + I CX>0 D E^XINDX1(CX) S CX="" + D:$L(CX) @CX S:ARG'="" GRB=GRB_$C(9)_ARG G EE +B S ERR=25 G ^XINDX1 +C S ERR=29 G ^XINDX1 +D G DG1^XINDX4 +E Q:ARG="" S ERR=7 G ^XINDX1 +F G:ARG]"" FR^XINDX4 S IND("F")=1 Q +G G DG^XINDX4 +H Q:ARG'="" S ERR=32 G ^XINDX1 +J S ERR=36,ARG="" G ^XINDX1 +K S ERR=$S(ARG?1"(".E:22,ARG?." ":23,1:0) D:ERR ^XINDX1 + G KL^XINDX3 +L G LO^XINDX4 +M G S^XINDX3 +N G NE^XINDX3 +O S ERR=34 D ^XINDX1,O^XINDX3 Q +Q Q:ARG="" G Q^XINDX4 +R S RDTIME=0 G RD^XINDX3 +S G S^XINDX3 +TR Q ;What to process. p110 +U S ARG=$P(ARG,":") Q +V S ARG="",ERR=20 G ^XINDX1 +W G WR^XINDX4 +X G XE^XINDX4 +Z S ERR=2 D ^XINDX1 G ZC^XINDX4 + ; + ;Save off items from line. +ST S R=LAB_$S(LABO:"+"_LABO,1:"") + ;Local variable, Global, Marked Items, Naked global, Internal ref, eXternal ref., Tag ref. + S LOC="" F S LOC=$O(V(LOC)),S="" Q:LOC="" F S S=$O(V(LOC,S)) Q:S="" D SET + S ^UTILITY($J,1,RTN,"COM",TXT)=IND("COM") + Q + ; +SET I V(LOC,S)]"" F %="!","~" I V(LOC,S)[%,$G(^UTILITY($J,1,RTN,LOC,S))'[% S ^(S)=$G(^(S))_% + S %=0 +SE2 S ARG=$G(^UTILITY($J,1,RTN,LOC,S,%)) I $L(ARG)>230 S %=%+1 G SE2 + S ^UTILITY($J,1,RTN,LOC,S,%)=ARG_R_V(LOC,S)_"," + Q + ; +POSTRTN ;Do more overall checking + N V,E,T,T1,T2 + S T="" ;Check for missing Labels + F S T=$O(^UTILITY($J,1,RTN,"I",T)),T2=T Q:T="" S T1=$G(^(T,0)) D + . Q:$E(T2,1,2)="@(" + . S:$E(T2,1,2)="$$" T2=$E(T2,3,99) + . I T2]"",'$D(^UTILITY($J,1,RTN,"T",$P(T2,"+",1))) D + . . F I=1:1:$L(T1,",")-1 S LAB=$P(T1,",",I),LABO=+$P(LAB,"+",2),LAB=$P(LAB,"+"),E=14,E(1)=T D E^XINDX1(.E) + . . Q + . Q + S LAB="",LABO=0 ;Check for valid label names + I 'INDLC F S LAB=$O(^UTILITY($J,1,RTN,"T",LAB)) Q:LAB="" D + . I '$$VA^XINDX2(LAB) D E^XINDX1(55) Q + . D:'$$VT^XINDX2(LAB) E^XINDX1(37) + . Q + S LAB="",LABO=0 ;Check for valid variable names. + F S LAB=$O(^UTILITY($J,1,RTN,"L",LAB)) Q:LAB="" D + . D VLNF^XINDX3($P(LAB,"(")) + . Q + Q + ; +QUICK ;Quick, Just get a routine an print the results + D QUICK^XINDX6() + Q diff --git a/Tests/MumpsCoverage/cache_coverage.cmcov.in b/Tests/MumpsCoverage/cache_coverage.cmcov.in new file mode 100644 index 000000000..b431dbdc1 --- /dev/null +++ b/Tests/MumpsCoverage/cache_coverage.cmcov.in @@ -0,0 +1,2 @@ +packages:${CMake_BINARY_DIR}/Testing/MumpsCoverage/VistA-FOIA/Packages +coverage_dir:${CMake_SOURCE_DIR}/Tests/MumpsCoverage diff --git a/Tests/MumpsCoverage/gtm_coverage.mcov.in b/Tests/MumpsCoverage/gtm_coverage.mcov.in new file mode 100644 index 000000000..b431dbdc1 --- /dev/null +++ b/Tests/MumpsCoverage/gtm_coverage.mcov.in @@ -0,0 +1,2 @@ +packages:${CMake_BINARY_DIR}/Testing/MumpsCoverage/VistA-FOIA/Packages +coverage_dir:${CMake_SOURCE_DIR}/Tests/MumpsCoverage diff --git a/Tests/NewlineArgs/CMakeLists.txt b/Tests/NewlineArgs/CMakeLists.txt new file mode 100644 index 000000000..a18230488 --- /dev/null +++ b/Tests/NewlineArgs/CMakeLists.txt @@ -0,0 +1,16 @@ +# a simple CXX only test case +cmake_minimum_required (VERSION 2.6) +project (NewlineArgs CXX) + +add_definitions("-DTEST_FLAG_1 +-DTEST_FLAG_2") + +include_directories(" ${NewlineArgs_BINARY_DIR} + ${NewlineArgs_SOURCE_DIR} ") + +configure_file("${NewlineArgs_SOURCE_DIR}/libcxx2.h.in" + "${NewlineArgs_BINARY_DIR}/libcxx2.h") + +add_library(testcxx1 libcxx1.cxx) +add_executable (NewlineArgs cxxonly.cxx) +target_link_libraries(NewlineArgs testcxx1) diff --git a/Tests/NewlineArgs/cxxonly.cxx b/Tests/NewlineArgs/cxxonly.cxx new file mode 100644 index 000000000..05d55e4ef --- /dev/null +++ b/Tests/NewlineArgs/cxxonly.cxx @@ -0,0 +1,19 @@ +#include "libcxx1.h" +#include "libcxx2.h" + +#include <stdio.h> + +int main () +{ + if ( LibCxx1Class::Method() != 2.0 ) + { + printf("Problem with libcxx1\n"); + return 1; + } +#ifdef TEST_FLAG_3 + return 0; +#else + printf("Problem with libcxx2.h include dir probably!\n"); + return 1; +#endif +} diff --git a/Tests/NewlineArgs/libcxx1.cxx b/Tests/NewlineArgs/libcxx1.cxx new file mode 100644 index 000000000..72f171d5c --- /dev/null +++ b/Tests/NewlineArgs/libcxx1.cxx @@ -0,0 +1,10 @@ +#include "libcxx1.h" + +#ifdef TEST_FLAG_1 +#ifdef TEST_FLAG_2 +float LibCxx1Class::Method() +{ + return 2.0; +} +#endif +#endif diff --git a/Tests/NewlineArgs/libcxx1.h b/Tests/NewlineArgs/libcxx1.h new file mode 100644 index 000000000..ea094d758 --- /dev/null +++ b/Tests/NewlineArgs/libcxx1.h @@ -0,0 +1,9 @@ +class LibCxx1Class +{ +public: +#ifdef TEST_FLAG_1 +#ifdef TEST_FLAG_2 + static float Method(); +#endif +#endif +}; diff --git a/Tests/NewlineArgs/libcxx2.h.in b/Tests/NewlineArgs/libcxx2.h.in new file mode 100644 index 000000000..bdf9cfa93 --- /dev/null +++ b/Tests/NewlineArgs/libcxx2.h.in @@ -0,0 +1,6 @@ +#ifdef TEST_FLAG_1 +#ifdef TEST_FLAG_2 +#define TEST_FLAG_3 +#endif +#endif + diff --git a/Tests/ObjC++/CMakeLists.txt b/Tests/ObjC++/CMakeLists.txt new file mode 100644 index 000000000..c892bd0a1 --- /dev/null +++ b/Tests/ObjC++/CMakeLists.txt @@ -0,0 +1,6 @@ +# a simple objc++ test case that uses Cocoa framework +PROJECT (ObjC++) + +ADD_EXECUTABLE (ObjC++ objc++.mm) +TARGET_LINK_LIBRARIES(ObjC++ "-framework Cocoa") + diff --git a/Tests/ObjC++/objc++.mm b/Tests/ObjC++/objc++.mm new file mode 100644 index 000000000..f0be25682 --- /dev/null +++ b/Tests/ObjC++/objc++.mm @@ -0,0 +1,23 @@ +#import <Cocoa/Cocoa.h> +#import <iostream> +using namespace std; + +int main() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSMutableSet *mySet = [NSMutableSet set]; + cout<<"Adding values to the set."<<endl; + [mySet addObject:[NSNumber numberWithInt:356]]; + [mySet addObject:[NSNumber numberWithInt:550]]; + [mySet addObject:[NSNumber numberWithInt:914]]; + + cout<<"The set contains "<<[mySet count]<<" objects."<<endl; + if ([mySet containsObject:[NSNumber numberWithInt:911]]) + cout<<"It's there!"<<endl; + else + cout<<"It's not there."<<endl; + + [pool release]; + return 0; +} diff --git a/Tests/ObjectLibrary/A/CMakeLists.txt b/Tests/ObjectLibrary/A/CMakeLists.txt new file mode 100644 index 000000000..121a8acba --- /dev/null +++ b/Tests/ObjectLibrary/A/CMakeLists.txt @@ -0,0 +1,17 @@ +# Add -fPIC so objects can be used in shared libraries. +# TODO: Need property for this. +if(CMAKE_SHARED_LIBRARY_C_FLAGS AND NOT WATCOM) + set(CMAKE_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_C_FLAGS}") +endif() + +add_definitions(-DA_DEF) + +add_custom_command( + OUTPUT a1.c + DEPENDS a1.c.in + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/a1.c.in + ${CMAKE_CURRENT_BINARY_DIR}/a1.c + ) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +add_library(A OBJECT a1.c a2.c) diff --git a/Tests/ObjectLibrary/A/a.h b/Tests/ObjectLibrary/A/a.h new file mode 100644 index 000000000..7259f982e --- /dev/null +++ b/Tests/ObjectLibrary/A/a.h @@ -0,0 +1,6 @@ +#ifndef A_DEF +# error "A_DEF not defined" +#endif +#ifdef B_DEF +# error "B_DEF must not be defined" +#endif diff --git a/Tests/ObjectLibrary/A/a1.c.in b/Tests/ObjectLibrary/A/a1.c.in new file mode 100644 index 000000000..d1eaf58fd --- /dev/null +++ b/Tests/ObjectLibrary/A/a1.c.in @@ -0,0 +1,2 @@ +#include "a.h" +int a1(void) { return 0; } diff --git a/Tests/ObjectLibrary/A/a2.c b/Tests/ObjectLibrary/A/a2.c new file mode 100644 index 000000000..d8f225eb7 --- /dev/null +++ b/Tests/ObjectLibrary/A/a2.c @@ -0,0 +1,2 @@ +#include "a.h" +int a2(void) { return 0; } diff --git a/Tests/ObjectLibrary/AB.def b/Tests/ObjectLibrary/AB.def new file mode 100644 index 000000000..3f2b5c054 --- /dev/null +++ b/Tests/ObjectLibrary/AB.def @@ -0,0 +1,5 @@ +EXPORTS +a1 +a2 +b1 +b2 diff --git a/Tests/ObjectLibrary/B/CMakeLists.txt b/Tests/ObjectLibrary/B/CMakeLists.txt new file mode 100644 index 000000000..67172d132 --- /dev/null +++ b/Tests/ObjectLibrary/B/CMakeLists.txt @@ -0,0 +1,15 @@ +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6") + # VS 6 generator does not use per-target object locations. + set(vs6 _vs6) +endif() + +# Add -fPIC so objects can be used in shared libraries. +# TODO: Need property for this. +if(CMAKE_SHARED_LIBRARY_C_FLAGS AND NOT WATCOM) + set(CMAKE_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_C_FLAGS}") +endif() + +add_definitions(-DB_DEF) +add_library(B OBJECT b1.c b2.c) +add_library(Bexport OBJECT b1${vs6}.c b2${vs6}.c) +set_property(TARGET Bexport PROPERTY COMPILE_DEFINITIONS Bexport) diff --git a/Tests/ObjectLibrary/B/b.h b/Tests/ObjectLibrary/B/b.h new file mode 100644 index 000000000..11b22f427 --- /dev/null +++ b/Tests/ObjectLibrary/B/b.h @@ -0,0 +1,11 @@ +#ifdef A_DEF +# error "A_DEF must not be defined" +#endif +#ifndef B_DEF +# error "B_DEF not defined" +#endif +#if defined(_WIN32) && defined(Bexport) +# define EXPORT_B __declspec(dllexport) +#else +# define EXPORT_B +#endif diff --git a/Tests/ObjectLibrary/B/b1.c b/Tests/ObjectLibrary/B/b1.c new file mode 100644 index 000000000..fdeffe491 --- /dev/null +++ b/Tests/ObjectLibrary/B/b1.c @@ -0,0 +1,2 @@ +#include "b.h" +EXPORT_B int b1(void) { return 0; } diff --git a/Tests/ObjectLibrary/B/b1_vs6.c b/Tests/ObjectLibrary/B/b1_vs6.c new file mode 100644 index 000000000..b606e10e6 --- /dev/null +++ b/Tests/ObjectLibrary/B/b1_vs6.c @@ -0,0 +1 @@ +#include "b1.c" diff --git a/Tests/ObjectLibrary/B/b2.c b/Tests/ObjectLibrary/B/b2.c new file mode 100644 index 000000000..6e0d17cbe --- /dev/null +++ b/Tests/ObjectLibrary/B/b2.c @@ -0,0 +1,2 @@ +#include "b.h" +EXPORT_B int b2(void) { return 0; } diff --git a/Tests/ObjectLibrary/B/b2_vs6.c b/Tests/ObjectLibrary/B/b2_vs6.c new file mode 100644 index 000000000..d96a43e04 --- /dev/null +++ b/Tests/ObjectLibrary/B/b2_vs6.c @@ -0,0 +1 @@ +#include "b2.c" diff --git a/Tests/ObjectLibrary/CMakeLists.txt b/Tests/ObjectLibrary/CMakeLists.txt new file mode 100644 index 000000000..87234159f --- /dev/null +++ b/Tests/ObjectLibrary/CMakeLists.txt @@ -0,0 +1,52 @@ +cmake_minimum_required(VERSION 2.8) +project(ObjectLibrary C) + +add_subdirectory(A) +add_subdirectory(B) + +add_library(Cstatic STATIC c.c $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B>) +add_executable(UseCstatic main.c) +target_link_libraries(UseCstatic Cstatic) + +add_library(Cshared SHARED c.c $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:Bexport>) +add_executable(UseCshared main.c) +set_property(TARGET UseCshared PROPERTY COMPILE_DEFINITIONS SHARED_C) +target_link_libraries(UseCshared Cshared) + +add_executable(UseCinternal main.c c.c $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B>) + +if("${CMAKE_GENERATOR}" MATCHES "^Visual Studio (6|7|7 .NET 2003)$") + # VS 6 and 7 generators do not add objects as sources so we need a + # dummy object to convince the IDE to build the targets below. + set(dummy dummy.obj) # In MinGW: gcc -c dummy.c -o dummy.obj +elseif("${CMAKE_GENERATOR}" MATCHES "Xcode") + # Xcode does not seem to support targets without sources. + set(dummy dummy.c) +endif() + +# Test static library without its own sources. +add_library(ABstatic STATIC ${dummy} $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B>) +add_executable(UseABstatic mainAB.c) +target_link_libraries(UseABstatic ABstatic) + +# Test module definition file to export object library symbols in the test +# below if the platform needs and supports it. +set(ABshared_SRCS $<TARGET_OBJECTS:A>) +if(CMAKE_LINK_DEF_FILE_FLAG OR NOT WIN32) + list(APPEND ABshared_SRCS $<TARGET_OBJECTS:B> AB.def) +else() + set(NO_A NO_A) + list(APPEND ABshared_SRCS $<TARGET_OBJECTS:Bexport>) +endif() + +# Test shared library without its own sources. +add_library(ABshared SHARED ${dummy} ${ABshared_SRCS}) +add_executable(UseABshared mainAB.c) +set_property(TARGET UseABshared PROPERTY COMPILE_DEFINITIONS SHARED_B ${NO_A}) +target_link_libraries(UseABshared ABshared) + +# Test executable without its own sources. +add_library(ABmain OBJECT mainAB.c) +add_executable(UseABinternal ${dummy} + $<TARGET_OBJECTS:ABmain> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B> + ) diff --git a/Tests/ObjectLibrary/c.c b/Tests/ObjectLibrary/c.c new file mode 100644 index 000000000..968095b8b --- /dev/null +++ b/Tests/ObjectLibrary/c.c @@ -0,0 +1,19 @@ +#if defined(_WIN32) && defined(Cshared_EXPORTS) +# define EXPORT_C __declspec(dllexport) +#else +# define EXPORT_C +#endif + +extern int a1(void); +extern int a2(void); +extern int b1(void); +extern int b2(void); +EXPORT_C int c(void) +{ + return 0 + + a1() + + a2() + + b1() + + b2() + ; +} diff --git a/Tests/ObjectLibrary/dummy.c b/Tests/ObjectLibrary/dummy.c new file mode 100644 index 000000000..2b17d816d --- /dev/null +++ b/Tests/ObjectLibrary/dummy.c @@ -0,0 +1 @@ +int dummy(void) {return 0;} diff --git a/Tests/ObjectLibrary/dummy.obj b/Tests/ObjectLibrary/dummy.obj Binary files differnew file mode 100644 index 000000000..77f6f2f1b --- /dev/null +++ b/Tests/ObjectLibrary/dummy.obj diff --git a/Tests/ObjectLibrary/main.c b/Tests/ObjectLibrary/main.c new file mode 100644 index 000000000..6819f1c6d --- /dev/null +++ b/Tests/ObjectLibrary/main.c @@ -0,0 +1,16 @@ +#if defined(_WIN32) && defined(SHARED_C) +# define IMPORT_C __declspec(dllimport) +#else +# define IMPORT_C +#endif +extern IMPORT_C int b1(void); +extern IMPORT_C int b2(void); +extern IMPORT_C int c(void); +int main(void) +{ + return 0 + + c() + + b1() + + b2() + ; +} diff --git a/Tests/ObjectLibrary/mainAB.c b/Tests/ObjectLibrary/mainAB.c new file mode 100644 index 000000000..556898b83 --- /dev/null +++ b/Tests/ObjectLibrary/mainAB.c @@ -0,0 +1,22 @@ +#if defined(_WIN32) && defined(SHARED_B) +# define IMPORT_B __declspec(dllimport) +#else +# define IMPORT_B +#endif +extern IMPORT_B int b1(void); +extern IMPORT_B int b2(void); +#ifndef NO_A +extern int a1(void); +extern int a2(void); +#endif +int main(void) +{ + return 0 +#ifndef NO_A + + a1() + + a2() +#endif + + b1() + + b2() + ; +} diff --git a/Tests/OutDir/CMakeLists.txt b/Tests/OutDir/CMakeLists.txt new file mode 100644 index 000000000..88468c3c0 --- /dev/null +++ b/Tests/OutDir/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 2.8) +project(OutDir C) + +if(CMAKE_CONFIGURATION_TYPES) + foreach(config ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${config}" CONFIG) + list(APPEND configs "${CONFIG}") + endforeach() + set(CMAKE_BUILD_TYPE) +elseif(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug) +endif() + +if(CMAKE_BUILD_TYPE) + string(TOUPPER "${CMAKE_BUILD_TYPE}" configs) +endif() + +set(top "${OutDir_BINARY_DIR}") +foreach(config ${configs}) + foreach(type archive runtime library) + string(TOUPPER "${type}" TYPE) + set(CMAKE_${TYPE}_OUTPUT_DIRECTORY_${config} "${top}/${type}") + file(REMOVE_RECURSE "${top}/${type}") + endforeach() +endforeach() + +add_subdirectory(../COnly COnly) + +add_custom_command( + OUTPUT OutDir.h + COMMAND ${CMAKE_COMMAND} -Dtop=${top} -P ${OutDir_SOURCE_DIR}/OutDir.cmake + DEPENDS COnly ${OutDir_SOURCE_DIR}/OutDir.cmake + ) +include_directories(${top}) +add_executable(OutDir OutDir.c OutDir.h) diff --git a/Tests/OutDir/OutDir.c b/Tests/OutDir/OutDir.c new file mode 100644 index 000000000..53f925926 --- /dev/null +++ b/Tests/OutDir/OutDir.c @@ -0,0 +1,24 @@ +#include <OutDir.h> +#include <stdio.h> + +int main(void) +{ + const char* files[] = {TESTC1_LIB, TESTC2_LIB, CONLY_EXE, 0}; + int result = 0; + const char** fname = files; + for(;*fname;++fname) + { + FILE* f = fopen(*fname, "rb"); + if(f) + { + printf("found: [%s]\n", *fname); + fclose(f); + } + else + { + printf("error: [%s]\n", *fname); + result = 1; + } + } + return result; +} diff --git a/Tests/OutDir/OutDir.cmake b/Tests/OutDir/OutDir.cmake new file mode 100644 index 000000000..e1e6b7f93 --- /dev/null +++ b/Tests/OutDir/OutDir.cmake @@ -0,0 +1,28 @@ +set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".a" ".so" ".sl" ".dylib" ".dll.a") + +find_library(TESTC1_LIB + NAMES testc1 testc1_test_debug_postfix + PATHS ${top}/archive + NO_DEFAULT_PATH) + +find_library(TESTC2_LIB + NAMES testc2 testc2_test_debug_postfix + PATHS ${top}/archive ${top}/library + NO_DEFAULT_PATH) + +find_program(CONLY_EXE + NAMES COnly + PATHS ${top}/runtime + NO_DEFAULT_PATH) + +file(WRITE ${top}/OutDir.h "/* Generated by ${CMAKE_CURRENT_LIST_FILE} */ +#ifndef OutDir_h +#define OutDir_h + +#define TESTC1_LIB \"${TESTC1_LIB}\" +#define TESTC2_LIB \"${TESTC2_LIB}\" +#define CONLY_EXE \"${CONLY_EXE}\" + +#endif +") diff --git a/Tests/OutOfBinary/CMakeLists.txt b/Tests/OutOfBinary/CMakeLists.txt new file mode 100644 index 000000000..fcf90bd0d --- /dev/null +++ b/Tests/OutOfBinary/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_LIBRARY(outlib outlib.c) + diff --git a/Tests/OutOfBinary/outlib.c b/Tests/OutOfBinary/outlib.c new file mode 100644 index 000000000..9ea579b7a --- /dev/null +++ b/Tests/OutOfBinary/outlib.c @@ -0,0 +1,2 @@ +int outlib() { return 456; } + diff --git a/Tests/OutOfSource/CMakeLists.txt b/Tests/OutOfSource/CMakeLists.txt new file mode 100644 index 000000000..e250f4177 --- /dev/null +++ b/Tests/OutOfSource/CMakeLists.txt @@ -0,0 +1,18 @@ +# a simple test cas +cmake_minimum_required (VERSION 2.6) +project (OutOfSource) + +add_subdirectory(SubDir) + +get_directory_property(ANIMAL DIRECTORY OutOfSourceSubdir DEFINITION WEASELS) +get_directory_property(ANIMALREL DIRECTORY SubDir/../OutOfSourceSubdir DEFINITION WEASELS) +IF(NOT "${ANIMAL}" STREQUAL "${ANIMALREL}") + MESSAGE(FATAL_ERROR "GET_DIRECTORY_PROPERTY does not seem to collapse paths.") +ENDIF(NOT "${ANIMAL}" STREQUAL "${ANIMALREL}") + +configure_file( + ${OutOfSource_SOURCE_DIR}/testdp.h.in + ${OutOfSource_BINARY_DIR}/SubDir/OutOfSourceSubdir/testdp.h + ) + +set(KEN 1) diff --git a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt new file mode 100644 index 000000000..c362e79ba --- /dev/null +++ b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt @@ -0,0 +1,62 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) + +IF ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}") + SET(BUILD_SHARED_LIBS 1) + + # Construct a source file outside the tree whose full path is close to + # the path length limit. This will cause the full path to the object + # file in the build tree to exceed the maximum path length which will + # test cmLocalGenerator::CreateSafeUniqueObjectFileName. + GET_FILENAME_COMPONENT(DEEPDIR + ${OutOfSource_BINARY_DIR}/../OutOfSourceDeep/deeper ABSOLUTE) + + # Test giving the generator a custom limit. + SET(CMAKE_OBJECT_PATH_MAX 220) + + # Use a separate variable for computation. + SET(MAXPATH "${CMAKE_OBJECT_PATH_MAX}") + + # VS8 adds "OutOfSource/SubDir/OutOfSourceSubdir/../../../" to the + # path of the source file for no good reason. Reduce the length + # limit by 46 characters to account for it. It should still be long + # enough to require special object file name conversion. + IF(${CMAKE_GENERATOR} MATCHES "Visual Studio (8|10)") + MATH(EXPR MAXPATH "${MAXPATH} - 46") + ENDIF() + + # Ninja imposes a maximum path component count of 30. Permit more + # path components in the source path. + IF(${CMAKE_GENERATOR} MATCHES "Ninja") + MATH(EXPR MAXPATH "${MAXPATH} - 44") + ENDIF() + + # MAXPATH less 25 for last /and/deeper/simple.cxx part and small safety + MATH(EXPR MAXPATH "${MAXPATH} - 25") + STRING(LENGTH "${DEEPDIR}" DEEPDIR_LEN) + WHILE("${DEEPDIR_LEN}" LESS "${MAXPATH}") + SET(DEEPDIR ${DEEPDIR}/and/deeper) + STRING(LENGTH "${DEEPDIR}" DEEPDIR_LEN) + ENDWHILE("${DEEPDIR_LEN}" LESS "${MAXPATH}") + SET(DEEPSRC ${DEEPDIR}/simple.cxx) + STRING(LENGTH "${DEEPSRC}" DEEPSRC_LEN) + CONFIGURE_FILE(simple.cxx.in ${DEEPSRC} COPYONLY) + + # Watcom WMake seems to have problems with long command lines. Just + # disable this part of the test until it is resolved. + IF(${CMAKE_GENERATOR} MATCHES "Watcom WMake") + SET(DEEPSRC "") + ADD_DEFINITIONS(-DNO_DEEPSRC) + ENDIF(${CMAKE_GENERATOR} MATCHES "Watcom WMake") + + ADD_LIBRARY(testlib testlib.cxx) + ADD_EXECUTABLE (simple simple.cxx ../simple.cxx ${DEEPSRC}) + TARGET_LINK_LIBRARIES(simple testlib outlib) +ENDIF ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}") + +# test getting a definition from a subdir +SET (WEASELS SIZZLING) + +GET_DIRECTORY_PROPERTY(incDirs INCLUDE_DIRECTORIES) +IF(NOT incDirs) + MESSAGE(FATAL_ERROR "GET_DIRECTORY_PROPERTY(INCLUDE_DIRECTORIES) returned empty list") +ENDIF(NOT incDirs) diff --git a/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx new file mode 100644 index 000000000..d88c311f8 --- /dev/null +++ b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <string.h> + +#include "testlib.h" +#include "testdp.h" + +extern int simple(); +#ifndef NO_DEEPSRC +extern int simple2(); +#endif +extern "C" int outlib(); + +int main () +{ + if(simple() != 123) + { + return -3; + } + if (strcmp(animal,"SIZZLING")) + { + fprintf(stderr,"Get definitions from a subdir did not work\n"); + return -2; + } + if(TestLib() != 1.0) + { + return -1; + } + if(outlib() != 456) + { + return -4; + } +#ifndef NO_DEEPSRC + if(simple2() != 789) + { + return -5; + } +#endif + return 0; +} diff --git a/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx.in b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx.in new file mode 100644 index 000000000..8339b7c6e --- /dev/null +++ b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx.in @@ -0,0 +1 @@ +int simple2() { return 789; } diff --git a/Tests/OutOfSource/OutOfSourceSubdir/testlib.cxx b/Tests/OutOfSource/OutOfSourceSubdir/testlib.cxx new file mode 100644 index 000000000..1f78bd3e0 --- /dev/null +++ b/Tests/OutOfSource/OutOfSourceSubdir/testlib.cxx @@ -0,0 +1,6 @@ +#include "testlib.h" + +float TestLib() +{ + return 1.0; +} diff --git a/Tests/OutOfSource/OutOfSourceSubdir/testlib.h b/Tests/OutOfSource/OutOfSourceSubdir/testlib.h new file mode 100644 index 000000000..289b67361 --- /dev/null +++ b/Tests/OutOfSource/OutOfSourceSubdir/testlib.h @@ -0,0 +1,11 @@ +#ifdef _WIN32 +# ifdef testlib_EXPORTS +# define CM_TEST_LIB_EXPORT __declspec( dllexport ) +# else +# define CM_TEST_LIB_EXPORT __declspec( dllimport ) +# endif +#else +# define CM_TEST_LIB_EXPORT +#endif + +CM_TEST_LIB_EXPORT float TestLib(); diff --git a/Tests/OutOfSource/SubDir/CMakeLists.txt b/Tests/OutOfSource/SubDir/CMakeLists.txt new file mode 100644 index 000000000..4fc48e13d --- /dev/null +++ b/Tests/OutOfSource/SubDir/CMakeLists.txt @@ -0,0 +1,8 @@ +PROJECT(ANOTHER_PROJ) + +# subdir to an out of source and out of binary directory +ADD_SUBDIRECTORY(${OutOfSource_SOURCE_DIR}/../OutOfBinary + ${OutOfSource_BINARY_DIR}/../OutOfBinary) + +# subdir to a sibling dir +ADD_SUBDIRECTORY(${OutOfSource_SOURCE_DIR}/${KEN}OutOfSourceSubdir OutOfSourceSubdir ) diff --git a/Tests/OutOfSource/simple.cxx b/Tests/OutOfSource/simple.cxx new file mode 100644 index 000000000..27e79f4ad --- /dev/null +++ b/Tests/OutOfSource/simple.cxx @@ -0,0 +1 @@ +int simple() { return 123; } diff --git a/Tests/OutOfSource/testdp.h.in b/Tests/OutOfSource/testdp.h.in new file mode 100644 index 000000000..2ca99d523 --- /dev/null +++ b/Tests/OutOfSource/testdp.h.in @@ -0,0 +1 @@ +char *animal = "${ANIMAL}"; diff --git a/Tests/PerConfig/CMakeLists.txt b/Tests/PerConfig/CMakeLists.txt new file mode 100644 index 000000000..3a473b883 --- /dev/null +++ b/Tests/PerConfig/CMakeLists.txt @@ -0,0 +1,34 @@ +project(PerConfig C) + +# Targets with per-configuration names. +ADD_LIBRARY(pcStatic STATIC pcStatic.c) +SET_PROPERTY(TARGET pcStatic PROPERTY RELEASE_POSTFIX -opt) +SET_PROPERTY(TARGET pcStatic PROPERTY DEBUG_POSTFIX -dbg) +ADD_LIBRARY(pcShared SHARED pcShared.c) +SET_PROPERTY(TARGET pcShared PROPERTY RELEASE_POSTFIX -opt) +SET_PROPERTY(TARGET pcShared PROPERTY DEBUG_POSTFIX -dbg) +SET_PROPERTY(TARGET pcShared PROPERTY VERSION 1.2) +SET_PROPERTY(TARGET pcShared PROPERTY SOVERSION 3) +IF(UNIX AND NOT CYGWIN) + SET(soname_file -DpcShared_soname_file=$<TARGET_SONAME_FILE:pcShared>) +ENDIF() +ADD_EXECUTABLE(perconfig perconfig.c) +TARGET_LINK_LIBRARIES(perconfig pcStatic pcShared) +SET_PROPERTY(TARGET perconfig PROPERTY RELEASE_POSTFIX -opt) +SET_PROPERTY(TARGET perconfig PROPERTY DEBUG_POSTFIX -dbg) + +SET(PerConfig_COMMAND + ${CMAKE_COMMAND} + -Dconfiguration=$<CONFIGURATION> + -Dperconfig_file_dir=$<TARGET_FILE_DIR:perconfig> + -Dperconfig_file_name=$<TARGET_FILE_NAME:perconfig> + -Dperconfig_file=$<TARGET_FILE:perconfig> + -DpcStatic_file=$<TARGET_FILE:pcStatic> + -DpcStatic_linker_file=$<TARGET_LINKER_FILE:pcStatic> + -DpcShared_file=$<TARGET_FILE:pcShared> + -DpcShared_linker_file=$<TARGET_LINKER_FILE:pcShared> + ${soname_file} + -P ${PerConfig_SOURCE_DIR}/perconfig.cmake + ) +SET(PerConfig_COMMAND "${PerConfig_COMMAND}" PARENT_SCOPE) +SET(PerConfig_DEPENDS ${PerConfig_SOURCE_DIR}/perconfig.cmake perconfig pcStatic pcShared) diff --git a/Tests/PerConfig/pcShared.c b/Tests/PerConfig/pcShared.c new file mode 100644 index 000000000..b08fadc94 --- /dev/null +++ b/Tests/PerConfig/pcShared.c @@ -0,0 +1,5 @@ +#include "pcShared.h" +const char* pcShared(void) +{ + return "INFO:symbol[pcShared]"; +} diff --git a/Tests/PerConfig/pcShared.h b/Tests/PerConfig/pcShared.h new file mode 100644 index 000000000..59a6ef43b --- /dev/null +++ b/Tests/PerConfig/pcShared.h @@ -0,0 +1,16 @@ +#ifndef pcShared_h +#define pcShared_h + +#ifdef _WIN32 +# ifdef pcShared_EXPORTS +# define PC_EXPORT __declspec(dllexport) +# else +# define PC_EXPORT __declspec(dllimport) +# endif +#else +# define PC_EXPORT +#endif + +PC_EXPORT const char* pcShared(void); + +#endif diff --git a/Tests/PerConfig/pcStatic.c b/Tests/PerConfig/pcStatic.c new file mode 100644 index 000000000..7e1bf512d --- /dev/null +++ b/Tests/PerConfig/pcStatic.c @@ -0,0 +1,4 @@ +const char* pcStatic(void) +{ + return "INFO:symbol[pcStatic]"; +} diff --git a/Tests/PerConfig/perconfig.c b/Tests/PerConfig/perconfig.c new file mode 100644 index 000000000..d942d4562 --- /dev/null +++ b/Tests/PerConfig/perconfig.c @@ -0,0 +1,8 @@ +#include "pcShared.h" +extern const char* pcStatic(void); +int main() +{ + pcStatic(); + pcShared(); + return 0; +} diff --git a/Tests/PerConfig/perconfig.cmake b/Tests/PerConfig/perconfig.cmake new file mode 100644 index 000000000..6a710ca4b --- /dev/null +++ b/Tests/PerConfig/perconfig.cmake @@ -0,0 +1,40 @@ +# Print values for human reference. +foreach(v + configuration + perconfig_file_dir + perconfig_file_name + perconfig_file + pcStatic_file + pcStatic_linker_file + pcShared_file + pcShared_linker_file + pcShared_soname_file + ) + message(STATUS "${v}=${${v}}") +endforeach() + +# Verify that file names match as expected. +set(pc_file_components ${perconfig_file_dir}/${perconfig_file_name}) +if(NOT "${pc_file_components}" STREQUAL "${perconfig_file}") + message(SEND_ERROR + "File components ${pc_file_components} do not match ${perconfig_file}") +endif() +if(NOT "${pcStatic_file}" STREQUAL "${pcStatic_linker_file}") + message(SEND_ERROR + "pcStatic_file does not match pcStatic_linker_file:\n" + " ${pcStatic_file}\n" + " ${pcStatic_linker_file}\n" + ) +endif() + +# Verify that the implementation files are named correctly. +foreach(lib pcStatic pcShared) + file(STRINGS "${${lib}_file}" info LIMIT_COUNT 1 REGEX "INFO:[^[]*\\[") + if(NOT "${info}" MATCHES ".*INFO:symbol\\[${lib}\\].*") + message(SEND_ERROR "No INFO:symbol[${lib}] found in:\n ${${lib}_file}") + endif() +endforeach() +execute_process(COMMAND ${perconfig_file} RESULT_VARIABLE result) +if(result) + message(SEND_ERROR "Error running:\n ${perconfig_file}\n(${result})") +endif() diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt new file mode 100644 index 000000000..31ca59c13 --- /dev/null +++ b/Tests/Plugin/CMakeLists.txt @@ -0,0 +1,88 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(Plugin) + +# Test per-target output directory properties. +SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/bin) +SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/plugin) +SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/static) + +# We need the dynamic loader support from KWSys to load the plugin in +# the executable. +SET(KWSYS_NAMESPACE kwsys) +SET(KWSYS_HEADER_ROOT ${Plugin_BINARY_DIR}/include) +SET(KWSYS_USE_DynamicLoader 1) +ADD_SUBDIRECTORY(${Plugin_SOURCE_DIR}/../../Source/kwsys src/kwsys) + +# Configure the location of plugins. +CONFIGURE_FILE(${Plugin_SOURCE_DIR}/src/example_exe.h.in + ${Plugin_BINARY_DIR}/include/example_exe.h @ONLY) + +# We need to include headers from the source tree and configured +# headers in the build tree. +INCLUDE_DIRECTORIES( + ${Plugin_BINARY_DIR}/include + ${Plugin_SOURCE_DIR}/include + ) + +# Create an executable that exports an API for use by plugins. +ADD_EXECUTABLE(example_exe src/example_exe.cxx) +SET_TARGET_PROPERTIES(example_exe PROPERTIES + ENABLE_EXPORTS 1 + OUTPUT_NAME example + # Test placing exe import library in unique directory. + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/exe + ) +TARGET_LINK_LIBRARIES(example_exe kwsys) + +# Create a plugin that uses the API provided by the executable. +# This module "links" to the executable to use the symbols. +ADD_LIBRARY(example_mod_1 MODULE src/example_mod_1.c) +TARGET_LINK_LIBRARIES(example_mod_1 example_exe) + + +IF(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG AND + "${CMAKE_C_CREATE_SHARED_MODULE}" MATCHES "SONAME_FLAG") + # Add a second plugin that should not have any soname. + ADD_LIBRARY(example_mod_2 MODULE src/example_mod_1.c) + TARGET_LINK_LIBRARIES(example_mod_2 example_exe) + SET_PROPERTY(TARGET example_mod_2 PROPERTY NO_SONAME 1) + + # Verify that targets export with proper IMPORTED SONAME properties. + EXPORT(TARGETS example_mod_1 example_mod_2 NAMESPACE exp_ + FILE ${CMAKE_CURRENT_BINARY_DIR}/mods.cmake) + INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/mods.cmake) + GET_PROPERTY(configs TARGET exp_example_mod_1 PROPERTY IMPORTED_CONFIGURATIONS) + FOREACH(c ${configs}) + STRING(TOUPPER "${c}" CONFIG) + GET_PROPERTY(soname1 TARGET exp_example_mod_1 PROPERTY IMPORTED_SONAME_${CONFIG}) + GET_PROPERTY(soname2 TARGET exp_example_mod_2 PROPERTY IMPORTED_NO_SONAME_${CONFIG}) + IF(soname1) + MESSAGE(STATUS "exp_example_mod_1 has IMPORTED_SONAME_${CONFIG} as expected: ${soname1}") + ELSE() + MESSAGE(SEND_ERROR "exp_example_mod_1 does not have IMPORTED_SONAME_${CONFIG} but should") + ENDIF() + IF(soname2) + MESSAGE(STATUS "exp_example_mod_2 has IMPORTED_NO_SONAME_${CONFIG} as expected: ${soname2}") + ELSE() + MESSAGE(SEND_ERROR "exp_example_mod_2 does not have IMPORTED_NO_SONAME_${CONFIG} but should") + ENDIF() + ENDFOREACH() + + # Parse the binary to check for SONAME if possible. + IF("${CMAKE_EXECUTABLE_FORMAT}" MATCHES "ELF") + FIND_PROGRAM(READELF_EXE readelf) + IF(READELF_EXE) + ADD_CUSTOM_TARGET(check_mod_soname ALL COMMAND + ${CMAKE_COMMAND} -Dreadelf=${READELF_EXE} + -Dmod1=$<TARGET_FILE:example_mod_1> + -Dmod2=$<TARGET_FILE:example_mod_2> + -P ${CMAKE_CURRENT_SOURCE_DIR}/check_mod_soname.cmake + ) + ADD_DEPENDENCIES(check_mod_soname example_mod_1 example_mod_2) + ENDIF() + ENDIF() +ENDIF() + +# TODO: +# - create a plugin that links to a static lib +# - create a plugin that links to a shared lib diff --git a/Tests/Plugin/check_mod_soname.cmake b/Tests/Plugin/check_mod_soname.cmake new file mode 100644 index 000000000..3737b450d --- /dev/null +++ b/Tests/Plugin/check_mod_soname.cmake @@ -0,0 +1,14 @@ +execute_process(COMMAND ${readelf} -d ${mod1} OUTPUT_FILE ${mod1}.readelf.txt) +execute_process(COMMAND ${readelf} -d ${mod2} OUTPUT_FILE ${mod2}.readelf.txt) +file(STRINGS ${mod1}.readelf.txt soname1 REGEX "\\(SONAME\\)") +file(STRINGS ${mod2}.readelf.txt soname2 REGEX "\\(SONAME\\)") +if(soname1) + message(STATUS "${mod1} has soname as expected: ${soname1}") +else() + message(FATAL_ERROR "${mod1} has no soname but should:\n ${soname1}") +endif() +if(soname2) + message(FATAL_ERROR "${mod2} has soname but should not:\n ${soname2}") +else() + message(STATUS "${mod2} has no soname as expected") +endif() diff --git a/Tests/Plugin/include/example.h b/Tests/Plugin/include/example.h new file mode 100644 index 000000000..1d7e8c015 --- /dev/null +++ b/Tests/Plugin/include/example.h @@ -0,0 +1,25 @@ +#ifndef example_h +#define example_h + +#if defined(_WIN32) || defined(__CYGWIN__) +# if defined(example_exe_EXPORTS) +# define EXAMPLE_EXPORT __declspec(dllexport) +# else +# define EXAMPLE_EXPORT __declspec(dllimport) +# endif +#else +# define EXAMPLE_EXPORT +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +EXAMPLE_EXPORT int example_exe_function(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Tests/Plugin/src/example_exe.cxx b/Tests/Plugin/src/example_exe.cxx new file mode 100644 index 000000000..d2c52052c --- /dev/null +++ b/Tests/Plugin/src/example_exe.cxx @@ -0,0 +1,60 @@ +#include <example.h> + +#include <example_exe.h> + +#include <kwsys/DynamicLoader.hxx> +#include <kwsys/ios/iostream> +#include <kwsys/stl/string> + +#include <stdio.h> + +// Implement the ABI used by plugins. +extern "C" int example_exe_function() +{ + kwsys_ios::cout << "hello" << kwsys_ios::endl; + return 123; +} + +#ifdef CMAKE_INTDIR +# define CONFIG_DIR "/" CMAKE_INTDIR +#else +# define CONFIG_DIR "" +#endif + +int main() +{ + kwsys_stl::string libName = EXAMPLE_EXE_PLUGIN_DIR CONFIG_DIR "/"; + libName += kwsys::DynamicLoader::LibPrefix(); + libName += "example_mod_1"; + libName += kwsys::DynamicLoader::LibExtension(); + kwsys::DynamicLoader::LibraryHandle handle = + kwsys::DynamicLoader::OpenLibrary(libName.c_str()); + if(!handle) + { + kwsys_ios::cerr << "Could not open plugin \"" + << libName << "\"!" << kwsys_ios::endl; + return 1; + } + kwsys::DynamicLoader::SymbolPointer sym = + kwsys::DynamicLoader::GetSymbolAddress(handle, "example_mod_1_function"); + if(!sym) + { + kwsys_ios::cerr + << "Could not get plugin symbol \"example_mod_1_function\"!" + << kwsys_ios::endl; + return 1; + } +#ifdef __WATCOMC__ + int(__cdecl *f)(int) = (int(__cdecl *)(int))(sym); +#else + int(*f)(int) = reinterpret_cast<int(*)(int)>(sym); +#endif + if(f(456) != (123+456)) + { + kwsys_ios::cerr << "Incorrect return value from plugin!" + << kwsys_ios::endl; + return 1; + } + kwsys::DynamicLoader::CloseLibrary(handle); + return 0; +} diff --git a/Tests/Plugin/src/example_exe.h.in b/Tests/Plugin/src/example_exe.h.in new file mode 100644 index 000000000..62f0d9f02 --- /dev/null +++ b/Tests/Plugin/src/example_exe.h.in @@ -0,0 +1,6 @@ +#ifndef example_exe_h +#define example_exe_h + +#define EXAMPLE_EXE_PLUGIN_DIR "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@" + +#endif diff --git a/Tests/Plugin/src/example_mod_1.c b/Tests/Plugin/src/example_mod_1.c new file mode 100644 index 000000000..1fc733845 --- /dev/null +++ b/Tests/Plugin/src/example_mod_1.c @@ -0,0 +1,22 @@ +#include <example.h> + +#include <stdio.h> + +#if defined(_WIN32) +# define MODULE_EXPORT __declspec(dllexport) +#else +# define MODULE_EXPORT +#endif + +#ifdef __WATCOMC__ +# define MODULE_CCONV __cdecl +#else +# define MODULE_CCONV +#endif + +MODULE_EXPORT int MODULE_CCONV example_mod_1_function(int n) +{ + int result = example_exe_function() + n; + printf("world\n"); + return result; +} diff --git a/Tests/Policy0002/A/CMakeLists.txt b/Tests/Policy0002/A/CMakeLists.txt new file mode 100644 index 000000000..cee6422a9 --- /dev/null +++ b/Tests/Policy0002/A/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(Policy0002 ../policy0002.c) diff --git a/Tests/Policy0002/CMakeLists.txt b/Tests/Policy0002/CMakeLists.txt new file mode 100644 index 000000000..0f6d3319a --- /dev/null +++ b/Tests/Policy0002/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.6) +project(Policy0002 C) +cmake_policy(SET CMP0002 OLD) +add_subdirectory(A) +add_executable(Policy0002 policy0002.c) diff --git a/Tests/Policy0002/policy0002.c b/Tests/Policy0002/policy0002.c new file mode 100644 index 000000000..8488f4e58 --- /dev/null +++ b/Tests/Policy0002/policy0002.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/PolicyScope/Bar.cmake b/Tests/PolicyScope/Bar.cmake new file mode 100644 index 000000000..cf1904c48 --- /dev/null +++ b/Tests/PolicyScope/Bar.cmake @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.6.3) + +# Make sure a policy set differently by our includer is now correct. +cmake_policy(GET CMP0003 cmp) +check(CMP0003 "NEW" "${cmp}") + +# Test allowing the top-level file to not have cmake_minimum_required. +cmake_policy(SET CMP0000 OLD) diff --git a/Tests/PolicyScope/CMakeLists.txt b/Tests/PolicyScope/CMakeLists.txt new file mode 100644 index 000000000..e6f2edc07 --- /dev/null +++ b/Tests/PolicyScope/CMakeLists.txt @@ -0,0 +1,104 @@ +project(PolicyScope C) +# No cmake_minimum_required(VERSION), it's in FindFoo. + +#----------------------------------------------------------------------------- +# Helper function to report results. +function(check msg lhs rhs) + if(NOT "${lhs}" STREQUAL "${rhs}") + message(FATAL_ERROR "${msg}: expected [${lhs}], got [${rhs}]") + endif() +endfunction(check) + +#----------------------------------------------------------------------------- +# Test using a development framework that sets policies for us. + +# Policy CMP0011 should not be set at this point. +cmake_policy(GET CMP0011 cmp) +check(CMP0011 "" "${cmp}") + +# Put the test modules in the search path. +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +# The included file should set policies for us. +find_package(Foo) + +# Check policies set by the package. +cmake_policy(GET CMP0003 cmp) +check(CMP0003 "OLD" "${cmp}") +cmake_policy(GET CMP0002 cmp) +check(CMP0002 "NEW" "${cmp}") +cmake_policy(GET CMP0011 cmp) +check(CMP0011 "NEW" "${cmp}") + +# Make sure an included file cannot change policies. +include(Bar) +cmake_policy(GET CMP0003 cmp) +check(CMP0003 "OLD" "${cmp}") + +# Allow the included file to change policies. +include(Bar NO_POLICY_SCOPE) +cmake_policy(GET CMP0003 cmp) +check(CMP0003 "NEW" "${cmp}") + +#----------------------------------------------------------------------------- +# Test function and macro policy recording. + +# Create the functions in an isolated scope in which we change policies. +cmake_policy(PUSH) +if(1) + # Change CMP0002 + cmake_policy(SET CMP0002 OLD) + function(func1) + # CMP0002 should be changed when this function is invoked + cmake_policy(GET CMP0002 cmp) + check(CMP0002 "OLD" "${cmp}") + endfunction(func1) + + # Unset CMP0002 + cmake_policy(VERSION 2.4) + macro(macro1) + # CMP0002 should be unset when this macro is invoked + cmake_policy(GET CMP0002 cmp) + check(CMP0002 "" "${cmp}") + + # Setting the policy should work here and also in the caller. + cmake_policy(SET CMP0002 OLD) + cmake_policy(GET CMP0002 cmp) + check(CMP0002 "OLD" "${cmp}") + endmacro(macro1) +endif(1) +cmake_policy(POP) + +# CMP0002 should still be NEW in this context. +cmake_policy(GET CMP0002 cmp) +check(CMP0002 "NEW" "${cmp}") + +# Check the recorded policies +func1() +macro1() + +# The macro should have changed CMP0002. +cmake_policy(GET CMP0002 cmp) +check(CMP0002 "OLD" "${cmp}") + +#----------------------------------------------------------------------------- +# Test CMAKE_POLICY_DEFAULT_CMP<NNNN> variable. +cmake_policy(PUSH) + set(CMAKE_POLICY_DEFAULT_CMP0010 OLD) # ignored + set(CMAKE_POLICY_DEFAULT_CMP0012 OLD) # honored + set(CMAKE_POLICY_DEFAULT_CMP0013 NEW) # honored + set(CMAKE_POLICY_DEFAULT_CMP0014 "") # noop + cmake_policy(VERSION 2.6.3) + cmake_policy(GET CMP0010 cmp) + check(CMP0010 "NEW" "${cmp}") + cmake_policy(GET CMP0012 cmp) + check(CMP0012 "OLD" "${cmp}") + cmake_policy(GET CMP0013 cmp) + check(CMP0013 "NEW" "${cmp}") + cmake_policy(GET CMP0014 cmp) + check(CMP0014 "" "${cmp}") +cmake_policy(POP) + +#----------------------------------------------------------------------------- +# Dummy executable so the project can build and run. +add_executable(PolicyScope main.c) diff --git a/Tests/PolicyScope/FindFoo.cmake b/Tests/PolicyScope/FindFoo.cmake new file mode 100644 index 000000000..5b441e20e --- /dev/null +++ b/Tests/PolicyScope/FindFoo.cmake @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 2.6.3) +cmake_policy(SET CMP0003 OLD) diff --git a/Tests/PolicyScope/main.c b/Tests/PolicyScope/main.c new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/PolicyScope/main.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/PositionIndependentTargets/CMakeLists.txt b/Tests/PositionIndependentTargets/CMakeLists.txt new file mode 100644 index 000000000..eec893d32 --- /dev/null +++ b/Tests/PositionIndependentTargets/CMakeLists.txt @@ -0,0 +1,13 @@ + +cmake_minimum_required(VERSION 2.8) + +project(PositionIndependentTargets) + +include(CheckCXXSourceCompiles) + +include_directories("${CMAKE_CURRENT_SOURCE_DIR}") # For pic_test.h + +add_subdirectory(global) +add_subdirectory(targets) + +add_executable(PositionIndependentTargets main.cpp) diff --git a/Tests/PositionIndependentTargets/global/CMakeLists.txt b/Tests/PositionIndependentTargets/global/CMakeLists.txt new file mode 100644 index 000000000..1d662f8ea --- /dev/null +++ b/Tests/PositionIndependentTargets/global/CMakeLists.txt @@ -0,0 +1,37 @@ + +set(CMAKE_POSITION_INDEPENDENT_CODE True) + +add_executable(test_target_executable_global + "${CMAKE_CURRENT_SOURCE_DIR}/../pic_main.cpp" +) + +add_library(test_target_shared_library_global + SHARED "${CMAKE_CURRENT_SOURCE_DIR}/../pic_lib.cpp" +) +set_target_properties(test_target_shared_library_global + PROPERTIES DEFINE_SYMBOL PIC_TEST_BUILD_DLL +) + +add_library(test_target_static_library_global + STATIC "${CMAKE_CURRENT_SOURCE_DIR}/../pic_lib.cpp" +) +set_target_properties(test_target_static_library_global + PROPERTIES COMPILE_DEFINITIONS PIC_TEST_STATIC_BUILD +) + + +file(READ + "${CMAKE_CURRENT_SOURCE_DIR}/../pic_test.h" + PIC_HEADER_CONTENT +) + +check_cxx_source_compiles( + " +${PIC_HEADER_CONTENT} +int main(int,char**) { return 0; }\n" + PIC_TRY_COMPILE_RESULT +) + +if (NOT PIC_TRY_COMPILE_RESULT) + message(SEND_ERROR "TRY_COMPILE with content requiring __PIC__ failed. ${OUTPUT}") +endif() diff --git a/Tests/PositionIndependentTargets/main.cpp b/Tests/PositionIndependentTargets/main.cpp new file mode 100644 index 000000000..e72cef7eb --- /dev/null +++ b/Tests/PositionIndependentTargets/main.cpp @@ -0,0 +1,2 @@ + +int main(int,char**) { return 0; } diff --git a/Tests/PositionIndependentTargets/pic_lib.cpp b/Tests/PositionIndependentTargets/pic_lib.cpp new file mode 100644 index 000000000..b8b25a33e --- /dev/null +++ b/Tests/PositionIndependentTargets/pic_lib.cpp @@ -0,0 +1,12 @@ + +#include "pic_test.h" + +class PIC_TEST_EXPORT Dummy +{ + int dummy(); +}; + +int Dummy::dummy() +{ + return 0; +} diff --git a/Tests/PositionIndependentTargets/pic_main.cpp b/Tests/PositionIndependentTargets/pic_main.cpp new file mode 100644 index 000000000..6a41a7a6b --- /dev/null +++ b/Tests/PositionIndependentTargets/pic_main.cpp @@ -0,0 +1,4 @@ + +#include "pic_test.h" + +int main(int,char**) { return 0; } diff --git a/Tests/PositionIndependentTargets/pic_test.h b/Tests/PositionIndependentTargets/pic_test.h new file mode 100644 index 000000000..13cf8f79f --- /dev/null +++ b/Tests/PositionIndependentTargets/pic_test.h @@ -0,0 +1,20 @@ + +#if defined(__ELF__) +# if !defined(__PIC__) && !defined(__PIE__) +# error "The POSITION_INDEPENDENT_CODE property should cause __PIC__ or __PIE__ to be defined on ELF platforms." +# endif +#endif + +#if defined(PIC_TEST_STATIC_BUILD) +# define PIC_TEST_EXPORT +#else +# if defined(_WIN32) || defined(WIN32) /* Win32 version */ +# ifdef PIC_TEST_BUILD_DLL +# define PIC_TEST_EXPORT __declspec(dllexport) +# else +# define PIC_TEST_EXPORT __declspec(dllimport) +# endif +# else +# define PIC_TEST_EXPORT +# endif +#endif diff --git a/Tests/PositionIndependentTargets/targets/CMakeLists.txt b/Tests/PositionIndependentTargets/targets/CMakeLists.txt new file mode 100644 index 000000000..4724c854a --- /dev/null +++ b/Tests/PositionIndependentTargets/targets/CMakeLists.txt @@ -0,0 +1,20 @@ + +add_executable(test_target_executable_properties "${CMAKE_CURRENT_SOURCE_DIR}/../pic_main.cpp") +set_target_properties(test_target_executable_properties + PROPERTIES + POSITION_INDEPENDENT_CODE True +) + +add_library(test_target_shared_library_properties SHARED "${CMAKE_CURRENT_SOURCE_DIR}/../pic_lib.cpp") +set_target_properties(test_target_shared_library_properties + PROPERTIES + POSITION_INDEPENDENT_CODE True + DEFINE_SYMBOL PIC_TEST_BUILD_DLL +) + +add_library(test_target_static_library_properties STATIC "${CMAKE_CURRENT_SOURCE_DIR}/../pic_lib.cpp") +set_target_properties(test_target_static_library_properties + PROPERTIES + POSITION_INDEPENDENT_CODE True + COMPILE_DEFINITIONS PIC_TEST_STATIC_BUILD +) diff --git a/Tests/PreOrder/CMakeLists.txt b/Tests/PreOrder/CMakeLists.txt new file mode 100644 index 000000000..29720e4c1 --- /dev/null +++ b/Tests/PreOrder/CMakeLists.txt @@ -0,0 +1,6 @@ +# a simple test case +PROJECT (PreOrder) +SET(CMAKE_IGNORE_DEPENDENCIES_ORDERING 1) +ADD_SUBDIRECTORY(Library) +ADD_EXECUTABLE (PreOrder simple.cxx) +TARGET_LINK_LIBRARIES(PreOrder simpleLib) diff --git a/Tests/PreOrder/Library/CMakeLists.txt b/Tests/PreOrder/Library/CMakeLists.txt new file mode 100644 index 000000000..6c011eca9 --- /dev/null +++ b/Tests/PreOrder/Library/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_LIBRARY(simpleLib simpleLib.cxx ) + diff --git a/Tests/PreOrder/Library/simpleLib.cxx b/Tests/PreOrder/Library/simpleLib.cxx new file mode 100644 index 000000000..281d8885a --- /dev/null +++ b/Tests/PreOrder/Library/simpleLib.cxx @@ -0,0 +1,3 @@ +void simpleLib() +{ +} diff --git a/Tests/PreOrder/simple.cxx b/Tests/PreOrder/simple.cxx new file mode 100644 index 000000000..ef26e7984 --- /dev/null +++ b/Tests/PreOrder/simple.cxx @@ -0,0 +1,6 @@ +extern void simpleLib(); +int main () +{ + simpleLib(); + return 0; +} diff --git a/Tests/PrecompiledHeader/CMakeLists.txt b/Tests/PrecompiledHeader/CMakeLists.txt new file mode 100644 index 000000000..3374e325f --- /dev/null +++ b/Tests/PrecompiledHeader/CMakeLists.txt @@ -0,0 +1,59 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(PrecompiledHeader C) + +# Make sure the proper compiler is in use. +IF(NOT MSVC AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") + MESSAGE(FATAL_ERROR "The PrecompiledHeader test works only with MSVC or Intel") +ENDIF() + +# Compute a custom name for the precompiled header. +IF(CMAKE_CONFIGURATION_TYPES) + SET(PCH_DIR "${CMAKE_CURRENT_BINARY_DIR}/PCH/${CMAKE_CFG_INTDIR}") + FOREACH(cfg ${CMAKE_CONFIGURATION_TYPES}) + FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/PCH/${cfg}) + ENDFOREACH() +ELSE(CMAKE_CONFIGURATION_TYPES) + SET(PCH_DIR "${CMAKE_CURRENT_BINARY_DIR}/PCH") + FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/PCH) +ENDIF(CMAKE_CONFIGURATION_TYPES) + +# The VS6 IDE does not support renaming .pch files with /Fp. +IF("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6") + SET(PCH_USE_INCLUDE_DIR 1) + SET(PCH_FILE) +ELSE("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6") + SET(PCH_USE_INCLUDE_DIR 0) + SET(PCH_FILE "\"/Fp${PCH_DIR}/foo_precompiled.pch\"") +ENDIF("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6") + +# Choose between an explicit include path and using /I during +# precompilation. The /I form is used to test that the PCH is +# actually used. In practice the include path form would be used. +IF(PCH_USE_INCLUDE_DIR) + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) +ELSE(PCH_USE_INCLUDE_DIR) + SET(PCH_INCLUDE_DIR "\"/I${CMAKE_CURRENT_SOURCE_DIR}/include\"") +ENDIF(PCH_USE_INCLUDE_DIR) + +# Create a target that will use a precompiled header. +SET(foo_SRCS foo1.c foo2.c) +ADD_EXECUTABLE(foo foo_precompile.c ${foo_SRCS}) + +# Setup flags on the target to create and use the precompiled header. +SET_TARGET_PROPERTIES(foo PROPERTIES + COMPILE_FLAGS "/Yufoo_precompiled.h /FIfoo_precompiled.h ${PCH_FILE}") +SET_SOURCE_FILES_PROPERTIES(foo_precompile.c PROPERTIES + COMPILE_FLAGS "/Ycfoo_precompiled.h ${PCH_INCLUDE_DIR}") + +# Setup dependencies for precompiled header creation and use. The VS +# IDE takes care of this automatically. +IF("${CMAKE_GENERATOR}" MATCHES "Makefile" OR + "${CMAKE_GENERATOR}" MATCHES "Ninja") + # This source file creates the precompiled header as a side-effect. + SET_SOURCE_FILES_PROPERTIES(foo_precompile.c PROPERTIES + OBJECT_OUTPUTS "${PCH_DIR}/foo_precompiled.pch") + + # These source files use the precompiled header. + SET_SOURCE_FILES_PROPERTIES(${foo_SRCS} PROPERTIES + OBJECT_DEPENDS "${PCH_DIR}/foo_precompiled.pch") +ENDIF("${CMAKE_GENERATOR}" MATCHES "Makefile") diff --git a/Tests/PrecompiledHeader/foo1.c b/Tests/PrecompiledHeader/foo1.c new file mode 100644 index 000000000..b10eba7e9 --- /dev/null +++ b/Tests/PrecompiledHeader/foo1.c @@ -0,0 +1,8 @@ +#ifndef foo_h +# error "Precompiled header foo_precompiled.h has not been loaded." +#endif + +int main() +{ + return foo(); +} diff --git a/Tests/PrecompiledHeader/foo2.c b/Tests/PrecompiledHeader/foo2.c new file mode 100644 index 000000000..2845cdb15 --- /dev/null +++ b/Tests/PrecompiledHeader/foo2.c @@ -0,0 +1,9 @@ +#ifndef foo_h +# include "foo.h" +# error "Precompiled header foo_precompiled.h has not been loaded." +#endif + +int foo() +{ + return 0; +} diff --git a/Tests/PrecompiledHeader/foo_precompile.c b/Tests/PrecompiledHeader/foo_precompile.c new file mode 100644 index 000000000..c37d69a1c --- /dev/null +++ b/Tests/PrecompiledHeader/foo_precompile.c @@ -0,0 +1,5 @@ +/* The foo_precompiled.h header is included by a /FI option when this + source is used to create a precompiled header. Include it here + explicitly to allow dependency scanning to detect the dependency + whether or not the include path is known to the scanner. */ +#include "include/foo_precompiled.h" diff --git a/Tests/PrecompiledHeader/include/foo.h b/Tests/PrecompiledHeader/include/foo.h new file mode 100644 index 000000000..2210cb41d --- /dev/null +++ b/Tests/PrecompiledHeader/include/foo.h @@ -0,0 +1,4 @@ +#ifndef foo_h +#define foo_h +extern int foo(); +#endif diff --git a/Tests/PrecompiledHeader/include/foo_precompiled.h b/Tests/PrecompiledHeader/include/foo_precompiled.h new file mode 100644 index 000000000..f4de601ff --- /dev/null +++ b/Tests/PrecompiledHeader/include/foo_precompiled.h @@ -0,0 +1 @@ +#include "foo.h" diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt new file mode 100644 index 000000000..1ed7b83ac --- /dev/null +++ b/Tests/Preprocess/CMakeLists.txt @@ -0,0 +1,269 @@ +cmake_minimum_required(VERSION 2.6) +project(Preprocess) + +# This test is meant both as a test and as a reference for supported +# syntax on native tool command lines. + +# Determine the build tool being used. Not all characters can be +# escaped for all build tools. This test checks all characters known +# to work with each tool and documents those known to not work. +if("${CMAKE_GENERATOR}" MATCHES "Xcode") + set(PP_XCODE 1) +endif("${CMAKE_GENERATOR}" MATCHES "Xcode") +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6") + set(PP_VS6 1) +endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6") +if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") + set(PP_UMAKE 1) +endif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") +if("${CMAKE_GENERATOR}" MATCHES "NMake Makefiles") + set(PP_NMAKE 1) +endif("${CMAKE_GENERATOR}" MATCHES "NMake Makefiles") +if("${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles") + set(PP_MINGW 1) +endif("${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles") +if("${CMAKE_GENERATOR}" MATCHES "Borland Makefiles") + set(PP_BORLAND 1) +endif("${CMAKE_GENERATOR}" MATCHES "Borland Makefiles") +if("${CMAKE_GENERATOR}" MATCHES "Watcom WMake") + set(PP_WATCOM 1) +endif("${CMAKE_GENERATOR}" MATCHES "Watcom WMake") +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 7$") + set(PP_VS70 1) +endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio 7$") +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + set(PP_VS 1) +endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio") +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 10") + set(PP_VS100 1) +endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio 10") +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 11") + set(PP_VS110 1) +endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio 11") + +# Some tests below check the PP_* variables set above. They are meant +# to test the case that the build tool is at fault. Other tests below +# check the compiler that will be used when the compiler is at fault +# (does not work even from a command shell). + +#----------------------------------------------------------------------------- +# Construct a C-string literal to test passing through a definition on +# the command line. We configure the value into a header so it can be +# checked in the executable at runtime. The semicolon is handled +# specially because it needs to be escaped in the COMPILE_DEFINITIONS +# property value to avoid separating definitions but the string value +# must not have it escaped inside the configured header. +set(STRING_EXTRA "") + +if(NOT BORLAND AND NOT PP_VS70 AND NOT PP_VS100 AND NOT PP_VS110) + # Borland, VS70 IDE: ; + # The Borland compiler will simply not accept a non-escaped semicolon + # on the command line. If it is escaped \; then the escape character + # shows up in the preprocessing output too. + # + # The VS 7.0 IDE separates definitions on semicolons and commas with + # no regard for quotes. Fortunately VS 7.1 and above are okay. + # VS 10 seems to also not like semicolons + set(SEMICOLON "\;") +endif() + +if(NOT PP_VS6) + # VS 6 IDE: spaces and '"', '$', or ';' + # The project parser cannot handle spaces if there are quotes. + # Since we test passing in a quoted string, we cannot have spaces. + set(STRING_EXTRA "${STRING_EXTRA} ") + + if(NOT PP_BORLAND AND NOT PP_WATCOM) + # Borland, WMake: multiple spaces + # The make tool seems to remove extra whitespace from inside + # quoted strings when passing to the compiler. It does not have + # trouble passing to other tools, and the compiler may be directly + # invoked from the command line. + set(STRING_EXTRA "${STRING_EXTRA} ") + endif(NOT PP_BORLAND AND NOT PP_WATCOM) +endif(NOT PP_VS6) + +if(NOT PP_VS) + # VS: , + # Visual Studio will not accept a comma in the value of a definition. + # The comma-separated list of PreprocessorDefinitions in the project + # file seems to be parsed before the content of entries is examined. + set(STRING_EXTRA "${STRING_EXTRA},") +endif(NOT PP_VS) + +if(NOT PP_MINGW) + # MinGW: & + # When inside -D"FOO=\"a & b\"" MinGW make wants -D"FOO=\"a "&" b\"" + # but it does not like quoted ampersand elsewhere. + set(STRING_EXTRA "${STRING_EXTRA}&") +endif(NOT PP_MINGW) + +if(NOT PP_MINGW) + # MinGW: | + # When inside -D"FOO=\"a | b\"" MinGW make wants -D"FOO=\"a "|" b\"" + # but it does not like quoted pipe elsewhere. + set(STRING_EXTRA "${STRING_EXTRA}|") +endif(NOT PP_MINGW) + +if(NOT PP_BORLAND AND NOT PP_MINGW AND NOT PP_NMAKE) + # Borland, NMake, MinGW: ^ + # When inside -D"FOO=\"a ^ b\"" the make tools want -D"FOO=\"a "^" b\"" + # but do not like quoted carrot elsewhere. In NMake the non-quoted + # syntax works when the flags are not in a make variable. + set(STRING_EXTRA "${STRING_EXTRA}^") +endif(NOT PP_BORLAND AND NOT PP_MINGW AND NOT PP_NMAKE) + +if(NOT PP_BORLAND AND NOT PP_MINGW AND NOT PP_NMAKE) + # Borland, MinGW: < > + # Angle-brackets have funny behavior that is hard to escape. + set(STRING_EXTRA "${STRING_EXTRA}<>") +endif(NOT PP_BORLAND AND NOT PP_MINGW AND NOT PP_NMAKE) + +set(EXPR_OP1 "/") +if((NOT MSVC OR PP_NMAKE) AND + NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") + # MSVC cl, Intel icl: % + # When the cl compiler is invoked from the command line then % must + # be written %% (to distinguish from %ENV% syntax). However cl does + # not seem to accept the syntax when it is invoked from inside a + # make tool (nmake, mingw32-make, etc.). Instead the argument must + # be placed inside a response file. Then cl accepts it because it + # parses the response file as it would the normal windows command + # line. Currently only NMake supports running cl with a response + # file. Supporting other make tools would require CMake to generate + # response files explicitly for each object file. + # + # When the icl compiler is invoked from the command line then % must + # be written just '%'. However nmake requires '%%' except when using + # response files. Currently we have no way to affect escaping based + # on whether flags go in a response file, so we just have to skip it. + set(STRING_EXTRA "${STRING_EXTRA}%") + set(EXPR_OP1 "%") +endif() + +# General: \" +# Make tools do not reliably accept \\\" syntax: +# - MinGW and MSYS make tools crash with \\\" +# - Borland make actually wants a mis-matched quote \\" +# or $(BACKSLASH)\" where BACKSLASH is a variable set to \\ +# - VS IDE gets confused about the bounds of the definition value \\\" +# - NMake is okay with just \\\" +if(PP_NMAKE OR PP_UMAKE) + set(STRING_EXTRA "${STRING_EXTRA}\\\"") +endif(PP_NMAKE OR PP_UMAKE) + +# General: # +# MSVC will not accept a # in the value of a string definition on the +# command line. The character seems to be simply replaced by an +# equals =. According to "cl -help" definitions may be specified by +# -DMACRO#VALUE as well as -DMACRO=VALUE. It must be implemented by a +# simple search-and-replace. +# +# The Borland compiler will parse both # and \# as just # but the make +# tool seems to want \# sometimes and not others. +# +# Unix make does not like # in variable settings without extra +# escaping. This could probably be fixed but since MSVC does not +# support it and it is not an operator it is not worthwhile. + +# Compose the final test string. +set(STRING_VALUE "hello`~!@$*)(_+-=}{][:'.?/${STRING_EXTRA}world") + +#----------------------------------------------------------------------------- +# Function-style macro command-line support: +# - Borland does not support +# - MSVC does not support +# - Watcom does not support +# - GCC supports + +# Too few platforms support this to bother implementing. +# People can just configure headers with the macros. + +#----------------------------------------------------------------------------- +# Construct a sample expression to pass as a macro definition. + +set(EXPR "x*y+!(x==(y+1*2))*f(x${EXPR_OP1}2)") + +if(NOT WATCOM) + # Watcom does not support - or / because it parses them as options. + set(EXPR "${EXPR} + y/x-x") +endif(NOT WATCOM) + +#----------------------------------------------------------------------------- + +# Inform the test if the debug configuration is getting built. +# The NDEBUG definition takes care of this for release. +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DPREPROCESS_DEBUG") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DPREPROCESS_DEBUG") + +# Inform the test if it built from Xcode or VS6 IDE. +if(PP_XCODE) + set(PREPROCESS_XCODE 1) +endif(PP_XCODE) +if(PP_VS6) + set(PREPROCESS_VS6 1) + set(VS6 _vs6) +endif(PP_VS6) + +# Test old-style definitions. +add_definitions(-DOLD_DEF -DOLD_EXPR=2) + +# Make sure old-style definitions are converted to directory property. +set(OLD_DEFS_EXPECTED "OLD_DEF;OLD_EXPR=2") +get_property(OLD_DEFS DIRECTORY PROPERTY COMPILE_DEFINITIONS) +if(NOT "${OLD_DEFS}" STREQUAL "${OLD_DEFS_EXPECTED}") + message(SEND_ERROR "add_definitions not converted to directory property!") +endif(NOT "${OLD_DEFS}" STREQUAL "${OLD_DEFS_EXPECTED}") + +add_executable(Preprocess preprocess.c preprocess${VS6}.cxx) + +set(FILE_PATH "${Preprocess_SOURCE_DIR}/file_def.h") +set(TARGET_PATH "${Preprocess_SOURCE_DIR}/target_def.h") + +# Set some definition properties. +foreach(c "" "_DEBUG" "_RELEASE") + set_property( + DIRECTORY . + APPEND PROPERTY COMPILE_DEFINITIONS${c} "DIRECTORY_DEF${c}" + ) + set_property( + TARGET Preprocess + PROPERTY COMPILE_DEFINITIONS${c} "TARGET_DEF${c}" + ) + set_property( + SOURCE preprocess.c preprocess${VS6}.cxx + PROPERTY COMPILE_DEFINITIONS${c} "FILE_DEF${c}" + ) +endforeach(c) + +# Add definitions with values. +if(NOT PREPROCESS_VS6) + # The path might have spaces, which VS6 does not support. + set(DEF_TARGET_PATH "TARGET_PATH=\"${TARGET_PATH}\"") + set(DEF_FILE_PATH "FILE_PATH=\"${FILE_PATH}\"") +endif(NOT PREPROCESS_VS6) +set_property( + TARGET Preprocess + APPEND PROPERTY COMPILE_DEFINITIONS + "TARGET_STRING=\"${STRING_VALUE}${SEMICOLON}\"" + "TARGET_EXPR=${EXPR}" + ${DEF_TARGET_PATH} + ) +set_property( + SOURCE preprocess.c preprocess${VS6}.cxx + APPEND PROPERTY COMPILE_DEFINITIONS + "FILE_STRING=\"${STRING_VALUE}${SEMICOLON}\"" + "FILE_EXPR=${EXPR}" + ${DEF_FILE_PATH} + ) + +# Helper target for running test manually in build tree. +add_custom_target(drive COMMAND Preprocess) + +# Configure the header file with the desired string value. +if(SEMICOLON) + set(STRING_VALUE "${STRING_VALUE};") +endif(SEMICOLON) +configure_file(${Preprocess_SOURCE_DIR}/preprocess.h.in + ${Preprocess_BINARY_DIR}/preprocess.h) +include_directories(${Preprocess_BINARY_DIR}) diff --git a/Tests/Preprocess/file_def.h b/Tests/Preprocess/file_def.h new file mode 100644 index 000000000..fbf8986a0 --- /dev/null +++ b/Tests/Preprocess/file_def.h @@ -0,0 +1 @@ +#define FILE_PATH_DEF diff --git a/Tests/Preprocess/preprocess.c b/Tests/Preprocess/preprocess.c new file mode 100644 index 000000000..16209acf4 --- /dev/null +++ b/Tests/Preprocess/preprocess.c @@ -0,0 +1,198 @@ +#include <preprocess.h> + +#include FILE_PATH +#include TARGET_PATH + +#include <string.h> +#include <stdio.h> + +int check_defines_C(void) +{ + int result = 1; + if(strcmp(FILE_STRING, STRING_VALUE) != 0) + { + fprintf(stderr, + "FILE_STRING has wrong value in C [%s]\n", FILE_STRING); + result = 0; + } + if(strcmp(TARGET_STRING, STRING_VALUE) != 0) + { + fprintf(stderr, + "TARGET_STRING has wrong value in C [%s]\n", TARGET_STRING); + result = 0; + } + { + int x = 2; + int y = 3; + if((FILE_EXPR) != (EXPR)) + { + fprintf(stderr, "FILE_EXPR did not work in C [%s]\n", + TO_STRING(FILE_EXPR)); + result = 0; + } + if((TARGET_EXPR) != (EXPR)) + { + fprintf(stderr, "TARGET_EXPR did not work in C [%s]\n", + TO_STRING(FILE_EXPR)); + result = 0; + } + } +#ifdef NDEBUG +# ifdef FILE_DEF_DEBUG + { + fprintf(stderr, "FILE_DEF_DEBUG should not be defined in C\n"); + result = 0; + } +# endif +# ifdef TARGET_DEF_DEBUG + { + fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in C\n"); + result = 0; + } +# endif +# ifdef DIRECTORY_DEF_DEBUG + { + fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in C\n"); + result = 0; + } +# endif +# ifndef FILE_DEF_RELEASE +# ifndef PREPROCESS_XCODE + { + fprintf(stderr, "FILE_DEF_RELEASE should be defined in C\n"); + result = 0; + } +# endif +# endif +# ifndef TARGET_DEF_RELEASE + { + fprintf(stderr, "TARGET_DEF_RELEASE should be defined in C\n"); + result = 0; + } +# endif +# ifndef DIRECTORY_DEF_RELEASE + { + fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in C\n"); + result = 0; + } +# endif +#endif +#ifdef PREPROCESS_DEBUG +# ifndef FILE_DEF_DEBUG +# ifndef PREPROCESS_XCODE + { + fprintf(stderr, "FILE_DEF_DEBUG should be defined in C\n"); + result = 0; + } +# endif +# endif +# ifndef TARGET_DEF_DEBUG + { + fprintf(stderr, "TARGET_DEF_DEBUG should be defined in C\n"); + result = 0; + } +# endif +# ifndef DIRECTORY_DEF_DEBUG + { + fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in C\n"); + result = 0; + } +# endif +# ifdef FILE_DEF_RELEASE + { + fprintf(stderr, "FILE_DEF_RELEASE should not be defined in C\n"); + result = 0; + } +# endif +# ifdef TARGET_DEF_RELEASE + { + fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in C\n"); + result = 0; + } +# endif +# ifdef DIRECTORY_DEF_RELEASE + { + fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in C\n"); + result = 0; + } +# endif +#endif +#if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG) +# if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG) +# ifndef PREPROCESS_XCODE + { + fprintf(stderr, + "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in C\n"); + result = 0; + } +# endif +# endif +# if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE) + { + fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in C\n"); + result = 0; + } +# endif +#endif +#if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE) +# if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE) +# ifndef PREPROCESS_XCODE + { + fprintf(stderr, + "FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in C\n"); + result = 0; + } +# endif +# endif +# if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG) + { + fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in C\n"); + result = 0; + } +# endif +#endif +#ifndef FILE_PATH_DEF + { + fprintf(stderr, "FILE_PATH_DEF not defined in C\n"); + result = 0; + } +#endif +#ifndef TARGET_PATH_DEF + { + fprintf(stderr, "TARGET_PATH_DEF not defined in C\n"); + result = 0; + } +#endif +#ifndef FILE_DEF + { + fprintf(stderr, "FILE_DEF not defined in C\n"); + result = 0; + } +#endif +#ifndef TARGET_DEF + { + fprintf(stderr, "TARGET_DEF not defined in C\n"); + result = 0; + } +#endif +#ifndef DIRECTORY_DEF + { + fprintf(stderr, "DIRECTORY_DEF not defined in C\n"); + result = 0; + } +#endif +#ifndef OLD_DEF + { + fprintf(stderr, "OLD_DEF not defined in C\n"); + result = 0; + } +#endif +#if !defined(OLD_EXPR) || OLD_EXPR != 2 + { + fprintf(stderr, "OLD_EXPR id not work in C [%s]\n", + TO_STRING(OLD_EXPR)); + result = 0; + } +#endif + return result; +} diff --git a/Tests/Preprocess/preprocess.cxx b/Tests/Preprocess/preprocess.cxx new file mode 100644 index 000000000..27b6ac89a --- /dev/null +++ b/Tests/Preprocess/preprocess.cxx @@ -0,0 +1,225 @@ +#include <preprocess.h> + +#include FILE_PATH +#include TARGET_PATH + +#include <string.h> +#include <stdio.h> + +extern "C" int check_defines_C(void); + +int check_defines_CXX() +{ + int result = 1; + if(strcmp(FILE_STRING, STRING_VALUE) != 0) + { + fprintf(stderr, + "FILE_STRING has wrong value in CXX [%s]\n", FILE_STRING); + result = 0; + } + if(strcmp(TARGET_STRING, STRING_VALUE) != 0) + { + fprintf(stderr, + "TARGET_STRING has wrong value in CXX [%s]\n", TARGET_STRING); + result = 0; + } + { + int x = 2; + int y = 3; + if((FILE_EXPR) != (EXPR)) + { + fprintf(stderr, "FILE_EXPR did not work in CXX [%s]\n", + TO_STRING(FILE_EXPR)); + result = 0; + } + if((TARGET_EXPR) != (EXPR)) + { + fprintf(stderr, "TARGET_EXPR did not work in CXX [%s]\n", + TO_STRING(FILE_EXPR)); + result = 0; + } + } +#ifdef NDEBUG +# ifdef FILE_DEF_DEBUG + { + fprintf(stderr, "FILE_DEF_DEBUG should not be defined in CXX\n"); + result = 0; + } +# endif +# ifdef TARGET_DEF_DEBUG + { + fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in CXX\n"); + result = 0; + } +# endif +# ifdef DIRECTORY_DEF_DEBUG + { + fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in CXX\n"); + result = 0; + } +# endif +# ifndef FILE_DEF_RELEASE +# ifndef PREPROCESS_XCODE + { + fprintf(stderr, "FILE_DEF_RELEASE should be defined in CXX\n"); + result = 0; + } +# endif +# endif +# ifndef TARGET_DEF_RELEASE + { + fprintf(stderr, "TARGET_DEF_RELEASE should be defined in CXX\n"); + result = 0; + } +# endif +# ifndef DIRECTORY_DEF_RELEASE + { + fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in CXX\n"); + result = 0; + } +# endif +#endif +#ifdef PREPROCESS_DEBUG +# ifndef FILE_DEF_DEBUG +# ifndef PREPROCESS_XCODE + { + fprintf(stderr, "FILE_DEF_DEBUG should be defined in CXX\n"); + result = 0; + } +# endif +# endif +# ifndef TARGET_DEF_DEBUG + { + fprintf(stderr, "TARGET_DEF_DEBUG should be defined in CXX\n"); + result = 0; + } +# endif +# ifndef DIRECTORY_DEF_DEBUG + { + fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in CXX\n"); + result = 0; + } +# endif +# ifdef FILE_DEF_RELEASE + { + fprintf(stderr, "FILE_DEF_RELEASE should not be defined in CXX\n"); + result = 0; + } +# endif +# ifdef TARGET_DEF_RELEASE + { + fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in CXX\n"); + result = 0; + } +# endif +# ifdef DIRECTORY_DEF_RELEASE + { + fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in CXX\n"); + result = 0; + } +# endif +#endif +#if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG) +# if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG) +# ifndef PREPROCESS_XCODE + { + fprintf(stderr, + "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in CXX\n"); + result = 0; + } +# endif +# endif +# if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE) + { + fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in CXX\n"); + result = 0; + } +# endif +#endif +#if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE) +# if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE) +# ifndef PREPROCESS_XCODE + { + fprintf(stderr, + "FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in CXX\n"); + result = 0; + } +# endif +# endif +# if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG) + { + fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in CXX\n"); + result = 0; + } +# endif +#endif +#ifndef FILE_PATH_DEF + { + fprintf(stderr, "FILE_PATH_DEF not defined in CXX\n"); + result = 0; + } +#endif +#ifndef TARGET_PATH_DEF + { + fprintf(stderr, "TARGET_PATH_DEF not defined in CXX\n"); + result = 0; + } +#endif +#ifndef FILE_DEF + { + fprintf(stderr, "FILE_DEF not defined in CXX\n"); + result = 0; + } +#endif +#ifndef TARGET_DEF + { + fprintf(stderr, "TARGET_DEF not defined in CXX\n"); + result = 0; + } +#endif +#ifndef DIRECTORY_DEF + { + fprintf(stderr, "DIRECTORY_DEF not defined in CXX\n"); + result = 0; + } +#endif +#ifndef OLD_DEF + { + fprintf(stderr, "OLD_DEF not defined in CXX\n"); + result = 0; + } +#endif +#if !defined(OLD_EXPR) || OLD_EXPR != 2 + { + fprintf(stderr, "OLD_EXPR id not work in C [%s]\n", + TO_STRING(OLD_EXPR)); + result = 0; + } +#endif + return result; +} + +int main() +{ + int result = 1; + + if(!check_defines_C()) + { + result = 0; + } + + if(!check_defines_CXX()) + { + result = 0; + } + + if(result) + { + printf("All preprocessor definitions are correct.\n"); + return 0; + } + else + { + return 1; + } +} diff --git a/Tests/Preprocess/preprocess.h.in b/Tests/Preprocess/preprocess.h.in new file mode 100644 index 000000000..3e1c7a07a --- /dev/null +++ b/Tests/Preprocess/preprocess.h.in @@ -0,0 +1,16 @@ +/* Define configured macros. */ +#define STRING_VALUE "@STRING_VALUE@" +#define EXPR @EXPR@ +#cmakedefine PREPROCESS_XCODE +#cmakedefine PREPROCESS_VS6 + +#ifdef PREPROCESS_VS6 +# define FILE_PATH "@FILE_PATH@" +# define TARGET_PATH "@TARGET_PATH@" +#endif + +/* Declarations and macros shared by all sources. */ +#define TO_STRING(x) TO_STRING0(x) +#define TO_STRING0(x) #x + +static int f(int i) { return i*3; } diff --git a/Tests/Preprocess/preprocess_vs6.cxx b/Tests/Preprocess/preprocess_vs6.cxx new file mode 100644 index 000000000..9df89f6a0 --- /dev/null +++ b/Tests/Preprocess/preprocess_vs6.cxx @@ -0,0 +1,3 @@ +// The VS6 IDE does not support object name configuration so we need a +// source file with a different name. Include the real source file. +#include "preprocess.cxx" diff --git a/Tests/Preprocess/target_def.h b/Tests/Preprocess/target_def.h new file mode 100644 index 000000000..f016d5cd2 --- /dev/null +++ b/Tests/Preprocess/target_def.h @@ -0,0 +1 @@ +#define TARGET_PATH_DEF diff --git a/Tests/Properties/CMakeLists.txt b/Tests/Properties/CMakeLists.txt new file mode 100644 index 000000000..c1bc3b9e3 --- /dev/null +++ b/Tests/Properties/CMakeLists.txt @@ -0,0 +1,147 @@ +# a simple CXX only test case +cmake_minimum_required (VERSION 2.6) +project (Properties) + +# these first three tests really test both properties and the management of +# cmSourceFile objects by CMake. + +# test properties on a build tree file that is relative (yuck) +configure_file(properties.h.in "${Properties_BINARY_DIR}/properties.h") +set_source_files_properties(properties.h PROPERTIES TEST1 1) +get_source_file_property(RESULT1 properties.h TEST1) + +# test properties on a headerfile in the source tree +# accessed without an extenion (also yuck) +set_source_files_properties(properties2 PROPERTIES TEST2 1) +get_source_file_property(RESULT2 properties2 TEST2) + +# test properties on a relative source that is not generated +set_source_files_properties(SubDir/properties3.cxx PROPERTIES TEST3 1) +get_source_file_property(RESULT3 SubDir/properties3.cxx TEST3) + +include_directories("${Properties_SOURCE_DIR}" "${Properties_BINARY_DIR}") + + +# test generic property interfaces +get_property(GLOBALRESULT GLOBAL PROPERTY GLOBALTEST DEFINED) +if (GLOBALRESULT) + message(SEND_ERROR "Error: global prop defined when it should not be, " + "result is GLOBALRESULT=${GLOBALRESULT}") +endif (GLOBALRESULT) + +define_property(GLOBAL PROPERTY GLOBALTEST + BRIEF_DOCS "A test property" + FULL_DOCS "A long description of this test property" + ) + +get_property(GLOBALRESULT GLOBAL PROPERTY GLOBALTEST DEFINED) +if (NOT GLOBALRESULT) + message(SEND_ERROR "Error: global prop not defined " + "result is GLOBALRESULT=${GLOBALRESULT}") +endif (NOT GLOBALRESULT) + +set_property(GLOBAL PROPERTY GLOBALTEST 1) +set_property(DIRECTORY PROPERTY DIRECTORYTEST 1) +set_property(SOURCE SubDir/properties3.cxx PROPERTY SOURCETEST 1) +get_property(GLOBALRESULT GLOBAL PROPERTY GLOBALTEST) +get_property(DIRECTORYRESULT DIRECTORY PROPERTY DIRECTORYTEST) +get_property(SOURCERESULT + SOURCE SubDir/properties3.cxx + PROPERTY SOURCETEST + ) + +if (RESULT1 AND RESULT2 AND RESULT3 AND GLOBALRESULT AND + DIRECTORYRESULT AND SOURCERESULT) + add_executable (Properties SubDir/properties3.cxx properties) +else (RESULT1 AND RESULT2 AND RESULT3 AND GLOBALRESULT AND + DIRECTORYRESULT AND SOURCERESULT) + message(SEND_ERROR + "Error: test results are RESULT1=${RESULT1} RESULT2=${RESULT2} " + "RESULT3=${RESULT3} GLOBALRESULT=${GLOBALRESULT} " + "DIRECTORYRESULT=${DIRECTORYRESULT} " + "SOURCERESULT=${SOURCERESULT}") +endif (RESULT1 AND RESULT2 AND RESULT3 AND GLOBALRESULT AND + DIRECTORYRESULT AND SOURCERESULT) + +# test the target property +set_property(TARGET Properties PROPERTY TARGETTEST 1) +get_property(TARGETRESULT TARGET Properties PROPERTY TARGETTEST) +if (NOT TARGETRESULT) + message(SEND_ERROR + "Error: target result is TARGETRESULT=${TARGETRESULT}") +endif (NOT TARGETRESULT) + +# test APPEND and APPEND_STRING set_property() +set_property(TARGET Properties PROPERTY FOO foo) +set_property(TARGET Properties PROPERTY BAR bar) +set_property(TARGET Properties APPEND PROPERTY FOO 123) +set_property(TARGET Properties APPEND_STRING PROPERTY BAR 456) + +get_property(APPEND_RESULT TARGET Properties PROPERTY FOO) +if (NOT "${APPEND_RESULT}" STREQUAL "foo;123") + message(SEND_ERROR + "Error: target result is APPEND_RESULT=${APPEND_RESULT}") +endif () + +get_property(APPEND_STRING_RESULT TARGET Properties PROPERTY BAR) +if (NOT "${APPEND_STRING_RESULT}" STREQUAL "bar456") + message(SEND_ERROR + "Error: target result is APPEND_STRING_RESULT=${APPEND_STRING_RESULT}") +endif () + +# test get_property SET +get_property(TARGETRESULT TARGET Properties PROPERTY TARGETTEST SET) +if (NOT TARGETRESULT) + message(SEND_ERROR + "Error: target prop not set, result is TARGETRESULT=${TARGETRESULT}") +endif (NOT TARGETRESULT) + +# test unsetting a property +set_property(TARGET Properties PROPERTY TARGETTEST) +get_property(TARGETRESULT TARGET Properties PROPERTY TARGETTEST SET) +if (TARGETRESULT) + message(SEND_ERROR "Error: target prop not unset, " + "result is TARGETRESULT=${TARGETRESULT}") +endif (TARGETRESULT) + + + +# test the target SOURCES property +get_property(Properties_SOURCES TARGET Properties PROPERTY SOURCES) +set_source_files_properties(${Properties_SOURCES} PROPERTIES TEST4 1) +get_source_file_property(RESULT4 properties.h TEST4) +if(NOT RESULT4) + message(SEND_ERROR "Error: target result is" + " RESULT4=${RESULT4}" + " Properties_SOURCES=[${Properties_SOURCES}]") +endif(NOT RESULT4) + +# test CACHE properties +macro(check_cache_props) + foreach(prop VALUE TYPE HELPSTRING ADVANCED STRINGS) + get_property(result CACHE SOME_ENTRY PROPERTY ${prop}) + if(NOT "x${result}" STREQUAL "x${expect_${prop}}") + message(SEND_ERROR "CACHE property ${prop} is [${result}], not [${expect_${prop}}]") + endif() + endforeach(prop) +endmacro(check_cache_props) +set(expect_VALUE "ON") +set(expect_TYPE "BOOL") +set(expect_HELPSTRING "sample cache entry") +set(expect_ADVANCED 0) +set(expect_STRINGS "") +set(SOME_ENTRY "${expect_VALUE}" CACHE ${expect_TYPE} "${expect_HELPSTRING}" FORCE) +mark_as_advanced(CLEAR SOME_ENTRY) +set_property(CACHE SOME_ENTRY PROPERTY STRINGS "") +check_cache_props() +set(expect_VALUE "Some string") +set(expect_TYPE "STRING") +set(expect_HELPSTRING "sample cache entry help") +set(expect_ADVANCED 1) +set(expect_STRINGS "Some string;Some other string;Some third string") +set_property(CACHE SOME_ENTRY PROPERTY TYPE "${expect_TYPE}") +set_property(CACHE SOME_ENTRY PROPERTY HELPSTRING "${expect_HELPSTRING}") +set_property(CACHE SOME_ENTRY PROPERTY VALUE "${expect_VALUE}") +set_property(CACHE SOME_ENTRY PROPERTY ADVANCED "${expect_ADVANCED}") +set_property(CACHE SOME_ENTRY PROPERTY STRINGS "${expect_STRINGS}") +check_cache_props() diff --git a/Tests/Properties/SubDir/properties3.cxx b/Tests/Properties/SubDir/properties3.cxx new file mode 100644 index 000000000..1a27a04d4 --- /dev/null +++ b/Tests/Properties/SubDir/properties3.cxx @@ -0,0 +1,9 @@ +#include "properties.h" +#include "properties2.h" + +#if defined HAVE_PROPERTIES_H && defined HAVE_PROPERTIES2_H +int main () +{ + return 0; +} +#endif diff --git a/Tests/Properties/properties.h.in b/Tests/Properties/properties.h.in new file mode 100644 index 000000000..5e9283168 --- /dev/null +++ b/Tests/Properties/properties.h.in @@ -0,0 +1 @@ +#define HAVE_PROPERTIES_H diff --git a/Tests/Properties/properties2.h b/Tests/Properties/properties2.h new file mode 100644 index 000000000..898fd9e6a --- /dev/null +++ b/Tests/Properties/properties2.h @@ -0,0 +1 @@ +#define HAVE_PROPERTIES2_H diff --git a/Tests/Qt4Deploy/CMakeLists.txt b/Tests/Qt4Deploy/CMakeLists.txt new file mode 100644 index 000000000..646ea9f3b --- /dev/null +++ b/Tests/Qt4Deploy/CMakeLists.txt @@ -0,0 +1,70 @@ +cmake_minimum_required(VERSION 2.8) + +project(Qt4Deploy) +set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install) + +find_package(Qt4 REQUIRED QtMain QtCore QtSql) +include(${QT_USE_FILE}) + +add_executable(testdeploy MACOSX_BUNDLE testdeploy.cpp) +target_link_libraries(testdeploy ${QT_LIBRARIES}) +set_target_properties(testdeploy PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") + +if(CMAKE_CONFIGURATION_TYPES AND QT_QTCORE_LIBRARY_RELEASE AND QT_QTCORE_LIBRARY_DEBUG) + # note: installing debug Qt libraries from a Qt installation configured with + # -debug-and-release not yet supported (very low priority). + install(CODE " + if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^([Dd][Ee][Bb][Uu][Gg])$\") + return() + endif() + ") +endif() + +# install the Qt4 app with qsqlite plugin +install(CODE "file(REMOVE_RECURSE \"${CMAKE_INSTALL_PREFIX}\")") +install(TARGETS testdeploy DESTINATION .) +include(../../Modules/DeployQt4.cmake) +if(APPLE) + install_qt4_executable(testdeploy.app "qsqlite") +elseif(WIN32) + install_qt4_executable(testdeploy.exe "qsqlite") +else() + install_qt4_executable(testdeploy "qsqlite") +endif() + + +# test depends on standard qsqlite plugin +if(QT_QSQLITE_PLUGIN_DEBUG OR QT_QSQLITE_PLUGIN_RELEASE) + + # test the deployed Qt application + if(APPLE) + install(CODE " + message(STATUS \"executing: ${CMAKE_INSTALL_PREFIX}/testdeploy.app/Contents/MacOS/testdeploy\") + execute_process(COMMAND \"${CMAKE_INSTALL_PREFIX}/testdeploy.app/Contents/MacOS/testdeploy\" + RESULT_VARIABLE result) + if(NOT result STREQUAL \"0\") + message(FATAL_ERROR \"error running testdeploy app\") + endif() + ") + else() + install(CODE " + message(STATUS \"executing: ${CMAKE_INSTALL_PREFIX}/testdeploy\") + execute_process(COMMAND \"${CMAKE_INSTALL_PREFIX}/testdeploy\" + RESULT_VARIABLE result) + if(NOT result STREQUAL \"0\") + message(FATAL_ERROR \"error running testdeploy app\") + endif() + ") + endif() + + # custom target to install and test the installation at build time + if(CMAKE_CONFIGURATION_TYPES) + set(install_config "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}") + endif() + + add_custom_target(testdeploy_test ALL + COMMAND ${CMAKE_COMMAND} ${install_config} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake + COMMENT "${CMAKE_COMMAND} ${install_config} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake" + DEPENDS testdeploy) + +endif() diff --git a/Tests/Qt4Deploy/testdeploy.cpp b/Tests/Qt4Deploy/testdeploy.cpp new file mode 100644 index 000000000..8b9c8d6fa --- /dev/null +++ b/Tests/Qt4Deploy/testdeploy.cpp @@ -0,0 +1,29 @@ +#include <QCoreApplication> +#include <QSqlDatabase> +#include <QLibraryInfo> +#include <QDebug> +#include <QStringList> + +int main(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + + qDebug() << "App path:" << app.applicationDirPath(); + qDebug() << "Plugin path:" << QLibraryInfo::location(QLibraryInfo::PluginsPath); + + bool foundSqlite = false; + + qDebug() << "Supported Database Drivers:"; + foreach(const QString &sqlDriver, QSqlDatabase::drivers()) + { + qDebug() << " " << sqlDriver; + if(sqlDriver == "QSQLITE") + foundSqlite = true; + } + + if(foundSqlite) + qDebug() << "Found sqlite support from plugin."; + else + qDebug() << "Could not find sqlite support from plugin."; + return foundSqlite ? 0 : 1; +} diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt new file mode 100644 index 000000000..5e3686dbc --- /dev/null +++ b/Tests/QtAutomoc/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 2.8) + +project(QtAutomoc) + +find_package(Qt4 REQUIRED) + +include(UseQt4) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +add_definitions(-DFOO -DSomeDefine="Barx") + +# enable relaxed mode so automoc can handle all the special cases: +set(CMAKE_AUTOMOC_RELAXED_MODE TRUE) + +# create an executable and a library target, both requiring automoc: +add_library(codeeditorLib STATIC codeeditor.cpp) + +add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp private_slot.cpp) + +set_target_properties(foo codeeditorLib PROPERTIES AUTOMOC TRUE) + +target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} ) diff --git a/Tests/QtAutomoc/abc.cpp b/Tests/QtAutomoc/abc.cpp new file mode 100644 index 000000000..4bbc76905 --- /dev/null +++ b/Tests/QtAutomoc/abc.cpp @@ -0,0 +1,49 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + + +#include "abc.h" +#include "abc_p.h" + +#include <stdio.h> + +class PrintAbc : public QObject +{ + Q_OBJECT + public: + PrintAbc():QObject() {} + public slots: + void print() const { printf("abc\n"); } +}; + +Abc::Abc() +:QObject() +{ +} + + +void Abc::doAbc() +{ + PrintAbc pa; + pa.print(); + AbcP abcP; + abcP.doAbcP(); +} + +// check that including the moc file for the cpp file and the header works: +#include "abc.moc" +#include "moc_abc.cpp" +#include "moc_abc_p.cpp" + +// check that including a moc file from another header works: +#include "moc_xyz.cpp" diff --git a/Tests/QtAutomoc/abc.h b/Tests/QtAutomoc/abc.h new file mode 100644 index 000000000..d1924b0da --- /dev/null +++ b/Tests/QtAutomoc/abc.h @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + +#ifndef ABC_H +#define ABC_H + +#include <QObject> + +class Abc : public QObject +{ + Q_OBJECT + public: + Abc(); + public slots: + void doAbc(); +}; + +#endif diff --git a/Tests/QtAutomoc/abc_p.h b/Tests/QtAutomoc/abc_p.h new file mode 100644 index 000000000..952fff315 --- /dev/null +++ b/Tests/QtAutomoc/abc_p.h @@ -0,0 +1,30 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + +#ifndef ABC_P_H +#define ABC_P_H + +#include <QObject> + +#include <stdio.h> + +class AbcP : public QObject +{ + Q_OBJECT + public: + AbcP() {} + public slots: + void doAbcP() { printf("I am private abc !\n"); } +}; + +#endif diff --git a/Tests/QtAutomoc/bar.cpp b/Tests/QtAutomoc/bar.cpp new file mode 100644 index 000000000..8be48159d --- /dev/null +++ b/Tests/QtAutomoc/bar.cpp @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + +#include "sub/bar.h" + +#include <stdio.h> + +Bar::Bar() +:QObject() +{ +} + +void Bar::doBar() +{ + printf("Hello bar !\n"); +} + +#include "sub/moc_bar.cpp" diff --git a/Tests/QtAutomoc/blub.cpp b/Tests/QtAutomoc/blub.cpp new file mode 100644 index 000000000..bd53972ac --- /dev/null +++ b/Tests/QtAutomoc/blub.cpp @@ -0,0 +1,40 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + +#include "blub.h" + +#include <stdio.h> + +class BlubBlub : public QObject +{ + Q_OBJECT + public: + BlubBlub():QObject() {} + public slots: + int getValue() const { return 13; } +}; + +Blub::Blub() +{ +} + + +void Blub::blubber() +{ + BlubBlub bb; + printf("Blub blub %d ! \n", bb.getValue()); +} + +// test the case that the wrong moc-file is included, it should +// actually be "blub.moc" +#include "moc_blub.cpp" diff --git a/Tests/QtAutomoc/blub.h b/Tests/QtAutomoc/blub.h new file mode 100644 index 000000000..1967bc1ea --- /dev/null +++ b/Tests/QtAutomoc/blub.h @@ -0,0 +1,26 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + +#ifndef BLUB_H +#define BLUB_H + +#include <QObject> + +class Blub +{ + public: + Blub(); + void blubber(); +}; + +#endif diff --git a/Tests/QtAutomoc/calwidget.cpp b/Tests/QtAutomoc/calwidget.cpp new file mode 100644 index 000000000..24f3b4efe --- /dev/null +++ b/Tests/QtAutomoc/calwidget.cpp @@ -0,0 +1,424 @@ +/**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + + #include <QtGui> + + #include "calwidget.h" + + Window::Window() + { + createPreviewGroupBox(); + createGeneralOptionsGroupBox(); + createDatesGroupBox(); + createTextFormatsGroupBox(); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(previewGroupBox, 0, 0); + layout->addWidget(generalOptionsGroupBox, 0, 1); + layout->addWidget(datesGroupBox, 1, 0); + layout->addWidget(textFormatsGroupBox, 1, 1); + layout->setSizeConstraint(QLayout::SetFixedSize); + setLayout(layout); + + previewLayout->setRowMinimumHeight(0, calendar->sizeHint().height()); + previewLayout->setColumnMinimumWidth(0, calendar->sizeHint().width()); + + setWindowTitle(tr("Calendar Widget")); + } + + void Window::localeChanged(int index) + { + calendar->setLocale(localeCombo->itemData(index).toLocale()); + } + + void Window::firstDayChanged(int index) + { + calendar->setFirstDayOfWeek(Qt::DayOfWeek( + firstDayCombo->itemData(index).toInt())); + } + + void Window::selectionModeChanged(int index) + { + calendar->setSelectionMode(QCalendarWidget::SelectionMode( + selectionModeCombo->itemData(index).toInt())); + } + + void Window::horizontalHeaderChanged(int index) + { + calendar->setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat( + horizontalHeaderCombo->itemData(index).toInt())); + } + + void Window::verticalHeaderChanged(int index) + { + calendar->setVerticalHeaderFormat(QCalendarWidget::VerticalHeaderFormat( + verticalHeaderCombo->itemData(index).toInt())); + } + + void Window::selectedDateChanged() + { + currentDateEdit->setDate(calendar->selectedDate()); + } + + void Window::minimumDateChanged(const QDate &date) + { + calendar->setMinimumDate(date); + maximumDateEdit->setDate(calendar->maximumDate()); + } + + void Window::maximumDateChanged(const QDate &date) + { + calendar->setMaximumDate(date); + minimumDateEdit->setDate(calendar->minimumDate()); + } + + void Window::weekdayFormatChanged() + { + QTextCharFormat format; + + format.setForeground(qvariant_cast<QColor>( + weekdayColorCombo->itemData(weekdayColorCombo->currentIndex()))); + calendar->setWeekdayTextFormat(Qt::Monday, format); + calendar->setWeekdayTextFormat(Qt::Tuesday, format); + calendar->setWeekdayTextFormat(Qt::Wednesday, format); + calendar->setWeekdayTextFormat(Qt::Thursday, format); + calendar->setWeekdayTextFormat(Qt::Friday, format); + } + + void Window::weekendFormatChanged() + { + QTextCharFormat format; + + format.setForeground(qvariant_cast<QColor>( + weekendColorCombo->itemData(weekendColorCombo->currentIndex()))); + calendar->setWeekdayTextFormat(Qt::Saturday, format); + calendar->setWeekdayTextFormat(Qt::Sunday, format); + } + + void Window::reformatHeaders() + { + QString text = headerTextFormatCombo->currentText(); + QTextCharFormat format; + + if (text == tr("Bold")) { + format.setFontWeight(QFont::Bold); + } else if (text == tr("Italic")) { + format.setFontItalic(true); + } else if (text == tr("Green")) { + format.setForeground(Qt::green); + } + calendar->setHeaderTextFormat(format); + } + + void Window::reformatCalendarPage() + { + if (firstFridayCheckBox->isChecked()) { + QDate firstFriday(calendar->yearShown(), calendar->monthShown(), 1); + while (firstFriday.dayOfWeek() != Qt::Friday) + firstFriday = firstFriday.addDays(1); + QTextCharFormat firstFridayFormat; + firstFridayFormat.setForeground(Qt::blue); + calendar->setDateTextFormat(firstFriday, firstFridayFormat); + } + + //May First in Red takes precedence + if (mayFirstCheckBox->isChecked()) { + const QDate mayFirst(calendar->yearShown(), 5, 1); + QTextCharFormat mayFirstFormat; + mayFirstFormat.setForeground(Qt::red); + calendar->setDateTextFormat(mayFirst, mayFirstFormat); + } + } + + void Window::createPreviewGroupBox() + { + previewGroupBox = new QGroupBox(tr("Preview")); + + calendar = new QCalendarWidget; + calendar->setMinimumDate(QDate(1900, 1, 1)); + calendar->setMaximumDate(QDate(3000, 1, 1)); + calendar->setGridVisible(true); + + connect(calendar, SIGNAL(currentPageChanged(int,int)), + this, SLOT(reformatCalendarPage())); + + previewLayout = new QGridLayout; + previewLayout->addWidget(calendar, 0, 0, Qt::AlignCenter); + previewGroupBox->setLayout(previewLayout); + } + + void Window::createGeneralOptionsGroupBox() + { + generalOptionsGroupBox = new QGroupBox(tr("General Options")); + + localeCombo = new QComboBox; + int curLocaleIndex = -1; + int index = 0; + for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) { + QLocale::Language lang = static_cast<QLocale::Language>(_lang); + QList<QLocale::Country> countries = QLocale::countriesForLanguage(lang); + for (int i = 0; i < countries.count(); ++i) { + QLocale::Country country = countries.at(i); + QString label = QLocale::languageToString(lang); + label += QLatin1Char('/'); + label += QLocale::countryToString(country); + QLocale locale(lang, country); + if (this->locale().language() == lang && this->locale().country() == country) + curLocaleIndex = index; + localeCombo->addItem(label, locale); + ++index; + } + } + if (curLocaleIndex != -1) + localeCombo->setCurrentIndex(curLocaleIndex); + localeLabel = new QLabel(tr("&Locale")); + localeLabel->setBuddy(localeCombo); + + firstDayCombo = new QComboBox; + firstDayCombo->addItem(tr("Sunday"), Qt::Sunday); + firstDayCombo->addItem(tr("Monday"), Qt::Monday); + firstDayCombo->addItem(tr("Tuesday"), Qt::Tuesday); + firstDayCombo->addItem(tr("Wednesday"), Qt::Wednesday); + firstDayCombo->addItem(tr("Thursday"), Qt::Thursday); + firstDayCombo->addItem(tr("Friday"), Qt::Friday); + firstDayCombo->addItem(tr("Saturday"), Qt::Saturday); + + firstDayLabel = new QLabel(tr("Wee&k starts on:")); + firstDayLabel->setBuddy(firstDayCombo); + + selectionModeCombo = new QComboBox; + selectionModeCombo->addItem(tr("Single selection"), + QCalendarWidget::SingleSelection); + selectionModeCombo->addItem(tr("None"), QCalendarWidget::NoSelection); + + selectionModeLabel = new QLabel(tr("&Selection mode:")); + selectionModeLabel->setBuddy(selectionModeCombo); + + gridCheckBox = new QCheckBox(tr("&Grid")); + gridCheckBox->setChecked(calendar->isGridVisible()); + + navigationCheckBox = new QCheckBox(tr("&Navigation bar")); + navigationCheckBox->setChecked(true); + + horizontalHeaderCombo = new QComboBox; + horizontalHeaderCombo->addItem(tr("Single letter day names"), + QCalendarWidget::SingleLetterDayNames); + horizontalHeaderCombo->addItem(tr("Short day names"), + QCalendarWidget::ShortDayNames); + horizontalHeaderCombo->addItem(tr("None"), + QCalendarWidget::NoHorizontalHeader); + horizontalHeaderCombo->setCurrentIndex(1); + + horizontalHeaderLabel = new QLabel(tr("&Horizontal header:")); + horizontalHeaderLabel->setBuddy(horizontalHeaderCombo); + + verticalHeaderCombo = new QComboBox; + verticalHeaderCombo->addItem(tr("ISO week numbers"), + QCalendarWidget::ISOWeekNumbers); + verticalHeaderCombo->addItem(tr("None"), QCalendarWidget::NoVerticalHeader); + + verticalHeaderLabel = new QLabel(tr("&Vertical header:")); + verticalHeaderLabel->setBuddy(verticalHeaderCombo); + + connect(localeCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(localeChanged(int))); + connect(firstDayCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(firstDayChanged(int))); + connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(selectionModeChanged(int))); + connect(gridCheckBox, SIGNAL(toggled(bool)), + calendar, SLOT(setGridVisible(bool))); + connect(navigationCheckBox, SIGNAL(toggled(bool)), + calendar, SLOT(setNavigationBarVisible(bool))); + connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(horizontalHeaderChanged(int))); + connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(verticalHeaderChanged(int))); + + QHBoxLayout *checkBoxLayout = new QHBoxLayout; + checkBoxLayout->addWidget(gridCheckBox); + checkBoxLayout->addStretch(); + checkBoxLayout->addWidget(navigationCheckBox); + + QGridLayout *outerLayout = new QGridLayout; + outerLayout->addWidget(localeLabel, 0, 0); + outerLayout->addWidget(localeCombo, 0, 1); + outerLayout->addWidget(firstDayLabel, 1, 0); + outerLayout->addWidget(firstDayCombo, 1, 1); + outerLayout->addWidget(selectionModeLabel, 2, 0); + outerLayout->addWidget(selectionModeCombo, 2, 1); + outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2); + outerLayout->addWidget(horizontalHeaderLabel, 4, 0); + outerLayout->addWidget(horizontalHeaderCombo, 4, 1); + outerLayout->addWidget(verticalHeaderLabel, 5, 0); + outerLayout->addWidget(verticalHeaderCombo, 5, 1); + generalOptionsGroupBox->setLayout(outerLayout); + + firstDayChanged(firstDayCombo->currentIndex()); + selectionModeChanged(selectionModeCombo->currentIndex()); + horizontalHeaderChanged(horizontalHeaderCombo->currentIndex()); + verticalHeaderChanged(verticalHeaderCombo->currentIndex()); + } + + void Window::createDatesGroupBox() + { + datesGroupBox = new QGroupBox(tr("Dates")); + + minimumDateEdit = new QDateEdit; + minimumDateEdit->setDisplayFormat("MMM d yyyy"); + minimumDateEdit->setDateRange(calendar->minimumDate(), + calendar->maximumDate()); + minimumDateEdit->setDate(calendar->minimumDate()); + + minimumDateLabel = new QLabel(tr("&Minimum Date:")); + minimumDateLabel->setBuddy(minimumDateEdit); + + currentDateEdit = new QDateEdit; + currentDateEdit->setDisplayFormat("MMM d yyyy"); + currentDateEdit->setDate(calendar->selectedDate()); + currentDateEdit->setDateRange(calendar->minimumDate(), + calendar->maximumDate()); + + currentDateLabel = new QLabel(tr("&Current Date:")); + currentDateLabel->setBuddy(currentDateEdit); + + maximumDateEdit = new QDateEdit; + maximumDateEdit->setDisplayFormat("MMM d yyyy"); + maximumDateEdit->setDateRange(calendar->minimumDate(), + calendar->maximumDate()); + maximumDateEdit->setDate(calendar->maximumDate()); + + maximumDateLabel = new QLabel(tr("Ma&ximum Date:")); + maximumDateLabel->setBuddy(maximumDateEdit); + + connect(currentDateEdit, SIGNAL(dateChanged(QDate)), + calendar, SLOT(setSelectedDate(QDate))); + connect(calendar, SIGNAL(selectionChanged()), + this, SLOT(selectedDateChanged())); + connect(minimumDateEdit, SIGNAL(dateChanged(QDate)), + this, SLOT(minimumDateChanged(QDate))); + connect(maximumDateEdit, SIGNAL(dateChanged(QDate)), + this, SLOT(maximumDateChanged(QDate))); + + QGridLayout *dateBoxLayout = new QGridLayout; + dateBoxLayout->addWidget(currentDateLabel, 1, 0); + dateBoxLayout->addWidget(currentDateEdit, 1, 1); + dateBoxLayout->addWidget(minimumDateLabel, 0, 0); + dateBoxLayout->addWidget(minimumDateEdit, 0, 1); + dateBoxLayout->addWidget(maximumDateLabel, 2, 0); + dateBoxLayout->addWidget(maximumDateEdit, 2, 1); + dateBoxLayout->setRowStretch(3, 1); + + datesGroupBox->setLayout(dateBoxLayout); + } + + void Window::createTextFormatsGroupBox() + { + textFormatsGroupBox = new QGroupBox(tr("Text Formats")); + + weekdayColorCombo = createColorComboBox(); + weekdayColorCombo->setCurrentIndex( + weekdayColorCombo->findText(tr("Black"))); + + weekdayColorLabel = new QLabel(tr("&Weekday color:")); + weekdayColorLabel->setBuddy(weekdayColorCombo); + + weekendColorCombo = createColorComboBox(); + weekendColorCombo->setCurrentIndex( + weekendColorCombo->findText(tr("Red"))); + + weekendColorLabel = new QLabel(tr("Week&end color:")); + weekendColorLabel->setBuddy(weekendColorCombo); + + headerTextFormatCombo = new QComboBox; + headerTextFormatCombo->addItem(tr("Bold")); + headerTextFormatCombo->addItem(tr("Italic")); + headerTextFormatCombo->addItem(tr("Plain")); + + headerTextFormatLabel = new QLabel(tr("&Header text:")); + headerTextFormatLabel->setBuddy(headerTextFormatCombo); + + firstFridayCheckBox = new QCheckBox(tr("&First Friday in blue")); + + mayFirstCheckBox = new QCheckBox(tr("May &1 in red")); + + connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(weekdayFormatChanged())); + connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(weekendFormatChanged())); + connect(headerTextFormatCombo, SIGNAL(currentIndexChanged(QString)), + this, SLOT(reformatHeaders())); + connect(firstFridayCheckBox, SIGNAL(toggled(bool)), + this, SLOT(reformatCalendarPage())); + connect(mayFirstCheckBox, SIGNAL(toggled(bool)), + this, SLOT(reformatCalendarPage())); + + QHBoxLayout *checkBoxLayout = new QHBoxLayout; + checkBoxLayout->addWidget(firstFridayCheckBox); + checkBoxLayout->addStretch(); + checkBoxLayout->addWidget(mayFirstCheckBox); + + QGridLayout *outerLayout = new QGridLayout; + outerLayout->addWidget(weekdayColorLabel, 0, 0); + outerLayout->addWidget(weekdayColorCombo, 0, 1); + outerLayout->addWidget(weekendColorLabel, 1, 0); + outerLayout->addWidget(weekendColorCombo, 1, 1); + outerLayout->addWidget(headerTextFormatLabel, 2, 0); + outerLayout->addWidget(headerTextFormatCombo, 2, 1); + outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2); + textFormatsGroupBox->setLayout(outerLayout); + + weekdayFormatChanged(); + weekendFormatChanged(); + reformatHeaders(); + reformatCalendarPage(); + } + +QComboBox *Window::createColorComboBox() + { + QComboBox *comboBox = new QComboBox; + comboBox->addItem(tr("Red"), Qt::red); + comboBox->addItem(tr("Blue"), Qt::blue); + comboBox->addItem(tr("Black"), Qt::black); + comboBox->addItem(tr("Magenta"), Qt::magenta); + return comboBox; + } + +//#include "moc_calwidget.cpp" diff --git a/Tests/QtAutomoc/calwidget.h b/Tests/QtAutomoc/calwidget.h new file mode 100644 index 000000000..844738937 --- /dev/null +++ b/Tests/QtAutomoc/calwidget.h @@ -0,0 +1,121 @@ + /**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + +#ifndef WINDOW_H +#define WINDOW_H + +#include <QWidget> + + class QCalendarWidget; + class QCheckBox; + class QComboBox; + class QDate; + class QDateEdit; + class QGridLayout; + class QGroupBox; + class QLabel; + + class Window : public QWidget + { + Q_OBJECT + + public: + Window(); + + private slots: + void localeChanged(int index); + void firstDayChanged(int index); + void selectionModeChanged(int index); + void horizontalHeaderChanged(int index); + void verticalHeaderChanged(int index); + void selectedDateChanged(); + void minimumDateChanged(const QDate &date); + void maximumDateChanged(const QDate &date); + void weekdayFormatChanged(); + void weekendFormatChanged(); + void reformatHeaders(); + void reformatCalendarPage(); + + private: + void createPreviewGroupBox(); + void createGeneralOptionsGroupBox(); + void createDatesGroupBox(); + void createTextFormatsGroupBox(); + QComboBox *createColorComboBox(); + + QGroupBox *previewGroupBox; + QGridLayout *previewLayout; + QCalendarWidget *calendar; + + QGroupBox *generalOptionsGroupBox; + QLabel *localeLabel; + QLabel *firstDayLabel; + QLabel *selectionModeLabel; + QLabel *horizontalHeaderLabel; + QLabel *verticalHeaderLabel; + QComboBox *localeCombo; + QComboBox *firstDayCombo; + QComboBox *selectionModeCombo; + QCheckBox *gridCheckBox; + QCheckBox *navigationCheckBox; + QComboBox *horizontalHeaderCombo; + QComboBox *verticalHeaderCombo; + + QGroupBox *datesGroupBox; + QLabel *currentDateLabel; + QLabel *minimumDateLabel; + QLabel *maximumDateLabel; + QDateEdit *currentDateEdit; + QDateEdit *minimumDateEdit; + QDateEdit *maximumDateEdit; + + QGroupBox *textFormatsGroupBox; + QLabel *weekdayColorLabel; + QLabel *weekendColorLabel; + QLabel *headerTextFormatLabel; + QComboBox *weekdayColorCombo; + QComboBox *weekendColorCombo; + QComboBox *headerTextFormatCombo; + + QCheckBox *firstFridayCheckBox; + QCheckBox *mayFirstCheckBox; + }; + + #endif diff --git a/Tests/QtAutomoc/codeeditor.cpp b/Tests/QtAutomoc/codeeditor.cpp new file mode 100644 index 000000000..01da06276 --- /dev/null +++ b/Tests/QtAutomoc/codeeditor.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + + #include <QtGui> + + #include "codeeditor.h" + + + CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) + { + lineNumberArea = new LineNumberArea(this); + + connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); + connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); + connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); + + updateLineNumberAreaWidth(0); + highlightCurrentLine(); + } + + + + int CodeEditor::lineNumberAreaWidth() + { + int digits = 1; + int max = qMax(1, blockCount()); + while (max >= 10) { + max /= 10; + ++digits; + } + + int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits; + + return space; + } + + + + void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */) + { + setViewportMargins(lineNumberAreaWidth(), 0, 0, 0); + } + + + + void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) + { + if (dy) + lineNumberArea->scroll(0, dy); + else + lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height()); + + if (rect.contains(viewport()->rect())) + updateLineNumberAreaWidth(0); + } + + + + void CodeEditor::resizeEvent(QResizeEvent *e) + { + QPlainTextEdit::resizeEvent(e); + + QRect cr = contentsRect(); + lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())); + } + + + + void CodeEditor::highlightCurrentLine() + { + QList<QTextEdit::ExtraSelection> extraSelections; + + if (!isReadOnly()) { + QTextEdit::ExtraSelection selection; + + QColor lineColor = QColor(Qt::yellow).lighter(160); + + selection.format.setBackground(lineColor); + selection.format.setProperty(QTextFormat::FullWidthSelection, true); + selection.cursor = textCursor(); + selection.cursor.clearSelection(); + extraSelections.append(selection); + } + + setExtraSelections(extraSelections); + } + + + + void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) + { + QPainter painter(lineNumberArea); + painter.fillRect(event->rect(), Qt::lightGray); + + + QTextBlock block = firstVisibleBlock(); + int blockNumber = block.blockNumber(); + int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top(); + int bottom = top + (int) blockBoundingRect(block).height(); + + while (block.isValid() && top <= event->rect().bottom()) { + if (block.isVisible() && bottom >= event->rect().top()) { + QString number = QString::number(blockNumber + 1); + painter.setPen(Qt::black); + painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(), + Qt::AlignRight, number); + } + + block = block.next(); + top = bottom; + bottom = top + (int) blockBoundingRect(block).height(); + ++blockNumber; + } + } + +#include "codeeditor.moc" diff --git a/Tests/QtAutomoc/codeeditor.h b/Tests/QtAutomoc/codeeditor.h new file mode 100644 index 000000000..56e9e7923 --- /dev/null +++ b/Tests/QtAutomoc/codeeditor.h @@ -0,0 +1,99 @@ + /**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + + #ifndef CODEEDITOR_H + #define CODEEDITOR_H + + #include <QPlainTextEdit> + #include <QObject> + + class QPaintEvent; + class QResizeEvent; + class QSize; + class QWidget; + + class LineNumberArea; + + + class CodeEditor : public QPlainTextEdit + { + Q_OBJECT + + public: + CodeEditor(QWidget *parent = 0); + + void lineNumberAreaPaintEvent(QPaintEvent *event); + int lineNumberAreaWidth(); + + protected: + void resizeEvent(QResizeEvent *event); + + private slots: + void updateLineNumberAreaWidth(int newBlockCount); + void highlightCurrentLine(); + void updateLineNumberArea(const QRect &, int); + + private: + QWidget *lineNumberArea; + }; + + + class LineNumberArea : public QWidget + { + public: + LineNumberArea(CodeEditor *editor) : QWidget(editor) { + codeEditor = editor; + } + + QSize sizeHint() const { + return QSize(codeEditor->lineNumberAreaWidth(), 0); + } + + protected: + void paintEvent(QPaintEvent *event) { + codeEditor->lineNumberAreaPaintEvent(event); + } + + private: + CodeEditor *codeEditor; + }; + + + #endif diff --git a/Tests/QtAutomoc/foo.cpp b/Tests/QtAutomoc/foo.cpp new file mode 100644 index 000000000..699ba094b --- /dev/null +++ b/Tests/QtAutomoc/foo.cpp @@ -0,0 +1,39 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + +#include "foo.h" + +#include <stdio.h> + +class FooFoo : public QObject +{ + Q_OBJECT + public: + FooFoo():QObject() {} + public slots: + int getValue() const { return 12; } +}; + +Foo::Foo() +:QObject() +{ +} + + +void Foo::doFoo() +{ + FooFoo ff; + printf("Hello automoc: %d\n", ff.getValue()); +} + +#include "foo.moc" diff --git a/Tests/QtAutomoc/foo.h b/Tests/QtAutomoc/foo.h new file mode 100644 index 000000000..32d4c8d8f --- /dev/null +++ b/Tests/QtAutomoc/foo.h @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + +#ifndef FOO_H +#define FOO_H + +#include <QObject> + +class Foo : public QObject +{ + Q_OBJECT + public: + Foo(); + public slots: + void doFoo(); +}; + +#endif diff --git a/Tests/QtAutomoc/main.cpp b/Tests/QtAutomoc/main.cpp new file mode 100644 index 000000000..738f67720 --- /dev/null +++ b/Tests/QtAutomoc/main.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + +#include <QtGui> + +#include "codeeditor.h" +#include "calwidget.h" +#include "foo.h" +#include "blub.h" +#include "sub/bar.h" +#include "abc.h" +#include "xyz.h" +#include "yaf.h" + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + CodeEditor editor; + editor.setWindowTitle(QObject::tr("Code Editor Example")); + editor.show(); + + Window w; + w.show(); + + Foo foo; + foo.doFoo(); + + Blub b; + b.blubber(); + + Bar bar; + bar.doBar(); + + Abc abc; + abc.doAbc(); + + Xyz xyz; + xyz.doXyz(); + + Yaf yaf; + yaf.doYaf(); + + return app.exec(); +} diff --git a/Tests/QtAutomoc/private_slot.cpp b/Tests/QtAutomoc/private_slot.cpp new file mode 100644 index 000000000..1387a70cf --- /dev/null +++ b/Tests/QtAutomoc/private_slot.cpp @@ -0,0 +1,21 @@ + +#include "private_slot.h" + +class PrivateSlotPrivate +{ +public: + + void privateSlot() + { + + } +}; + +PrivateSlot::PrivateSlot(QObject *parent) + : QObject(parent), + d(new PrivateSlotPrivate) +{ + +} + +#include "private_slot.moc" diff --git a/Tests/QtAutomoc/private_slot.h b/Tests/QtAutomoc/private_slot.h new file mode 100644 index 000000000..28e54482a --- /dev/null +++ b/Tests/QtAutomoc/private_slot.h @@ -0,0 +1,20 @@ + +#ifndef PRIVATE_SLOT_H +#define PRIVATE_SLOT_H + +#include <QObject> + +class PrivateSlotPrivate; + +class PrivateSlot : public QObject +{ + Q_OBJECT +public: + PrivateSlot(QObject *parent = 0); + +private: + PrivateSlotPrivate * const d; + Q_PRIVATE_SLOT(d, void privateSlot()) +}; + +#endif diff --git a/Tests/QtAutomoc/sub/bar.h b/Tests/QtAutomoc/sub/bar.h new file mode 100644 index 000000000..db56b8ed5 --- /dev/null +++ b/Tests/QtAutomoc/sub/bar.h @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + +#ifndef BAR_H +#define BAR_H + +#include <QObject> + +class Bar : public QObject +{ + Q_OBJECT + public: + Bar(); + public slots: + void doBar(); +}; + +#endif diff --git a/Tests/QtAutomoc/xyz.cpp b/Tests/QtAutomoc/xyz.cpp new file mode 100644 index 000000000..a3562a337 --- /dev/null +++ b/Tests/QtAutomoc/xyz.cpp @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + + +#include "xyz.h" + +#include <stdio.h> + +Xyz::Xyz() +:QObject() +{ +} + + +void Xyz::doXyz() +{ + printf("This is xyz !\n"); +} diff --git a/Tests/QtAutomoc/xyz.h b/Tests/QtAutomoc/xyz.h new file mode 100644 index 000000000..8175d3792 --- /dev/null +++ b/Tests/QtAutomoc/xyz.h @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + +#ifndef XYZ_H +#define XYZ_H + +#include <QObject> + +class Xyz : public QObject +{ + Q_OBJECT + public: + Xyz(); + public slots: + void doXyz(); +}; + +#endif diff --git a/Tests/QtAutomoc/yaf.cpp b/Tests/QtAutomoc/yaf.cpp new file mode 100644 index 000000000..d278ab422 --- /dev/null +++ b/Tests/QtAutomoc/yaf.cpp @@ -0,0 +1,32 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + + +#include "yaf.h" +#include "yaf_p.h" + +#include <stdio.h> + +Yaf::Yaf() +{ +} + + +void Yaf::doYaf() +{ + YafP yafP; + yafP.doYafP(); +} + +// check that including a moc file from a private header the wrong way works: +#include "yaf_p.moc" diff --git a/Tests/QtAutomoc/yaf.h b/Tests/QtAutomoc/yaf.h new file mode 100644 index 000000000..8689f8308 --- /dev/null +++ b/Tests/QtAutomoc/yaf.h @@ -0,0 +1,25 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + +#ifndef YAF_H +#define YAF_H + +class Yaf +{ + public: + Yaf(); + public: + void doYaf(); +}; + +#endif diff --git a/Tests/QtAutomoc/yaf_p.h b/Tests/QtAutomoc/yaf_p.h new file mode 100644 index 000000000..f0368ade1 --- /dev/null +++ b/Tests/QtAutomoc/yaf_p.h @@ -0,0 +1,30 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + 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. +============================================================================*/ + +#ifndef YAF_P_H +#define YAF_P_H + +#include <QObject> + +#include <stdio.h> + +class YafP : public QObject +{ + Q_OBJECT + public: + YafP() {} + public slots: + void doYafP() { printf("I am yet another file !\n"); } +}; + +#endif diff --git a/Tests/README b/Tests/README new file mode 100644 index 000000000..8b2fda845 --- /dev/null +++ b/Tests/README @@ -0,0 +1,39 @@ +If you think about adding a new testcase then here is a small checklist you +can run through to find a proper place for it. Go through the list from the +beginning and stop once you find something that matches your tests needs, +i.e. if you will test a module and only need the configure mode use the +instructions from section 2, not 3. + +1. Your testcase can run in CMake script mode, i.e. "cmake -P something" + +Put your test in Tests/CMakeTests/ directory as a .cmake.in file. It will be +put into the test binary directory by configure_file(... @ONLY) and run from +there. Use the AddCMakeTest() macro in Tests/CMakeTests/CMakeLists.txt to add +your test to the test runs. + +2. Your test needs CMake to run in configure mode, but will not build anything + +This includes tests that will build something using try_compile() and friends, +but nothing that expects add_executable(), add_library(), or add_test() to run. + +If the test configures the project only once and it must succeed then put it +into the Tests/CMakeOnly/ directory. Create a subdirectory named like your +test and write the CMakeLists.txt you need into that subdirectory. Use the +add_CMakeOnly_test() macro from Tests/CMakeOnly/CMakeLists.txt to add your +test to the test runs. + +If the test configures the project with multiple variations and verifies +success or failure each time then put it into the Tests/RunCMake/ directory. +Read the instructions in Tests/RunCMake/CMakeLists.txt to add a test. + +3. If you are testing something from the Modules directory + +Put your test in the Tests/Modules/ directory. Create a subdirectory there +named after your test. Use the ADD_TEST_MACRO macro from Tests/CMakeLists.txt +to add your test to the test run. If you have put your stuff in +Tests/Modules/Foo then you call it using ADD_TEST_MACRO(Module.Foo Foo). + +4. You are doing other stuff. + +Find a good place ;) In doubt mail to cmake-developers@cmake.org and ask for +advise. diff --git a/Tests/ReturnTest/CMakeLists.txt b/Tests/ReturnTest/CMakeLists.txt new file mode 100644 index 000000000..a08855ec1 --- /dev/null +++ b/Tests/ReturnTest/CMakeLists.txt @@ -0,0 +1,147 @@ +# a simple C only test case +cmake_minimum_required (VERSION 2.6) +project (ReturnTest) + +function (FAILED testname) + message (SEND_ERROR "${testname} failed ${ARGN}") +endfunction (FAILED) + +function (PASS testname) + message ("${testname} passed ${ARGN}") +endfunction (PASS) + +# test simple return +function (simple) + set(simpleResult 1 PARENT_SCOPE) + return() + set(simpleResult 0 PARENT_SCOPE) +endfunction (simple) +simple() +if ("${simpleResult}") + pass ("simple") +else ("${simpleResult}") + failed ("simple got: ${simpleResult}") +endif ("${simpleResult}") + +#test return in an if statement +set (simple2IF 1) +function (simple2) + set(simple2Result 1 PARENT_SCOPE) + if (simple2IF) + return() + endif (simple2IF) + set(simple2Result 0 PARENT_SCOPE) +endfunction (simple2) +simple2() +if ("${simple2Result}") + pass ("simple2") +else ("${simple2Result}") + failed ("simple2 got: ${simple2Result}") +endif ("${simple2Result}") + +#test return in a foreach loop +function (looptest) + foreach (iter RANGE 1 5) + set (looptestResult "${iter}" PARENT_SCOPE) + if ("${iter}" EQUAL 3) + return () + endif ("${iter}" EQUAL 3) + endforeach (iter) +endfunction (looptest) +looptest() +if ("${looptestResult}" EQUAL 3) + pass ("looptest") +else ("${looptestResult}" EQUAL 3) + failed ("looptest got: ${looptestResult}") +endif ("${looptestResult}" EQUAL 3) + +#test return in a while loop +function (whiletest) + set (iter "a") + while(NOT "${iter}" STREQUAL "aaaaa") + set (whiletestResult "${iter}" PARENT_SCOPE) + if ("${iter}" STREQUAL "aaa") + return () + endif ("${iter}" STREQUAL "aaa") + set (iter "${iter}a") + endwhile(NOT "${iter}" STREQUAL "aaaaa") +endfunction (whiletest) +whiletest() +if ("${whiletestResult}" STREQUAL "aaa") + pass ("whiletest") +else ("${whiletestResult}" STREQUAL "aaa") + failed ("whiletest got: ${whiletestResult}") +endif ("${whiletestResult}" STREQUAL "aaa") + +# check subdir return +add_subdirectory(subdir) +get_directory_property(subdirResult DIRECTORY subdir DEFINITION subdirreturn) +if ("${subdirResult}" EQUAL 1) + pass ("subdir") +else ("${subdirResult}" EQUAL 1) + failed ("subdir got: ${subdirResult}") +endif ("${subdirResult}" EQUAL 1) + +# check return from a file +include(include_return.cmake) +if ("${include_returnResult}" EQUAL 1) + pass ("include_return") +else ("${include_returnResult}" EQUAL 1) + failed ("include_return got: ${include_returnResult}") +endif ("${include_returnResult}" EQUAL 1) + +# check return from within a macro +macro (mymacro) + set (foo 1) + if (foo) + return() + endif (foo) +endmacro(mymacro) + +# test simple return +function (simple3) + set (bar 0) + set(simple3Result 1 PARENT_SCOPE) + if (bar) + else (bar) + mymacro() + endif(bar) + set(simple3Result 0 PARENT_SCOPE) +endfunction (simple3) +simple3() +if ("${simple3Result}") + pass ("macrotest") +else ("${simple3Result}") + failed ("macrotest got: ${simple3Result}") +endif ("${simple3Result}") + + +# test break command now in a foreach +foreach (iter RANGE 1 5) + set (break1 "${iter}") + if ("${iter}" EQUAL 3) + break () + endif ("${iter}" EQUAL 3) +endforeach (iter) +if ("${break1}" EQUAL 3) + pass ("break in foreach") +else ("${break1}" EQUAL 3) + failed ("break in foreach got: ${break1}") +endif ("${break1}" EQUAL 3) + +# test break in a while loop +set (iter "a") +while(NOT "${iter}" STREQUAL "aaaaa") + if ("${iter}" STREQUAL "aaa") + break () + endif ("${iter}" STREQUAL "aaa") + set (iter "${iter}a") +endwhile(NOT "${iter}" STREQUAL "aaaaa") +if ("${iter}" STREQUAL "aaa") + pass ("break in a while") +else ("${iter}" STREQUAL "aaa") + failed ("break in a whi;e got: ${whiletestResult}") +endif ("${iter}" STREQUAL "aaa") + + +add_executable (ReturnTest returnTest.c) diff --git a/Tests/ReturnTest/include_return.cmake b/Tests/ReturnTest/include_return.cmake new file mode 100644 index 000000000..7cea1fb2d --- /dev/null +++ b/Tests/ReturnTest/include_return.cmake @@ -0,0 +1,3 @@ +set(include_returnResult 1) +return() +set(include_returnResult 0) diff --git a/Tests/ReturnTest/returnTest.c b/Tests/ReturnTest/returnTest.c new file mode 100644 index 000000000..e0ced6afd --- /dev/null +++ b/Tests/ReturnTest/returnTest.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char* argv[]) +{ + printf("Running command: %s with %d arguments\n", argv[0], argc); + return 0; +} diff --git a/Tests/ReturnTest/subdir/CMakeLists.txt b/Tests/ReturnTest/subdir/CMakeLists.txt new file mode 100644 index 000000000..b9510924f --- /dev/null +++ b/Tests/ReturnTest/subdir/CMakeLists.txt @@ -0,0 +1,3 @@ +set (subdirreturn 1) +return() +set (subdirreturn 0) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt new file mode 100644 index 000000000..eca96f907 --- /dev/null +++ b/Tests/RunCMake/CMakeLists.txt @@ -0,0 +1,58 @@ +# This directory contains tests that run CMake to configure a project +# but do not actually build anything. To add a test: +# +# 1.) Add a subdirectory named for the test. +# +# 2.) Call add_RunCMake_test and pass the test directory name. +# +# 3.) Create a RunCMakeTest.cmake script in the directory containing +# include(RunCMake) +# run_cmake(SubTest1) +# ... +# run_cmake(SubTestN) +# where SubTest1..SubTestN are sub-test names each corresponding to +# an independent CMake run and project configuration. +# +# 3.) Create a CMakeLists.txt file in the directory containing +# cmake_minimum_required(...) +# project(${RunCMake_TEST} NONE) # or languages needed +# include(${RunCMake_TEST}.cmake) +# where "${RunCMake_TEST}" is literal. A value for RunCMake_TEST +# will be passed to CMake by the run_cmake macro when running each +# sub-test. +# +# 4.) Create a <SubTest>.cmake file for each sub-test named above +# containing the actual test code. Optionally create files +# containing expected test results: +# <SubTest>-result.txt = Process result expected if not "0" +# <SubTest>-stdout.txt = Regex matching expected stdout content +# <SubTest>-stderr.txt = Regex matching expected stderr content +# <SubTest>-check.cmake = Custom result check +# Note that trailing newlines will be stripped from actual test +# output before matching against the stdout and stderr expressions. +# The code in <SubTest>-check.cmake may use variables +# RunCMake_TEST_SOURCE_DIR = Top of test source tree +# RunCMake_TEST_BINARY_DIR = Top of test binary tree +# and an failure must store a message in RunCMake_TEST_FAILED. + +macro(add_RunCMake_test test) + add_test(RunCMake.${test} ${CMAKE_CMAKE_COMMAND} + -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR} + -DRunCMake_GENERATOR=${CMAKE_TEST_GENERATOR} + -DRunCMake_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${test} + -DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${test} + -P "${CMAKE_CURRENT_SOURCE_DIR}/${test}/RunCMakeTest.cmake" + ) +endmacro() + +add_RunCMake_test(Languages) +add_RunCMake_test(ObjectLibrary) + +add_RunCMake_test(build_command) +add_RunCMake_test(find_package) +add_RunCMake_test(include) +add_RunCMake_test(list) + +if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") + add_RunCMake_test(include_external_msproject) +endif() diff --git a/Tests/RunCMake/Languages/CMakeLists.txt b/Tests/RunCMake/Languages/CMakeLists.txt new file mode 100644 index 000000000..e8db6b05b --- /dev/null +++ b/Tests/RunCMake/Languages/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Languages/NoLangSHARED-result.txt b/Tests/RunCMake/Languages/NoLangSHARED-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/Languages/NoLangSHARED-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt b/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt new file mode 100644 index 000000000..3f93cf86c --- /dev/null +++ b/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt @@ -0,0 +1 @@ +CMake Error: CMake can not determine linker language for target:NoLang diff --git a/Tests/RunCMake/Languages/NoLangSHARED.cmake b/Tests/RunCMake/Languages/NoLangSHARED.cmake new file mode 100644 index 000000000..de6adf7cb --- /dev/null +++ b/Tests/RunCMake/Languages/NoLangSHARED.cmake @@ -0,0 +1 @@ +add_library(NoLang SHARED foo.nolang) diff --git a/Tests/RunCMake/Languages/RunCMakeTest.cmake b/Tests/RunCMake/Languages/RunCMakeTest.cmake new file mode 100644 index 000000000..a99548f05 --- /dev/null +++ b/Tests/RunCMake/Languages/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(NoLangSHARED) diff --git a/Tests/RunCMake/Languages/foo.nolang b/Tests/RunCMake/Languages/foo.nolang new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/Languages/foo.nolang diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource1-result.txt b/Tests/RunCMake/ObjectLibrary/BadObjSource1-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource1-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadObjSource1-stderr.txt new file mode 100644 index 000000000..b31225b48 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource1-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at BadObjSource1.cmake:1 \(add_library\): + OBJECT library "A" contains: + + bad.def + + but may contain only headers and sources that compile. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource1.cmake b/Tests/RunCMake/ObjectLibrary/BadObjSource1.cmake new file mode 100644 index 000000000..aa3514d90 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource1.cmake @@ -0,0 +1 @@ +add_library(A OBJECT a.c bad.def) diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource2-result.txt b/Tests/RunCMake/ObjectLibrary/BadObjSource2-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt new file mode 100644 index 000000000..906cf0b64 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at BadObjSource2.cmake:1 \(add_library\): + OBJECT library "A" contains: + + bad.obj + + but may contain only headers and sources that compile. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource2.cmake b/Tests/RunCMake/ObjectLibrary/BadObjSource2.cmake new file mode 100644 index 000000000..7957c99f2 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadObjSource2.cmake @@ -0,0 +1 @@ +add_library(A OBJECT a.c bad.obj) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-result.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt new file mode 100644 index 000000000..a1cac36fa --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at BadSourceExpression1.cmake:1 \(add_library\): + Unrecognized generator expression: + + \$<BAD_EXPRESSION> +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1.cmake b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1.cmake new file mode 100644 index 000000000..020c9a00f --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1.cmake @@ -0,0 +1 @@ +add_library(A STATIC a.c $<BAD_EXPRESSION>) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-result.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt new file mode 100644 index 000000000..f1fcbe85f --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at BadSourceExpression2.cmake:1 \(add_library\): + Objects of target "DoesNotExist" referenced but no such target exists. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2.cmake b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2.cmake new file mode 100644 index 000000000..ed5dc4335 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2.cmake @@ -0,0 +1 @@ +add_library(A STATIC a.c $<TARGET_OBJECTS:DoesNotExist>) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-result.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt new file mode 100644 index 000000000..ad14a3513 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at BadSourceExpression3.cmake:2 \(add_library\): + Objects of target "NotObjLib" referenced but is not an OBJECT library. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake new file mode 100644 index 000000000..c3d9a622d --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake @@ -0,0 +1,2 @@ +add_library(NotObjLib STATIC a.c) +add_library(A STATIC a.c $<TARGET_OBJECTS:NotObjLib>) diff --git a/Tests/RunCMake/ObjectLibrary/CMakeLists.txt b/Tests/RunCMake/ObjectLibrary/CMakeLists.txt new file mode 100644 index 000000000..a7f077912 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} C) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ObjectLibrary/Export-result.txt b/Tests/RunCMake/ObjectLibrary/Export-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Export-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/Export-stderr.txt b/Tests/RunCMake/ObjectLibrary/Export-stderr.txt new file mode 100644 index 000000000..bdadca488 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Export-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Export.cmake:2 \(export\): + export given OBJECT library "A" which may not be exported. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/Export.cmake b/Tests/RunCMake/ObjectLibrary/Export.cmake new file mode 100644 index 000000000..a3f104e29 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Export.cmake @@ -0,0 +1,2 @@ +add_library(A OBJECT a.c) +export(TARGETS A FILE AExport.cmake) diff --git a/Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake b/Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake new file mode 100644 index 000000000..0796c21ba --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake @@ -0,0 +1,15 @@ +enable_language(CXX) +add_library(A OBJECT a.cxx) +add_library(B STATIC a.c $<TARGET_OBJECTS:A>) + +# Verify that object library languages are propagated. +export(TARGETS B NAMESPACE Exp FILE BExport.cmake) +include(${CMAKE_CURRENT_BINARY_DIR}/BExport.cmake) +get_property(configs TARGET ExpB PROPERTY IMPORTED_CONFIGURATIONS) +foreach(c ${configs}) + get_property(langs TARGET ExpB PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES_${c}) + list(FIND langs CXX pos) + if(${pos} LESS 0) + message(FATAL_ERROR "Target export does not list object library languages.") + endif() +endforeach() diff --git a/Tests/RunCMake/ObjectLibrary/Import-result.txt b/Tests/RunCMake/ObjectLibrary/Import-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Import-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/Import-stderr.txt b/Tests/RunCMake/ObjectLibrary/Import-stderr.txt new file mode 100644 index 000000000..74b496ab8 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Import-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Import.cmake:1 \(add_library\): + The OBJECT library type may not be used for IMPORTED libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/Import.cmake b/Tests/RunCMake/ObjectLibrary/Import.cmake new file mode 100644 index 000000000..806b44a25 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Import.cmake @@ -0,0 +1 @@ +add_library(A OBJECT IMPORTED) diff --git a/Tests/RunCMake/ObjectLibrary/Install-result.txt b/Tests/RunCMake/ObjectLibrary/Install-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Install-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/Install-stderr.txt b/Tests/RunCMake/ObjectLibrary/Install-stderr.txt new file mode 100644 index 000000000..d2f9f4a37 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Install-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Install.cmake:2 \(install\): + install TARGETS given OBJECT library "A" which may not be installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/Install.cmake b/Tests/RunCMake/ObjectLibrary/Install.cmake new file mode 100644 index 000000000..c1d214bd4 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Install.cmake @@ -0,0 +1,2 @@ +add_library(A OBJECT a.c) +install(TARGETS A DESTINATION lib) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHS-result.txt b/Tests/RunCMake/ObjectLibrary/LinkObjLHS-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjLHS-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt b/Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt new file mode 100644 index 000000000..90e828bdb --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at LinkObjLHS.cmake:2 \(target_link_libraries\): + Object library target "AnObjLib" may not link to anything. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake new file mode 100644 index 000000000..5d7831a23 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake @@ -0,0 +1,2 @@ +add_library(AnObjLib OBJECT a.c) +target_link_libraries(AnObjLib OtherLib) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-result.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt new file mode 100644 index 000000000..8809f8933 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at LinkObjRHS1.cmake:3 \(target_link_libraries\): + Target "AnObjLib" of type OBJECT_LIBRARY may not be linked into another + target. One may link only to STATIC or SHARED libraries, or to executables + with the ENABLE_EXPORTS property set. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake new file mode 100644 index 000000000..113d6a841 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake @@ -0,0 +1,3 @@ +add_library(A STATIC a.c) +add_library(AnObjLib OBJECT a.c) +target_link_libraries(A AnObjLib) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-result.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt new file mode 100644 index 000000000..3295fcac3 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at LinkObjRHS2.cmake:1 \(add_library\): + Target "A" links to OBJECT library "AnObjLib" but this is not allowed. One + may link only to STATIC or SHARED libraries, or to executables with the + ENABLE_EXPORTS property set. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake new file mode 100644 index 000000000..616372949 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake @@ -0,0 +1,3 @@ +add_library(A SHARED a.c) +target_link_libraries(A AnObjLib) +add_library(AnObjLib OBJECT a.c) diff --git a/Tests/RunCMake/ObjectLibrary/ObjWithObj-result.txt b/Tests/RunCMake/ObjectLibrary/ObjWithObj-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/ObjWithObj-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt b/Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt new file mode 100644 index 000000000..d67b4ae32 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at ObjWithObj.cmake:2 \(add_library\): + Only executables and non-OBJECT libraries may reference target objects. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/ObjWithObj.cmake b/Tests/RunCMake/ObjectLibrary/ObjWithObj.cmake new file mode 100644 index 000000000..d0ef34bfe --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/ObjWithObj.cmake @@ -0,0 +1,2 @@ +add_library(A OBJECT a.c) +add_library(B OBJECT $<TARGET_OBJECTS:A>) diff --git a/Tests/RunCMake/ObjectLibrary/PostBuild-result.txt b/Tests/RunCMake/ObjectLibrary/PostBuild-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PostBuild-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/PostBuild-stderr.txt b/Tests/RunCMake/ObjectLibrary/PostBuild-stderr.txt new file mode 100644 index 000000000..4b067bbc3 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PostBuild-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at PostBuild.cmake:2 \(add_custom_command\): + Target "A" is an OBJECT library that may not have PRE_BUILD, PRE_LINK, or + POST_BUILD commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/PostBuild.cmake b/Tests/RunCMake/ObjectLibrary/PostBuild.cmake new file mode 100644 index 000000000..dea9a099e --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PostBuild.cmake @@ -0,0 +1,4 @@ +add_library(A OBJECT a.c) +add_custom_command(TARGET A POST_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "A post-build" + ) diff --git a/Tests/RunCMake/ObjectLibrary/PreBuild-result.txt b/Tests/RunCMake/ObjectLibrary/PreBuild-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PreBuild-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/PreBuild-stderr.txt b/Tests/RunCMake/ObjectLibrary/PreBuild-stderr.txt new file mode 100644 index 000000000..3b27a6da5 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PreBuild-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at PreBuild.cmake:2 \(add_custom_command\): + Target "A" is an OBJECT library that may not have PRE_BUILD, PRE_LINK, or + POST_BUILD commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/PreBuild.cmake b/Tests/RunCMake/ObjectLibrary/PreBuild.cmake new file mode 100644 index 000000000..e4424c100 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PreBuild.cmake @@ -0,0 +1,4 @@ +add_library(A OBJECT a.c) +add_custom_command(TARGET A PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "A pre-build" + ) diff --git a/Tests/RunCMake/ObjectLibrary/PreLink-result.txt b/Tests/RunCMake/ObjectLibrary/PreLink-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PreLink-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/PreLink-stderr.txt b/Tests/RunCMake/ObjectLibrary/PreLink-stderr.txt new file mode 100644 index 000000000..947b9f177 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PreLink-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at PreLink.cmake:2 \(add_custom_command\): + Target "A" is an OBJECT library that may not have PRE_BUILD, PRE_LINK, or + POST_BUILD commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/PreLink.cmake b/Tests/RunCMake/ObjectLibrary/PreLink.cmake new file mode 100644 index 000000000..b88905511 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/PreLink.cmake @@ -0,0 +1,4 @@ +add_library(A OBJECT a.c) +add_custom_command(TARGET A PRE_LINK + COMMAND ${CMAKE_COMMAND} -E echo "A pre-link" + ) diff --git a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake new file mode 100644 index 000000000..55db14dfd --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake @@ -0,0 +1,18 @@ +include(RunCMake) + +run_cmake(BadSourceExpression1) +run_cmake(BadSourceExpression2) +run_cmake(BadSourceExpression3) +run_cmake(BadObjSource1) +run_cmake(BadObjSource2) +run_cmake(Export) +run_cmake(ExportLanguages) +run_cmake(Import) +run_cmake(Install) +run_cmake(LinkObjLHS) +run_cmake(LinkObjRHS1) +run_cmake(LinkObjRHS2) +run_cmake(ObjWithObj) +run_cmake(PostBuild) +run_cmake(PreBuild) +run_cmake(PreLink) diff --git a/Tests/RunCMake/ObjectLibrary/a.c b/Tests/RunCMake/ObjectLibrary/a.c new file mode 100644 index 000000000..af20d3ff6 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/a.c @@ -0,0 +1 @@ +int a(void) { return 0; } diff --git a/Tests/RunCMake/ObjectLibrary/a.cxx b/Tests/RunCMake/ObjectLibrary/a.cxx new file mode 100644 index 000000000..ae9c87c49 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/a.cxx @@ -0,0 +1 @@ +extern "C" int acxx(void) { return 0; } diff --git a/Tests/RunCMake/ObjectLibrary/bad.def b/Tests/RunCMake/ObjectLibrary/bad.def new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/bad.def diff --git a/Tests/RunCMake/ObjectLibrary/bad.obj b/Tests/RunCMake/ObjectLibrary/bad.obj new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/bad.obj diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake new file mode 100644 index 000000000..c3c161abe --- /dev/null +++ b/Tests/RunCMake/RunCMake.cmake @@ -0,0 +1,74 @@ +foreach(arg + RunCMake_GENERATOR + RunCMake_SOURCE_DIR + RunCMake_BINARY_DIR + ) + if(NOT DEFINED ${arg}) + message(FATAL_ERROR "${arg} not given!") + endif() +endforeach() + +function(run_cmake test) + set(top_src "${RunCMake_SOURCE_DIR}") + set(top_bin "${RunCMake_BINARY_DIR}") + if(EXISTS ${top_src}/${test}-result.txt) + file(READ ${top_src}/${test}-result.txt expect_result) + string(REGEX REPLACE "\n+$" "" expect_result "${expect_result}") + else() + set(expect_result 0) + endif() + foreach(o out err) + if(EXISTS ${top_src}/${test}-std${o}.txt) + file(READ ${top_src}/${test}-std${o}.txt expect_std${o}) + string(REGEX REPLACE "\n+$" "" expect_std${o} "${expect_std${o}}") + else() + unset(expect_std${o}) + endif() + endforeach() + set(RunCMake_TEST_SOURCE_DIR "${top_src}") + set(RunCMake_TEST_BINARY_DIR "${top_bin}/${test}-build") + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + execute_process( + COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}" + -G "${RunCMake_GENERATOR}" -DRunCMake_TEST=${test} + WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" + OUTPUT_VARIABLE actual_stdout + ERROR_VARIABLE actual_stderr + RESULT_VARIABLE actual_result + ) + set(msg "") + if(NOT "${actual_result}" STREQUAL "${expect_result}") + set(msg "${msg}Result is [${actual_result}], not [${expect_result}].\n") + endif() + foreach(o out err) + string(REGEX REPLACE "\n+$" "" actual_std${o} "${actual_std${o}}") + set(expect_${o} "") + if(DEFINED expect_std${o}) + if(NOT "${actual_std${o}}" MATCHES "${expect_std${o}}") + string(REGEX REPLACE "\n" "\n expect-${o}> " expect_${o} + " expect-${o}> ${expect_std${o}}") + set(expect_${o} "Expected std${o} to match:\n${expect_${o}}\n") + set(msg "${msg}std${o} does not match that expected.\n") + endif() + endif() + endforeach() + unset(RunCMake_TEST_FAILED) + include(${top_src}/${test}-check.cmake OPTIONAL) + if(RunCMake_TEST_FAILED) + set(msg "${RunCMake_TEST_FAILED}\n${msg}") + endif() + if(msg) + string(REGEX REPLACE "\n" "\n actual-out> " actual_out " actual-out> ${actual_stdout}") + string(REGEX REPLACE "\n" "\n actual-err> " actual_err " actual-err> ${actual_stderr}") + message(SEND_ERROR "${test} - FAILED:\n" + "${msg}" + "${expect_out}" + "Actual stdout:\n${actual_out}\n" + "${expect_err}" + "Actual stderr:\n${actual_err}\n" + ) + else() + message(STATUS "${test} - PASSED") + endif() +endfunction() diff --git a/Tests/RunCMake/build_command/CMakeLists.txt b/Tests/RunCMake/build_command/CMakeLists.txt new file mode 100644 index 000000000..0fbb94803 --- /dev/null +++ b/Tests/RunCMake/build_command/CMakeLists.txt @@ -0,0 +1,59 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) + +# This CMakeLists file is *sometimes expected* to result in a configure error. +# +# expect this to succeed: +# ../bin/Release/cmake -G Xcode +# ../../CMake/Tests/CMakeCommands/build_command +# +# expect this to fail: +# ../bin/Release/cmake -DTEST_ERROR_CONDITIONS:BOOL=ON -G Xcode +# ../../CMake/Tests/CMakeCommands/build_command +# +# This project exists merely to test the CMake command 'build_command'... +# ...even purposefully calling it with known-bad argument lists to cover +# error handling code. +# + +set(cmd "initial") + +message("0. begin") + +if(TEST_ERROR_CONDITIONS) + # Test with no arguments (an error): + build_command() + message("1. cmd='${cmd}'") + + # Test with unknown arguments (also an error): + build_command(cmd BOGUS STUFF) + message("2. cmd='${cmd}'") + + build_command(cmd STUFF BOGUS) + message("3. cmd='${cmd}'") +else() + message("(skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF)") +endif() + +# Test the one arg signature with none of the optional KEYWORD arguments: +build_command(cmd) +message("4. cmd='${cmd}'") + +# Test the two-arg legacy signature: +build_command(legacy_cmd ${CMAKE_BUILD_TOOL}) +message("5. legacy_cmd='${legacy_cmd}'") +message(" CMAKE_BUILD_TOOL='${CMAKE_BUILD_TOOL}'") + +# Test the optional KEYWORDs: +build_command(cmd CONFIGURATION hoohaaConfig) +message("6. cmd='${cmd}'") + +build_command(cmd PROJECT_NAME hoohaaProject) +message("7. cmd='${cmd}'") + +build_command(cmd TARGET hoohaaTarget) +message("8. cmd='${cmd}'") + +set(cmd "final") +message("9. cmd='${cmd}'") diff --git a/Tests/RunCMake/build_command/ErrorsOFF-stderr.txt b/Tests/RunCMake/build_command/ErrorsOFF-stderr.txt new file mode 100644 index 000000000..331885b94 --- /dev/null +++ b/Tests/RunCMake/build_command/ErrorsOFF-stderr.txt @@ -0,0 +1 @@ +skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF diff --git a/Tests/RunCMake/build_command/ErrorsOFF-stdout.txt b/Tests/RunCMake/build_command/ErrorsOFF-stdout.txt new file mode 100644 index 000000000..cf66a9d7a --- /dev/null +++ b/Tests/RunCMake/build_command/ErrorsOFF-stdout.txt @@ -0,0 +1 @@ +Build files have been written to: diff --git a/Tests/RunCMake/build_command/ErrorsOFF.cmake b/Tests/RunCMake/build_command/ErrorsOFF.cmake new file mode 100644 index 000000000..a243fab01 --- /dev/null +++ b/Tests/RunCMake/build_command/ErrorsOFF.cmake @@ -0,0 +1 @@ +set(TEST_ERROR_CONDITIONS OFF) diff --git a/Tests/RunCMake/build_command/ErrorsON-result.txt b/Tests/RunCMake/build_command/ErrorsON-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/build_command/ErrorsON-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/build_command/ErrorsON-stderr.txt b/Tests/RunCMake/build_command/ErrorsON-stderr.txt new file mode 100644 index 000000000..0be7475d7 --- /dev/null +++ b/Tests/RunCMake/build_command/ErrorsON-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at CMakeLists.txt:[0-9]+ \(build_command\): + build_command requires at least one argument naming a CMake variable + ++ +1. cmd='initial' +CMake Error at CMakeLists.txt:[0-9]+ \(build_command\): + build_command unknown argument "BOGUS" + ++ +2. cmd='initial' +CMake Error at CMakeLists.txt:[0-9]+ \(build_command\): + build_command unknown argument "STUFF" diff --git a/Tests/RunCMake/build_command/ErrorsON-stdout.txt b/Tests/RunCMake/build_command/ErrorsON-stdout.txt new file mode 100644 index 000000000..841dd0d88 --- /dev/null +++ b/Tests/RunCMake/build_command/ErrorsON-stdout.txt @@ -0,0 +1 @@ +Configuring incomplete, errors occurred! diff --git a/Tests/RunCMake/build_command/ErrorsON.cmake b/Tests/RunCMake/build_command/ErrorsON.cmake new file mode 100644 index 000000000..27814bf64 --- /dev/null +++ b/Tests/RunCMake/build_command/ErrorsON.cmake @@ -0,0 +1 @@ +set(TEST_ERROR_CONDITIONS ON) diff --git a/Tests/RunCMake/build_command/RunCMakeTest.cmake b/Tests/RunCMake/build_command/RunCMakeTest.cmake new file mode 100644 index 000000000..4525c5725 --- /dev/null +++ b/Tests/RunCMake/build_command/RunCMakeTest.cmake @@ -0,0 +1,4 @@ +include(RunCMake) + +run_cmake(ErrorsOFF) +run_cmake(ErrorsON) diff --git a/Tests/RunCMake/find_package/CMakeLists.txt b/Tests/RunCMake/find_package/CMakeLists.txt new file mode 100644 index 000000000..e8db6b05b --- /dev/null +++ b/Tests/RunCMake/find_package/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/find_package/ComponentRequiredAndOptional-result.txt b/Tests/RunCMake/find_package/ComponentRequiredAndOptional-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/find_package/ComponentRequiredAndOptional-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/ComponentRequiredAndOptional-stderr.txt b/Tests/RunCMake/find_package/ComponentRequiredAndOptional-stderr.txt new file mode 100644 index 000000000..db8f51222 --- /dev/null +++ b/Tests/RunCMake/find_package/ComponentRequiredAndOptional-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at ComponentRequiredAndOptional.cmake:1 \(find_package\): + find_package called with components that are both required and optional: + + CompA + CompB + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/ComponentRequiredAndOptional.cmake b/Tests/RunCMake/find_package/ComponentRequiredAndOptional.cmake new file mode 100644 index 000000000..0355f5af3 --- /dev/null +++ b/Tests/RunCMake/find_package/ComponentRequiredAndOptional.cmake @@ -0,0 +1 @@ +find_package(NotHere REQUIRED CompA CompB CompC OPTIONAL_COMPONENTS CompA CompB CompD) diff --git a/Tests/RunCMake/find_package/MissingConfig-stderr.txt b/Tests/RunCMake/find_package/MissingConfig-stderr.txt new file mode 100644 index 000000000..1eae0bb0b --- /dev/null +++ b/Tests/RunCMake/find_package/MissingConfig-stderr.txt @@ -0,0 +1,19 @@ +CMake Warning at MissingConfig.cmake:1 \(find_package\): + Could not find a package configuration file provided by "NotHere" with any + of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Warning at MissingConfig.cmake:2 \(message\): + This warning must be reachable. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/find_package/MissingConfig.cmake b/Tests/RunCMake/find_package/MissingConfig.cmake new file mode 100644 index 000000000..238e7e498 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingConfig.cmake @@ -0,0 +1,2 @@ +find_package(NotHere CONFIG) +message(WARNING "This warning must be reachable.") diff --git a/Tests/RunCMake/find_package/MissingConfigOneName-stderr.txt b/Tests/RunCMake/find_package/MissingConfigOneName-stderr.txt new file mode 100644 index 000000000..10e71faa3 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingConfigOneName-stderr.txt @@ -0,0 +1,10 @@ +CMake Warning at MissingConfigOneName.cmake:1 \(find_package\): + Could not find a package configuration file named "NotHereConfig.cmake" + provided by package "NotHere". + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/MissingConfigOneName.cmake b/Tests/RunCMake/find_package/MissingConfigOneName.cmake new file mode 100644 index 000000000..11676a9ab --- /dev/null +++ b/Tests/RunCMake/find_package/MissingConfigOneName.cmake @@ -0,0 +1 @@ +find_package(NotHere CONFIGS NotHereConfig.cmake) diff --git a/Tests/RunCMake/find_package/MissingConfigRequired-result.txt b/Tests/RunCMake/find_package/MissingConfigRequired-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingConfigRequired-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/MissingConfigRequired-stderr.txt b/Tests/RunCMake/find_package/MissingConfigRequired-stderr.txt new file mode 100644 index 000000000..2ba774aa2 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingConfigRequired-stderr.txt @@ -0,0 +1,13 @@ +CMake Error at MissingConfigRequired.cmake:1 \(find_package\): + Could not find a package configuration file provided by "NotHere" with any + of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/find_package/MissingConfigRequired.cmake b/Tests/RunCMake/find_package/MissingConfigRequired.cmake new file mode 100644 index 000000000..0ae67023a --- /dev/null +++ b/Tests/RunCMake/find_package/MissingConfigRequired.cmake @@ -0,0 +1,2 @@ +find_package(NotHere CONFIG REQUIRED) +message(FATAL_ERROR "This error must not be reachable.") diff --git a/Tests/RunCMake/find_package/MissingConfigVersion-stderr.txt b/Tests/RunCMake/find_package/MissingConfigVersion-stderr.txt new file mode 100644 index 000000000..2f5086ea8 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingConfigVersion-stderr.txt @@ -0,0 +1,13 @@ +CMake Warning at MissingConfigVersion.cmake:1 \(find_package\): + Could not find a package configuration file provided by "NotHere" + \(requested version 1\.2\) with any of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/MissingConfigVersion.cmake b/Tests/RunCMake/find_package/MissingConfigVersion.cmake new file mode 100644 index 000000000..ac35a79e4 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingConfigVersion.cmake @@ -0,0 +1 @@ +find_package(NotHere 1.2 CONFIG) diff --git a/Tests/RunCMake/find_package/MissingModule-stderr.txt b/Tests/RunCMake/find_package/MissingModule-stderr.txt new file mode 100644 index 000000000..2ad460f58 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingModule-stderr.txt @@ -0,0 +1,26 @@ +CMake Warning at MissingModule.cmake:1 \(find_package\): + No "FindNotHere.cmake" found in CMAKE_MODULE_PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Warning \(dev\) at MissingModule.cmake:1 \(find_package\): + FindNotHere.cmake must either be part of this project itself, in this case + adjust CMAKE_MODULE_PATH so that it points to the correct location inside + its source tree. + + Or it must be installed by a package which has already been found via + find_package\(\). In this case make sure that package has indeed been found + and adjust CMAKE_MODULE_PATH to contain the location where that package has + installed FindNotHere.cmake. This must be a location provided by that + package. This error in general means that the buildsystem of this project + is relying on a Find-module without ensuring that it is actually available. + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Warning at MissingModule.cmake:2 \(message\): + This warning must be reachable. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/find_package/MissingModule.cmake b/Tests/RunCMake/find_package/MissingModule.cmake new file mode 100644 index 000000000..76bcef293 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingModule.cmake @@ -0,0 +1,2 @@ +find_package(NotHere MODULE) +message(WARNING "This warning must be reachable.") diff --git a/Tests/RunCMake/find_package/MissingModuleRequired-result.txt b/Tests/RunCMake/find_package/MissingModuleRequired-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingModuleRequired-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/MissingModuleRequired-stderr.txt b/Tests/RunCMake/find_package/MissingModuleRequired-stderr.txt new file mode 100644 index 000000000..fec05f183 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingModuleRequired-stderr.txt @@ -0,0 +1,21 @@ +CMake Error at MissingModuleRequired.cmake:1 \(find_package\): + No "FindNotHere.cmake" found in CMAKE_MODULE_PATH. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Warning \(dev\) at MissingModuleRequired.cmake:1 \(find_package\): + FindNotHere.cmake must either be part of this project itself, in this case + adjust CMAKE_MODULE_PATH so that it points to the correct location inside + its source tree. + + Or it must be installed by a package which has already been found via + find_package\(\). In this case make sure that package has indeed been found + and adjust CMAKE_MODULE_PATH to contain the location where that package has + installed FindNotHere.cmake. This must be a location provided by that + package. This error in general means that the buildsystem of this project + is relying on a Find-module without ensuring that it is actually available. + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/find_package/MissingModuleRequired.cmake b/Tests/RunCMake/find_package/MissingModuleRequired.cmake new file mode 100644 index 000000000..897eda688 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingModuleRequired.cmake @@ -0,0 +1,2 @@ +find_package(NotHere MODULE REQUIRED) +message(FATAL_ERROR "This error must not be reachable.") diff --git a/Tests/RunCMake/find_package/MissingNormal-stderr.txt b/Tests/RunCMake/find_package/MissingNormal-stderr.txt new file mode 100644 index 000000000..f4c6fbafd --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormal-stderr.txt @@ -0,0 +1,23 @@ +CMake Warning at MissingNormal.cmake:1 \(find_package\): + By not providing "FindNotHere.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "NotHere", but + CMake did not find one. + + Could not find a package configuration file provided by "NotHere" with any + of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Warning at MissingNormal.cmake:2 \(message\): + This warning must be reachable. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/find_package/MissingNormal.cmake b/Tests/RunCMake/find_package/MissingNormal.cmake new file mode 100644 index 000000000..fb90e0128 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormal.cmake @@ -0,0 +1,2 @@ +find_package(NotHere) +message(WARNING "This warning must be reachable.") diff --git a/Tests/RunCMake/find_package/MissingNormalRequired-result.txt b/Tests/RunCMake/find_package/MissingNormalRequired-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormalRequired-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/MissingNormalRequired-stderr.txt b/Tests/RunCMake/find_package/MissingNormalRequired-stderr.txt new file mode 100644 index 000000000..7bb7902b6 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormalRequired-stderr.txt @@ -0,0 +1,17 @@ +CMake Error at MissingNormalRequired.cmake:1 \(find_package\): + By not providing "FindNotHere.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "NotHere", but + CMake did not find one. + + Could not find a package configuration file provided by "NotHere" with any + of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/find_package/MissingNormalRequired.cmake b/Tests/RunCMake/find_package/MissingNormalRequired.cmake new file mode 100644 index 000000000..33353d8cd --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormalRequired.cmake @@ -0,0 +1,2 @@ +find_package(NotHere REQUIRED) +message(FATAL_ERROR "This error must not be reachable.") diff --git a/Tests/RunCMake/find_package/MissingNormalVersion-stderr.txt b/Tests/RunCMake/find_package/MissingNormalVersion-stderr.txt new file mode 100644 index 000000000..36de8009e --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormalVersion-stderr.txt @@ -0,0 +1,17 @@ +CMake Warning at MissingNormalVersion.cmake:1 \(find_package\): + By not providing "FindNotHere.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "NotHere", but + CMake did not find one. + + Could not find a package configuration file provided by "NotHere" + \(requested version 1\.2\) with any of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/MissingNormalVersion.cmake b/Tests/RunCMake/find_package/MissingNormalVersion.cmake new file mode 100644 index 000000000..2d9ce4ea5 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormalVersion.cmake @@ -0,0 +1 @@ +find_package(NotHere 1.2) diff --git a/Tests/RunCMake/find_package/MissingNormalWarnNoModuleNew-stderr.txt b/Tests/RunCMake/find_package/MissingNormalWarnNoModuleNew-stderr.txt new file mode 100644 index 000000000..d34f23c8f --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormalWarnNoModuleNew-stderr.txt @@ -0,0 +1,30 @@ +CMake Warning \(dev\) at MissingNormalWarnNoModuleNew.cmake:3 \(find_package\): + find_package called without either MODULE or CONFIG option and no + FindNotHere.cmake module is in CMAKE_MODULE_PATH. Add MODULE to + exclusively request Module mode and fail if FindNotHere.cmake is missing. + Add CONFIG to exclusively request Config mode and search for a package + configuration file provided by NotHere \(NotHereConfig.cmake or + nothere-config.cmake\). + + \(Variable CMAKE_FIND_PACKAGE_WARN_NO_MODULE enabled this warning.\) +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Warning at MissingNormalWarnNoModuleNew.cmake:3 \(find_package\): + By not providing "FindNotHere.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "NotHere", but + CMake did not find one. + + Could not find a package configuration file provided by "NotHere" with any + of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/MissingNormalWarnNoModuleNew.cmake b/Tests/RunCMake/find_package/MissingNormalWarnNoModuleNew.cmake new file mode 100644 index 000000000..0211249c6 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormalWarnNoModuleNew.cmake @@ -0,0 +1,3 @@ +set(CMAKE_FIND_PACKAGE_WARN_NO_MODULE 1) +set(CMAKE_MINIMUM_REQUIRED_VERSION 2.8.8) +find_package(NotHere) diff --git a/Tests/RunCMake/find_package/MissingNormalWarnNoModuleOld-stderr.txt b/Tests/RunCMake/find_package/MissingNormalWarnNoModuleOld-stderr.txt new file mode 100644 index 000000000..b336b5621 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormalWarnNoModuleOld-stderr.txt @@ -0,0 +1,29 @@ +CMake Warning \(dev\) at MissingNormalWarnNoModuleOld.cmake:2 \(find_package\): + find_package called without NO_MODULE option and no FindNotHere.cmake + module is in CMAKE_MODULE_PATH. Add NO_MODULE to exclusively request + Config mode and search for a package configuration file provided by NotHere + \(NotHereConfig.cmake or nothere-config.cmake\). Otherwise make + FindNotHere.cmake available in CMAKE_MODULE_PATH. + + \(Variable CMAKE_FIND_PACKAGE_WARN_NO_MODULE enabled this warning.\) +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Warning at MissingNormalWarnNoModuleOld.cmake:2 \(find_package\): + By not providing "FindNotHere.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "NotHere", but + CMake did not find one. + + Could not find a package configuration file provided by "NotHere" with any + of the following names: + + NotHereConfig.cmake + nothere-config.cmake + + Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set + "NotHere_DIR" to a directory containing one of the above files. If + "NotHere" provides a separate development package or SDK, be sure it has + been installed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/MissingNormalWarnNoModuleOld.cmake b/Tests/RunCMake/find_package/MissingNormalWarnNoModuleOld.cmake new file mode 100644 index 000000000..1c4a77599 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingNormalWarnNoModuleOld.cmake @@ -0,0 +1,2 @@ +set(CMAKE_FIND_PACKAGE_WARN_NO_MODULE 1) +find_package(NotHere) diff --git a/Tests/RunCMake/find_package/MixedModeOptions-result.txt b/Tests/RunCMake/find_package/MixedModeOptions-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/find_package/MixedModeOptions-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/MixedModeOptions-stderr.txt b/Tests/RunCMake/find_package/MixedModeOptions-stderr.txt new file mode 100644 index 000000000..b8670221b --- /dev/null +++ b/Tests/RunCMake/find_package/MixedModeOptions-stderr.txt @@ -0,0 +1,14 @@ +CMake Error at MixedModeOptions.cmake:1 \(find_package\): + find_package given options exclusive to Module mode: + + MODULE + + and options exclusive to Config mode: + + CONFIG + CONFIGS + NO_DEFAULT_PATH + + The options are incompatible. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/MixedModeOptions.cmake b/Tests/RunCMake/find_package/MixedModeOptions.cmake new file mode 100644 index 000000000..7f78ee05f --- /dev/null +++ b/Tests/RunCMake/find_package/MixedModeOptions.cmake @@ -0,0 +1 @@ +find_package(NotHere MODULE CONFIG CONFIGS NotHereConfig.cmake NO_DEFAULT_PATH) diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake new file mode 100644 index 000000000..42705b77a --- /dev/null +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -0,0 +1,16 @@ +include(RunCMake) + +run_cmake(ComponentRequiredAndOptional) +run_cmake(MissingNormal) +run_cmake(MissingNormalRequired) +run_cmake(MissingNormalVersion) +run_cmake(MissingNormalWarnNoModuleOld) +run_cmake(MissingNormalWarnNoModuleNew) +run_cmake(MissingModule) +run_cmake(MissingModuleRequired) +run_cmake(MissingConfig) +run_cmake(MissingConfigOneName) +run_cmake(MissingConfigRequired) +run_cmake(MissingConfigVersion) +run_cmake(MixedModeOptions) +run_cmake(SetFoundFALSE) diff --git a/Tests/RunCMake/find_package/SetFoundFALSE-stderr.txt b/Tests/RunCMake/find_package/SetFoundFALSE-stderr.txt new file mode 100644 index 000000000..695f6450d --- /dev/null +++ b/Tests/RunCMake/find_package/SetFoundFALSE-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning at SetFoundFALSE.cmake:2 \(find_package\): + Found package configuration file: + + .*/Tests/RunCMake/find_package/SetFoundFALSEConfig.cmake + + but it set SetFoundFALSE_FOUND to FALSE so package "SetFoundFALSE" is + considered to be NOT FOUND. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/SetFoundFALSE.cmake b/Tests/RunCMake/find_package/SetFoundFALSE.cmake new file mode 100644 index 000000000..fbcec3c56 --- /dev/null +++ b/Tests/RunCMake/find_package/SetFoundFALSE.cmake @@ -0,0 +1,2 @@ +set(SetFoundFALSE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +find_package(SetFoundFALSE CONFIG) diff --git a/Tests/RunCMake/find_package/SetFoundFALSEConfig.cmake b/Tests/RunCMake/find_package/SetFoundFALSEConfig.cmake new file mode 100644 index 000000000..ae6bd1454 --- /dev/null +++ b/Tests/RunCMake/find_package/SetFoundFALSEConfig.cmake @@ -0,0 +1 @@ +set(SetFoundFALSE_FOUND FALSE) diff --git a/Tests/RunCMake/include/CMakeLists.txt b/Tests/RunCMake/include/CMakeLists.txt new file mode 100644 index 000000000..e8db6b05b --- /dev/null +++ b/Tests/RunCMake/include/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/include/EmptyString-stderr.txt b/Tests/RunCMake/include/EmptyString-stderr.txt new file mode 100644 index 000000000..006c647c6 --- /dev/null +++ b/Tests/RunCMake/include/EmptyString-stderr.txt @@ -0,0 +1,5 @@ +CMake Warning \(dev\) at EmptyString.cmake:1 \(include\): + include\(\) given empty file name \(ignored\). +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/include/EmptyString.cmake b/Tests/RunCMake/include/EmptyString.cmake new file mode 100644 index 000000000..4285cb3d5 --- /dev/null +++ b/Tests/RunCMake/include/EmptyString.cmake @@ -0,0 +1 @@ +include("") diff --git a/Tests/RunCMake/include/EmptyStringOptional-stderr.txt b/Tests/RunCMake/include/EmptyStringOptional-stderr.txt new file mode 100644 index 000000000..b61c67912 --- /dev/null +++ b/Tests/RunCMake/include/EmptyStringOptional-stderr.txt @@ -0,0 +1,5 @@ +CMake Warning \(dev\) at EmptyStringOptional.cmake:1 \(include\): + include\(\) given empty file name \(ignored\). +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/include/EmptyStringOptional.cmake b/Tests/RunCMake/include/EmptyStringOptional.cmake new file mode 100644 index 000000000..549d46b3d --- /dev/null +++ b/Tests/RunCMake/include/EmptyStringOptional.cmake @@ -0,0 +1 @@ +include("" OPTIONAL) diff --git a/Tests/RunCMake/include/RunCMakeTest.cmake b/Tests/RunCMake/include/RunCMakeTest.cmake new file mode 100644 index 000000000..59b87ca75 --- /dev/null +++ b/Tests/RunCMake/include/RunCMakeTest.cmake @@ -0,0 +1,4 @@ +include(RunCMake) + +run_cmake(EmptyString) +run_cmake(EmptyStringOptional) diff --git a/Tests/RunCMake/include_external_msproject/CMakeLists.txt b/Tests/RunCMake/include_external_msproject/CMakeLists.txt new file mode 100644 index 000000000..e8db6b05b --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/include_external_msproject/CustomGuid-check.cmake b/Tests/RunCMake/include_external_msproject/CustomGuid-check.cmake new file mode 100644 index 000000000..68dec4c08 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomGuid-check.cmake @@ -0,0 +1 @@ +check_project(CustomGuid external "aaa-bbb-ccc-000" "" "") diff --git a/Tests/RunCMake/include_external_msproject/CustomGuid.cmake b/Tests/RunCMake/include_external_msproject/CustomGuid.cmake new file mode 100644 index 000000000..1dbe7da05 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomGuid.cmake @@ -0,0 +1,2 @@ +include_external_msproject(external external.project + GUID aaa-bbb-ccc-000) diff --git a/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform-check.cmake b/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform-check.cmake new file mode 100644 index 000000000..614712ee6 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform-check.cmake @@ -0,0 +1 @@ +check_project(CustomGuidTypePlatform external "aaa-bbb-ccc-111" "aaa-bbb-ccc-ddd-eee" "Custom Platform") diff --git a/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform.cmake b/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform.cmake new file mode 100644 index 000000000..ee4db655f --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform.cmake @@ -0,0 +1,5 @@ +# Test all optional parameters are set. +include_external_msproject(external external.project + GUID aaa-bbb-ccc-111 + TYPE aaa-bbb-ccc-ddd-eee + PLATFORM "Custom Platform") diff --git a/Tests/RunCMake/include_external_msproject/CustomTypePlatform-check.cmake b/Tests/RunCMake/include_external_msproject/CustomTypePlatform-check.cmake new file mode 100644 index 000000000..054eeb037 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomTypePlatform-check.cmake @@ -0,0 +1 @@ +check_project(CustomTypePlatform external "" "aaa-bbb-ccc-ddd-eee" "Custom Platform") diff --git a/Tests/RunCMake/include_external_msproject/CustomTypePlatform.cmake b/Tests/RunCMake/include_external_msproject/CustomTypePlatform.cmake new file mode 100644 index 000000000..8c76adbc8 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomTypePlatform.cmake @@ -0,0 +1,3 @@ +include_external_msproject(external external.project + TYPE aaa-bbb-ccc-ddd-eee + PLATFORM "Custom Platform") diff --git a/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake b/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake new file mode 100644 index 000000000..90710f9bf --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) +include(${CMAKE_CURRENT_LIST_DIR}/check_utils.cmake) + +run_cmake(CustomGuid) +run_cmake(CustomTypePlatform) +run_cmake(CustomGuidTypePlatform) diff --git a/Tests/RunCMake/include_external_msproject/check_utils.cmake b/Tests/RunCMake/include_external_msproject/check_utils.cmake new file mode 100644 index 000000000..7d6b8f8ea --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/check_utils.cmake @@ -0,0 +1,109 @@ +# Check that file contains line that matches regular expression. +# Sets IS_FOUND variable to TRUE if found and to FALSE otherwise. +macro(check_line_exists TARGET_FILE REG_EXP_REF) + set(IS_FOUND "FALSE") + + file(STRINGS ${TARGET_FILE} FOUND_LINE LIMIT_COUNT 1 REGEX "${${REG_EXP_REF}}") + list(LENGTH FOUND_LINE _VAR_LEN) + + if(_VAR_LEN GREATER 0) + set(IS_FOUND "TRUE") + endif(_VAR_LEN GREATER 0) +endmacro(check_line_exists TARGET_FILE REG_EXP_REF) + +# Search and parse project section line by project name. +# If search was successful stores found type and guid into FOUND_TYPE and FOUND_GUID variables respectively. +# Sets IS_FOUND variable to TRUE if found and to FALSE otherwise. +macro(parse_project_section TARGET_FILE PROJECT_NAME) + set(REG_EXP "^Project\\(\\\"{(.+)}\\\"\\) = \\\"${PROJECT_NAME}\\\", \\\".+\\..+\\\", \\\"{(.+)}\\\"$") + + check_line_exists(${TARGET_FILE} REG_EXP) + if(NOT IS_FOUND) + return() + endif(NOT IS_FOUND) + + string(REGEX REPLACE "${REG_EXP}" "\\1;\\2" _GUIDS "${FOUND_LINE}") + + list(GET _GUIDS 0 FOUND_TYPE) + list(GET _GUIDS 1 FOUND_GUID) +endmacro(parse_project_section TARGET_FILE PROJECT_NAME) + +# Search project section line by project name and type. +# Returns TRUE if found and FALSE otherwise +function(check_project_type TARGET_FILE PROJECT_NAME PROJECT_TYPE RESULT) + set(${RESULT} "FALSE" PARENT_SCOPE) + + parse_project_section(${TARGET_FILE} ${PROJECT_NAME}) + if(IS_FOUND AND FOUND_TYPE STREQUAL PROJECT_TYPE) + set(${RESULT} "TRUE" PARENT_SCOPE) + endif(IS_FOUND AND FOUND_TYPE STREQUAL PROJECT_TYPE) +endfunction(check_project_type TARGET_FILE PROJECT_NAME PROJECT_TYPE RESULT) + + +# Search project section line by project name and id. +# Returns TRUE if found and FALSE otherwise +function(check_project_guid TARGET_FILE PROJECT_NAME PROJECT_GUID RESULT) + set(${RESULT} "FALSE" PARENT_SCOPE) + + parse_project_section(${TARGET_FILE} ${PROJECT_NAME}) + if(IS_FOUND AND FOUND_GUID STREQUAL PROJECT_GUID) + set(${RESULT} "TRUE" PARENT_SCOPE) + endif(IS_FOUND AND FOUND_GUID STREQUAL PROJECT_GUID) +endfunction(check_project_guid TARGET_FILE PROJECT_NAME PROJECT_GUID RESULT) + + +# Search project's build configuration line by project name and target platform name. +# Returns TRUE if found and FALSE otherwise +function(check_custom_platform TARGET_FILE PROJECT_NAME PLATFORM_NAME RESULT) + set(${RESULT} "FALSE" PARENT_SCOPE) + + # extract project guid + parse_project_section(${TARGET_FILE} ${PROJECT_NAME}) + if(NOT IS_FOUND) + return() + endif(NOT IS_FOUND) + + # probably whould be better to use configuration name + # extracted from CMAKE_CONFIGURATION_TYPES than just hardcoded "Debug" instead + set(REG_EXP "^(\t)*\\{${FOUND_GUID}\\}\\.Debug[^ ]*\\.ActiveCfg = Debug\\|${PLATFORM_NAME}$") + check_line_exists(${TARGET_FILE} REG_EXP) + + set(${RESULT} ${IS_FOUND} PARENT_SCOPE) +endfunction(check_custom_platform TARGET_FILE PLATFORM_NAME RESULT) + +# RunCMake test check helper +function(check_project test name guid type platform) + set(sln "${RunCMake_TEST_BINARY_DIR}/${test}.sln") + set(sep "") + set(failed "") + if(NOT type) + set(type 8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942) + endif() + if(NOT platform) + if("${RunCMake_GENERATOR}" MATCHES "Win64") + set(platform "x64") + else() + set(platform "Win32") + endif() + endif() + if(guid) + check_project_guid("${sln}" "${name}" "${guid}" passed_guid) + if(NOT passed_guid) + set(failed "${failed}${sep}${name} solution has no project with expected GUID=${guid}") + set(sep "\n") + endif() + else() + set(passed_guid 1) + endif() + check_project_type("${sln}" "${name}" "${type}" passed_type) + if(NOT passed_type) + set(failed "${failed}${sep}${name} solution has no project with expected TYPE=${type}") + set(sep "\n") + endif() + check_custom_platform("${sln}" "${name}" "${platform}" passed_platform) + if(NOT passed_platform) + set(failed "${failed}${sep}${name} solution has no project with expected PLATFORM=${platform}") + set(sep "\n") + endif() + set(RunCMake_TEST_FAILED "${failed}" PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/include_external_msproject/main.cpp b/Tests/RunCMake/include_external_msproject/main.cpp new file mode 100644 index 000000000..919810306 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/main.cpp @@ -0,0 +1,3 @@ +void main() +{ +} diff --git a/Tests/RunCMake/list/CMakeLists.txt b/Tests/RunCMake/list/CMakeLists.txt new file mode 100644 index 000000000..e8db6b05b --- /dev/null +++ b/Tests/RunCMake/list/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/list/EmptyGet0-result.txt b/Tests/RunCMake/list/EmptyGet0-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/list/EmptyGet0-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/EmptyGet0-stderr.txt b/Tests/RunCMake/list/EmptyGet0-stderr.txt new file mode 100644 index 000000000..0c61b011f --- /dev/null +++ b/Tests/RunCMake/list/EmptyGet0-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at EmptyGet0.cmake:2 \(list\): + list GET given empty list +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/EmptyGet0.cmake b/Tests/RunCMake/list/EmptyGet0.cmake new file mode 100644 index 000000000..494710825 --- /dev/null +++ b/Tests/RunCMake/list/EmptyGet0.cmake @@ -0,0 +1,2 @@ +set(mylist "") +list(GET mylist 0 result) diff --git a/Tests/RunCMake/list/EmptyInsert-1-result.txt b/Tests/RunCMake/list/EmptyInsert-1-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/list/EmptyInsert-1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/EmptyInsert-1-stderr.txt b/Tests/RunCMake/list/EmptyInsert-1-stderr.txt new file mode 100644 index 000000000..0900ff941 --- /dev/null +++ b/Tests/RunCMake/list/EmptyInsert-1-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at EmptyInsert-1.cmake:2 \(list\): + list index: -1 out of range \(0, 0\) +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/EmptyInsert-1.cmake b/Tests/RunCMake/list/EmptyInsert-1.cmake new file mode 100644 index 000000000..140da5d07 --- /dev/null +++ b/Tests/RunCMake/list/EmptyInsert-1.cmake @@ -0,0 +1,2 @@ +set(mylist "") +list(INSERT mylist -1 x) diff --git a/Tests/RunCMake/list/EmptyRemoveAt0-result.txt b/Tests/RunCMake/list/EmptyRemoveAt0-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/list/EmptyRemoveAt0-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt b/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt new file mode 100644 index 000000000..b24a0ed0b --- /dev/null +++ b/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at EmptyRemoveAt0.cmake:2 \(list\): + list REMOVE_AT given empty list +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/EmptyRemoveAt0.cmake b/Tests/RunCMake/list/EmptyRemoveAt0.cmake new file mode 100644 index 000000000..d6a3e85c6 --- /dev/null +++ b/Tests/RunCMake/list/EmptyRemoveAt0.cmake @@ -0,0 +1,2 @@ +set(mylist "") +list(REMOVE_AT mylist 0) diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake new file mode 100644 index 000000000..555051de0 --- /dev/null +++ b/Tests/RunCMake/list/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(EmptyGet0) +run_cmake(EmptyRemoveAt0) +run_cmake(EmptyInsert-1) diff --git a/Tests/RuntimePath/CMakeLists.txt b/Tests/RuntimePath/CMakeLists.txt new file mode 100644 index 000000000..2164cdb8d --- /dev/null +++ b/Tests/RuntimePath/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required (VERSION 2.6) +project(RuntimePath C) + +# Add a simple chain of shared libraries that must be found. +add_library(foo1 SHARED foo1.c) +set_property(TARGET foo1 PROPERTY OUTPUT_NAME foo) +set_property(TARGET foo1 PROPERTY LIBRARY_OUTPUT_DIRECTORY A) + +add_library(bar1 SHARED bar1.c) +set_property(TARGET bar1 PROPERTY OUTPUT_NAME bar) +set_property(TARGET bar1 PROPERTY VERSION 1) +set_property(TARGET bar1 PROPERTY LIBRARY_OUTPUT_DIRECTORY B) +target_link_libraries(bar1 foo1) + +add_executable(RuntimePath main.c) +target_link_libraries(RuntimePath bar1) + +# Add a library that provides a conflicting location to make sure +# rpath ordering works. +add_library(foo2 SHARED foo2.c) +set_property(TARGET foo2 PROPERTY OUTPUT_NAME foo) +set_property(TARGET foo2 PROPERTY LIBRARY_OUTPUT_DIRECTORY B) + +# Add a library that would provide a conflicting location if not for +# soname analysis in rpath ordering. This will also break the old +# link directory ordering to make sure files are linked with full +# paths. +if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG) + add_library(bar2 SHARED bar2.c) + set_property(TARGET bar2 PROPERTY OUTPUT_NAME bar) + set_property(TARGET bar2 PROPERTY LIBRARY_OUTPUT_DIRECTORY A) + target_link_libraries(bar2 foo2) +endif(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG) diff --git a/Tests/RuntimePath/bar1.c b/Tests/RuntimePath/bar1.c new file mode 100644 index 000000000..ebad8d20c --- /dev/null +++ b/Tests/RuntimePath/bar1.c @@ -0,0 +1,2 @@ +extern int foo1(); +int bar1() { return foo1(); } diff --git a/Tests/RuntimePath/bar2.c b/Tests/RuntimePath/bar2.c new file mode 100644 index 000000000..60d5e686a --- /dev/null +++ b/Tests/RuntimePath/bar2.c @@ -0,0 +1,2 @@ +extern int foo2(); +int bar2() { return foo2(); } diff --git a/Tests/RuntimePath/foo1.c b/Tests/RuntimePath/foo1.c new file mode 100644 index 000000000..27cd9125b --- /dev/null +++ b/Tests/RuntimePath/foo1.c @@ -0,0 +1 @@ +int foo1() { return 0; } diff --git a/Tests/RuntimePath/foo2.c b/Tests/RuntimePath/foo2.c new file mode 100644 index 000000000..40b4f56a9 --- /dev/null +++ b/Tests/RuntimePath/foo2.c @@ -0,0 +1 @@ +int foo2() { return 0; } diff --git a/Tests/RuntimePath/main.c b/Tests/RuntimePath/main.c new file mode 100644 index 000000000..c71ee0639 --- /dev/null +++ b/Tests/RuntimePath/main.c @@ -0,0 +1,5 @@ +extern int bar1(); +int main() +{ + return bar1(); +} diff --git a/Tests/SBCS/CMakeLists.txt b/Tests/SBCS/CMakeLists.txt new file mode 100644 index 000000000..b3c3c2cfc --- /dev/null +++ b/Tests/SBCS/CMakeLists.txt @@ -0,0 +1,6 @@ +# a SBCS test case +project (SBCS) + +add_definitions(-D_SBCS) + +add_executable (SBCS SBCS.cxx) diff --git a/Tests/SBCS/SBCS.cxx b/Tests/SBCS/SBCS.cxx new file mode 100644 index 000000000..6ce2c9f25 --- /dev/null +++ b/Tests/SBCS/SBCS.cxx @@ -0,0 +1,22 @@ +// Test to verify that _SBCS being defined causes CharacterSet to be set to 0 (Single Byte Character Set) + +int main () +{ +#ifdef _UNICODE + bool UnicodeSet=true; +#else + bool UnicodeSet=false; +#endif + +#ifdef _MBCS + bool MBCSSet=true; +#else + bool MBCSSet=false; +#endif + + // if neither _UNICODE nor _MBCS is set, CharacterSet must be set to SBCS. + bool SBCSSet=(!UnicodeSet && !MBCSSet); + + // Reverse boolean to indicate error case correctly + return !SBCSSet; +} diff --git a/Tests/SameName/CMakeLists.txt b/Tests/SameName/CMakeLists.txt new file mode 100644 index 000000000..a4b993cfd --- /dev/null +++ b/Tests/SameName/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(SameName C) + +ADD_SUBDIRECTORY(Lib1) + +INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/Lib1) +ADD_SUBDIRECTORY(Exe1) diff --git a/Tests/SameName/Exe1/CMakeLists.txt b/Tests/SameName/Exe1/CMakeLists.txt new file mode 100644 index 000000000..3917a2f6b --- /dev/null +++ b/Tests/SameName/Exe1/CMakeLists.txt @@ -0,0 +1,11 @@ +# a target with the same name as a target in a different dir +ADD_EXECUTABLE(mytest_exe conly.c) +SET_TARGET_PROPERTIES(mytest_exe PROPERTIES OUTPUT_NAME mytest) +TARGET_LINK_LIBRARIES(mytest_exe mytest) + +# and two targets in the same dir with the same name +ADD_LIBRARY(mytest2 ../Lib1/libc1.c) + +ADD_EXECUTABLE(mytest2_exe conly.c) +SET_TARGET_PROPERTIES(mytest2_exe PROPERTIES OUTPUT_NAME mytest2) +TARGET_LINK_LIBRARIES(mytest2_exe mytest2) diff --git a/Tests/SameName/Exe1/conly.c b/Tests/SameName/Exe1/conly.c new file mode 100644 index 000000000..eb62c301a --- /dev/null +++ b/Tests/SameName/Exe1/conly.c @@ -0,0 +1,12 @@ +#include "libc1.h" +#include <stdio.h> + +int main () +{ + if ( LibC1Func() != 2.0 ) + { + printf("Problem with libc1\n"); + return 1; + } + return 0; +} diff --git a/Tests/SameName/Lib1/CMakeLists.txt b/Tests/SameName/Lib1/CMakeLists.txt new file mode 100644 index 000000000..67e7f6843 --- /dev/null +++ b/Tests/SameName/Lib1/CMakeLists.txt @@ -0,0 +1 @@ +ADD_LIBRARY(mytest libc1.c) diff --git a/Tests/SameName/Lib1/libc1.c b/Tests/SameName/Lib1/libc1.c new file mode 100644 index 000000000..b01e1e1b5 --- /dev/null +++ b/Tests/SameName/Lib1/libc1.c @@ -0,0 +1,4 @@ +float LibC1Func() +{ + return 2.0; +} diff --git a/Tests/SameName/Lib1/libc1.h b/Tests/SameName/Lib1/libc1.h new file mode 100644 index 000000000..84c94a9cb --- /dev/null +++ b/Tests/SameName/Lib1/libc1.h @@ -0,0 +1 @@ +extern float LibC1Func(); diff --git a/Tests/SetLang/CMakeLists.txt b/Tests/SetLang/CMakeLists.txt new file mode 100644 index 000000000..ab6570c33 --- /dev/null +++ b/Tests/SetLang/CMakeLists.txt @@ -0,0 +1,10 @@ +# test forcing a source file language to c++ from c +cmake_minimum_required (VERSION 2.6) +project(SetLang) +# force this to be verbose so I can debug a dashboard entry +SET(CMAKE_VERBOSE_MAKEFILE 1) +add_library(foo foo.c) +add_executable(SetLang bar.c) +set_source_files_properties(foo.c bar.c PROPERTIES LANGUAGE CXX) +target_link_libraries(SetLang foo) +set_target_properties(SetLang PROPERTIES LINKER_LANGUAGE CXX) diff --git a/Tests/SetLang/bar.c b/Tests/SetLang/bar.c new file mode 100644 index 000000000..f59c318b1 --- /dev/null +++ b/Tests/SetLang/bar.c @@ -0,0 +1,21 @@ +#include <stdio.h> + +int foo(); +class A +{ +public: + A() {this->i = foo();} + int i; +}; + +int main() +{ + A a; + if(a.i == 21) + { + printf("passed foo is 21\n"); + return 0; + } + printf("Failed foo is not 21\n"); + return -1; +} diff --git a/Tests/SetLang/foo.c b/Tests/SetLang/foo.c new file mode 100644 index 000000000..e7918af58 --- /dev/null +++ b/Tests/SetLang/foo.c @@ -0,0 +1,7 @@ +int foo() +{ + int r = 10; + r++; + int ret = r+10; + return ret; +} diff --git a/Tests/Simple/CMakeLists.txt b/Tests/Simple/CMakeLists.txt new file mode 100644 index 000000000..dc965a733 --- /dev/null +++ b/Tests/Simple/CMakeLists.txt @@ -0,0 +1,17 @@ +# a simple test case +project (Simple) + +add_executable (Simple simple.cxx) + +add_library (simpleLib STATIC + simpleLib.cxx + simpleCLib.c + simpleWe.cpp + ) + +target_link_libraries (Simple simpleLib) + +# make sure optimized libs are not used by debug builds +if(CMAKE_BUILD_TYPE MATCHES Debug) + target_link_libraries(Simple optimized c:/not/here.lib ) +endif(CMAKE_BUILD_TYPE MATCHES Debug) diff --git a/Tests/Simple/simple.cxx b/Tests/Simple/simple.cxx new file mode 100644 index 000000000..7bee7c074 --- /dev/null +++ b/Tests/Simple/simple.cxx @@ -0,0 +1,11 @@ +extern void simpleLib(); +extern "C" int FooBar(); +extern int bar(); +extern int bar1(); +int main () +{ + FooBar(); + bar(); + simpleLib(); + return 0; +} diff --git a/Tests/Simple/simpleCLib.c b/Tests/Simple/simpleCLib.c new file mode 100644 index 000000000..88fc33efc --- /dev/null +++ b/Tests/Simple/simpleCLib.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +int FooBar() +{ + int class; + int private = 10; + for ( class = 0; class < private; class ++ ) + { + printf("Count: %d/%d\n", class, private); + } + return 0; +} diff --git a/Tests/Simple/simpleLib.cxx b/Tests/Simple/simpleLib.cxx new file mode 100644 index 000000000..281d8885a --- /dev/null +++ b/Tests/Simple/simpleLib.cxx @@ -0,0 +1,3 @@ +void simpleLib() +{ +} diff --git a/Tests/Simple/simpleWe.cpp b/Tests/Simple/simpleWe.cpp new file mode 100644 index 000000000..859e07c06 --- /dev/null +++ b/Tests/Simple/simpleWe.cpp @@ -0,0 +1,17 @@ +#include <stdio.h> + +class Foo +{ +public: + Foo() + { + printf("This one has nonstandard extension\n"); + } + int getnum() { return 0; } +}; + +int bar() +{ + Foo f; + return f.getnum(); +} diff --git a/Tests/SimpleCOnly/CMakeLists.txt b/Tests/SimpleCOnly/CMakeLists.txt new file mode 100644 index 000000000..d0ed651b1 --- /dev/null +++ b/Tests/SimpleCOnly/CMakeLists.txt @@ -0,0 +1,17 @@ +# this enables only C, i.e. disables C++ +project(SimpleCOnly C) + +add_library(SimpleCLib STATIC bar.c foo.c) + +add_executable(SimpleC main.c) +target_link_libraries(SimpleC SimpleCLib) + +# and some check, just to make sure it works: +include(CheckTypeSize) +check_type_size(float SIZE_FLOAT) +message(STATUS "sizeof(float): ${SIZE_FLOAT}") + +# make sure optimized libs are not used by debug builds +if(CMAKE_BUILD_TYPE MATCHES Debug) + target_link_libraries(Simple optimized c:/not/here.lib ) +endif(CMAKE_BUILD_TYPE MATCHES Debug) diff --git a/Tests/SimpleCOnly/bar.c b/Tests/SimpleCOnly/bar.c new file mode 100644 index 000000000..5d8eac09f --- /dev/null +++ b/Tests/SimpleCOnly/bar.c @@ -0,0 +1 @@ +int bar() {return 5;} diff --git a/Tests/SimpleCOnly/foo.c b/Tests/SimpleCOnly/foo.c new file mode 100644 index 000000000..b8cdea427 --- /dev/null +++ b/Tests/SimpleCOnly/foo.c @@ -0,0 +1 @@ +int foo() { return 12;} diff --git a/Tests/SimpleCOnly/main.c b/Tests/SimpleCOnly/main.c new file mode 100644 index 000000000..e4df685cb --- /dev/null +++ b/Tests/SimpleCOnly/main.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +extern int foo(); +extern int bar(); + +int main() +{ + int i=foo(); + int k=bar(); + i=i*k; + return i; +} diff --git a/Tests/SimpleExclude/CMakeLists.txt b/Tests/SimpleExclude/CMakeLists.txt new file mode 100644 index 000000000..baca23e39 --- /dev/null +++ b/Tests/SimpleExclude/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 2.6) +project(SimpleExclude C) + +set(EXECUTABLE_OUTPUT_PATH "${SimpleExclude_BINARY_DIR}" CACHE INTERNAL "" FORCE) +set(LIBRARY_OUTPUT_PATH "${SimpleExclude_BINARY_DIR}" CACHE INTERNAL "" FORCE) + +add_subdirectory(dirC EXCLUDE_FROM_ALL) +add_subdirectory(dirD) + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/run.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/run.cmake" @ONLY) diff --git a/Tests/SimpleExclude/dirC/CMakeLists.txt b/Tests/SimpleExclude/dirC/CMakeLists.txt new file mode 100644 index 000000000..9b59fdaff --- /dev/null +++ b/Tests/SimpleExclude/dirC/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(dirA EXCLUDE_FROM_ALL) +add_subdirectory(dirB) + diff --git a/Tests/SimpleExclude/dirC/dirA/CMakeLists.txt b/Tests/SimpleExclude/dirC/dirA/CMakeLists.txt new file mode 100644 index 000000000..52fac8183 --- /dev/null +++ b/Tests/SimpleExclude/dirC/dirA/CMakeLists.txt @@ -0,0 +1,10 @@ +add_library(t1 STATIC t1.c) + +add_library(t2 STATIC t2.c) + +add_executable(t3 t3.c) + +add_executable(t4 t4.c) + +add_executable(t5 t5.c) +target_link_libraries(t5 t1) diff --git a/Tests/SimpleExclude/dirC/dirA/t1.c b/Tests/SimpleExclude/dirC/dirA/t1.c new file mode 100644 index 000000000..67fe06fee --- /dev/null +++ b/Tests/SimpleExclude/dirC/dirA/t1.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int tlib1func() +{ + Should not be build unless target directory A, B, or C are build; + printf("This is T1\n"); + return 5; +} diff --git a/Tests/SimpleExclude/dirC/dirA/t2.c b/Tests/SimpleExclude/dirC/dirA/t2.c new file mode 100644 index 000000000..6aaf40675 --- /dev/null +++ b/Tests/SimpleExclude/dirC/dirA/t2.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int tlib2func() +{ + printf("This is T2\n"); + return 2; +} diff --git a/Tests/SimpleExclude/dirC/dirA/t3.c b/Tests/SimpleExclude/dirC/dirA/t3.c new file mode 100644 index 000000000..1366dc0a6 --- /dev/null +++ b/Tests/SimpleExclude/dirC/dirA/t3.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char* argv[]) +{ + Should not be build unless target directory A, B, or C are build; + return 0; +} diff --git a/Tests/SimpleExclude/dirC/dirA/t4.c b/Tests/SimpleExclude/dirC/dirA/t4.c new file mode 100644 index 000000000..7c36ca927 --- /dev/null +++ b/Tests/SimpleExclude/dirC/dirA/t4.c @@ -0,0 +1,17 @@ +#include <stdio.h> + +#ifdef __CLASSIC_C__ +int main() +{ + int ac; + char*av[]; +#else + int main(int ac, char*av[]) + { +#endif + if(ac > 1000){return *av[0];} + printf("This is T4. This one should work.\n"); + return 0; + } + + diff --git a/Tests/SimpleExclude/dirC/dirA/t5.c b/Tests/SimpleExclude/dirC/dirA/t5.c new file mode 100644 index 000000000..1fba2127c --- /dev/null +++ b/Tests/SimpleExclude/dirC/dirA/t5.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char* argv[]) +{ + Should not be build unless target directory A, B, or C are build; + return 5; +} diff --git a/Tests/SimpleExclude/dirC/dirB/CMakeLists.txt b/Tests/SimpleExclude/dirC/dirB/CMakeLists.txt new file mode 100644 index 000000000..ea4650c4a --- /dev/null +++ b/Tests/SimpleExclude/dirC/dirB/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library(t6 STATIC t6.c) + +add_library(t7 STATIC t7.c) +target_link_libraries(t7 t2) + diff --git a/Tests/SimpleExclude/dirC/dirB/t6.c b/Tests/SimpleExclude/dirC/dirB/t6.c new file mode 100644 index 000000000..e8877df60 --- /dev/null +++ b/Tests/SimpleExclude/dirC/dirB/t6.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int tlib6func() +{ + Should not be build unless target directory B, or C are build; + printf("This is T6\n"); + return 6; +} diff --git a/Tests/SimpleExclude/dirC/dirB/t7.c b/Tests/SimpleExclude/dirC/dirB/t7.c new file mode 100644 index 000000000..b95d3ec43 --- /dev/null +++ b/Tests/SimpleExclude/dirC/dirB/t7.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +extern int tlib2func(); + +int tlib7func() +{ + printf("This is T7\n"); + + if ( tlib2func() != 2 ) + { + fprintf(stderr, "Something wrong with T2\n"); + return 1; + } + + return 7; +} diff --git a/Tests/SimpleExclude/dirD/CMakeLists.txt b/Tests/SimpleExclude/dirD/CMakeLists.txt new file mode 100644 index 000000000..44b8c27b6 --- /dev/null +++ b/Tests/SimpleExclude/dirD/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(t8 STATIC t8.c) + +add_executable(t9 t9.c) +target_link_libraries(t9 t7) + +add_custom_target(t4_custom ALL) +add_dependencies(t4_custom t4) diff --git a/Tests/SimpleExclude/dirD/t8.c b/Tests/SimpleExclude/dirD/t8.c new file mode 100644 index 000000000..bddec6f7e --- /dev/null +++ b/Tests/SimpleExclude/dirD/t8.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int tlib8func() +{ + printf("This is T8\n"); + return 8; +} diff --git a/Tests/SimpleExclude/dirD/t9.c b/Tests/SimpleExclude/dirD/t9.c new file mode 100644 index 000000000..321014b17 --- /dev/null +++ b/Tests/SimpleExclude/dirD/t9.c @@ -0,0 +1,24 @@ +#include <stdio.h> + +extern int tlib7func(); + +#ifdef __CLASSIC_C__ +int main() +{ + int ac; + char*av[]; +#else + int main(int ac, char*av[]) + { +#endif + if(ac > 1000){return *av[0];} + printf("This is T9. This one should work.\n"); + + if ( tlib7func() != 7 ) + { + fprintf(stderr, "Something wrong with T7\n"); + return 1; + } + return 0; + } + diff --git a/Tests/SimpleExclude/run.cmake.in b/Tests/SimpleExclude/run.cmake.in new file mode 100644 index 000000000..8f83380c8 --- /dev/null +++ b/Tests/SimpleExclude/run.cmake.in @@ -0,0 +1,13 @@ +set(t4_name "\"@CMAKE_CURRENT_BINARY_DIR@${CFG_DIR}/t4\"") +exec_program("${t4_name}" RETURN_VALUE "t4_var") +message("T4 ${t4_name} resulted ${t4_var}") + +set(t9_name "\"@CMAKE_CURRENT_BINARY_DIR@${CFG_DIR}/t9\"") +exec_program("${t9_name}" RETURN_VALUE "t9_var") +message("T9 ${t9_name} resulted ${t9_var}") + +if ( "${t4_var}" EQUAL "0" AND "${t9_var}" EQUAL "0" ) + message("Everything is good, Yoshimi won...") +else ( "${t4_var}" EQUAL "0" AND "${t9_var}" EQUAL "0" ) + message(FATAL_ERROR "Yoshimi lost... The evil pink robots will take over the world") +endif ( "${t4_var}" EQUAL "0" AND "${t9_var}" EQUAL "0" ) diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt new file mode 100644 index 000000000..378b5292b --- /dev/null +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -0,0 +1,398 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT (TestSimpleInstall) +SET(CMAKE_VERBOSE_MAKEFILE 1) +SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY + "${TestSimpleInstall_BINARY_DIR}/bin") +SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY + "${TestSimpleInstall_BINARY_DIR}/lib/static") +SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY + "${TestSimpleInstall_BINARY_DIR}/lib") + +# Skip generating the rpath pointing at the build tree to make sure +# the executable is installed with the proper rpath in the install +# tree. +SET(CMAKE_SKIP_BUILD_RPATH 1) + +# Make sure the executable can run from the install tree. +SET(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/MyTest/lib) + +# Skip the dependency that causes a build when installing. This +# avoids infinite loops when the post-build rule below installs. +SET(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1) +SET(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY 1) + +SET(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") + +SET(EXTRA_INSTALL_FLAGS) +MESSAGE("Extra install: ${EXTRA_INSTALL_FLAGS}") + +IF(STAGE2) + SET(LIBPATHS + ${CMAKE_INSTALL_PREFIX}/MyTest/lib/static + ${CMAKE_INSTALL_PREFIX}/MyTest/lib + ) + SET(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX} test1rel) + SET(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX}) + SET(t4NAMES test4out test4out${CMAKE_DEBUG_POSTFIX}) + + # Make sure the install script ran. + SET(CMAKE_INSTALL_SCRIPT_DID_RUN 0) + INCLUDE(${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake OPTIONAL) + IF(CMAKE_INSTALL_SCRIPT_DID_RUN) + MESSAGE(STATUS "Stage 1 did run install script 2.") + ELSE(CMAKE_INSTALL_SCRIPT_DID_RUN) + MESSAGE(SEND_ERROR "Stage 1 did not run install script 2.") + ENDIF(CMAKE_INSTALL_SCRIPT_DID_RUN) + + IF(CYGWIN OR MINGW) + SET(LIBPATHS ${LIBPATHS} "${CMAKE_INSTALL_PREFIX}/MyTest/bin") + ENDIF(CYGWIN OR MINGW) + MESSAGE("Search for library in: ${LIBPATHS}") + + SET(TEST1_LIBRARY "TEST1_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE) + SET(TEST2_LIBRARY "TEST2_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE) + SET(TEST4_LIBRARY "TEST4_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE) + + FIND_LIBRARY(TEST1_LIBRARY + NAMES ${t1NAMES} + PATHS ${LIBPATHS} + DOC "First library") + FIND_LIBRARY(TEST2_LIBRARY + NAMES ${t2NAMES} + PATHS ${LIBPATHS} + DOC "Second library") + FIND_LIBRARY(TEST4_LIBRARY + NAMES ${t4NAMES} + PATHS ${LIBPATHS} + DOC "Fourth library") + + # Test importing a library found on disk. + ADD_LIBRARY(lib_test4 UNKNOWN IMPORTED) + SET_PROPERTY(TARGET lib_test4 PROPERTY IMPORTED_LOCATION ${TEST4_LIBRARY}) + + INCLUDE_DIRECTORIES(${CMAKE_INSTALL_PREFIX}/MyTest/include) + ADD_EXECUTABLE (SimpleInstExeS2 inst2.cxx foo.c foo.h) + TARGET_LINK_LIBRARIES(SimpleInstExeS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} lib_test4) + SET(install_target SimpleInstExeS2) + + IF("${TEST1_LIBRARY}" MATCHES "static") + MESSAGE(STATUS "test1 correctly found in lib/static") + ELSE("${TEST1_LIBRARY}" MATCHES "static") + MESSAGE(SEND_ERROR "test1 not found in lib/static!") + ENDIF("${TEST1_LIBRARY}" MATCHES "static") + + # Check for failure of configuration-specific installation. + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Release/lib1debug.h") + MESSAGE(FATAL_ERROR "Debug-configuration file installed for Release!") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Release/lib1debug.h") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h") + MESSAGE(FATAL_ERROR "Release-configuration file installed for Debug!") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h") + + # Check for failure of directory installation. + IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/TSD.h") + MESSAGE(FATAL_ERROR "Directory installation did not install TSD.h") + ENDIF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/TSD.h") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") + MESSAGE(FATAL_ERROR "Directory installation installed CVS directory.") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") + MESSAGE(FATAL_ERROR "Directory installation installed CVS directory.") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CMakeLists.txt") + MESSAGE(FATAL_ERROR "Directory installation installed CMakeLists.txt.") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CMakeLists.txt") + IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.h") + MESSAGE(FATAL_ERROR "Directory installation did not install alternate TSD.h") + ENDIF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.h") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.cxx") + MESSAGE(FATAL_ERROR "Directory installation installed alternate TSD.cxx") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.cxx") + + # Check that scripts properly installed. + IF(WIN32 AND NOT CYGWIN) + SET(BAT .bat) + ELSE(WIN32 AND NOT CYGWIN) + SET(BAT) + ENDIF(WIN32 AND NOT CYGWIN) + FOREACH(loc share share/old1 share/old2 share/old3 share/alt) + SET(CUR_SCRIPT "${CMAKE_INSTALL_PREFIX}/MyTest/${loc}/sample_script${BAT}") + EXECUTE_PROCESS( + COMMAND ${CUR_SCRIPT} + RESULT_VARIABLE SAMPLE_SCRIPT_RESULT + OUTPUT_VARIABLE SAMPLE_SCRIPT_OUTPUT + ) + IF(NOT "${SAMPLE_SCRIPT_RESULT}" MATCHES "^0$") + MESSAGE(FATAL_ERROR + "Sample script [${CUR_SCRIPT}] failed: [${SAMPLE_SCRIPT_RESULT}]") + ENDIF(NOT "${SAMPLE_SCRIPT_RESULT}" MATCHES "^0$") + IF(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output") + MESSAGE(FATAL_ERROR + "Bad sample script [${CUR_SCRIPT}] output: [${SAMPLE_SCRIPT_OUTPUT}]") + ENDIF(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output") + ENDFOREACH(loc) + + # Check for failure of empty directory installation. + IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty") + MESSAGE(FATAL_ERROR "Empty directory installation did not install.") + ENDIF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty") + FILE(GLOB EMPTY_FILES "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty/*") + IF(EMPTY_FILES) + MESSAGE(FATAL_ERROR "Empty directory installed [${EMPTY_FILES}].") + ENDIF(EMPTY_FILES) + + # Make sure the test executable can run from the install tree. + SET_TARGET_PROPERTIES(SimpleInstExeS2 PROPERTIES + INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) + + INSTALL_TARGETS(/MyTest/bin SimpleInstExeS2) + +# try to import the exported targets again + SET(SimpleInstallS1_DIR ${CMAKE_INSTALL_PREFIX}/MyTest/lib) + FIND_PACKAGE(SimpleInstallS1 REQUIRED) + GET_TARGET_PROPERTY(simpleInstallImported S1_SimpleInstall IMPORTED) + IF(NOT simpleInstallImported) + MESSAGE(FATAL_ERROR "Target S1_SimpleInstall could not be imported") + ENDIF(NOT simpleInstallImported) + +ELSE(STAGE2) + # Wipe out the install directory to do a fresh test. + FILE(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/MyTest) + + # this is stage 1, so create libraries and modules and install everything + ADD_LIBRARY(test1 STATIC lib1.cxx) + ADD_LIBRARY(test2 SHARED lib2.cxx) + ADD_LIBRARY(test3 MODULE lib3.cxx) + ADD_LIBRARY(test4 SHARED lib4.cxx) + + # Test <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME properties. + SET_PROPERTY(TARGET test4 PROPERTY ARCHIVE_OUTPUT_NAME test4out) + SET_PROPERTY(TARGET test4 PROPERTY LIBRARY_OUTPUT_NAME test4out) + + ADD_EXECUTABLE (SimpleInstall inst.cxx foo.c foo.h) + TARGET_LINK_LIBRARIES(SimpleInstall test1 test2 test4) + SET(install_target SimpleInstall) + + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) + # Disable VERSION test until it is implemented in the Xcode generator. + IF(NOT XCODE) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) + ENDIF(NOT XCODE) + + # Make sure the test executable can run from the install tree. + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES + INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) + + # Test per-configuration output name. + SET_TARGET_PROPERTIES(test1 PROPERTIES RELEASE_OUTPUT_NAME test1rel) + SET_TARGET_PROPERTIES(test2 PROPERTIES PUBLIC_HEADER foo.h) + + IF(CMAKE_GENERATOR MATCHES "Makefiles") + ADD_SUBDIRECTORY(TestSubDir) + ADD_DEPENDENCIES(SimpleInstall TSD) + ENDIF(CMAKE_GENERATOR MATCHES "Makefiles") + + ADD_DEPENDENCIES(SimpleInstall test3) + ADD_DEPENDENCIES(test2 test3) + ADD_DEPENDENCIES(test4 test2) + + INSTALL(TARGETS SimpleInstall test1 test2 test3 EXPORT SimpleInstallS1 + RUNTIME DESTINATION MyTest/bin COMPONENT Runtime # .exe, .dll + LIBRARY DESTINATION MyTest/lib COMPONENT Runtime # .so, mod.dll + ARCHIVE DESTINATION MyTest/lib/static COMPONENT Development # .a, .lib + PUBLIC_HEADER DESTINATION MyTest/include COMPONENT Development + ) + + INSTALL(TARGETS test4 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + RUNTIME DESTINATION MyTest/bin + LIBRARY DESTINATION MyTest/lib + ARCHIVE DESTINATION MyTest/lib/static + OPTIONAL # for coverage...target should always exist + ) + INSTALL(FILES lib1.h DESTINATION MyTest/include/foo) + INSTALL(FILES lib2.h + DESTINATION MyTest/include/foo + COMPONENT Development + PERMISSIONS OWNER_READ OWNER_WRITE + RENAME lib2renamed.h + ) + + # Test old-style install commands. + INSTALL_FILES(/MyTest/include FILES lib3.h) + INSTALL_FILES(/MyTest/include/old .h lib3) + INSTALL_FILES(/MyTest/include/old "^lib2.h$") + INSTALL_PROGRAMS(/MyTest/share/old1 FILES + scripts/sample_script scripts/sample_script.bat) + INSTALL_PROGRAMS(/MyTest/share/old2 + scripts/sample_script scripts/sample_script.bat) + +# "export" the targets collected in "SimpleInstallS1" + INSTALL(EXPORT SimpleInstallS1 FILE SimpleInstallS1Config.cmake + DESTINATION MyTest/lib + NAMESPACE S1_ ) + + EXPORT(TARGETS SimpleInstall test1 test2 test3 + FILE "${CMAKE_CURRENT_BINARY_DIR}/SimpleInstallS1Config.cmake" + NAMESPACE S2_ ) + + ADD_SUBDIRECTORY(scripts) + + # Test optional installation. + INSTALL(FILES does_not_exist.h DESTINATION MyTest/include/foo OPTIONAL) + + # Test configuration-specific installation. + INSTALL(FILES lib1.h RENAME lib1release.h CONFIGURATIONS Release + DESTINATION MyTest/include/Release + ) + INSTALL(FILES lib1.h RENAME lib1debug.h CONFIGURATIONS Debug + DESTINATION MyTest/include/Debug + ) + + # Test directory installation. + FILE(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") + FILE(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") + INSTALL( + DIRECTORY TestSubDir scripts/ DESTINATION MyTest/share + FILE_PERMISSIONS OWNER_READ OWNER_WRITE + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + PATTERN "CVS" EXCLUDE + REGEX "\\.txt$" EXCLUDE + PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + ) + + # Alternate directory installation for coverage. + INSTALL( + DIRECTORY scripts/ DESTINATION MyTest/share/alt + COMPONENT Development + USE_SOURCE_PERMISSIONS + PATTERN "CVS" EXCLUDE + REGEX "\\.txt$" EXCLUDE + ) + INSTALL( + DIRECTORY TestSubDir DESTINATION MyTest/share/alt + FILE_PERMISSIONS OWNER_READ OWNER_WRITE + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + FILES_MATCHING PATTERN "*.h" + ) + + # Test empty directory installation. + INSTALL(DIRECTORY DESTINATION MyTest/share/empty) + + # Test optional directory installation. + INSTALL(DIRECTORY does-not-exist DESTINATION MyTest/share OPTIONAL) + + # Test user-specified install scripts, with and without COMPONENT. + INSTALL( + SCRIPT InstallScript1.cmake + CODE "SET(INSTALL_CODE_DID_RUN 1)" + SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript2.cmake + ) + INSTALL( + SCRIPT InstallScript3.cmake + CODE "SET(INSTALL_CODE_WITH_COMPONENT_DID_RUN 1)" + SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript4.cmake + COMPONENT Development + ) + SET_DIRECTORY_PROPERTIES(PROPERTIES + ADDITIONAL_MAKE_CLEAN_FILES + "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake") + + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT + ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT + ${CMAKE_CURRENT_SOURCE_DIR}/PostInstall.cmake) + SET_TARGET_PROPERTIES(test4 PROPERTIES VERSION 1.2 SOVERSION 3 + INSTALL_NAME_DIR @executable_path/../lib) +ENDIF(STAGE2) + +IF(CMAKE_CONFIGURATION_TYPES) + SET(SI_CONFIG -C ${CMAKE_CFG_INTDIR}) +ELSE(CMAKE_CONFIGURATION_TYPES) + SET(SI_CONFIG) +ENDIF(CMAKE_CONFIGURATION_TYPES) + +# Dummy test of CPack +SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Test of packaging with cpack") +SET(CPACK_PACKAGE_VENDOR "Kitware") +SET(CPACK_INSTALL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/PackageScript.cmake") + +IF(WIN32 AND NOT UNIX) + FIND_PROGRAM(NSIS_MAKENSIS NAMES makensis + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS] + DOC "Where is makensis.exe located" + ) + IF(NOT NSIS_MAKENSIS) + SET(CPACK_GENERATOR TGZ) + ENDIF(NOT NSIS_MAKENSIS) +ENDIF(WIN32 AND NOT UNIX) +IF(UNIX AND NOT APPLE) + SET(CPACK_GENERATOR "TGZ;STGZ;TZ") + # FIND_PROGRAM(found_compress + # NAMES compress) + # IF(found_compress) + # FIND_PROGRAM(file_command NAMES file) + # IF(NOT file_command) + # set(file_command file) + # ENDIF(NOT file_command) + # EXECUTE_PROCESS(COMMAND ${file_command} ${found_compress} + # OUTPUT_VARIABLE output) + # set(SKIP_TZ FALSE) + # if("${output}" MATCHES "script") + # set(SKIP_TZ TRUE) + # endif("${output}" MATCHES "script") + # if("${output}" MATCHES "dummy.sh") + # set(SKIP_TZ TRUE) + # endif("${output}" MATCHES "dummy.sh") + # if(NOT SKIP_TZ) + # message("compress found and it was not a script") + # message("output from file command: [${output}]") + # SET(CPACK_GENERATOR "${CPACK_GENERATOR};TZ") + # else(NOT SKIP_TZ) + # message("compress found, but it was a script so dont use it") + # message("output from file command: [${output}]") + # endif(NOT SKIP_TZ) + # ENDIF(found_compress) + FIND_PROGRAM(found_bz2 + NAMES bzip2) + IF(found_bz2) + SET(CPACK_GENERATOR "${CPACK_GENERATOR};TBZ2") + ENDIF(found_bz2) +ENDIF(UNIX AND NOT APPLE) + +SET(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install") +SET(CMAKE_INSTALL_MFC_LIBRARIES 1) +SET(CMAKE_INSTALL_DEBUG_LIBRARIES 1) +INCLUDE(InstallRequiredSystemLibraries) + +IF(CTEST_TEST_CPACK) + SET(PACKAGE_TARGET --build-target package) + + # Avoid settings that require the .zip file command line tools... + # (just build an NSIS installer without component support) + # + SET(CPACK_BINARY_ZIP OFF) + SET(CPACK_MONOLITHIC_INSTALL ON) +ELSE(CTEST_TEST_CPACK) + SET(PACKAGE_TARGET) +ENDIF(CTEST_TEST_CPACK) + +INCLUDE(CPack) + +ADD_CUSTOM_COMMAND( + TARGET ${install_target} + POST_BUILD + COMMAND ${CMAKE_CTEST_COMMAND} + ARGS ${SI_CONFIG} + --build-and-test + ${CMAKE_SOURCE_DIR} + ${CMAKE_BINARY_DIR} + --build-generator ${CMAKE_GENERATOR} + --build-project ${PROJECT_NAME} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-noclean + --build-target install + ${PACKAGE_TARGET} + COMMENT "Install Project" + ) diff --git a/Tests/SimpleInstall/InstallScript1.cmake b/Tests/SimpleInstall/InstallScript1.cmake new file mode 100644 index 000000000..27b7725f8 --- /dev/null +++ b/Tests/SimpleInstall/InstallScript1.cmake @@ -0,0 +1,5 @@ +MESSAGE("This is install script 1.") +SET(INSTALL_SCRIPT_1_DID_RUN 1) +IF(INSTALL_CODE_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 1 did not run before install code.") +ENDIF(INSTALL_CODE_DID_RUN) diff --git a/Tests/SimpleInstall/InstallScript2.cmake b/Tests/SimpleInstall/InstallScript2.cmake new file mode 100644 index 000000000..927cae8b6 --- /dev/null +++ b/Tests/SimpleInstall/InstallScript2.cmake @@ -0,0 +1,14 @@ +MESSAGE("This is install script 2.") +IF(INSTALL_SCRIPT_1_DID_RUN) + MESSAGE("Install script ordering works.") +ELSE(INSTALL_SCRIPT_1_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 1 did not run before install script 2.") +ENDIF(INSTALL_SCRIPT_1_DID_RUN) +IF(INSTALL_CODE_DID_RUN) + MESSAGE("Install code ordering works.") +ELSE(INSTALL_CODE_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 2 did not run after install code.") +ENDIF(INSTALL_CODE_DID_RUN) +FILE(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake" + "SET(CMAKE_INSTALL_SCRIPT_DID_RUN 1)\n" + ) diff --git a/Tests/SimpleInstall/InstallScript3.cmake b/Tests/SimpleInstall/InstallScript3.cmake new file mode 100644 index 000000000..b1aecd4c2 --- /dev/null +++ b/Tests/SimpleInstall/InstallScript3.cmake @@ -0,0 +1,12 @@ +MESSAGE("This is install script 3.") +SET(INSTALL_SCRIPT_3_DID_RUN 1) +IF(INSTALL_CODE_WITH_COMPONENT_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 3 did not run before install code with component.") +ENDIF(INSTALL_CODE_WITH_COMPONENT_DID_RUN) + +IF(CMAKE_INSTALL_COMPONENT) +IF(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development") + MESSAGE("CMAKE_INSTALL_COMPONENT=\"${CMAKE_INSTALL_COMPONENT}\"") + MESSAGE(FATAL_ERROR "Install script 3 should only run for \"Development\" INSTALL COMPONENT.") +ENDIF(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development") +ENDIF(CMAKE_INSTALL_COMPONENT) diff --git a/Tests/SimpleInstall/InstallScript4.cmake b/Tests/SimpleInstall/InstallScript4.cmake new file mode 100644 index 000000000..0ffea4bc8 --- /dev/null +++ b/Tests/SimpleInstall/InstallScript4.cmake @@ -0,0 +1,22 @@ +MESSAGE("This is install script 4.") +IF(INSTALL_SCRIPT_3_DID_RUN) + MESSAGE("Install script ordering works.") +ELSE(INSTALL_SCRIPT_3_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 3 did not run before install script 4.") +ENDIF(INSTALL_SCRIPT_3_DID_RUN) +IF(INSTALL_CODE_WITH_COMPONENT_DID_RUN) + MESSAGE("Install code ordering works.") +ELSE(INSTALL_CODE_WITH_COMPONENT_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 4 did not run after install with component code.") +ENDIF(INSTALL_CODE_WITH_COMPONENT_DID_RUN) + +IF(CMAKE_INSTALL_COMPONENT) +IF(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development") + MESSAGE("CMAKE_INSTALL_COMPONENT=\"${CMAKE_INSTALL_COMPONENT}\"") + MESSAGE(FATAL_ERROR "Install script 4 should only run for \"Development\" INSTALL COMPONENT.") +ENDIF(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development") +ENDIF(CMAKE_INSTALL_COMPONENT) + +FILE(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScript4Out.cmake" + "SET(CMAKE_INSTALL_SCRIPT_4_DID_RUN 1)\n" + ) diff --git a/Tests/SimpleInstall/PackageScript.cmake b/Tests/SimpleInstall/PackageScript.cmake new file mode 100644 index 000000000..3567a2f43 --- /dev/null +++ b/Tests/SimpleInstall/PackageScript.cmake @@ -0,0 +1,10 @@ +MESSAGE("This is packaging script") +MESSAGE("It writes a file with all variables available in ${CMAKE_INSTALL_PREFIX}/AllVariables.txt") + +FILE(WRITE ${CMAKE_INSTALL_PREFIX}/AllVariables.txt "") +GET_CMAKE_PROPERTY(res VARIABLES) +FOREACH(var ${res}) + FILE(APPEND ${CMAKE_INSTALL_PREFIX}/AllVariables.txt + "${var} \"${${var}}\"\n") +ENDFOREACH(var ${res}) + diff --git a/Tests/SimpleInstall/PostInstall.cmake b/Tests/SimpleInstall/PostInstall.cmake new file mode 100644 index 000000000..52ea140a5 --- /dev/null +++ b/Tests/SimpleInstall/PostInstall.cmake @@ -0,0 +1,6 @@ +MESSAGE("In post install") +IF(PRE_INSTALL_DID_RUN) + MESSAGE("Pre and post install work fine") +ELSE(PRE_INSTALL_DID_RUN) + MESSAGE(FATAL_ERROR "Pre install did not run before post install") +ENDIF(PRE_INSTALL_DID_RUN) diff --git a/Tests/SimpleInstall/PreInstall.cmake b/Tests/SimpleInstall/PreInstall.cmake new file mode 100644 index 000000000..2ea2f7716 --- /dev/null +++ b/Tests/SimpleInstall/PreInstall.cmake @@ -0,0 +1,2 @@ +MESSAGE("This is in pre install") +SET(PRE_INSTALL_DID_RUN 1) diff --git a/Tests/SimpleInstall/TestSubDir/CMakeLists.txt b/Tests/SimpleInstall/TestSubDir/CMakeLists.txt new file mode 100644 index 000000000..4f6295300 --- /dev/null +++ b/Tests/SimpleInstall/TestSubDir/CMakeLists.txt @@ -0,0 +1,3 @@ +ADD_EXECUTABLE(TSD TSD.cxx TSD_utils.cxx) +INSTALL_FILES(/MyTest/include FILES TSD.h) +INSTALL_TARGETS(/MyTest/bin TSD) diff --git a/Tests/SimpleInstall/TestSubDir/TSD.cxx b/Tests/SimpleInstall/TestSubDir/TSD.cxx new file mode 100644 index 000000000..8fc38787a --- /dev/null +++ b/Tests/SimpleInstall/TestSubDir/TSD.cxx @@ -0,0 +1,10 @@ +#include <stdio.h> + +#include "TSD.h" + +int main() +{ + int res = TSD("TEST"); + printf("Hello from TSD\n"); + return res; +} diff --git a/Tests/SimpleInstall/TestSubDir/TSD.h b/Tests/SimpleInstall/TestSubDir/TSD.h new file mode 100644 index 000000000..6a3c1affa --- /dev/null +++ b/Tests/SimpleInstall/TestSubDir/TSD.h @@ -0,0 +1 @@ +int TSD(const char*); diff --git a/Tests/SimpleInstall/TestSubDir/TSD_utils.cxx b/Tests/SimpleInstall/TestSubDir/TSD_utils.cxx new file mode 100644 index 000000000..0277f05ae --- /dev/null +++ b/Tests/SimpleInstall/TestSubDir/TSD_utils.cxx @@ -0,0 +1,10 @@ +#include <string.h> + +int TSD(const char* foo) +{ + if ( strcmp(foo, "TEST") == 0 ) + { + return 0; + } + return 1; +} diff --git a/Tests/SimpleInstall/foo.c b/Tests/SimpleInstall/foo.c new file mode 100644 index 000000000..45d5b2bf2 --- /dev/null +++ b/Tests/SimpleInstall/foo.c @@ -0,0 +1,6 @@ +char* foo = "Foo"; + +int SomeFunctionInFoo() +{ + return 5; +} diff --git a/Tests/SimpleInstall/foo.h b/Tests/SimpleInstall/foo.h new file mode 100644 index 000000000..2708baffe --- /dev/null +++ b/Tests/SimpleInstall/foo.h @@ -0,0 +1,11 @@ +#ifdef __cplusplus +extern "C" { +#endif + +extern char* foo; +extern int SomeFunctionInFoo(); + +#ifdef __cplusplus +} +#endif + diff --git a/Tests/SimpleInstall/inst.cxx b/Tests/SimpleInstall/inst.cxx new file mode 100644 index 000000000..7f2962d00 --- /dev/null +++ b/Tests/SimpleInstall/inst.cxx @@ -0,0 +1,37 @@ +#include "foo.h" + +#ifdef STAGE_2 +# include <foo/lib1.h> +# include <foo/lib2renamed.h> +# include <lib3.h> +# include <old/lib2.h> +# include <old/lib3.h> +#else +# include "lib1.h" +# include "lib2.h" +#endif + +#include "lib4.h" + +#include <stdio.h> + +int main () +{ + if ( Lib1Func() != 2.0 ) + { + printf("Problem with lib1\n"); + return 1; + } + if ( Lib2Func() != 1.0 ) + { + printf("Problem with lib2\n"); + return 1; + } + if ( Lib4Func() != 4.0 ) + { + printf("Problem with lib4\n"); + return 1; + } + printf("The value of Foo: %s\n", foo); + return SomeFunctionInFoo()-5; +} diff --git a/Tests/SimpleInstall/inst2.cxx b/Tests/SimpleInstall/inst2.cxx new file mode 100644 index 000000000..c70b93af1 --- /dev/null +++ b/Tests/SimpleInstall/inst2.cxx @@ -0,0 +1,2 @@ +#define STAGE_2 +#include "inst.cxx" diff --git a/Tests/SimpleInstall/lib1.cxx b/Tests/SimpleInstall/lib1.cxx new file mode 100644 index 000000000..7aa905205 --- /dev/null +++ b/Tests/SimpleInstall/lib1.cxx @@ -0,0 +1,6 @@ +#include "lib1.h" + +float Lib1Func() +{ + return 2.0; +} diff --git a/Tests/SimpleInstall/lib1.h b/Tests/SimpleInstall/lib1.h new file mode 100644 index 000000000..0d64e76bc --- /dev/null +++ b/Tests/SimpleInstall/lib1.h @@ -0,0 +1 @@ +extern float Lib1Func(); diff --git a/Tests/SimpleInstall/lib2.cxx b/Tests/SimpleInstall/lib2.cxx new file mode 100644 index 000000000..dccc48b78 --- /dev/null +++ b/Tests/SimpleInstall/lib2.cxx @@ -0,0 +1,6 @@ +#include "lib2.h" + +float Lib2Func() +{ + return 1.0; +} diff --git a/Tests/SimpleInstall/lib2.h b/Tests/SimpleInstall/lib2.h new file mode 100644 index 000000000..ea5a6f7ea --- /dev/null +++ b/Tests/SimpleInstall/lib2.h @@ -0,0 +1,11 @@ +#ifdef _WIN32 +# ifdef test2_EXPORTS +# define CM_TEST_LIB_EXPORT __declspec( dllexport ) +# else +# define CM_TEST_LIB_EXPORT __declspec( dllimport ) +# endif +#else +# define CM_TEST_LIB_EXPORT +#endif + +CM_TEST_LIB_EXPORT float Lib2Func(); diff --git a/Tests/SimpleInstall/lib3.cxx b/Tests/SimpleInstall/lib3.cxx new file mode 100644 index 000000000..da8dbf942 --- /dev/null +++ b/Tests/SimpleInstall/lib3.cxx @@ -0,0 +1,6 @@ +#include "lib3.h" + +float Lib3Func() +{ + return 2.0; +} diff --git a/Tests/SimpleInstall/lib3.h b/Tests/SimpleInstall/lib3.h new file mode 100644 index 000000000..c250ed769 --- /dev/null +++ b/Tests/SimpleInstall/lib3.h @@ -0,0 +1,11 @@ +#ifdef _WIN32 +# ifdef test3_EXPORTS +# define CM_TEST_LIB_EXPORT __declspec( dllexport ) +# else +# define CM_TEST_LIB_EXPORT __declspec( dllimport ) +# endif +#else +# define CM_TEST_LIB_EXPORT +#endif + +CM_TEST_LIB_EXPORT float Lib3Func(); diff --git a/Tests/SimpleInstall/lib4.cxx b/Tests/SimpleInstall/lib4.cxx new file mode 100644 index 000000000..fbfa23aa4 --- /dev/null +++ b/Tests/SimpleInstall/lib4.cxx @@ -0,0 +1,7 @@ +#include "lib4.h" + +float Lib4Func() +{ + return 4.0; +} + diff --git a/Tests/SimpleInstall/lib4.h b/Tests/SimpleInstall/lib4.h new file mode 100644 index 000000000..4b94ea207 --- /dev/null +++ b/Tests/SimpleInstall/lib4.h @@ -0,0 +1,12 @@ +#ifdef _WIN32 +# ifdef test4_EXPORTS +# define CM_TEST_LIB_EXPORT __declspec( dllexport ) +# else +# define CM_TEST_LIB_EXPORT __declspec( dllimport ) +# endif +#else +# define CM_TEST_LIB_EXPORT +#endif + +CM_TEST_LIB_EXPORT float Lib4Func(); + diff --git a/Tests/SimpleInstall/scripts/.gitattributes b/Tests/SimpleInstall/scripts/.gitattributes new file mode 100644 index 000000000..5e3db2fb3 --- /dev/null +++ b/Tests/SimpleInstall/scripts/.gitattributes @@ -0,0 +1 @@ +sample_script crlf=input diff --git a/Tests/SimpleInstall/scripts/CMakeLists.txt b/Tests/SimpleInstall/scripts/CMakeLists.txt new file mode 100644 index 000000000..d46c1652e --- /dev/null +++ b/Tests/SimpleInstall/scripts/CMakeLists.txt @@ -0,0 +1 @@ +INSTALL_PROGRAMS(/MyTest/share/old3 "^sample_script(\\.bat)?$") diff --git a/Tests/SimpleInstall/scripts/sample_script b/Tests/SimpleInstall/scripts/sample_script new file mode 100755 index 000000000..81f9f5315 --- /dev/null +++ b/Tests/SimpleInstall/scripts/sample_script @@ -0,0 +1,2 @@ +#!/bin/sh +echo "Sample Script Output" diff --git a/Tests/SimpleInstall/scripts/sample_script.bat b/Tests/SimpleInstall/scripts/sample_script.bat new file mode 100755 index 000000000..64a77b5b0 --- /dev/null +++ b/Tests/SimpleInstall/scripts/sample_script.bat @@ -0,0 +1 @@ +@echo Sample Script Output
diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt new file mode 100644 index 000000000..378b5292b --- /dev/null +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -0,0 +1,398 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT (TestSimpleInstall) +SET(CMAKE_VERBOSE_MAKEFILE 1) +SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY + "${TestSimpleInstall_BINARY_DIR}/bin") +SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY + "${TestSimpleInstall_BINARY_DIR}/lib/static") +SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY + "${TestSimpleInstall_BINARY_DIR}/lib") + +# Skip generating the rpath pointing at the build tree to make sure +# the executable is installed with the proper rpath in the install +# tree. +SET(CMAKE_SKIP_BUILD_RPATH 1) + +# Make sure the executable can run from the install tree. +SET(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/MyTest/lib) + +# Skip the dependency that causes a build when installing. This +# avoids infinite loops when the post-build rule below installs. +SET(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1) +SET(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY 1) + +SET(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") + +SET(EXTRA_INSTALL_FLAGS) +MESSAGE("Extra install: ${EXTRA_INSTALL_FLAGS}") + +IF(STAGE2) + SET(LIBPATHS + ${CMAKE_INSTALL_PREFIX}/MyTest/lib/static + ${CMAKE_INSTALL_PREFIX}/MyTest/lib + ) + SET(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX} test1rel) + SET(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX}) + SET(t4NAMES test4out test4out${CMAKE_DEBUG_POSTFIX}) + + # Make sure the install script ran. + SET(CMAKE_INSTALL_SCRIPT_DID_RUN 0) + INCLUDE(${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake OPTIONAL) + IF(CMAKE_INSTALL_SCRIPT_DID_RUN) + MESSAGE(STATUS "Stage 1 did run install script 2.") + ELSE(CMAKE_INSTALL_SCRIPT_DID_RUN) + MESSAGE(SEND_ERROR "Stage 1 did not run install script 2.") + ENDIF(CMAKE_INSTALL_SCRIPT_DID_RUN) + + IF(CYGWIN OR MINGW) + SET(LIBPATHS ${LIBPATHS} "${CMAKE_INSTALL_PREFIX}/MyTest/bin") + ENDIF(CYGWIN OR MINGW) + MESSAGE("Search for library in: ${LIBPATHS}") + + SET(TEST1_LIBRARY "TEST1_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE) + SET(TEST2_LIBRARY "TEST2_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE) + SET(TEST4_LIBRARY "TEST4_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE) + + FIND_LIBRARY(TEST1_LIBRARY + NAMES ${t1NAMES} + PATHS ${LIBPATHS} + DOC "First library") + FIND_LIBRARY(TEST2_LIBRARY + NAMES ${t2NAMES} + PATHS ${LIBPATHS} + DOC "Second library") + FIND_LIBRARY(TEST4_LIBRARY + NAMES ${t4NAMES} + PATHS ${LIBPATHS} + DOC "Fourth library") + + # Test importing a library found on disk. + ADD_LIBRARY(lib_test4 UNKNOWN IMPORTED) + SET_PROPERTY(TARGET lib_test4 PROPERTY IMPORTED_LOCATION ${TEST4_LIBRARY}) + + INCLUDE_DIRECTORIES(${CMAKE_INSTALL_PREFIX}/MyTest/include) + ADD_EXECUTABLE (SimpleInstExeS2 inst2.cxx foo.c foo.h) + TARGET_LINK_LIBRARIES(SimpleInstExeS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} lib_test4) + SET(install_target SimpleInstExeS2) + + IF("${TEST1_LIBRARY}" MATCHES "static") + MESSAGE(STATUS "test1 correctly found in lib/static") + ELSE("${TEST1_LIBRARY}" MATCHES "static") + MESSAGE(SEND_ERROR "test1 not found in lib/static!") + ENDIF("${TEST1_LIBRARY}" MATCHES "static") + + # Check for failure of configuration-specific installation. + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Release/lib1debug.h") + MESSAGE(FATAL_ERROR "Debug-configuration file installed for Release!") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Release/lib1debug.h") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h") + MESSAGE(FATAL_ERROR "Release-configuration file installed for Debug!") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h") + + # Check for failure of directory installation. + IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/TSD.h") + MESSAGE(FATAL_ERROR "Directory installation did not install TSD.h") + ENDIF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/TSD.h") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") + MESSAGE(FATAL_ERROR "Directory installation installed CVS directory.") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") + MESSAGE(FATAL_ERROR "Directory installation installed CVS directory.") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CMakeLists.txt") + MESSAGE(FATAL_ERROR "Directory installation installed CMakeLists.txt.") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CMakeLists.txt") + IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.h") + MESSAGE(FATAL_ERROR "Directory installation did not install alternate TSD.h") + ENDIF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.h") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.cxx") + MESSAGE(FATAL_ERROR "Directory installation installed alternate TSD.cxx") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.cxx") + + # Check that scripts properly installed. + IF(WIN32 AND NOT CYGWIN) + SET(BAT .bat) + ELSE(WIN32 AND NOT CYGWIN) + SET(BAT) + ENDIF(WIN32 AND NOT CYGWIN) + FOREACH(loc share share/old1 share/old2 share/old3 share/alt) + SET(CUR_SCRIPT "${CMAKE_INSTALL_PREFIX}/MyTest/${loc}/sample_script${BAT}") + EXECUTE_PROCESS( + COMMAND ${CUR_SCRIPT} + RESULT_VARIABLE SAMPLE_SCRIPT_RESULT + OUTPUT_VARIABLE SAMPLE_SCRIPT_OUTPUT + ) + IF(NOT "${SAMPLE_SCRIPT_RESULT}" MATCHES "^0$") + MESSAGE(FATAL_ERROR + "Sample script [${CUR_SCRIPT}] failed: [${SAMPLE_SCRIPT_RESULT}]") + ENDIF(NOT "${SAMPLE_SCRIPT_RESULT}" MATCHES "^0$") + IF(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output") + MESSAGE(FATAL_ERROR + "Bad sample script [${CUR_SCRIPT}] output: [${SAMPLE_SCRIPT_OUTPUT}]") + ENDIF(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output") + ENDFOREACH(loc) + + # Check for failure of empty directory installation. + IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty") + MESSAGE(FATAL_ERROR "Empty directory installation did not install.") + ENDIF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty") + FILE(GLOB EMPTY_FILES "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty/*") + IF(EMPTY_FILES) + MESSAGE(FATAL_ERROR "Empty directory installed [${EMPTY_FILES}].") + ENDIF(EMPTY_FILES) + + # Make sure the test executable can run from the install tree. + SET_TARGET_PROPERTIES(SimpleInstExeS2 PROPERTIES + INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) + + INSTALL_TARGETS(/MyTest/bin SimpleInstExeS2) + +# try to import the exported targets again + SET(SimpleInstallS1_DIR ${CMAKE_INSTALL_PREFIX}/MyTest/lib) + FIND_PACKAGE(SimpleInstallS1 REQUIRED) + GET_TARGET_PROPERTY(simpleInstallImported S1_SimpleInstall IMPORTED) + IF(NOT simpleInstallImported) + MESSAGE(FATAL_ERROR "Target S1_SimpleInstall could not be imported") + ENDIF(NOT simpleInstallImported) + +ELSE(STAGE2) + # Wipe out the install directory to do a fresh test. + FILE(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/MyTest) + + # this is stage 1, so create libraries and modules and install everything + ADD_LIBRARY(test1 STATIC lib1.cxx) + ADD_LIBRARY(test2 SHARED lib2.cxx) + ADD_LIBRARY(test3 MODULE lib3.cxx) + ADD_LIBRARY(test4 SHARED lib4.cxx) + + # Test <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME properties. + SET_PROPERTY(TARGET test4 PROPERTY ARCHIVE_OUTPUT_NAME test4out) + SET_PROPERTY(TARGET test4 PROPERTY LIBRARY_OUTPUT_NAME test4out) + + ADD_EXECUTABLE (SimpleInstall inst.cxx foo.c foo.h) + TARGET_LINK_LIBRARIES(SimpleInstall test1 test2 test4) + SET(install_target SimpleInstall) + + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) + # Disable VERSION test until it is implemented in the Xcode generator. + IF(NOT XCODE) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) + ENDIF(NOT XCODE) + + # Make sure the test executable can run from the install tree. + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES + INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) + + # Test per-configuration output name. + SET_TARGET_PROPERTIES(test1 PROPERTIES RELEASE_OUTPUT_NAME test1rel) + SET_TARGET_PROPERTIES(test2 PROPERTIES PUBLIC_HEADER foo.h) + + IF(CMAKE_GENERATOR MATCHES "Makefiles") + ADD_SUBDIRECTORY(TestSubDir) + ADD_DEPENDENCIES(SimpleInstall TSD) + ENDIF(CMAKE_GENERATOR MATCHES "Makefiles") + + ADD_DEPENDENCIES(SimpleInstall test3) + ADD_DEPENDENCIES(test2 test3) + ADD_DEPENDENCIES(test4 test2) + + INSTALL(TARGETS SimpleInstall test1 test2 test3 EXPORT SimpleInstallS1 + RUNTIME DESTINATION MyTest/bin COMPONENT Runtime # .exe, .dll + LIBRARY DESTINATION MyTest/lib COMPONENT Runtime # .so, mod.dll + ARCHIVE DESTINATION MyTest/lib/static COMPONENT Development # .a, .lib + PUBLIC_HEADER DESTINATION MyTest/include COMPONENT Development + ) + + INSTALL(TARGETS test4 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + RUNTIME DESTINATION MyTest/bin + LIBRARY DESTINATION MyTest/lib + ARCHIVE DESTINATION MyTest/lib/static + OPTIONAL # for coverage...target should always exist + ) + INSTALL(FILES lib1.h DESTINATION MyTest/include/foo) + INSTALL(FILES lib2.h + DESTINATION MyTest/include/foo + COMPONENT Development + PERMISSIONS OWNER_READ OWNER_WRITE + RENAME lib2renamed.h + ) + + # Test old-style install commands. + INSTALL_FILES(/MyTest/include FILES lib3.h) + INSTALL_FILES(/MyTest/include/old .h lib3) + INSTALL_FILES(/MyTest/include/old "^lib2.h$") + INSTALL_PROGRAMS(/MyTest/share/old1 FILES + scripts/sample_script scripts/sample_script.bat) + INSTALL_PROGRAMS(/MyTest/share/old2 + scripts/sample_script scripts/sample_script.bat) + +# "export" the targets collected in "SimpleInstallS1" + INSTALL(EXPORT SimpleInstallS1 FILE SimpleInstallS1Config.cmake + DESTINATION MyTest/lib + NAMESPACE S1_ ) + + EXPORT(TARGETS SimpleInstall test1 test2 test3 + FILE "${CMAKE_CURRENT_BINARY_DIR}/SimpleInstallS1Config.cmake" + NAMESPACE S2_ ) + + ADD_SUBDIRECTORY(scripts) + + # Test optional installation. + INSTALL(FILES does_not_exist.h DESTINATION MyTest/include/foo OPTIONAL) + + # Test configuration-specific installation. + INSTALL(FILES lib1.h RENAME lib1release.h CONFIGURATIONS Release + DESTINATION MyTest/include/Release + ) + INSTALL(FILES lib1.h RENAME lib1debug.h CONFIGURATIONS Debug + DESTINATION MyTest/include/Debug + ) + + # Test directory installation. + FILE(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") + FILE(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") + INSTALL( + DIRECTORY TestSubDir scripts/ DESTINATION MyTest/share + FILE_PERMISSIONS OWNER_READ OWNER_WRITE + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + PATTERN "CVS" EXCLUDE + REGEX "\\.txt$" EXCLUDE + PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + ) + + # Alternate directory installation for coverage. + INSTALL( + DIRECTORY scripts/ DESTINATION MyTest/share/alt + COMPONENT Development + USE_SOURCE_PERMISSIONS + PATTERN "CVS" EXCLUDE + REGEX "\\.txt$" EXCLUDE + ) + INSTALL( + DIRECTORY TestSubDir DESTINATION MyTest/share/alt + FILE_PERMISSIONS OWNER_READ OWNER_WRITE + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + FILES_MATCHING PATTERN "*.h" + ) + + # Test empty directory installation. + INSTALL(DIRECTORY DESTINATION MyTest/share/empty) + + # Test optional directory installation. + INSTALL(DIRECTORY does-not-exist DESTINATION MyTest/share OPTIONAL) + + # Test user-specified install scripts, with and without COMPONENT. + INSTALL( + SCRIPT InstallScript1.cmake + CODE "SET(INSTALL_CODE_DID_RUN 1)" + SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript2.cmake + ) + INSTALL( + SCRIPT InstallScript3.cmake + CODE "SET(INSTALL_CODE_WITH_COMPONENT_DID_RUN 1)" + SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript4.cmake + COMPONENT Development + ) + SET_DIRECTORY_PROPERTIES(PROPERTIES + ADDITIONAL_MAKE_CLEAN_FILES + "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake") + + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT + ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT + ${CMAKE_CURRENT_SOURCE_DIR}/PostInstall.cmake) + SET_TARGET_PROPERTIES(test4 PROPERTIES VERSION 1.2 SOVERSION 3 + INSTALL_NAME_DIR @executable_path/../lib) +ENDIF(STAGE2) + +IF(CMAKE_CONFIGURATION_TYPES) + SET(SI_CONFIG -C ${CMAKE_CFG_INTDIR}) +ELSE(CMAKE_CONFIGURATION_TYPES) + SET(SI_CONFIG) +ENDIF(CMAKE_CONFIGURATION_TYPES) + +# Dummy test of CPack +SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Test of packaging with cpack") +SET(CPACK_PACKAGE_VENDOR "Kitware") +SET(CPACK_INSTALL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/PackageScript.cmake") + +IF(WIN32 AND NOT UNIX) + FIND_PROGRAM(NSIS_MAKENSIS NAMES makensis + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS] + DOC "Where is makensis.exe located" + ) + IF(NOT NSIS_MAKENSIS) + SET(CPACK_GENERATOR TGZ) + ENDIF(NOT NSIS_MAKENSIS) +ENDIF(WIN32 AND NOT UNIX) +IF(UNIX AND NOT APPLE) + SET(CPACK_GENERATOR "TGZ;STGZ;TZ") + # FIND_PROGRAM(found_compress + # NAMES compress) + # IF(found_compress) + # FIND_PROGRAM(file_command NAMES file) + # IF(NOT file_command) + # set(file_command file) + # ENDIF(NOT file_command) + # EXECUTE_PROCESS(COMMAND ${file_command} ${found_compress} + # OUTPUT_VARIABLE output) + # set(SKIP_TZ FALSE) + # if("${output}" MATCHES "script") + # set(SKIP_TZ TRUE) + # endif("${output}" MATCHES "script") + # if("${output}" MATCHES "dummy.sh") + # set(SKIP_TZ TRUE) + # endif("${output}" MATCHES "dummy.sh") + # if(NOT SKIP_TZ) + # message("compress found and it was not a script") + # message("output from file command: [${output}]") + # SET(CPACK_GENERATOR "${CPACK_GENERATOR};TZ") + # else(NOT SKIP_TZ) + # message("compress found, but it was a script so dont use it") + # message("output from file command: [${output}]") + # endif(NOT SKIP_TZ) + # ENDIF(found_compress) + FIND_PROGRAM(found_bz2 + NAMES bzip2) + IF(found_bz2) + SET(CPACK_GENERATOR "${CPACK_GENERATOR};TBZ2") + ENDIF(found_bz2) +ENDIF(UNIX AND NOT APPLE) + +SET(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install") +SET(CMAKE_INSTALL_MFC_LIBRARIES 1) +SET(CMAKE_INSTALL_DEBUG_LIBRARIES 1) +INCLUDE(InstallRequiredSystemLibraries) + +IF(CTEST_TEST_CPACK) + SET(PACKAGE_TARGET --build-target package) + + # Avoid settings that require the .zip file command line tools... + # (just build an NSIS installer without component support) + # + SET(CPACK_BINARY_ZIP OFF) + SET(CPACK_MONOLITHIC_INSTALL ON) +ELSE(CTEST_TEST_CPACK) + SET(PACKAGE_TARGET) +ENDIF(CTEST_TEST_CPACK) + +INCLUDE(CPack) + +ADD_CUSTOM_COMMAND( + TARGET ${install_target} + POST_BUILD + COMMAND ${CMAKE_CTEST_COMMAND} + ARGS ${SI_CONFIG} + --build-and-test + ${CMAKE_SOURCE_DIR} + ${CMAKE_BINARY_DIR} + --build-generator ${CMAKE_GENERATOR} + --build-project ${PROJECT_NAME} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-noclean + --build-target install + ${PACKAGE_TARGET} + COMMENT "Install Project" + ) diff --git a/Tests/SimpleInstallS2/InstallScript1.cmake b/Tests/SimpleInstallS2/InstallScript1.cmake new file mode 100644 index 000000000..27b7725f8 --- /dev/null +++ b/Tests/SimpleInstallS2/InstallScript1.cmake @@ -0,0 +1,5 @@ +MESSAGE("This is install script 1.") +SET(INSTALL_SCRIPT_1_DID_RUN 1) +IF(INSTALL_CODE_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 1 did not run before install code.") +ENDIF(INSTALL_CODE_DID_RUN) diff --git a/Tests/SimpleInstallS2/InstallScript2.cmake b/Tests/SimpleInstallS2/InstallScript2.cmake new file mode 100644 index 000000000..927cae8b6 --- /dev/null +++ b/Tests/SimpleInstallS2/InstallScript2.cmake @@ -0,0 +1,14 @@ +MESSAGE("This is install script 2.") +IF(INSTALL_SCRIPT_1_DID_RUN) + MESSAGE("Install script ordering works.") +ELSE(INSTALL_SCRIPT_1_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 1 did not run before install script 2.") +ENDIF(INSTALL_SCRIPT_1_DID_RUN) +IF(INSTALL_CODE_DID_RUN) + MESSAGE("Install code ordering works.") +ELSE(INSTALL_CODE_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 2 did not run after install code.") +ENDIF(INSTALL_CODE_DID_RUN) +FILE(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake" + "SET(CMAKE_INSTALL_SCRIPT_DID_RUN 1)\n" + ) diff --git a/Tests/SimpleInstallS2/InstallScript3.cmake b/Tests/SimpleInstallS2/InstallScript3.cmake new file mode 100644 index 000000000..b1aecd4c2 --- /dev/null +++ b/Tests/SimpleInstallS2/InstallScript3.cmake @@ -0,0 +1,12 @@ +MESSAGE("This is install script 3.") +SET(INSTALL_SCRIPT_3_DID_RUN 1) +IF(INSTALL_CODE_WITH_COMPONENT_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 3 did not run before install code with component.") +ENDIF(INSTALL_CODE_WITH_COMPONENT_DID_RUN) + +IF(CMAKE_INSTALL_COMPONENT) +IF(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development") + MESSAGE("CMAKE_INSTALL_COMPONENT=\"${CMAKE_INSTALL_COMPONENT}\"") + MESSAGE(FATAL_ERROR "Install script 3 should only run for \"Development\" INSTALL COMPONENT.") +ENDIF(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development") +ENDIF(CMAKE_INSTALL_COMPONENT) diff --git a/Tests/SimpleInstallS2/InstallScript4.cmake b/Tests/SimpleInstallS2/InstallScript4.cmake new file mode 100644 index 000000000..0ffea4bc8 --- /dev/null +++ b/Tests/SimpleInstallS2/InstallScript4.cmake @@ -0,0 +1,22 @@ +MESSAGE("This is install script 4.") +IF(INSTALL_SCRIPT_3_DID_RUN) + MESSAGE("Install script ordering works.") +ELSE(INSTALL_SCRIPT_3_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 3 did not run before install script 4.") +ENDIF(INSTALL_SCRIPT_3_DID_RUN) +IF(INSTALL_CODE_WITH_COMPONENT_DID_RUN) + MESSAGE("Install code ordering works.") +ELSE(INSTALL_CODE_WITH_COMPONENT_DID_RUN) + MESSAGE(FATAL_ERROR "Install script 4 did not run after install with component code.") +ENDIF(INSTALL_CODE_WITH_COMPONENT_DID_RUN) + +IF(CMAKE_INSTALL_COMPONENT) +IF(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development") + MESSAGE("CMAKE_INSTALL_COMPONENT=\"${CMAKE_INSTALL_COMPONENT}\"") + MESSAGE(FATAL_ERROR "Install script 4 should only run for \"Development\" INSTALL COMPONENT.") +ENDIF(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development") +ENDIF(CMAKE_INSTALL_COMPONENT) + +FILE(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScript4Out.cmake" + "SET(CMAKE_INSTALL_SCRIPT_4_DID_RUN 1)\n" + ) diff --git a/Tests/SimpleInstallS2/PackageScript.cmake b/Tests/SimpleInstallS2/PackageScript.cmake new file mode 100644 index 000000000..3567a2f43 --- /dev/null +++ b/Tests/SimpleInstallS2/PackageScript.cmake @@ -0,0 +1,10 @@ +MESSAGE("This is packaging script") +MESSAGE("It writes a file with all variables available in ${CMAKE_INSTALL_PREFIX}/AllVariables.txt") + +FILE(WRITE ${CMAKE_INSTALL_PREFIX}/AllVariables.txt "") +GET_CMAKE_PROPERTY(res VARIABLES) +FOREACH(var ${res}) + FILE(APPEND ${CMAKE_INSTALL_PREFIX}/AllVariables.txt + "${var} \"${${var}}\"\n") +ENDFOREACH(var ${res}) + diff --git a/Tests/SimpleInstallS2/PostInstall.cmake b/Tests/SimpleInstallS2/PostInstall.cmake new file mode 100644 index 000000000..52ea140a5 --- /dev/null +++ b/Tests/SimpleInstallS2/PostInstall.cmake @@ -0,0 +1,6 @@ +MESSAGE("In post install") +IF(PRE_INSTALL_DID_RUN) + MESSAGE("Pre and post install work fine") +ELSE(PRE_INSTALL_DID_RUN) + MESSAGE(FATAL_ERROR "Pre install did not run before post install") +ENDIF(PRE_INSTALL_DID_RUN) diff --git a/Tests/SimpleInstallS2/PreInstall.cmake b/Tests/SimpleInstallS2/PreInstall.cmake new file mode 100644 index 000000000..2ea2f7716 --- /dev/null +++ b/Tests/SimpleInstallS2/PreInstall.cmake @@ -0,0 +1,2 @@ +MESSAGE("This is in pre install") +SET(PRE_INSTALL_DID_RUN 1) diff --git a/Tests/SimpleInstallS2/TestSubDir/CMakeLists.txt b/Tests/SimpleInstallS2/TestSubDir/CMakeLists.txt new file mode 100644 index 000000000..4f6295300 --- /dev/null +++ b/Tests/SimpleInstallS2/TestSubDir/CMakeLists.txt @@ -0,0 +1,3 @@ +ADD_EXECUTABLE(TSD TSD.cxx TSD_utils.cxx) +INSTALL_FILES(/MyTest/include FILES TSD.h) +INSTALL_TARGETS(/MyTest/bin TSD) diff --git a/Tests/SimpleInstallS2/TestSubDir/TSD.cxx b/Tests/SimpleInstallS2/TestSubDir/TSD.cxx new file mode 100644 index 000000000..8fc38787a --- /dev/null +++ b/Tests/SimpleInstallS2/TestSubDir/TSD.cxx @@ -0,0 +1,10 @@ +#include <stdio.h> + +#include "TSD.h" + +int main() +{ + int res = TSD("TEST"); + printf("Hello from TSD\n"); + return res; +} diff --git a/Tests/SimpleInstallS2/TestSubDir/TSD.h b/Tests/SimpleInstallS2/TestSubDir/TSD.h new file mode 100644 index 000000000..6a3c1affa --- /dev/null +++ b/Tests/SimpleInstallS2/TestSubDir/TSD.h @@ -0,0 +1 @@ +int TSD(const char*); diff --git a/Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx b/Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx new file mode 100644 index 000000000..0277f05ae --- /dev/null +++ b/Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx @@ -0,0 +1,10 @@ +#include <string.h> + +int TSD(const char* foo) +{ + if ( strcmp(foo, "TEST") == 0 ) + { + return 0; + } + return 1; +} diff --git a/Tests/SimpleInstallS2/foo.c b/Tests/SimpleInstallS2/foo.c new file mode 100644 index 000000000..45d5b2bf2 --- /dev/null +++ b/Tests/SimpleInstallS2/foo.c @@ -0,0 +1,6 @@ +char* foo = "Foo"; + +int SomeFunctionInFoo() +{ + return 5; +} diff --git a/Tests/SimpleInstallS2/foo.h b/Tests/SimpleInstallS2/foo.h new file mode 100644 index 000000000..2708baffe --- /dev/null +++ b/Tests/SimpleInstallS2/foo.h @@ -0,0 +1,11 @@ +#ifdef __cplusplus +extern "C" { +#endif + +extern char* foo; +extern int SomeFunctionInFoo(); + +#ifdef __cplusplus +} +#endif + diff --git a/Tests/SimpleInstallS2/inst.cxx b/Tests/SimpleInstallS2/inst.cxx new file mode 100644 index 000000000..7f2962d00 --- /dev/null +++ b/Tests/SimpleInstallS2/inst.cxx @@ -0,0 +1,37 @@ +#include "foo.h" + +#ifdef STAGE_2 +# include <foo/lib1.h> +# include <foo/lib2renamed.h> +# include <lib3.h> +# include <old/lib2.h> +# include <old/lib3.h> +#else +# include "lib1.h" +# include "lib2.h" +#endif + +#include "lib4.h" + +#include <stdio.h> + +int main () +{ + if ( Lib1Func() != 2.0 ) + { + printf("Problem with lib1\n"); + return 1; + } + if ( Lib2Func() != 1.0 ) + { + printf("Problem with lib2\n"); + return 1; + } + if ( Lib4Func() != 4.0 ) + { + printf("Problem with lib4\n"); + return 1; + } + printf("The value of Foo: %s\n", foo); + return SomeFunctionInFoo()-5; +} diff --git a/Tests/SimpleInstallS2/inst2.cxx b/Tests/SimpleInstallS2/inst2.cxx new file mode 100644 index 000000000..c70b93af1 --- /dev/null +++ b/Tests/SimpleInstallS2/inst2.cxx @@ -0,0 +1,2 @@ +#define STAGE_2 +#include "inst.cxx" diff --git a/Tests/SimpleInstallS2/lib1.cxx b/Tests/SimpleInstallS2/lib1.cxx new file mode 100644 index 000000000..7aa905205 --- /dev/null +++ b/Tests/SimpleInstallS2/lib1.cxx @@ -0,0 +1,6 @@ +#include "lib1.h" + +float Lib1Func() +{ + return 2.0; +} diff --git a/Tests/SimpleInstallS2/lib1.h b/Tests/SimpleInstallS2/lib1.h new file mode 100644 index 000000000..0d64e76bc --- /dev/null +++ b/Tests/SimpleInstallS2/lib1.h @@ -0,0 +1 @@ +extern float Lib1Func(); diff --git a/Tests/SimpleInstallS2/lib2.cxx b/Tests/SimpleInstallS2/lib2.cxx new file mode 100644 index 000000000..dccc48b78 --- /dev/null +++ b/Tests/SimpleInstallS2/lib2.cxx @@ -0,0 +1,6 @@ +#include "lib2.h" + +float Lib2Func() +{ + return 1.0; +} diff --git a/Tests/SimpleInstallS2/lib2.h b/Tests/SimpleInstallS2/lib2.h new file mode 100644 index 000000000..ea5a6f7ea --- /dev/null +++ b/Tests/SimpleInstallS2/lib2.h @@ -0,0 +1,11 @@ +#ifdef _WIN32 +# ifdef test2_EXPORTS +# define CM_TEST_LIB_EXPORT __declspec( dllexport ) +# else +# define CM_TEST_LIB_EXPORT __declspec( dllimport ) +# endif +#else +# define CM_TEST_LIB_EXPORT +#endif + +CM_TEST_LIB_EXPORT float Lib2Func(); diff --git a/Tests/SimpleInstallS2/lib3.cxx b/Tests/SimpleInstallS2/lib3.cxx new file mode 100644 index 000000000..da8dbf942 --- /dev/null +++ b/Tests/SimpleInstallS2/lib3.cxx @@ -0,0 +1,6 @@ +#include "lib3.h" + +float Lib3Func() +{ + return 2.0; +} diff --git a/Tests/SimpleInstallS2/lib3.h b/Tests/SimpleInstallS2/lib3.h new file mode 100644 index 000000000..c250ed769 --- /dev/null +++ b/Tests/SimpleInstallS2/lib3.h @@ -0,0 +1,11 @@ +#ifdef _WIN32 +# ifdef test3_EXPORTS +# define CM_TEST_LIB_EXPORT __declspec( dllexport ) +# else +# define CM_TEST_LIB_EXPORT __declspec( dllimport ) +# endif +#else +# define CM_TEST_LIB_EXPORT +#endif + +CM_TEST_LIB_EXPORT float Lib3Func(); diff --git a/Tests/SimpleInstallS2/lib4.cxx b/Tests/SimpleInstallS2/lib4.cxx new file mode 100644 index 000000000..fbfa23aa4 --- /dev/null +++ b/Tests/SimpleInstallS2/lib4.cxx @@ -0,0 +1,7 @@ +#include "lib4.h" + +float Lib4Func() +{ + return 4.0; +} + diff --git a/Tests/SimpleInstallS2/lib4.h b/Tests/SimpleInstallS2/lib4.h new file mode 100644 index 000000000..4b94ea207 --- /dev/null +++ b/Tests/SimpleInstallS2/lib4.h @@ -0,0 +1,12 @@ +#ifdef _WIN32 +# ifdef test4_EXPORTS +# define CM_TEST_LIB_EXPORT __declspec( dllexport ) +# else +# define CM_TEST_LIB_EXPORT __declspec( dllimport ) +# endif +#else +# define CM_TEST_LIB_EXPORT +#endif + +CM_TEST_LIB_EXPORT float Lib4Func(); + diff --git a/Tests/SimpleInstallS2/scripts/.gitattributes b/Tests/SimpleInstallS2/scripts/.gitattributes new file mode 100644 index 000000000..5e3db2fb3 --- /dev/null +++ b/Tests/SimpleInstallS2/scripts/.gitattributes @@ -0,0 +1 @@ +sample_script crlf=input diff --git a/Tests/SimpleInstallS2/scripts/CMakeLists.txt b/Tests/SimpleInstallS2/scripts/CMakeLists.txt new file mode 100644 index 000000000..d46c1652e --- /dev/null +++ b/Tests/SimpleInstallS2/scripts/CMakeLists.txt @@ -0,0 +1 @@ +INSTALL_PROGRAMS(/MyTest/share/old3 "^sample_script(\\.bat)?$") diff --git a/Tests/SimpleInstallS2/scripts/sample_script b/Tests/SimpleInstallS2/scripts/sample_script new file mode 100755 index 000000000..81f9f5315 --- /dev/null +++ b/Tests/SimpleInstallS2/scripts/sample_script @@ -0,0 +1,2 @@ +#!/bin/sh +echo "Sample Script Output" diff --git a/Tests/SimpleInstallS2/scripts/sample_script.bat b/Tests/SimpleInstallS2/scripts/sample_script.bat new file mode 100755 index 000000000..64a77b5b0 --- /dev/null +++ b/Tests/SimpleInstallS2/scripts/sample_script.bat @@ -0,0 +1 @@ +@echo Sample Script Output
diff --git a/Tests/SourceGroups/CMakeLists.txt b/Tests/SourceGroups/CMakeLists.txt new file mode 100644 index 000000000..c3cf38c7a --- /dev/null +++ b/Tests/SourceGroups/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required (VERSION 2.6) +project(SourceGroups) + +# this is not really a test which can fail +# it is more an example with several source_group() +# commands. +# The created projects have to be loaded manually +# in Visual Studio/Xcode/Eclipse/... +# to see whether the correct groups have been created. + +source_group(Base FILES main.c) + +# a sub group +source_group(Base\\Sub1 FILES sub1/foo.c) + +# a sub sub group +source_group(Base\\Sub1\\Sub2 FILES sub1/foobar.c) + +# a group with empty name +source_group("" FILES foo.c) + +# a group, whose name consists only of the delimiter +#should be handled the same way as an empty name +source_group("\\" FILES baz.c) + +# a sub sub group whose last component has the same name +# as an already existing group +source_group(Base\\Sub1\\Base FILES bar.c) + +# a group without files, is currently not created +source_group(EmptyGroup) + + +add_executable(SourceGroups main.c bar.c foo.c sub1/foo.c sub1/foobar.c baz.c README.txt) + diff --git a/Tests/SourceGroups/README.txt b/Tests/SourceGroups/README.txt new file mode 100644 index 000000000..1a4baf536 --- /dev/null +++ b/Tests/SourceGroups/README.txt @@ -0,0 +1 @@ + diff --git a/Tests/SourceGroups/bar.c b/Tests/SourceGroups/bar.c new file mode 100644 index 000000000..a2fcad5e9 --- /dev/null +++ b/Tests/SourceGroups/bar.c @@ -0,0 +1,4 @@ +int barbar(void) +{ + return 2; +} diff --git a/Tests/SourceGroups/baz.c b/Tests/SourceGroups/baz.c new file mode 100644 index 000000000..477f4fa6e --- /dev/null +++ b/Tests/SourceGroups/baz.c @@ -0,0 +1,4 @@ +int baz(void) +{ + return 13; +} diff --git a/Tests/SourceGroups/foo.c b/Tests/SourceGroups/foo.c new file mode 100644 index 000000000..3bebc4d22 --- /dev/null +++ b/Tests/SourceGroups/foo.c @@ -0,0 +1,4 @@ +int bar(void) +{ + return 42; +} diff --git a/Tests/SourceGroups/main.c b/Tests/SourceGroups/main.c new file mode 100644 index 000000000..212e64baa --- /dev/null +++ b/Tests/SourceGroups/main.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +extern int foo(void); +extern int bar(void); +extern int foobar(void); +extern int barbar(void); +extern int baz(void); + +int main() +{ + printf("foo: %d bar: %d foobar: %d barbar: %d baz: %d\n", foo(), bar(), foobar(), barbar(), baz()); + return 0; +} diff --git a/Tests/SourceGroups/sub1/foo.c b/Tests/SourceGroups/sub1/foo.c new file mode 100644 index 000000000..39912a748 --- /dev/null +++ b/Tests/SourceGroups/sub1/foo.c @@ -0,0 +1,4 @@ +int foo(void) +{ + return 17; +} diff --git a/Tests/SourceGroups/sub1/foobar.c b/Tests/SourceGroups/sub1/foobar.c new file mode 100644 index 000000000..32588b5e1 --- /dev/null +++ b/Tests/SourceGroups/sub1/foobar.c @@ -0,0 +1,4 @@ +int foobar(void) +{ + return 1477; +} diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt new file mode 100644 index 000000000..7792a353d --- /dev/null +++ b/Tests/StringFileTest/CMakeLists.txt @@ -0,0 +1,282 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(StringFileTest) +INCLUDE_DIRECTORIES(${StringFileTest_BINARY_DIR}) + +# Read file test +FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in" infile) + +# Test reading a binary file into hex representation +FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/test.bin" hexContents HEX) + +IF("${hexContents}" STREQUAL "0001027700") + MESSAGE("FILE(READ HEX) correctly read [${hexContents}]") +ELSE("${hexContents}" STREQUAL "0001027700") + MESSAGE(SEND_ERROR "FILE(READ HEX) incorrectly read [${hexContents}], but expected was [0001027700]") +ENDIF("${hexContents}" STREQUAL "0001027700") + +# FILE(STRINGS) test +FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in" infile_strings + LIMIT_COUNT 1 LIMIT_INPUT 1024 LIMIT_OUTPUT 1024 + LENGTH_MINIMUM 10 LENGTH_MAXIMUM 23 REGEX include NEWLINE_CONSUME) +SET(infile_strings_goal "#include \"includefile\"\n") +IF("${infile_strings}" STREQUAL "${infile_strings_goal}") + MESSAGE("FILE(STRINGS) correctly read [${infile_strings}]") +ELSE("${infile_strings}" STREQUAL "${infile_strings_goal}") + MESSAGE(SEND_ERROR + "FILE(STRINGS) incorrectly read [${infile_strings}]") +ENDIF("${infile_strings}" STREQUAL "${infile_strings_goal}") + +# test reading a file and getting its binary data as hex string +FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/main.srec" infilehex LIMIT 4 HEX) +IF(NOT "${infilehex}" STREQUAL "53313036") + MESSAGE(SEND_ERROR + "FILE(READ ... HEX) error, read: \"${infilehex}\", expected \"53313036\"") +ENDIF(NOT "${infilehex}" STREQUAL "53313036") + + +# test that FILE(STRINGS) also work with Intel hex and Motorola S-record files +# this file has been created with "sdcc main.c" +FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/main.ihx" infile_strings REGEX INFO) +SET(infile_strings_goal "INFO:compiler\\[SDCC-HEX\\]") +IF("${infile_strings}" MATCHES "${infile_strings_goal}") + MESSAGE("FILE(STRINGS) correctly read from hex file [${infile_strings}]") +ELSE("${infile_strings}" MATCHES "${infile_strings_goal}") + MESSAGE(SEND_ERROR + "FILE(STRINGS) incorrectly read from hex file [${infile_strings}]") +ENDIF("${infile_strings}" MATCHES "${infile_strings_goal}") + +# this file has been created with "sdcc main.c --out-fmt-s19" +FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/main.srec" infile_strings REGEX INFO) +SET(infile_strings_goal "INFO:compiler\\[SDCC-SREC\\]") +IF("${infile_strings}" MATCHES "${infile_strings_goal}") + MESSAGE("FILE(STRINGS) correctly read from srec file [${infile_strings}]") +ELSE("${infile_strings}" MATCHES "${infile_strings_goal}") + MESSAGE(SEND_ERROR + "FILE(STRINGS) incorrectly read from srec file [${infile_strings}]") +ENDIF("${infile_strings}" MATCHES "${infile_strings_goal}") + +# String test +STRING(REGEX MATCH "[cC][mM][aA][kK][eE]" rmvar "CMake is great") +STRING(REGEX MATCHALL "[cC][mM][aA][kK][eE]" rmallvar "CMake is better than cmake or CMake") +STRING(REGEX REPLACE "[Aa][uU][tT][oO]([cC][oO][nN][fF]|[mM][aA][kK][eE])" + "CMake" rrepvar "People should use Autoconf and Automake") +STRING(COMPARE EQUAL "CMake" "Autoconf" nceqvar) +STRING(COMPARE EQUAL "CMake" "CMake" ceqvar) +STRING(COMPARE NOTEQUAL "CMake" "Autoconf" cneqvar) +STRING(COMPARE NOTEQUAL "CMake" "CMake" ncneqvar) +STRING(COMPARE LESS "before" "after" nclvar) +STRING(COMPARE LESS "max" "min" clvar) +STRING(COMPARE GREATER "before" "after" cgvar) +STRING(COMPARE GREATER "max" "min" ncgvar) +STRING(ASCII 67 109 97 107 101 savar) +STRING(TOUPPER "CMake" tuvar) +STRING(TOLOWER "CMake" tlvar) +STRING(REPLACE "Autoconf" "CMake" repvar "People should use Autoconf") + +IF("abc" STREQUAL "xyz") + MESSAGE(SEND_ERROR "Problem with the IF(STREQUAL), \"abc\" and \"xyz\" considered equal") +ENDIF("abc" STREQUAL "xyz") + +IF("CMake is cool" MATCHES "(CMake) (is).+") + IF(NOT "${CMAKE_MATCH_0}" STREQUAL "CMake is cool") + MESSAGE(SEND_ERROR "CMAKE_MATCH_0 wrong: \"${CMAKE_MATCH_0}\", expected \"CMake is cool\"") + ENDIF(NOT "${CMAKE_MATCH_0}" STREQUAL "CMake is cool") + IF(NOT "${CMAKE_MATCH_1}" STREQUAL "CMake") + MESSAGE(SEND_ERROR "CMAKE_MATCH_1 wrong: \"${CMAKE_MATCH_1}\", expected \"CMake\"") + ENDIF(NOT "${CMAKE_MATCH_1}" STREQUAL "CMake") + IF(NOT "${CMAKE_MATCH_2}" STREQUAL "is") + MESSAGE(SEND_ERROR "CMAKE_MATCH_2 wrong: \"${CMAKE_MATCH_2}\", expected \"is\"") + ENDIF(NOT "${CMAKE_MATCH_2}" STREQUAL "is") +ELSE("CMake is cool" MATCHES "(CMake) (is).+") + MESSAGE(SEND_ERROR "Problem with the IF(MATCHES), no match found") +ENDIF("CMake is cool" MATCHES "(CMake) (is).+") + +STRING(REGEX MATCH "(People).+CMake" matchResultVar "People should use CMake") +IF(NOT "${matchResultVar}" STREQUAL "People should use CMake") + MESSAGE(SEND_ERROR "STRING(REGEX MATCH) problem: \"${matchResultVar}\", expected \"People should use CMake\"") +ENDIF(NOT "${matchResultVar}" STREQUAL "People should use CMake") +IF(NOT "${CMAKE_MATCH_0}" STREQUAL "People should use CMake") + MESSAGE(SEND_ERROR "CMAKE_MATCH_0 wrong: \"${CMAKE_MATCH_0}\", expected \"People should use CMake\"") +ENDIF(NOT "${CMAKE_MATCH_0}" STREQUAL "People should use CMake") +IF(NOT "${CMAKE_MATCH_1}" STREQUAL "People") + MESSAGE(SEND_ERROR "CMAKE_MATCH_1 wrong: \"${CMAKE_MATCH_1}\", expected \"People\"") +ENDIF(NOT "${CMAKE_MATCH_1}" STREQUAL "People") +IF(NOT "${CMAKE_MATCH_2}" STREQUAL "") + MESSAGE(SEND_ERROR "CMAKE_MATCH_2 wrong: \"${CMAKE_MATCH_2}\", expected empty string") +ENDIF(NOT "${CMAKE_MATCH_2}" STREQUAL "") + + +STRING(STRIP " + ST1 + " ST1) +STRING(STRIP "ST2 " ST2) +STRING(STRIP " ST3" ST3) + +FOREACH(var ST1 ST2 ST3) + IF("${var}" STREQUAL "${${var}}") + MESSAGE("[${var}] == [${${var}}]") + ELSE("${var}" STREQUAL "${${var}}") + MESSAGE(SEND_ERROR "Problem with the STRIP command for ${var}: [${${var}}]") + ENDIF("${var}" STREQUAL "${${var}}") +ENDFOREACH(var) + +STRING(SUBSTRING "People should use Autoconf" 7 10 substringres) +SET(substringres "Everybody ${substringres} CMake") + +STRING(LENGTH ${substringres} lengthres) + +FILE(RELATIVE_PATH relpath "/usr/local/bin" "/usr/X11R6/bin/xnest") + +# Escaping test +SET(var "\\ \" \ \t \n \r \# \( \) \0") +MESSAGE("Output: [${var}]") +SET(var \\ \" \ \t \n \r \# \( \) \0) +MESSAGE("Output: [${var}]") + +# Make-style unquoted argument test +SET(var $(VAR1)$(VAR2)/$(VAR3)) +MESSAGE("Output: [${var}]") +STRING(COMPARE EQUAL "${var}" "$(VAR1)$(VAR2)/$(VAR3)" result) +IF(NOT result) + MESSAGE(SEND_ERROR "Unquoted $(VAR) syntax is broken.") +ENDIF(NOT result) + +# Obscure environment variable name +SET("ENV{x+(y)}" "Obscure environment variable value") +MESSAGE("Output: [$ENV{x+(y)}]") +IF(NOT "$ENV{x+(y)}" STREQUAL "Obscure environment variable value") + MESSAGE(SEND_ERROR "Environment variable \"ENV{x+(y)}\" does not work.") +ENDIF() + +# Make directories test +FILE(MAKE_DIRECTORY + "${CMAKE_CURRENT_BINARY_DIR}/Includes" + "${CMAKE_CURRENT_BINARY_DIR}/Directory1" + "${CMAKE_CURRENT_BINARY_DIR}/Directory2" + ) + +# Write results to the file (test write file) +SET(file "${CMAKE_CURRENT_BINARY_DIR}/Includes/Values.h") +FILE(WRITE "${file}" "/* this file is generated */\n") +FOREACH(var + rmvar + rmallvar + rrepvar + repvar + relpath + substringres + lengthres + nceqvar + ceqvar + cneqvar + ncneqvar + nclvar + clvar + cgvar + ncgvar + savar + tuvar + tlvar) + FILE(APPEND "${file}" "#define ${var} \"${${var}}\"\n") +ENDFOREACH(var) + +# Verify that the file was created recently. +IF(NOT "${file}" IS_NEWER_THAN "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in") + MESSAGE(FATAL_ERROR "IF(FILE_IS_NEWER) does not seem to work.") +ENDIF(NOT "${file}" IS_NEWER_THAN "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in") + +# Test configuration of the string +SET(TEST_DEFINED 123) +SET(TEST_NOT_DEFINED) +STRING(CONFIGURE "${infile}" infile+-/out @ONLY) +SET(infile "${infile+-/out}") + +# Write include file to a file +STRING(REGEX REPLACE "includefile" "${file}" outfile "${infile}") +FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/OutputFile.h-tmp" "${outfile}") +FILE(RENAME "${CMAKE_CURRENT_BINARY_DIR}/OutputFile.h-tmp" + "${CMAKE_CURRENT_BINARY_DIR}/OutputFile.h") + +# Test file copy with relative paths +FILE(COPY . + DESTINATION src + FILE_PERMISSIONS OWNER_READ # test no OWNER_WRITE + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + FILES_MATCHING PATTERN *.cxx # Only copy the main source file + REGEX /src$ EXCLUDE # Block recursion for in-source build + ) + +# Test file glob +FILE(GLOB_RECURSE src_files "${CMAKE_CURRENT_SOURCE_DIR}/*") +MESSAGE("Files in ${CMAKE_CURRENT_SOURCE_DIR} are ${src_files}") +SET(expr "${CMAKE_CURRENT_BINARY_DIR}/src/[sS][!a-su-zA-Z0-9][^a-qs-zA-Z0-9]ing?ile*.cxx") +MESSAGE("Glob expression is [${expr}].") +FILE(GLOB src_files "${expr}") +MESSAGE("Globbed files [${src_files}].") +ADD_EXECUTABLE(StringFileTest ${src_files}) + +SET(expr "${CMAKE_CURRENT_SOURCE_DIR}/../*.cxx") +FILE(GLOB_RECURSE rel_src_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/.." "${expr}") +MESSAGE("Globbed files [${rel_src_files}].") + +# Test FOREACH range +MESSAGE("Cheack if FOREACH with RANGE works") +MACRO(TEST_RANGE ARGS CHECK) + SET(r) + FOREACH(a RANGE ${ARGS}) + SET(r ${r} ${a}) + ENDFOREACH(a) + MESSAGE("FOREACH with RANGE ${ARGS} produces ${r}") + IF("x${r}x" MATCHES "^x${CHECK}x$") + ELSE("x${r}x" MATCHES "^x${CHECK}x$") + MESSAGE(SEND_ERROR "The range resulted in: ${r} should be ${CHECK}") + ENDIF("x${r}x" MATCHES "^x${CHECK}x$") +ENDMACRO(TEST_RANGE) +TEST_RANGE("5" "0;1;2;3;4;5") +TEST_RANGE("3;5" "3;4;5") +TEST_RANGE("5;3" "5;4;3") +TEST_RANGE("3;10;2" "3;5;7;9") +TEST_RANGE("10;0;-3" "10;7;4;1") + +# Test FOREACH IN signature +set(list1 "" a "") +set(list2 a "" b) +set(var_) +set(var_a) +set(var_b) +foreach(item IN LISTS list1 list2 ITEMS "" a "") + set(var_${item} "${var_${item}}x") +endforeach(item) +if(NOT "${var_}" STREQUAL "xxxxx") + message(FATAL_ERROR "count incorrect for \"\": [${var_}]") +endif() +if(NOT "${var_a}" STREQUAL "xxx") + message(FATAL_ERROR "count incorrect for \"a\": [${var_a}]") +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/StringFileTest/InputFile.h.in b/Tests/StringFileTest/InputFile.h.in new file mode 100644 index 000000000..3e70a36e8 --- /dev/null +++ b/Tests/StringFileTest/InputFile.h.in @@ -0,0 +1,38 @@ +#include "includefile" + +/* This should be configured to a define. */ +#cmakedefine TEST_DEFINED @TEST_DEFINED@ +/* This should be configured to a commented undef with the curlies in place */ +#cmakedefine TEST_NOT_DEFINED ${TEST_NOT_DEFINED} + +/* This complicated line should be configured unchanged: */ +static const char* configvar = +"@$@$junk =~ s/#$xyz#/$foo_bar{$wibble}->{$xyz}/;@@"; + +int CheckMethod(const char* var, const char* val ) +{ + if ( !var ) + { + printf("Var not specified\n"); + return 1; + } + if ( !val ) + { + printf("Val not specified\n"); + return 1; + } + if ( strcmp(var, val) != 0) + { + printf("Var (%s) and Val (%s) are not the same...\n", var, val); + return 1; + } +#if !defined(TEST_DEFINED) || TEST_DEFINED != 123 + printf("TEST_DEFINED is not defined to 123\n"); + return 1; +#elif defined(TEST_NOT_DEFINED) + printf("TEST_NOT_DEFINED is defined\n"); + return 1; +#else + return 0; +#endif +} diff --git a/Tests/StringFileTest/StringFile.cxx b/Tests/StringFileTest/StringFile.cxx new file mode 100644 index 000000000..609ebaf20 --- /dev/null +++ b/Tests/StringFileTest/StringFile.cxx @@ -0,0 +1,31 @@ +#include <stdio.h> +#include <string.h> +#include "OutputFile.h" + +int main(int, char*[]) +{ + int res = 0; + + res += CheckMethod(rmvar, "CMake"); + res += CheckMethod(rmallvar, "CMake;cmake;CMake"); + res += CheckMethod(rrepvar, "People should use CMake and CMake"); + res += CheckMethod(repvar, "People should use CMake"); + res += CheckMethod(substringres, "Everybody should use CMake"); + res += CheckMethod(nceqvar, "0"); + res += CheckMethod(lengthres, "26"); + res += CheckMethod(ceqvar, "1"); + res += CheckMethod(cneqvar, "1"); + res += CheckMethod(ncneqvar, "0"); + res += CheckMethod(nclvar, "0"); + res += CheckMethod(clvar, "1"); + res += CheckMethod(cgvar, "1"); + res += CheckMethod(ncgvar, "0"); + res += CheckMethod(savar, "Cmake"); + res += CheckMethod(tuvar, "CMAKE"); + res += CheckMethod(tlvar, "cmake"); + res += CheckMethod(relpath, "../../X11R6/bin/xnest"); + res += CheckMethod(configvar, + "@$@$junk =~ s/#$xyz#/$foo_bar{$wibble}->{$xyz}/;@@"); + + return res; +} diff --git a/Tests/StringFileTest/main.ihx b/Tests/StringFileTest/main.ihx new file mode 100644 index 000000000..c1d1dd2b3 --- /dev/null +++ b/Tests/StringFileTest/main.ihx @@ -0,0 +1,21 @@ +:03000000020003F8 +:03005C0002005F40 +:05005F0012006480FEA8 +:010064002279 +:0E006900494E464F3A636F6D70696C65725B6D +:0A007700534443432D4845585D00F3 +:06003200E478FFF6D8FDA2 +:080010007900E94400601B7A4D +:0500180000900081785A +:03001D000075A0CB +:0A00200000E493F2A308B800020503 +:08002A00A0D9F4DAF275A0FF81 +:080038007800E84400600A7939 +:030040000075A0A8 +:0600430000E4F309D8FC03 +:080049007800E84400600C7926 +:0B00510000900000E4F0A3D8FCD9FAF6 +:03000300758107FD +:0A000600120065E582600302005F4E +:04006500758200227E +:00000001FF diff --git a/Tests/StringFileTest/main.srec b/Tests/StringFileTest/main.srec new file mode 100644 index 000000000..bd47c29cc --- /dev/null +++ b/Tests/StringFileTest/main.srec @@ -0,0 +1,21 @@ +S1060000020003F4 +S106005C02005F3C +S108005F12006480FEA4 +S10400642275 +S1110069494E464F3A636F6D70696C65725B69 +S10E0077534443432D535245435D00A6 +S1090032E478FFF6D8FD9E +S10B00107900E94400601B7A49 +S1080018009000827855 +S106001D0075A0C7 +S10D002000E493F2A308B8000205FF +S10B002AA0D9F4DAF275A0FF7D +S10B00387800E84400600A7935 +S10600400075A0A4 +S109004300E4F309D8FCFF +S10B00497800E84400600C7922 +S10E005100900000E4F0A3D8FCD9FAF2 +S1060003758107F9 +S10D0006120065E582600302005F4A +S1070065758200227A +S9030000FC diff --git a/Tests/StringFileTest/test.bin b/Tests/StringFileTest/test.bin Binary files differnew file mode 100644 index 000000000..18d62a144 --- /dev/null +++ b/Tests/StringFileTest/test.bin diff --git a/Tests/SubDir/AnotherSubdir/pair+int.int.c b/Tests/SubDir/AnotherSubdir/pair+int.int.c new file mode 100644 index 000000000..b7a623781 --- /dev/null +++ b/Tests/SubDir/AnotherSubdir/pair+int.int.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void pair_stuff() +{ + printf("Placeholder for a strange file in subdirectory\n"); +} diff --git a/Tests/SubDir/AnotherSubdir/pair_int.int.c b/Tests/SubDir/AnotherSubdir/pair_int.int.c new file mode 100644 index 000000000..b7a623781 --- /dev/null +++ b/Tests/SubDir/AnotherSubdir/pair_int.int.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void pair_stuff() +{ + printf("Placeholder for a strange file in subdirectory\n"); +} diff --git a/Tests/SubDir/AnotherSubdir/secondone.c b/Tests/SubDir/AnotherSubdir/secondone.c new file mode 100644 index 000000000..3e9e5afe6 --- /dev/null +++ b/Tests/SubDir/AnotherSubdir/secondone.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void secondone() +{ + printf("Hello again\n"); +} diff --git a/Tests/SubDir/AnotherSubdir/testfromsubdir.c b/Tests/SubDir/AnotherSubdir/testfromsubdir.c new file mode 100644 index 000000000..34b6e7a88 --- /dev/null +++ b/Tests/SubDir/AnotherSubdir/testfromsubdir.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void secondone(); +void pair_stuff(); +void vcl_stuff(); + +int main() +{ + printf("Hello from subdirectory\n"); + secondone(); + pair_stuff(); + vcl_stuff(); + return 0; +} diff --git a/Tests/SubDir/CMakeLists.txt b/Tests/SubDir/CMakeLists.txt new file mode 100644 index 000000000..9cfbe25ce --- /dev/null +++ b/Tests/SubDir/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(SUBDIR) +SUBDIRS(Executable EXCLUDE_FROM_ALL Examples) +WRITE_FILE(${SUBDIR_BINARY_DIR}/ShouldBeHere "This file should exist.") +#WATCOM WMAKE does not support + in the name of a file! +IF(WATCOM) + SET(PLUS_NAME_FILES + AnotherSubdir/pair_int.int.c + vcl_algorithm_vcl_pair_double.foo.c) +ELSE(WATCOM) + SET(PLUS_NAME_FILES + AnotherSubdir/pair+int.int.c + vcl_algorithm+vcl_pair+double.foo.c) +ENDIF(WATCOM) + +ADD_EXECUTABLE(TestFromSubdir + AnotherSubdir/testfromsubdir.c + AnotherSubdir/secondone + ${PLUS_NAME_FILES} + ) + +AUX_SOURCE_DIRECTORY(ThirdSubDir SOURCES) +IF(WATCOM) + FOREACH(f ${SOURCES}) + IF("${f}" STREQUAL "ThirdSubDir/pair+int.int1.c") + ELSE("${f}" STREQUAL "ThirdSubDir/pair+int.int1.c") + SET(SOURCES2 ${f} ${SOURCES2}) + ENDIF("${f}" STREQUAL "ThirdSubDir/pair+int.int1.c") + ENDFOREACH(f) + SET(SOURCES ${SOURCES2}) + SET(SOURCES ${SOURCES} + vcl_algorithm_vcl_pair_double.foo.c) +ELSE(WATCOM) + FOREACH(f ${SOURCES}) + IF("${f}" STREQUAL "ThirdSubDir/pair_int.int1.c") + ELSE("${f}" STREQUAL "ThirdSubDir/pair_int.int1.c") + SET(SOURCES2 ${f} ${SOURCES2}) + MESSAGE("${f}") + ENDIF("${f}" STREQUAL "ThirdSubDir/pair_int.int1.c") + ENDFOREACH(f) + SET(SOURCES ${SOURCES2}) + SET(SOURCES ${SOURCES} + vcl_algorithm+vcl_pair+double.foo.c) +ENDIF(WATCOM) +MESSAGE("Sources: ${SOURCES}") +ADD_EXECUTABLE(TestWithAuxSourceDir ${SOURCES}) diff --git a/Tests/SubDir/Examples/CMakeLists.txt b/Tests/SubDir/Examples/CMakeLists.txt new file mode 100644 index 000000000..b0f1e896c --- /dev/null +++ b/Tests/SubDir/Examples/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(Examples) +SUBDIRS(example1 example2) diff --git a/Tests/SubDir/Examples/example1/CMakeLists.txt b/Tests/SubDir/Examples/example1/CMakeLists.txt new file mode 100644 index 000000000..303618321 --- /dev/null +++ b/Tests/SubDir/Examples/example1/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(example1) +ADD_EXECUTABLE(example1 example1.cxx) + +ADD_CUSTOM_COMMAND(TARGET example1 POST_BUILD + COMMAND "${CMAKE_COMMAND}" ARGS -E remove ${SUBDIR_BINARY_DIR}/ShouldBeHere + COMMENT "Remove marker file that should exist because this should not be run") diff --git a/Tests/SubDir/Examples/example1/example1.cxx b/Tests/SubDir/Examples/example1/example1.cxx new file mode 100644 index 000000000..3c4819415 --- /dev/null +++ b/Tests/SubDir/Examples/example1/example1.cxx @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main() +{ + printf("example1\n"); + return 0; +} diff --git a/Tests/SubDir/Examples/example2/CMakeLists.txt b/Tests/SubDir/Examples/example2/CMakeLists.txt new file mode 100644 index 000000000..19a537686 --- /dev/null +++ b/Tests/SubDir/Examples/example2/CMakeLists.txt @@ -0,0 +1,2 @@ +PROJECT(example2) +ADD_EXECUTABLE(example2 example2.cxx) diff --git a/Tests/SubDir/Examples/example2/example2.cxx b/Tests/SubDir/Examples/example2/example2.cxx new file mode 100644 index 000000000..60ef3c940 --- /dev/null +++ b/Tests/SubDir/Examples/example2/example2.cxx @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main() +{ + printf("example2\n"); + return 0; +} diff --git a/Tests/SubDir/Executable/CMakeLists.txt b/Tests/SubDir/Executable/CMakeLists.txt new file mode 100644 index 000000000..d679168d8 --- /dev/null +++ b/Tests/SubDir/Executable/CMakeLists.txt @@ -0,0 +1 @@ +ADD_EXECUTABLE(test test.cxx) diff --git a/Tests/SubDir/Executable/test.cxx b/Tests/SubDir/Executable/test.cxx new file mode 100644 index 000000000..c528fb166 --- /dev/null +++ b/Tests/SubDir/Executable/test.cxx @@ -0,0 +1,49 @@ +#include <stdio.h> +#include <stdlib.h> +#ifdef _WIN32 +#include <io.h> +#else +#include <unistd.h> +#endif + +// return true if the file exists +int FileExists(const char* filename) +{ +#ifdef _MSC_VER +# define access _access +#endif +#ifndef F_OK +#define F_OK 0 +#endif + if ( access(filename, F_OK) != 0 ) + { + return false; + } + else + { + return true; + } +} + + +int main(int ac, char** av) +{ + if(ac <= 1) + { + printf("Usage: %s <file>\n", av[0]); + return 1; + } + if(!FileExists(av[1])) + { + printf("Missing file %s\n", av[1]); + return 1; + } + if(FileExists(av[2])) + { + printf("File %s should be in subdirectory\n", av[2]); + return 1; + } + printf("%s is not there! Good.", av[2]); + printf("%s is there! Good.", av[1]); + return 0; +} diff --git a/Tests/SubDir/ThirdSubDir/pair+int.int1.c b/Tests/SubDir/ThirdSubDir/pair+int.int1.c new file mode 100644 index 000000000..b7a623781 --- /dev/null +++ b/Tests/SubDir/ThirdSubDir/pair+int.int1.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void pair_stuff() +{ + printf("Placeholder for a strange file in subdirectory\n"); +} diff --git a/Tests/SubDir/ThirdSubDir/pair_int.int1.c b/Tests/SubDir/ThirdSubDir/pair_int.int1.c new file mode 100644 index 000000000..b7a623781 --- /dev/null +++ b/Tests/SubDir/ThirdSubDir/pair_int.int1.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void pair_stuff() +{ + printf("Placeholder for a strange file in subdirectory\n"); +} diff --git a/Tests/SubDir/ThirdSubDir/pair_p_int.int1.c b/Tests/SubDir/ThirdSubDir/pair_p_int.int1.c new file mode 100644 index 000000000..95a66eee6 --- /dev/null +++ b/Tests/SubDir/ThirdSubDir/pair_p_int.int1.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void pair_p_stuff() +{ + printf("Placeholder for another strange file in subdirectory\n"); +} diff --git a/Tests/SubDir/ThirdSubDir/testfromauxsubdir.c b/Tests/SubDir/ThirdSubDir/testfromauxsubdir.c new file mode 100644 index 000000000..d1620845f --- /dev/null +++ b/Tests/SubDir/ThirdSubDir/testfromauxsubdir.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +void secondone(); +void pair_stuff(); +void pair_p_stuff(); +void vcl_stuff(); + +int main() +{ + printf("Hello from subdirectory\n"); + secondone(); + pair_stuff(); + pair_p_stuff(); + vcl_stuff(); + return 0; +} diff --git a/Tests/SubDir/ThirdSubDir/thirdone.c b/Tests/SubDir/ThirdSubDir/thirdone.c new file mode 100644 index 000000000..3e9e5afe6 --- /dev/null +++ b/Tests/SubDir/ThirdSubDir/thirdone.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void secondone() +{ + printf("Hello again\n"); +} diff --git a/Tests/SubDir/vcl_algorithm+vcl_pair+double.foo.c b/Tests/SubDir/vcl_algorithm+vcl_pair+double.foo.c new file mode 100644 index 000000000..a0c60f75a --- /dev/null +++ b/Tests/SubDir/vcl_algorithm+vcl_pair+double.foo.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void vcl_stuff() +{ + printf("Placeholder for a file with strange name\n"); +} diff --git a/Tests/SubDir/vcl_algorithm_vcl_pair_double.foo.c b/Tests/SubDir/vcl_algorithm_vcl_pair_double.foo.c new file mode 100644 index 000000000..a0c60f75a --- /dev/null +++ b/Tests/SubDir/vcl_algorithm_vcl_pair_double.foo.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void vcl_stuff() +{ + printf("Placeholder for a file with strange name\n"); +} diff --git a/Tests/SubDirSpaces/Another Subdir/pair+int.int.c b/Tests/SubDirSpaces/Another Subdir/pair+int.int.c new file mode 100644 index 000000000..b7a623781 --- /dev/null +++ b/Tests/SubDirSpaces/Another Subdir/pair+int.int.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void pair_stuff() +{ + printf("Placeholder for a strange file in subdirectory\n"); +} diff --git a/Tests/SubDirSpaces/Another Subdir/pair_int.int.c b/Tests/SubDirSpaces/Another Subdir/pair_int.int.c new file mode 100644 index 000000000..b7a623781 --- /dev/null +++ b/Tests/SubDirSpaces/Another Subdir/pair_int.int.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void pair_stuff() +{ + printf("Placeholder for a strange file in subdirectory\n"); +} diff --git a/Tests/SubDirSpaces/Another Subdir/secondone.c b/Tests/SubDirSpaces/Another Subdir/secondone.c new file mode 100644 index 000000000..3e9e5afe6 --- /dev/null +++ b/Tests/SubDirSpaces/Another Subdir/secondone.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void secondone() +{ + printf("Hello again\n"); +} diff --git a/Tests/SubDirSpaces/Another Subdir/testfromsubdir.c b/Tests/SubDirSpaces/Another Subdir/testfromsubdir.c new file mode 100644 index 000000000..34b6e7a88 --- /dev/null +++ b/Tests/SubDirSpaces/Another Subdir/testfromsubdir.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void secondone(); +void pair_stuff(); +void vcl_stuff(); + +int main() +{ + printf("Hello from subdirectory\n"); + secondone(); + pair_stuff(); + vcl_stuff(); + return 0; +} diff --git a/Tests/SubDirSpaces/CMakeLists.txt b/Tests/SubDirSpaces/CMakeLists.txt new file mode 100644 index 000000000..879530b56 --- /dev/null +++ b/Tests/SubDirSpaces/CMakeLists.txt @@ -0,0 +1,77 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(SUBDIR) + +# Some systems do not seem to support rpath with spaces. +IF("${CMAKE_SYSTEM}" MATCHES "IRIX|QNX") + SET(CMAKE_SKIP_BUILD_RPATH 1) +ENDIF("${CMAKE_SYSTEM}" MATCHES "IRIX|QNX") + +# be able to see output from make on dashboards +SET(CMAKE_VERBOSE_MAKEFILE 1) +message("${CMAKE_MAKE_PROGRAM}") +set(CMAKE_PAREN TRUE) +IF("${CMAKE_MAKE_PROGRAM}" MATCHES "wmake") + message("wmake does not support () in path") + set(CMAKE_PAREN FALSE) +elseif("${CMAKE_MAKE_PROGRAM}" MATCHES "make") + execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} no_such_target --version + RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out) + if("${out}" MATCHES "GNU Make 3.82") + # GNU Make 3.82 fails on parens: http://savannah.gnu.org/bugs/?30612 + message(STATUS "GNU Make 3.82 sometimes fails on () in path") + set(CMAKE_PAREN FALSE) + endif() +endif() + +IF(CMAKE_PAREN) + ADD_DEFINITIONS(-DCMAKE_PAREN=1) + SUBDIRS("Executable Sources" "Some(x86) Sources" EXCLUDE_FROM_ALL "Some Examples") +ELSE(CMAKE_PAREN) + SUBDIRS("Executable Sources" EXCLUDE_FROM_ALL "Some Examples") +ENDIF(CMAKE_PAREN) + +WRITE_FILE(${SUBDIR_BINARY_DIR}/ShouldBeHere "This file should exist.") +#WATCOM WMAKE does not support + in the name of a file! +IF(WATCOM) + SET(PLUS_NAME_FILES + "Another Subdir/pair_int.int.c" + vcl_algorithm_vcl_pair_double.foo.c) +ELSE(WATCOM) + SET(PLUS_NAME_FILES + "Another Subdir/pair+int.int.c" + vcl_algorithm+vcl_pair+double.foo.c) +ENDIF(WATCOM) + +ADD_EXECUTABLE(TestFromSubdir + "Another Subdir/testfromsubdir.c" + "Another Subdir/secondone" + ${PLUS_NAME_FILES} + ) + +AUX_SOURCE_DIRECTORY(ThirdSubDir SOURCES) +IF(WATCOM) + FOREACH(f ${SOURCES}) + IF("${f}" STREQUAL "ThirdSubDir/pair+int.int1.c") + ELSE("${f}" STREQUAL "ThirdSubDir/pair+int.int1.c") + SET(SOURCES2 ${f} ${SOURCES2}) + ENDIF("${f}" STREQUAL "ThirdSubDir/pair+int.int1.c") + ENDFOREACH(f) + SET(SOURCES ${SOURCES2}) + SET(SOURCES ${SOURCES} + vcl_algorithm_vcl_pair_double.foo.c) +ELSE(WATCOM) + FOREACH(f ${SOURCES}) + IF("${f}" STREQUAL "ThirdSubDir/pair_int.int1.c") + ELSE("${f}" STREQUAL "ThirdSubDir/pair_int.int1.c") + SET(SOURCES2 ${f} ${SOURCES2}) + ENDIF("${f}" STREQUAL "ThirdSubDir/pair_int.int1.c") + ENDFOREACH(f) + SET(SOURCES ${SOURCES2}) + SET(SOURCES ${SOURCES} + vcl_algorithm+vcl_pair+double.foo.c) +ENDIF(WATCOM) +ADD_EXECUTABLE(TestWithAuxSourceDir ${SOURCES}) +IF(CMAKE_PAREN) + target_link_libraries(TestWithAuxSourceDir testOddPath) +ENDIF(CMAKE_PAREN) + diff --git a/Tests/SubDirSpaces/Executable Sources/CMakeLists.txt b/Tests/SubDirSpaces/Executable Sources/CMakeLists.txt new file mode 100644 index 000000000..d679168d8 --- /dev/null +++ b/Tests/SubDirSpaces/Executable Sources/CMakeLists.txt @@ -0,0 +1 @@ +ADD_EXECUTABLE(test test.cxx) diff --git a/Tests/SubDirSpaces/Executable Sources/test.cxx b/Tests/SubDirSpaces/Executable Sources/test.cxx new file mode 100644 index 000000000..c528fb166 --- /dev/null +++ b/Tests/SubDirSpaces/Executable Sources/test.cxx @@ -0,0 +1,49 @@ +#include <stdio.h> +#include <stdlib.h> +#ifdef _WIN32 +#include <io.h> +#else +#include <unistd.h> +#endif + +// return true if the file exists +int FileExists(const char* filename) +{ +#ifdef _MSC_VER +# define access _access +#endif +#ifndef F_OK +#define F_OK 0 +#endif + if ( access(filename, F_OK) != 0 ) + { + return false; + } + else + { + return true; + } +} + + +int main(int ac, char** av) +{ + if(ac <= 1) + { + printf("Usage: %s <file>\n", av[0]); + return 1; + } + if(!FileExists(av[1])) + { + printf("Missing file %s\n", av[1]); + return 1; + } + if(FileExists(av[2])) + { + printf("File %s should be in subdirectory\n", av[2]); + return 1; + } + printf("%s is not there! Good.", av[2]); + printf("%s is there! Good.", av[1]); + return 0; +} diff --git a/Tests/SubDirSpaces/Executable/CMakeLists.txt b/Tests/SubDirSpaces/Executable/CMakeLists.txt new file mode 100644 index 000000000..d679168d8 --- /dev/null +++ b/Tests/SubDirSpaces/Executable/CMakeLists.txt @@ -0,0 +1 @@ +ADD_EXECUTABLE(test test.cxx) diff --git a/Tests/SubDirSpaces/Executable/test.cxx b/Tests/SubDirSpaces/Executable/test.cxx new file mode 100644 index 000000000..c528fb166 --- /dev/null +++ b/Tests/SubDirSpaces/Executable/test.cxx @@ -0,0 +1,49 @@ +#include <stdio.h> +#include <stdlib.h> +#ifdef _WIN32 +#include <io.h> +#else +#include <unistd.h> +#endif + +// return true if the file exists +int FileExists(const char* filename) +{ +#ifdef _MSC_VER +# define access _access +#endif +#ifndef F_OK +#define F_OK 0 +#endif + if ( access(filename, F_OK) != 0 ) + { + return false; + } + else + { + return true; + } +} + + +int main(int ac, char** av) +{ + if(ac <= 1) + { + printf("Usage: %s <file>\n", av[0]); + return 1; + } + if(!FileExists(av[1])) + { + printf("Missing file %s\n", av[1]); + return 1; + } + if(FileExists(av[2])) + { + printf("File %s should be in subdirectory\n", av[2]); + return 1; + } + printf("%s is not there! Good.", av[2]); + printf("%s is there! Good.", av[1]); + return 0; +} diff --git a/Tests/SubDirSpaces/Some Examples/CMakeLists.txt b/Tests/SubDirSpaces/Some Examples/CMakeLists.txt new file mode 100644 index 000000000..b0f1e896c --- /dev/null +++ b/Tests/SubDirSpaces/Some Examples/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(Examples) +SUBDIRS(example1 example2) diff --git a/Tests/SubDirSpaces/Some Examples/example1/CMakeLists.txt b/Tests/SubDirSpaces/Some Examples/example1/CMakeLists.txt new file mode 100644 index 000000000..303618321 --- /dev/null +++ b/Tests/SubDirSpaces/Some Examples/example1/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(example1) +ADD_EXECUTABLE(example1 example1.cxx) + +ADD_CUSTOM_COMMAND(TARGET example1 POST_BUILD + COMMAND "${CMAKE_COMMAND}" ARGS -E remove ${SUBDIR_BINARY_DIR}/ShouldBeHere + COMMENT "Remove marker file that should exist because this should not be run") diff --git a/Tests/SubDirSpaces/Some Examples/example1/example1.cxx b/Tests/SubDirSpaces/Some Examples/example1/example1.cxx new file mode 100644 index 000000000..3c4819415 --- /dev/null +++ b/Tests/SubDirSpaces/Some Examples/example1/example1.cxx @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main() +{ + printf("example1\n"); + return 0; +} diff --git a/Tests/SubDirSpaces/Some Examples/example2/CMakeLists.txt b/Tests/SubDirSpaces/Some Examples/example2/CMakeLists.txt new file mode 100644 index 000000000..19a537686 --- /dev/null +++ b/Tests/SubDirSpaces/Some Examples/example2/CMakeLists.txt @@ -0,0 +1,2 @@ +PROJECT(example2) +ADD_EXECUTABLE(example2 example2.cxx) diff --git a/Tests/SubDirSpaces/Some Examples/example2/example2.cxx b/Tests/SubDirSpaces/Some Examples/example2/example2.cxx new file mode 100644 index 000000000..60ef3c940 --- /dev/null +++ b/Tests/SubDirSpaces/Some Examples/example2/example2.cxx @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main() +{ + printf("example2\n"); + return 0; +} diff --git a/Tests/SubDirSpaces/Some(x86) Sources/CMakeLists.txt b/Tests/SubDirSpaces/Some(x86) Sources/CMakeLists.txt new file mode 100644 index 000000000..cfba9169c --- /dev/null +++ b/Tests/SubDirSpaces/Some(x86) Sources/CMakeLists.txt @@ -0,0 +1 @@ +add_library(testOddPath test.c) diff --git a/Tests/SubDirSpaces/Some(x86) Sources/test.c b/Tests/SubDirSpaces/Some(x86) Sources/test.c new file mode 100644 index 000000000..66568d4c2 --- /dev/null +++ b/Tests/SubDirSpaces/Some(x86) Sources/test.c @@ -0,0 +1,3 @@ +void testOdd() +{ +} diff --git a/Tests/SubDirSpaces/ThirdSubDir/pair+int.int1.c b/Tests/SubDirSpaces/ThirdSubDir/pair+int.int1.c new file mode 100644 index 000000000..b7a623781 --- /dev/null +++ b/Tests/SubDirSpaces/ThirdSubDir/pair+int.int1.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void pair_stuff() +{ + printf("Placeholder for a strange file in subdirectory\n"); +} diff --git a/Tests/SubDirSpaces/ThirdSubDir/pair_int.int1.c b/Tests/SubDirSpaces/ThirdSubDir/pair_int.int1.c new file mode 100644 index 000000000..b7a623781 --- /dev/null +++ b/Tests/SubDirSpaces/ThirdSubDir/pair_int.int1.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void pair_stuff() +{ + printf("Placeholder for a strange file in subdirectory\n"); +} diff --git a/Tests/SubDirSpaces/ThirdSubDir/pair_p_int.int1.c b/Tests/SubDirSpaces/ThirdSubDir/pair_p_int.int1.c new file mode 100644 index 000000000..95a66eee6 --- /dev/null +++ b/Tests/SubDirSpaces/ThirdSubDir/pair_p_int.int1.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void pair_p_stuff() +{ + printf("Placeholder for another strange file in subdirectory\n"); +} diff --git a/Tests/SubDirSpaces/ThirdSubDir/testfromauxsubdir.c b/Tests/SubDirSpaces/ThirdSubDir/testfromauxsubdir.c new file mode 100644 index 000000000..fa6c33ced --- /dev/null +++ b/Tests/SubDirSpaces/ThirdSubDir/testfromauxsubdir.c @@ -0,0 +1,21 @@ +#include <stdio.h> + +void secondone(); +void pair_stuff(); +void pair_p_stuff(); +void vcl_stuff(); +#ifdef CMAKE_PAREN +void testOdd(); +#endif +int main() +{ + printf("Hello from subdirectory\n"); + secondone(); +#ifdef CMAKE_PAREN + testOdd(); +#endif + pair_stuff(); + pair_p_stuff(); + vcl_stuff(); + return 0; +} diff --git a/Tests/SubDirSpaces/ThirdSubDir/thirdone.c b/Tests/SubDirSpaces/ThirdSubDir/thirdone.c new file mode 100644 index 000000000..3e9e5afe6 --- /dev/null +++ b/Tests/SubDirSpaces/ThirdSubDir/thirdone.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void secondone() +{ + printf("Hello again\n"); +} diff --git a/Tests/SubDirSpaces/vcl_algorithm+vcl_pair+double.foo.c b/Tests/SubDirSpaces/vcl_algorithm+vcl_pair+double.foo.c new file mode 100644 index 000000000..a0c60f75a --- /dev/null +++ b/Tests/SubDirSpaces/vcl_algorithm+vcl_pair+double.foo.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void vcl_stuff() +{ + printf("Placeholder for a file with strange name\n"); +} diff --git a/Tests/SubDirSpaces/vcl_algorithm_vcl_pair_double.foo.c b/Tests/SubDirSpaces/vcl_algorithm_vcl_pair_double.foo.c new file mode 100644 index 000000000..a0c60f75a --- /dev/null +++ b/Tests/SubDirSpaces/vcl_algorithm_vcl_pair_double.foo.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void vcl_stuff() +{ + printf("Placeholder for a file with strange name\n"); +} diff --git a/Tests/SubProject/CMakeLists.txt b/Tests/SubProject/CMakeLists.txt new file mode 100644 index 000000000..b669621df --- /dev/null +++ b/Tests/SubProject/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required (VERSION 2.6) +project(SubProject) +message("${CMAKE_IMPORT_LIBRARY_SUFFIX}") +add_library(bar bar.cxx) +add_executable(car car.cxx) +add_subdirectory(foo) diff --git a/Tests/SubProject/bar.cxx b/Tests/SubProject/bar.cxx new file mode 100644 index 000000000..c3f6a181a --- /dev/null +++ b/Tests/SubProject/bar.cxx @@ -0,0 +1,4 @@ +int bar() +{ + return 10; +} diff --git a/Tests/SubProject/car.cxx b/Tests/SubProject/car.cxx new file mode 100644 index 000000000..95de4a327 --- /dev/null +++ b/Tests/SubProject/car.cxx @@ -0,0 +1,6 @@ +int main(int ac, char** av) +{ + (void) ac; + (void) av; + return 0; +} diff --git a/Tests/SubProject/foo/CMakeLists.txt b/Tests/SubProject/foo/CMakeLists.txt new file mode 100644 index 000000000..011178b26 --- /dev/null +++ b/Tests/SubProject/foo/CMakeLists.txt @@ -0,0 +1,3 @@ +project(foo) +add_executable(foo foo.cxx) +target_link_libraries(foo bar) diff --git a/Tests/SubProject/foo/foo.cxx b/Tests/SubProject/foo/foo.cxx new file mode 100644 index 000000000..68fa36376 --- /dev/null +++ b/Tests/SubProject/foo/foo.cxx @@ -0,0 +1,15 @@ +int bar(); +#include <stdio.h> + +int main(int ac, char** av) +{ + (void)ac; + (void)av; + int ret = bar(); + printf("bar = %d\n", ret); + if(ret == 10) + { + return 0; + } + return -1; +} diff --git a/Tests/SwigTest/CMakeLists.txt b/Tests/SwigTest/CMakeLists.txt new file mode 100644 index 000000000..5a8e61922 --- /dev/null +++ b/Tests/SwigTest/CMakeLists.txt @@ -0,0 +1,50 @@ +SET(language "python") + +cmake_minimum_required (VERSION 2.6) + +PROJECT(example_${language}_class) + +FIND_PACKAGE(SWIG REQUIRED) +INCLUDE(${SWIG_USE_FILE}) + +IF(${language} MATCHES python) + FIND_PACKAGE(PythonLibs) + INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) + SET(SWIG_LANG_LIBRARIES ${PYTHON_LIBRARIES}) +ENDIF(${language} MATCHES python) +IF(${language} MATCHES perl) + FIND_PACKAGE(PerlLibs) + INCLUDE_DIRECTORIES(${PERL_INCLUDE_PATH}) + ADD_DEFINITIONS(${PERL_EXTRA_C_FLAGS}) + SET(SWIG_LANG_LIBRARIES ${PERL_LIBRARY}) +ENDIF(${language} MATCHES perl) +IF(${language} MATCHES tcl) + FIND_PACKAGE(TCL) + INCLUDE_DIRECTORIES(${TCL_INCLUDE_PATH}) + SET(SWIG_LANG_LIBRARIES ${TCL_LIBRARY}) +ENDIF(${language} MATCHES tcl) +IF(${language} MATCHES ruby) + FIND_PACKAGE(Ruby) + INCLUDE_DIRECTORIES(${RUBY_INCLUDE_PATH}) + SET(SWIG_LANG_LIBRARIES ${RUBY_LIBRARY}) +ENDIF(${language} MATCHES ruby) +IF(${language} MATCHES php4) + FIND_PACKAGE(PHP4) + INCLUDE_DIRECTORIES(${PHP4_INCLUDE_PATH}) + SET(SWIG_LANG_LIBRARIES ${PHP4_LIBRARY}) +ENDIF(${language} MATCHES php4) +IF(${language} MATCHES pike) + FIND_PACKAGE(Pike) + INCLUDE_DIRECTORIES(${PIKE_INCLUDE_PATH}) + SET(SWIG_LANG_LIBRARIES ${PIKE_LIBRARY}) +ENDIF(${language} MATCHES pike) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +SET(CMAKE_SWIG_FLAGS "") + +SET_SOURCE_FILES_PROPERTIES(example.i PROPERTIES CPLUSPLUS ON) +SET_SOURCE_FILES_PROPERTIES(example.i PROPERTIES SWIG_FLAGS "-includeall") +SWIG_ADD_MODULE(example "${language}" + example.i example.cxx) +SWIG_LINK_LIBRARIES(example ${SWIG_LANG_LIBRARIES}) diff --git a/Tests/SwigTest/example.cxx b/Tests/SwigTest/example.cxx new file mode 100644 index 000000000..1e8e203dd --- /dev/null +++ b/Tests/SwigTest/example.cxx @@ -0,0 +1,28 @@ +/* File : example.c */ + +#include "example.h" +#define M_PI 3.14159265358979323846 + +/* Move the shape to a new location */ +void Shape::move(double dx, double dy) { + x += dx; + y += dy; +} + +int Shape::nshapes = 0; + +double Circle::area(void) { + return M_PI*radius*radius; +} + +double Circle::perimeter(void) { + return 2*M_PI*radius; +} + +double Square::area(void) { + return width*width; +} + +double Square::perimeter(void) { + return 4*width; +} diff --git a/Tests/SwigTest/example.h b/Tests/SwigTest/example.h new file mode 100644 index 000000000..46d901361 --- /dev/null +++ b/Tests/SwigTest/example.h @@ -0,0 +1,39 @@ +/* File : example.h */ + +class Shape { +public: + Shape() { + nshapes++; + } + virtual ~Shape() { + nshapes--; + }; + double x, y; + void move(double dx, double dy); + virtual double area(void) = 0; + virtual double perimeter(void) = 0; + static int nshapes; +}; + +class Circle : public Shape { +private: + double radius; +public: + Circle(double r) : radius(r) { }; + virtual double area(void); + virtual double perimeter(void); +}; + +class Square : public Shape { +private: + double width; +public: + Square(double w) : width(w) { }; + virtual double area(void); + virtual double perimeter(void); +}; + + + + + diff --git a/Tests/SwigTest/example.i b/Tests/SwigTest/example.i new file mode 100644 index 000000000..75700b305 --- /dev/null +++ b/Tests/SwigTest/example.i @@ -0,0 +1,10 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" + diff --git a/Tests/SwigTest/runme.php4 b/Tests/SwigTest/runme.php4 new file mode 100644 index 000000000..653ced256 --- /dev/null +++ b/Tests/SwigTest/runme.php4 @@ -0,0 +1,58 @@ +<?php + +# This file illustrates the low-level C++ interface +# created by SWIG. In this case, all of our C++ classes +# get converted into function calls. + +require("example.php"); + +# ----- Object creation ----- + +print "Creating some objects:\n"; +$c = new_Circle(10); +print " Created circle $c\n"; +$s = new_Square(10); +print " Created square $s\n"; + +# ----- Access a static member ----- + +print "\nA total of " . nshapes() . " shapes were created\n"; + +# ----- Member data access ----- + +# Set the location of the object. +# Note: methods in the base class Shape are used since +# x and y are defined there. + +Shape_x_set($c, 20); +Shape_y_set($c, 30); +Shape_x_set($s,-10); +Shape_y_set($s,5); + +print "\nHere is their current position:\n"; +print " Circle = (" . Shape_x_get($c) . "," . Shape_y_get($c) . ")\n"; +print " Square = (" . Shape_x_get($s) . "," . Shape_y_get($s) . ")\n"; + +# ----- Call some methods ----- + +print "\nHere are some properties of the shapes:\n"; +foreach (array($c,$s) as $o) { + print " $o\n"; + print " area = " . Shape_area($o) . "\n"; + print " perimeter = " . Shape_perimeter($o) . "\n"; + } +# Notice how the Shape_area() and Shape_perimeter() functions really +# invoke the appropriate virtual method on each object. + +# ----- Delete everything ----- + +print "\nGuess I'll clean up now\n"; + +# Note: this invokes the virtual destructor +delete_Shape($c); +delete_Shape($s); + +print nshapes() . " shapes remain\n"; +print "Goodbye\n"; + +?> diff --git a/Tests/SwigTest/runme.pike b/Tests/SwigTest/runme.pike new file mode 100755 index 000000000..a6377600e --- /dev/null +++ b/Tests/SwigTest/runme.pike @@ -0,0 +1,53 @@ +import .example; + +int main() +{ + // ----- Object creation ----- + + write("Creating some objects:\n"); + Circle c = Circle(10.0); + write(" Created circle.\n"); + Square s = Square(10.0); + write(" Created square.\n"); + + // ----- Access a static member ----- + + write("\nA total of " + Shape_nshapes_get() + " shapes were created\n"); + + // ----- Member data access ----- + + // Set the location of the object + + c->x_set(20.0); + c->y_set(30.0); + + s->x_set(-10.0); + s->y_set(5.0); + + write("\nHere is their current position:\n"); + write(" Circle = (%f, %f)\n", c->x_get(), c->y_get()); + write(" Square = (%f, %f)\n", s->x_get(), s->y_get()); + + // ----- Call some methods ----- + + write("\nHere are some properties of the shapes:\n"); + write(" The circle:\n"); + write(" area = %f.\n", c->area()); + write(" perimeter = %f.\n", c->perimeter()); + write(" The square:\n"); + write(" area = %f.\n", s->area()); + write(" perimeter = %f.\n", s->perimeter()); + + write("\nGuess I'll clean up now\n"); + + /* See if we can force 's' to be garbage-collected */ + s = 0; + + /* Now we should be down to only 1 shape */ + write("%d shapes remain\n", Shape_nshapes_get()); + + /* Done */ + write("Goodbye\n"); + + return 0; +} diff --git a/Tests/SwigTest/runme.pl b/Tests/SwigTest/runme.pl new file mode 100644 index 000000000..5bfb3d83a --- /dev/null +++ b/Tests/SwigTest/runme.pl @@ -0,0 +1,57 @@ +# file: runme.pl + +# This file illustrates the low-level C++ interface +# created by SWIG. In this case, all of our C++ classes +# get converted into function calls. + +use example; + +# ----- Object creation ----- + +print "Creating some objects:\n"; +$c = examplec::new_Circle(10); +print " Created circle $c\n"; +$s = examplec::new_Square(10); +print " Created square $s\n"; + +# ----- Access a static member ----- + +print "\nA total of $examplec::Shape_nshapes shapes were created\n"; + +# ----- Member data access ----- + +# Set the location of the object. +# Note: methods in the base class Shape are used since +# x and y are defined there. + +examplec::Shape_x_set($c, 20); +examplec::Shape_y_set($c, 30); +examplec::Shape_x_set($s,-10); +examplec::Shape_y_set($s,5); + +print "\nHere is their current position:\n"; +print " Circle = (",examplec::Shape_x_get($c),",", examplec::Shape_y_get($c),")\n"; +print " Square = (",examplec::Shape_x_get($s),",", examplec::Shape_y_get($s),")\n"; + +# ----- Call some methods ----- + +print "\nHere are some properties of the shapes:\n"; +foreach $o ($c,$s) { + print " $o\n"; + print " area = ", examplec::Shape_area($o), "\n"; + print " perimeter = ", examplec::Shape_perimeter($o), "\n"; + } +# Notice how the Shape_area() and Shape_perimeter() functions really +# invoke the appropriate virtual method on each object. + +# ----- Delete everything ----- + +print "\nGuess I'll clean up now\n"; + +# Note: this invokes the virtual destructor +examplec::delete_Shape($c); +examplec::delete_Shape($s); + +print $examplec::Shape_nshapes," shapes remain\n"; +print "Goodbye\n"; + diff --git a/Tests/SwigTest/runme.py b/Tests/SwigTest/runme.py new file mode 100644 index 000000000..42a5aa363 --- /dev/null +++ b/Tests/SwigTest/runme.py @@ -0,0 +1,51 @@ +# file: runme.py + +# This file illustrates the shadow-class C++ interface generated +# by SWIG. + +import example + +# ----- Object creation ----- + +print "Creating some objects:" +c = example.Circle(10) +print " Created circle", c +s = example.Square(10) +print " Created square", s + +# ----- Access a static member ----- + +print "\nA total of", example.cvar.Shape_nshapes,"shapes were created" + +# ----- Member data access ----- + +# Set the location of the object + +c.x = 20 +c.y = 30 + +s.x = -10 +s.y = 5 + +print "\nHere is their current position:" +print " Circle = (%f, %f)" % (c.x,c.y) +print " Square = (%f, %f)" % (s.x,s.y) + +# ----- Call some methods ----- + +print "\nHere are some properties of the shapes:" +for o in [c,s]: + print " ", o + print " area = ", o.area() + print " perimeter = ", o.perimeter() + +print "\nGuess I'll clean up now" + +# Note: this invokes the virtual destructor +del c +del s + +s = 3 +print example.cvar.Shape_nshapes,"shapes remain" +print "Goodbye" + diff --git a/Tests/SwigTest/runme.rb b/Tests/SwigTest/runme.rb new file mode 100644 index 000000000..de73bcd46 --- /dev/null +++ b/Tests/SwigTest/runme.rb @@ -0,0 +1,49 @@ +# file: runme.rb + +# This file illustrates the C++ interface created by SWIG. +# All of our C++ classes get converted into Ruby classes. + +require 'example' + +# ----- Object creation ----- + +print "Creating some objects:\n" +c = Example::Circle.new(10) +print " Created circle #{c}\n" +s = Example::Square.new(10) +print " Created square #{s}\n" + +# ----- Access a static member ----- + +print "\nA total of #{Example::Shape.nshapes} shapes were created\n" + +# ----- Member data access ----- + +# Set the location of the object + +# Notice how we can do this using functions specific to +# the 'Circle' class. +c.x = 20 +c.y = 30 + +# Now use the same functions in the base class +s.x = -10 +s.y = 5 + +print "\nHere is their current position:\n" +print " Circle = (", c.x, ",", c.y, ")\n" +print " Square = (", s.x, ",", s.y, ")\n" + +# ----- Call some methods ----- + +print "\nHere are some properties of the shapes:\n" +for o in [c, s] + print " #{o}\n" + print " area = ", o.area, "\n" + print " perimeter = ", o.perimeter, "\n" +end +# Notice how the Shape#area() and Shape#perimeter() functions really +# invoke the appropriate virtual method on each object. + +print "\n", Example::Shape.nshapes," shapes remain\n" +print "Goodbye\n" diff --git a/Tests/SwigTest/runme.tcl b/Tests/SwigTest/runme.tcl new file mode 100644 index 000000000..c7f472560 --- /dev/null +++ b/Tests/SwigTest/runme.tcl @@ -0,0 +1,50 @@ +# file: runme.tcl + +# This file illustrates the high level C++ interface. +# In this case C++ classes work kind of like Tk widgets + +catch { load ./example[info sharedlibextension] example} + +# ----- Object creation ----- + +puts "Creating some objects:" +Circle c 10 +puts " Created circle [c cget -this]" +Square s 10 +puts " Created square [s cget -this]" + +# ----- Access a static member ----- + +puts "\nA total of $Shape_nshapes shapes were created" + +# ----- Member data access ----- + +# Set the location of the object + +c configure -x 20 -y 30 +s configure -x -10 -y 5 + +puts "\nHere is their current position:" +puts " Circle = ([c cget -x], [c cget -y])" +puts " Square = ([s cget -x], [s cget -y])" + +# ----- Call some methods ----- + +puts "\nHere are some properties of the shapes:" +foreach o "c s" { + puts " [$o cget -this]" + puts " area = [$o area]" + puts " perimeter = [$o perimeter]" +} + +# ----- Delete everything ----- + +puts "\nGuess I'll clean up now" + +# Note: this invokes the virtual destructor +rename c "" +rename s "" + +puts "$Shape_nshapes shapes remain" +puts "Goodbye" + diff --git a/Tests/SwigTest/runme2.tcl b/Tests/SwigTest/runme2.tcl new file mode 100644 index 000000000..88ec2f678 --- /dev/null +++ b/Tests/SwigTest/runme2.tcl @@ -0,0 +1,70 @@ +# file: runme2.tcl + +# This file illustrates the low-level C++ interface +# created by SWIG. In this case, all of our C++ classes +# get converted into function calls. + +catch { load ./example[info sharedlibextension] example} + +# ----- Object creation ----- + +puts "Creating some objects:" +set c [new_Circle 10] +puts " Created circle $c" +set s [new_Square 10] +puts " Created square $s" + +# ----- Access a static member ----- + +puts "\nA total of $Shape_nshapes shapes were created" + +# ----- Member data access ----- + +# Set the location of the object +# Note: the base class must be used since that's where x and y +# were declared. + +Shape_x_set $c 20 +Shape_y_set $c 30 +Shape_x_set $s -10 +Shape_y_set $s 5 + +puts "\nHere is their current position:" +puts " Circle = ([Shape_x_get $c], [Shape_y_get $c])" +puts " Square = ([Shape_x_get $s], [Shape_y_get $s])" + +# ----- Call some methods ----- + +puts "\nHere are some properties of the shapes:" +foreach o "$c $s" { + puts " $o" + puts " area = [Shape_area $o]" + puts " perimeter = [Shape_perimeter $o]" +} +# Notice how the Shape_area() and Shape_perimeter() functions really +# invoke the appropriate virtual method on each object. + +# ----- Try to cause a type error ----- + +puts "\nI'm going to try and break the type system" + +if { [catch { + # Bad script! + Square_area $c # Try to invoke Square method on a Circle + puts " Bad bad SWIG!" + +}]} { + puts " Well, it didn't work. Good SWIG." +} + +# ----- Delete everything ----- + +puts "\nGuess I'll clean up now" + +# Note: this invokes the virtual destructor +delete_Shape $c +delete_Shape $s + +puts "$Shape_nshapes shapes remain" +puts "Goodbye" + diff --git a/Tests/SystemInformation/CMakeLists.txt b/Tests/SystemInformation/CMakeLists.txt new file mode 100644 index 000000000..c4285758e --- /dev/null +++ b/Tests/SystemInformation/CMakeLists.txt @@ -0,0 +1,61 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(SystemInformation) + +INCLUDE_DIRECTORIES("This does not exists") +GET_DIRECTORY_PROPERTY(incl INCLUDE_DIRECTORIES) +SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${SystemInformation_BINARY_DIR};${SystemInformation_SOURCE_DIR}") + +MESSAGE("To prevent CTest from stripping output, you have to display: CTEST_FULL_OUTPUT") + + +CONFIGURE_FILE(${SystemInformation_SOURCE_DIR}/SystemInformation.in +${SystemInformation_BINARY_DIR}/SystemInformation.out) +CONFIGURE_FILE(${SystemInformation_SOURCE_DIR}/DumpInformation.h.in +${SystemInformation_BINARY_DIR}/DumpInformation.h) +ADD_EXECUTABLE(SystemInformation DumpInformation.cxx) + +MACRO(FOO args) + MESSAGE("Test macro") +ENDMACRO(FOO) + +FOO(lala) + +FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/AllVariables.txt "") +GET_CMAKE_PROPERTY(res VARIABLES) +FOREACH(var ${res}) + FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/AllVariables.txt + "${var} \"${${var}}\"\n") +ENDFOREACH(var ${res}) + +FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/AllCommands.txt "") +GET_CMAKE_PROPERTY(res COMMANDS) +FOREACH(var ${res}) + FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/AllCommands.txt + "${var}\n") +ENDFOREACH(var ${res}) + +FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/AllMacros.txt "") +GET_CMAKE_PROPERTY(res MACROS) +FOREACH(var ${res}) + FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/AllMacros.txt + "${var}\n") +ENDFOREACH(var ${res}) + +FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/OtherProperties.txt "") +GET_DIRECTORY_PROPERTY(res INCLUDE_DIRECTORIES) +FOREACH(var ${res}) + FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/OtherProperties.txt + "INCLUDE_DIRECTORY: ${var}\n") +ENDFOREACH(var) + +GET_DIRECTORY_PROPERTY(res LINK_DIRECTORIES) +FOREACH(var ${res}) + FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/OtherProperties.txt + "LINK_DIRECTORIES: ${var}\n") +ENDFOREACH(var) + +GET_DIRECTORY_PROPERTY(res INCLUDE_REGULAR_EXPRESSION) +FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/OtherProperties.txt + "INCLUDE_REGULAR_EXPRESSION: ${res}\n") + + diff --git a/Tests/SystemInformation/DumpInformation.cxx b/Tests/SystemInformation/DumpInformation.cxx new file mode 100644 index 000000000..579dcbcf2 --- /dev/null +++ b/Tests/SystemInformation/DumpInformation.cxx @@ -0,0 +1,80 @@ +#include "DumpInformation.h" +#include <stdio.h> +#include <sys/stat.h> + +void cmDumpInformationPrintFile(const char* name, FILE* fout) +{ + fprintf(fout, + "Avoid ctest truncation of output: CTEST_FULL_OUTPUT\n"); + fprintf(fout, + "================================================================\n"); + struct stat fs; + if(stat(name, &fs) != 0) + { + fprintf(fout, "The file \"%s\" does not exist.\n", name); + fflush(fout); + return; + } + + FILE* fin = fopen(name, "r"); + if(fin) + { + fprintf(fout, + "Contents of \"%s\":\n" + "----------------------------------------------------------------\n", + name); + const int bufferSize = 4096; + char buffer[bufferSize]; + int n; + while((n = fread(buffer, 1, bufferSize, fin)) > 0) + { + for(char* c = buffer; c < buffer+n; ++c) + { + switch(*c) + { + case '<': fprintf(fout, "<"); break; + case '>': fprintf(fout, ">"); break; + case '&': fprintf(fout, "&"); break; + default: putc(*c, fout); break; + } + } + fflush(fout); + } + fclose(fin); + } + else + { + fprintf(fout, "Error opening \"%s\" for reading.\n", name); + fflush(fout); + } +} + +int main(int,char *[]) +{ + const char* files[] = + { + DumpInformation_BINARY_DIR "/SystemInformation.out", + DumpInformation_BINARY_DIR "/AllVariables.txt", + DumpInformation_BINARY_DIR "/AllCommands.txt", + DumpInformation_BINARY_DIR "/AllMacros.txt", + DumpInformation_BINARY_DIR "/OtherProperties.txt", + DumpInformation_BINARY_DIR "/../../Source/cmConfigure.h", + DumpInformation_BINARY_DIR "/../../CMakeCache.txt", + DumpInformation_BINARY_DIR "/../../CMakeFiles/CMakeOutput.log", + DumpInformation_BINARY_DIR "/../../CMakeFiles/CMakeError.log", + DumpInformation_BINARY_DIR "/../../Bootstrap.cmk/cmake_bootstrap.log", + DumpInformation_BINARY_DIR "/../../Source/cmsys/Configure.hxx", + DumpInformation_BINARY_DIR "/../../Source/cmsys/Configure.h", + DumpInformation_BINARY_DIR "/CMakeFiles/CMakeOutput.log", + DumpInformation_BINARY_DIR "/CMakeFiles/CMakeError.log", + 0 + }; + + const char** f; + for(f = files; *f; ++f) + { + cmDumpInformationPrintFile(*f, stdout); + } + + return 0; +} diff --git a/Tests/SystemInformation/DumpInformation.h.in b/Tests/SystemInformation/DumpInformation.h.in new file mode 100644 index 000000000..72d5cd179 --- /dev/null +++ b/Tests/SystemInformation/DumpInformation.h.in @@ -0,0 +1,6 @@ +#ifndef _DumpInformation_h +#define _DumpInformation_h + +#define DumpInformation_BINARY_DIR "@SystemInformation_BINARY_DIR@" + +#endif diff --git a/Tests/SystemInformation/SystemInformation.in b/Tests/SystemInformation/SystemInformation.in new file mode 100644 index 000000000..ecbc05408 --- /dev/null +++ b/Tests/SystemInformation/SystemInformation.in @@ -0,0 +1,102 @@ +CMAKE_STATIC_LIBRARY_PREFIX == "${CMAKE_STATIC_LIBRARY_PREFIX}" +CMAKE_STATIC_LIBRARY_SUFFIX == "${CMAKE_STATIC_LIBRARY_SUFFIX}" +CMAKE_SHARED_LIBRARY_PREFIX == "${CMAKE_SHARED_LIBRARY_PREFIX}" +CMAKE_SHARED_LIBRARY_SUFFIX == "${CMAKE_SHARED_LIBRARY_SUFFIX}" +CMAKE_SHARED_MODULE_PREFIX == "${CMAKE_SHARED_MODULE_PREFIX}" +CMAKE_SHARED_MODULE_SUFFIX == "${CMAKE_SHARED_MODULE_SUFFIX}" + + +CMAKE_DL_LIBS == "${CMAKE_DL_LIBS}" +CMAKE_LIBRARY_PATH_FLAG == "${CMAKE_LIBRARY_PATH_FLAG}" +CMAKE_LINK_LIBRARY_FLAG == "${CMAKE_LINK_LIBRARY_FLAG}" +CMAKE_SKIP_RPATH == "${CMAKE_SKIP_RPATH}" +CMAKE_SYSTEM_INFO_FILE == "${CMAKE_SYSTEM_INFO_FILE}" +CMAKE_SYSTEM_NAME == "${CMAKE_SYSTEM_NAME}" +CMAKE_SYSTEM == "${CMAKE_SYSTEM}" +CMAKE_CXX_COMPILER == "${CMAKE_CXX_COMPILER}" +CMAKE_C_COMPILER == "${CMAKE_C_COMPILER}" +CMAKE_COMPILER_IS_GNUCC == "${CMAKE_COMPILER_IS_GNUCC}" +CMAKE_COMPILER_IS_GNUCXX == "${CMAKE_COMPILER_IS_GNUCXX}" +CMAKE_C_COMPILER_ID == "${CMAKE_C_COMPILER_ID}" +CMAKE_C_COMPILER_VERSION == "${CMAKE_C_COMPILER_VERSION}" +CMAKE_CXX_COMPILER_ID == "${CMAKE_CXX_COMPILER_ID}" +CMAKE_CXX_COMPILER_VERSION == "${CMAKE_CXX_COMPILER_VERSION}" + +// C shared library flag +CMAKE_SHARED_LIBRARY_C_FLAGS == "${CMAKE_SHARED_LIBRARY_C_FLAGS}" +CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS == "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}" +CMAKE_SHARED_LIBRARY_LINK_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_FLAGS}" +CMAKE_SHARED_LIBRARY_RUNTIME_FLAG == "${CMAKE_SHARED_LIBRARY_RUNTIME_FLAG}" +CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP == "${CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP}" +CMAKE_SHARED_LIBRARY_LINK_STATIC_C_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_STATIC_C_FLAGS}" +CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_C_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_C_FLAGS}" +CMAKE_C_COMPILE_OPTIONS_PIC == "${CMAKE_C_COMPILE_OPTIONS_PIC}" +CMAKE_C_COMPILE_OPTIONS_PIE == "${CMAKE_C_COMPILE_OPTIONS_PIE}" +CMAKE_C_COMPILE_OPTIONS_DLL == "${CMAKE_C_COMPILE_OPTIONS_DLL}" + +// C shared module flags +CMAKE_SHARED_MODULE_C_FLAGS == "${CMAKE_SHARED_MODULE_C_FLAGS}" +CMAKE_SHARED_MODULE_CREATE_C_FLAGS == "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS}" +CMAKE_SHARED_MODULE_LINK_STATIC_C_FLAGS == "${CMAKE_SHARED_MODULE_LINK_STATIC_C_FLAGS}" +CMAKE_SHARED_MODULE_LINK_DYNAMIC_C_FLAGS == "${CMAKE_SHARED_MODULE_LINK_DYNAMIC_C_FLAGS}" + +// C exe flags +CMAKE_EXE_LINK_STATIC_C_FLAGS == "${CMAKE_EXE_LINK_STATIC_C_FLAGS}" +CMAKE_EXE_LINK_DYNAMIC_C_FLAGS == "${CMAKE_EXE_LINK_DYNAMIC_C_FLAGS}" + +// CXX shared library flags +CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}" +CMAKE_SHARED_LIBRARY_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}" +CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}" +CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG == "${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG}" +CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP == "${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP}" +CMAKE_SHARED_LIBRARY_LINK_STATIC_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_STATIC_CXX_FLAGS}" +CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS}" +CMAKE_CXX_COMPILE_OPTIONS_PIC == "${CMAKE_CXX_COMPILE_OPTIONS_PIC}" +CMAKE_CXX_COMPILE_OPTIONS_PIE == "${CMAKE_CXX_COMPILE_OPTIONS_PIE}" +CMAKE_CXX_COMPILE_OPTIONS_DLL == "${CMAKE_CXX_COMPILE_OPTIONS_DLL}" + +// CXX shared module flags +CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS == "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS}" +CMAKE_SHARED_MODULE_CXX_FLAGS == "${CMAKE_SHARED_MODULE_CXX_FLAGS}" +CMAKE_SHARED_MODULE_LINK_STATIC_CXX_FLAGS == "${CMAKE_SHARED_MODULE_LINK_STATIC_CXX_FLAGS}" +CMAKE_SHARED_MODULE_LINK_DYNAMIC_CXX_FLAGS == "${CMAKE_SHARED_MODULE_LINK_DYNAMIC_CXX_FLAGS}" + +// CXX exe flags +CMAKE_EXE_LINK_STATIC_CXX_FLAGS == "${CMAKE_EXE_LINK_STATIC_CXX_FLAGS}" +CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS == "${CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS}" + +CMAKE_USER_MAKE_RULES_OVERRIDE == "${CMAKE_USER_MAKE_RULES_OVERRIDE}" +CMAKE_VERBOSE_MAKEFILE == "${CMAKE_VERBOSE_MAKEFILE}" +CMAKE_BUILD_TYPE == "${CMAKE_BUILD_TYPE}" +CMAKE_CXX_FLAGS == "${CMAKE_CXX_FLAGS}" +CMAKE_CXX_FLAGS_DEBUG == "${CMAKE_CXX_FLAGS_DEBUG}" +CMAKE_CXX_FLAGS_MINSIZEREL == "${CMAKE_CXX_FLAGS_MINSIZEREL}" +CMAKE_CXX_FLAGS_RELEASE == "${CMAKE_CXX_FLAGS_RELEASE}" +CMAKE_CXX_FLAGS_RELWITHDEBINFO == "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" + +CMAKE_C_FLAGS == "${CMAKE_C_FLAGS}" +CMAKE_C_FLAGS_DEBUG == "${CMAKE_C_FLAGS_DEBUG}" +CMAKE_C_FLAGS_MINSIZEREL == "${CMAKE_C_FLAGS_MINSIZEREL}" +CMAKE_C_FLAGS_RELEASE == "${CMAKE_C_FLAGS_RELEASE}" +CMAKE_C_FLAGS_RELWITHDEBINFO == "${CMAKE_C_FLAGS_RELWITHDEBINFO}" + +// build rules +CMAKE_CXX_CREATE_SHARED_LIBRARY == "${CMAKE_CXX_CREATE_SHARED_LIBRARY}" +CMAKE_CXX_CREATE_SHARED_MODULE == "${CMAKE_CXX_CREATE_SHARED_MODULE}" +CMAKE_C_CREATE_SHARED_LIBRARY == "${CMAKE_C_CREATE_SHARED_LIBRARY}" +CMAKE_C_CREATE_SHARED_MODULE == "${CMAKE_C_CREATE_SHARED_MODULE}" +CMAKE_CXX_CREATE_STATIC_LIBRARY == "${CMAKE_CXX_CREATE_STATIC_LIBRARY}" +CMAKE_C_CREATE_STATIC_LIBRARY == "${CMAKE_C_CREATE_STATIC_LIBRARY}" +CMAKE_CXX_COMPILE_OBJECT == "${CMAKE_CXX_COMPILE_OBJECT}" +CMAKE_C_COMPILE_OBJECT == "${CMAKE_C_COMPILE_OBJECT}" +CMAKE_C_LINK_EXECUTABLE == "${CMAKE_C_LINK_EXECUTABLE}" +CMAKE_CXX_LINK_EXECUTABLE == "${CMAKE_CXX_LINK_EXECUTABLE}" + +// implicit link info +CMAKE_C_IMPLICIT_LINK_LIBRARIES == "${CMAKE_C_IMPLICIT_LINK_LIBRARIES}" +CMAKE_C_IMPLICIT_LINK_DIRECTORIES == "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}" +CMAKE_CXX_IMPLICIT_LINK_LIBRARIES == "${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}" +CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES == "${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}" + +XCODE_VERSION == "${XCODE_VERSION}" diff --git a/Tests/TarTest/CMakeLists.txt b/Tests/TarTest/CMakeLists.txt new file mode 100644 index 000000000..a3c5b31ff --- /dev/null +++ b/Tests/TarTest/CMakeLists.txt @@ -0,0 +1,69 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(TarTest) + +# this is macro that we will be running +MACRO(EXEC_TAR_COMMAND DIR ARGS) + EXEC_PROGRAM("${CMAKE_COMMAND}" "${DIR}" ARGS "-E tar ${ARGS}" RETURN_VALUE RET) + IF(${RET}) + MESSAGE(FATAL_ERROR "CMake tar command failed with arguments \"${ARGS}\"") + ENDIF(${RET}) +ENDMACRO(EXEC_TAR_COMMAND) + +# Create a directory structure +SET(CHECK_FILES) +MACRO(COPY F1 F2) + CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/${F1}" "${CMAKE_CURRENT_BINARY_DIR}/tar_dir/${F2}" COPYONLY) + SET(CHECK_FILES ${CHECK_FILES} "${F2}") +ENDMACRO(COPY) +COPY("CMakeLists.txt" "f1.txt") +COPY("CMakeLists.txt" "d1/f1.txt") +COPY("CMakeLists.txt" "d 2/f1.txt") +COPY("CMakeLists.txt" "d + 3/f1.txt") +COPY("CMakeLists.txt" "d_4/f1.txt") +COPY("CMakeLists.txt" "d-4/f1.txt") +COPY("CMakeLists.txt" "My Special Directory/f1.txt") + +IF(UNIX) + EXEC_PROGRAM("ln" ARGS "-sf f1.txt \"${CMAKE_CURRENT_BINARY_DIR}/tar_dir/d1/f2.txt\"") + SET(CHECK_FILES ${CHECK_FILES} "d1/f2.txt") +ENDIF(UNIX) + +# cleanup first in case there are files left from previous runs +# if the umask is odd on the machine it might create files that +# are not automatically over written. These tests are run +# each time the configure step is run. +FILE(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test_tar.tar") +FILE(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test_tgz.tgz") +FILE(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/test_output_tar") +FILE(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/test_output_tgz") + +MAKE_DIRECTORY("${CMAKE_CURRENT_BINARY_DIR}/test_output_tar") +MAKE_DIRECTORY("${CMAKE_CURRENT_BINARY_DIR}/test_output_tgz") + + +# Run tests +EXEC_TAR_COMMAND("${CMAKE_CURRENT_BINARY_DIR}" "cvf \"${CMAKE_CURRENT_BINARY_DIR}/test_tar.tar\" tar_dir") +EXEC_TAR_COMMAND("${CMAKE_CURRENT_BINARY_DIR}" "cvfz \"${CMAKE_CURRENT_BINARY_DIR}/test_tgz.tgz\" tar_dir") + +EXEC_TAR_COMMAND("${CMAKE_CURRENT_BINARY_DIR}/test_output_tar" "xvf \"${CMAKE_CURRENT_BINARY_DIR}/test_tar.tar\"") +EXEC_TAR_COMMAND("${CMAKE_CURRENT_BINARY_DIR}/test_output_tgz" "xvfz \"${CMAKE_CURRENT_BINARY_DIR}/test_tgz.tgz\"") + +MACRO(CHECK_DIR_STRUCTURE DIR) + FOREACH(file ${CHECK_FILES}) + SET(sfile "${DIR}/${file}") + SET(rfile "${CMAKE_CURRENT_BINARY_DIR}/tar_dir/${file}") + IF(NOT EXISTS "${sfile}") + MESSAGE(SEND_ERROR "Cannot find file ${sfile}") + ELSE(NOT EXISTS "${sfile}") + EXEC_PROGRAM("${CMAKE_COMMAND}" ARGS "-E compare_files \"${sfile}\" \"${rfile}\"" RETURN_VALUE ret) + IF(${ret}) + MESSAGE(SEND_ERROR "Files \"${sfile}\" \"${rfile}\" are different") + ENDIF(${ret}) + ENDIF(NOT EXISTS "${sfile}") + ENDFOREACH(file) +ENDMACRO(CHECK_DIR_STRUCTURE) + +CHECK_DIR_STRUCTURE("${CMAKE_CURRENT_BINARY_DIR}/test_output_tar/tar_dir") + +ADD_EXECUTABLE(TarTest TestTarExec.cxx) + diff --git a/Tests/TarTest/TestTarExec.cxx b/Tests/TarTest/TestTarExec.cxx new file mode 100644 index 000000000..86f2cd170 --- /dev/null +++ b/Tests/TarTest/TestTarExec.cxx @@ -0,0 +1,5 @@ +int main() +{ + return 0; +} + diff --git a/Tests/TargetName/CMakeLists.txt b/Tests/TargetName/CMakeLists.txt new file mode 100644 index 000000000..9729d21ff --- /dev/null +++ b/Tests/TargetName/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required (VERSION 2.6) +project(TargetName) + +add_subdirectory(executables) +add_subdirectory(scripts) diff --git a/Tests/TargetName/executables/CMakeLists.txt b/Tests/TargetName/executables/CMakeLists.txt new file mode 100644 index 000000000..2671e3e90 --- /dev/null +++ b/Tests/TargetName/executables/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(hello_world hello_world.c) diff --git a/Tests/TargetName/executables/hello_world.c b/Tests/TargetName/executables/hello_world.c new file mode 100644 index 000000000..539d867e0 --- /dev/null +++ b/Tests/TargetName/executables/hello_world.c @@ -0,0 +1,5 @@ +#include <stdio.h> +main() +{ + printf("hello, world\n"); +} diff --git a/Tests/TargetName/scripts/.gitattributes b/Tests/TargetName/scripts/.gitattributes new file mode 100644 index 000000000..51b8ce901 --- /dev/null +++ b/Tests/TargetName/scripts/.gitattributes @@ -0,0 +1 @@ +hello_world crlf=input diff --git a/Tests/TargetName/scripts/CMakeLists.txt b/Tests/TargetName/scripts/CMakeLists.txt new file mode 100644 index 000000000..40d4e2fb0 --- /dev/null +++ b/Tests/TargetName/scripts/CMakeLists.txt @@ -0,0 +1,13 @@ +if(NOT CMAKE_BINARY_DIR STREQUAL "${CMAKE_SOURCE_DIR}") + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hello_world + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/hello_world ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/hello_world + ) + add_custom_target( + hello_world_copy ALL + DEPENDS #hello_world + ${CMAKE_CURRENT_BINARY_DIR}/hello_world + ) +endif(NOT CMAKE_BINARY_DIR STREQUAL "${CMAKE_SOURCE_DIR}") diff --git a/Tests/TargetName/scripts/hello_world b/Tests/TargetName/scripts/hello_world new file mode 100755 index 000000000..ea3a72c1c --- /dev/null +++ b/Tests/TargetName/scripts/hello_world @@ -0,0 +1,2 @@ +#!/bin/sh +echo "hello, world" diff --git a/Tests/TestDriver/CMakeLists.txt b/Tests/TestDriver/CMakeLists.txt new file mode 100644 index 000000000..bd5e97414 --- /dev/null +++ b/Tests/TestDriver/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(TestDriverTest) + +SET(Extra_SRCS testExtraStuff.cxx testExtraStuff2.cxx ) +SET(Extra_SRCS ${Extra_SRCS};testExtraStuff3.cxx ) +INCLUDE_DIRECTORIES(${TestDriverTest_SOURCE_DIR}) +CREATE_TEST_SOURCELIST(testSrcs + TestDriverTest.cxx + test1.cxx + test2.cxx + subdir/test3.cxx + EXTRA_INCLUDE testArgs.h FUNCTION testProccessArgs) + +ADD_EXECUTABLE(TestDriverTest ${testSrcs} ${Extra_SRCS}) + diff --git a/Tests/TestDriver/subdir/test3.cxx b/Tests/TestDriver/subdir/test3.cxx new file mode 100644 index 000000000..976d6ebaa --- /dev/null +++ b/Tests/TestDriver/subdir/test3.cxx @@ -0,0 +1,8 @@ +#include <stdio.h> +int subdir_test3(int ac, char*av[]) +{ + printf("test3\n"); + for(int i =0; i < ac; i++) + printf("arg %d is %s\n", ac, av[i]); + return 0; +} diff --git a/Tests/TestDriver/test1.cxx b/Tests/TestDriver/test1.cxx new file mode 100644 index 000000000..ac82f8ae9 --- /dev/null +++ b/Tests/TestDriver/test1.cxx @@ -0,0 +1,25 @@ +#include <stdio.h> +int testExtraStuff3(); +int testExtraStuff(); +int testExtraStuff2(); + +int test1(int ac, char* av[]) +{ + if(!testExtraStuff2()) + { + return -1; + } + if(!testExtraStuff()) + { + return -1; + } + if(!testExtraStuff3()) + { + return -1; + } + + printf("test1\n"); + for(int i =0; i < ac; i++) + printf("arg %d is %s\n", ac, av[i]); + return 0; +} diff --git a/Tests/TestDriver/test2.cxx b/Tests/TestDriver/test2.cxx new file mode 100644 index 000000000..69f0fff17 --- /dev/null +++ b/Tests/TestDriver/test2.cxx @@ -0,0 +1,8 @@ +#include <stdio.h> +int test2(int ac, char*av[]) +{ + printf("test2\n"); + for(int i =0; i < ac; i++) + printf("arg %d is %s\n", ac, av[i]); + return 0; +} diff --git a/Tests/TestDriver/testArgs.h b/Tests/TestDriver/testArgs.h new file mode 100644 index 000000000..04893660b --- /dev/null +++ b/Tests/TestDriver/testArgs.h @@ -0,0 +1,20 @@ +void testProccessArgs(int* ac, char***av) +{ + char** argv = *av; + if(*ac < 2) + { + return; + } + if(strcmp(argv[1], "--with-threads") == 0) + { + printf("number of threads is %s\n", argv[2]); + *av +=2; + *ac -=2; + } + else if (strcmp(argv[1], "--without-threads") == 0) + { + printf("no threads\n"); + *av += 1; + *ac -= 1; + } +} diff --git a/Tests/TestDriver/testExtraStuff.cxx b/Tests/TestDriver/testExtraStuff.cxx new file mode 100644 index 000000000..bfd073c9a --- /dev/null +++ b/Tests/TestDriver/testExtraStuff.cxx @@ -0,0 +1,4 @@ +int testExtraStuff() +{ + return 1; +} diff --git a/Tests/TestDriver/testExtraStuff2.cxx b/Tests/TestDriver/testExtraStuff2.cxx new file mode 100644 index 000000000..e755dbe02 --- /dev/null +++ b/Tests/TestDriver/testExtraStuff2.cxx @@ -0,0 +1,4 @@ +int testExtraStuff2() +{ + return 1; +} diff --git a/Tests/TestDriver/testExtraStuff3.cxx b/Tests/TestDriver/testExtraStuff3.cxx new file mode 100644 index 000000000..9c239d42a --- /dev/null +++ b/Tests/TestDriver/testExtraStuff3.cxx @@ -0,0 +1,4 @@ +int testExtraStuff3() +{ + return 1; +} diff --git a/Tests/TestInstall.sh.in b/Tests/TestInstall.sh.in new file mode 100755 index 000000000..953578050 --- /dev/null +++ b/Tests/TestInstall.sh.in @@ -0,0 +1,63 @@ +#!/bin/sh + +CMAKE_COMMAND="@CMAKE_INSTALL_PREFIX@/bin/cmake" +CMake_SOURCE_DIR="@CMake_SOURCE_DIR@" +CMake_BINARY_DIR="@CMake_BINARY_DIR@" +CMAKE_INSTALL_PREFIX="@CMAKE_INSTALL_PREFIX@" +CMAKE_BUILD_TOOL="@CMAKE_BUILD_TOOL@" + +SOURCE_DIR="${CMake_SOURCE_DIR}/Tests/Simple" +BINARY_DIR="${CMake_BINARY_DIR}/Tests/TestInstall" + +install() +{ + echo "Erasing ${CMAKE_INSTALL_PREFIX}" && + ([ ! -d "${CMAKE_INSTALL_PREFIX}" ] || rm -rf "${CMAKE_INSTALL_PREFIX}") && + mkdir -p "${CMAKE_INSTALL_PREFIX}" && + echo "Running make install" && + ( + cd "${CMake_BINARY_DIR}" && + "${CMAKE_BUILD_TOOL}" install + ) +} + +setup() +{ + echo "Entering ${BINARY_DIR}" && + cd "${BINARY_DIR}" +} + +write_cache() +{ + install || return 1 + setup || return 1 + echo "Writing CMakeCache.txt" + ( + cat > CMakeCache.txt <<EOF +EOF + ) +} + +run_cmake() +{ + write_cache || return 1 + echo "Running CMake" + "${CMAKE_COMMAND}" "${SOURCE_DIR}" +} + +run_make() +{ + run_cmake || return 1 + echo "Running ${CMAKE_BUILD_TOOL}" + "${CMAKE_BUILD_TOOL}" +} + +run_test() +{ + echo "Running ${BINARY_DIR}/simple" + ( + "${BINARY_DIR}/simple" + ) +} + +run_make && run_test diff --git a/Tests/Testing/CMakeLists.txt b/Tests/Testing/CMakeLists.txt new file mode 100644 index 000000000..815b52b58 --- /dev/null +++ b/Tests/Testing/CMakeLists.txt @@ -0,0 +1,59 @@ +# +# Testing +# +cmake_minimum_required (VERSION 2.7) +PROJECT (Testing) + +# +# Lib and exe path +# +SET (LIBRARY_OUTPUT_PATH + ${Testing_BINARY_DIR}/bin/ CACHE PATH + "Single output directory for building all libraries.") + +SET (EXECUTABLE_OUTPUT_PATH + ${Testing_BINARY_DIR}/bin/ CACHE PATH + "Single output directory for building all executables.") + +# +# Where will executable tests be written ? +# +IF (EXECUTABLE_OUTPUT_PATH) + SET (CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH}) +ELSE (EXECUTABLE_OUTPUT_PATH) + SET (CXX_TEST_PATH .) +ENDIF (EXECUTABLE_OUTPUT_PATH) + +# +# Include Dart +# (will also set NSLOOKUP, HOSTNAME, etc.) +# +INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) + +# +# Extra coverage +# +BUILD_COMMAND(BUILD_COMMAND_VAR ${CMAKE_MAKE_PROGRAM}) +BUILD_NAME(BUILD_NAME_VAR) +SITE_NAME(SITE_NAME_VAR) + +# +# Enable testing +# +ENABLE_TESTING() + +# +# Add test +# +ADD_EXECUTABLE(testing testing.cxx) +ADD_TEST(testing.1 ${Testing_BINARY_DIR}/bin/testing) + +# +# skip level test +# +ADD_SUBDIRECTORY(Sub/Sub2) + +# Per-config target name and generator expressions. +ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../PerConfig PerConfig) +ADD_TEST(NAME testing.perconfig COMMAND perconfig) +ADD_TEST(NAME testing.driver COMMAND ${PerConfig_COMMAND}) diff --git a/Tests/Testing/DartConfig.cmake b/Tests/Testing/DartConfig.cmake new file mode 100644 index 000000000..26af720ac --- /dev/null +++ b/Tests/Testing/DartConfig.cmake @@ -0,0 +1,24 @@ +# Dashboard is opened for submissions for a 24 hour period starting at +# the specified NIGHLY_START_TIME. Time is specified in 24 hour format. +SET (NIGHTLY_START_TIME "23:00:00 EST") + +# Dart server to submit results (used by client) +SET (DROP_SITE "") +SET (DROP_LOCATION "") +SET (DROP_SITE_USER "") +SET (DROP_SITE_PASSWORD "") +SET (TRIGGER_SITE "") + +# Dart server configuration +# SET (CVS_WEB_URL "") +# SET (CVS_WEB_CVSROOT "") +# SET (USE_DOXYGEN "Off") +# SET (DOXYGEN_URL "") +# SET (GNATS_WEB_URL "") + +# Continuous email delivery variables +# SET (CONTINUOUS_FROM "") +# SET (SMTP_MAILHOST "") +# SET (CONTINUOUS_MONITOR_LIST "") +# SET (CONTINUOUS_BASE_URL "") + diff --git a/Tests/Testing/Sub/Sub2/CMakeLists.txt b/Tests/Testing/Sub/Sub2/CMakeLists.txt new file mode 100644 index 000000000..fb9e8619e --- /dev/null +++ b/Tests/Testing/Sub/Sub2/CMakeLists.txt @@ -0,0 +1,17 @@ +# +# Add test +# +ADD_EXECUTABLE(testing2 testing2.cxx) +ADD_TEST(testing.2 ${Testing_BINARY_DIR}/bin/testing2) + +add_test(NotCycle.a ${CMAKE_COMMAND} -E echo a) +add_test(NotCycle.test1 ${CMAKE_COMMAND} -E echo test1) +set_property(TEST NotCycle.test1 PROPERTY DEPENDS NotCycle.a) + +add_test(NotCycle.b ${CMAKE_COMMAND} -E echo b) +add_test(NotCycle.test2 ${CMAKE_COMMAND} -E echo test2) +set_property(TEST NotCycle.test2 PROPERTY DEPENDS NotCycle.b NotCycle.test1) + +add_test(NotCycle.c ${CMAKE_COMMAND} -E echo c) +add_test(NotCycle.test3 ${CMAKE_COMMAND} -E echo test3) +set_property(TEST NotCycle.test3 PROPERTY DEPENDS NotCycle.c NotCycle.test1 NotCycle.test2) diff --git a/Tests/Testing/Sub/Sub2/testing2.cxx b/Tests/Testing/Sub/Sub2/testing2.cxx new file mode 100644 index 000000000..1482f27e5 --- /dev/null +++ b/Tests/Testing/Sub/Sub2/testing2.cxx @@ -0,0 +1,4 @@ +int main () +{ + return 0; +} diff --git a/Tests/Testing/testing.cxx b/Tests/Testing/testing.cxx new file mode 100644 index 000000000..1482f27e5 --- /dev/null +++ b/Tests/Testing/testing.cxx @@ -0,0 +1,4 @@ +int main () +{ + return 0; +} diff --git a/Tests/TestsWorkingDirectory/CMakeLists.txt b/Tests/TestsWorkingDirectory/CMakeLists.txt new file mode 100644 index 000000000..6a6e9b6c7 --- /dev/null +++ b/Tests/TestsWorkingDirectory/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 2.6) +project(TestsWorkingDirectoryProj) + +add_executable(WorkingDirectory main.c) + +enable_testing() + +set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin") + +add_test(NAME WorkingDirectory0 COMMAND WorkingDirectory "${CMAKE_BINARY_DIR}") + +add_test(NAME WorkingDirectory1 COMMAND WorkingDirectory "${CMAKE_BINARY_DIR}") +set_tests_properties(WorkingDirectory1 PROPERTIES + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" +) + +string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_BINARY_DIR}") + +add_test(NAME WorkingDirectory2 COMMAND WorkingDirectory "${_parent_dir}") +set_tests_properties(WorkingDirectory2 PROPERTIES + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.." +) + +set(_default_cwd "${CMAKE_BINARY_DIR}") + +# FIXME: How to deal with /debug, /release, etc. with VS or Xcode? +if(${CMAKE_GENERATOR} MATCHES "Makefiles") +add_test(WorkingDirectory3 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd}) +endif() + +add_test(NAME WorkingDirectory4 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND WorkingDirectory ${CMAKE_BINARY_DIR}) + +string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_BINARY_DIR}") + +add_test(NAME WorkingDirectory5 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/.. COMMAND WorkingDirectory ${_parent_dir}) + +# FIXME: How to deal with /debug, /release, etc. with VS or Xcode? +if(${CMAKE_GENERATOR} MATCHES "Makefiles") +add_test(WorkingDirectory6 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..) +endif() + +add_subdirectory(subdir) diff --git a/Tests/TestsWorkingDirectory/main.c b/Tests/TestsWorkingDirectory/main.c new file mode 100644 index 000000000..19f2f14af --- /dev/null +++ b/Tests/TestsWorkingDirectory/main.c @@ -0,0 +1,64 @@ +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.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 + +static const char* Getcwd(char* buf, unsigned int len) +{ + const char* ret = _getcwd(buf, len); + char* p = NULL; + 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]); + } + for(p = buf; *p; ++p) + { + if(*p == '\\') + { + *p = '/'; + } + } + return ret; +} + +#else +#include <sys/types.h> +#include <fcntl.h> +#include <unistd.h> + +static 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)); + + return strcmp(cwd, argv[1]); +} diff --git a/Tests/TestsWorkingDirectory/subdir/CMakeLists.txt b/Tests/TestsWorkingDirectory/subdir/CMakeLists.txt new file mode 100644 index 000000000..c16b1db43 --- /dev/null +++ b/Tests/TestsWorkingDirectory/subdir/CMakeLists.txt @@ -0,0 +1,31 @@ +add_test(NAME WorkingDirectory-Subdir0 COMMAND WorkingDirectory "${CMAKE_CURRENT_BINARY_DIR}") + +add_test(NAME WorkingDirectory-Subdir1 COMMAND WorkingDirectory "${CMAKE_CURRENT_BINARY_DIR}") +set_tests_properties(WorkingDirectory-Subdir1 PROPERTIES + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" +) + +string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_CURRENT_BINARY_DIR}") + +add_test(NAME WorkingDirectory-Subdir2 COMMAND WorkingDirectory "${_parent_dir}") +set_tests_properties(WorkingDirectory-Subdir2 PROPERTIES + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.." +) + +set(_default_cwd "${CMAKE_CURRENT_BINARY_DIR}") + +# FIXME: How to deal with /debug, /release, etc. with VS or Xcode? +if(${CMAKE_GENERATOR} MATCHES "Makefiles") +add_test(WorkingDirectory-Subdir3 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd}) +endif() + +add_test(NAME WorkingDirectory-Subdir4 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND WorkingDirectory ${CMAKE_CURRENT_BINARY_DIR}) + +string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_CURRENT_BINARY_DIR}") + +add_test(NAME WorkingDirectory-Subdir5 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.. COMMAND WorkingDirectory ${_parent_dir}) + +# FIXME: How to deal with /debug, /release, etc. with VS or Xcode? +if(${CMAKE_GENERATOR} MATCHES "Makefiles") +add_test(WorkingDirectory-Subdir6 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..) +endif() diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt new file mode 100644 index 000000000..938c092c0 --- /dev/null +++ b/Tests/TryCompile/CMakeLists.txt @@ -0,0 +1,247 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(TryCompile) + +MACRO(TEST_ASSERT value msg) + IF (NOT ${value}) + MESSAGE (SEND_ERROR "Assertion failure:" ${msg} ) + ENDIF (NOT ${value}) +ENDMACRO(TEST_ASSERT) + +MACRO(TEST_FAIL value msg) + IF (${value}) + MESSAGE (SEND_ERROR "Failing test succeeded:" ${msg} ) + ENDIF (${value}) +ENDMACRO(TEST_FAIL) + +MACRO(TEST_EXPECT_EXACT command expected) + IF(NOT "x${result}" STREQUAL "x${expected}") + MESSAGE(SEND_ERROR "${CMAKE_CURRENT_LIST_LINE}: TEST \"${command}\" failed: \"${result}\" expected: \"${expected}\"") + ENDIF(NOT "x${result}" STREQUAL "x${expected}") +ENDMACRO(TEST_EXPECT_EXACT command expected) + +MACRO(TEST_EXPECT_CONTAINS command expected) + IF(NOT "${result}" MATCHES "${expected}") + MESSAGE(SEND_ERROR "${CMAKE_CURRENT_LIST_LINE}: TEST \"${command}\" failed: \"${result}\" expected: \"${expected}\"") + ENDIF(NOT "${result}" MATCHES "${expected}") +ENDMACRO(TEST_EXPECT_CONTAINS command expected) + + +# try to compile a file that should compile +# also check that COPY_FILE works +TRY_COMPILE(SHOULD_PASS + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/pass.c + OUTPUT_VARIABLE TRY_OUT + COPY_FILE ${TryCompile_BINARY_DIR}/CopyOfPass + ) + +IF(NOT SHOULD_PASS) + MESSAGE(SEND_ERROR "should pass failed ${TRY_OUT}") +ENDIF(NOT SHOULD_PASS) +IF(NOT EXISTS "${TryCompile_BINARY_DIR}/CopyOfPass") + MESSAGE(SEND_ERROR "COPY_FILE to \"${TryCompile_BINARY_DIR}/CopyOfPass\" failed") +ELSE(NOT EXISTS "${TryCompile_BINARY_DIR}/CopyOfPass") + FILE(REMOVE "${TryCompile_BINARY_DIR}/CopyOfPass") +ENDIF(NOT EXISTS "${TryCompile_BINARY_DIR}/CopyOfPass") + +# try to compile a file that should not compile +TRY_COMPILE(SHOULD_FAIL + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/fail.c + OUTPUT_VARIABLE TRY_OUT) +IF(SHOULD_FAIL) + MESSAGE(SEND_ERROR "Should fail passed ${TRY_OUT}") +ENDIF(SHOULD_FAIL) + +# try to compile a file that should compile +TRY_COMPILE(SHOULD_PASS + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/pass.c + OUTPUT_VARIABLE TRY_OUT) +IF(NOT SHOULD_PASS) + MESSAGE(SEND_ERROR "should pass failed ${TRY_OUT}") +ENDIF(NOT SHOULD_PASS) + +# try to compile a file that should not compile +TRY_COMPILE(SHOULD_FAIL + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/fail.c + OUTPUT_VARIABLE TRY_OUT) +IF(SHOULD_FAIL) + MESSAGE(SEND_ERROR "Should fail passed ${TRY_OUT}") +ENDIF(SHOULD_FAIL) + +IF(NOT SHOULD_FAIL) + IF(SHOULD_PASS) + MESSAGE("All Tests passed, ignore all previous output.") + ELSE(SHOULD_PASS) + MESSAGE("Test failed") + ENDIF(SHOULD_PASS) +ELSE(NOT SHOULD_FAIL) + MESSAGE("Test failed") +ENDIF(NOT SHOULD_FAIL) +TRY_COMPILE(CMAKE_ANSI_FOR_SCOPE + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT) +IF (CMAKE_ANSI_FOR_SCOPE) + MESSAGE("Compiler supports ansi for") +ELSE(CMAKE_ANSI_FOR_SCOPE) + MESSAGE("Compiler does not support ansi for scope") +ENDIF(CMAKE_ANSI_FOR_SCOPE) + +TRY_COMPILE(CMAKE_ANSI_FOR_SCOPE + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT) +IF (CMAKE_ANSI_FOR_SCOPE) + MESSAGE("Compiler supports ansi for") +ELSE(CMAKE_ANSI_FOR_SCOPE) + MESSAGE("Compiler does not support ansi for scope") +ENDIF(CMAKE_ANSI_FOR_SCOPE) + +MESSAGE("use the module now") +INCLUDE(${CMAKE_ROOT}/Modules/TestForANSIForScope.cmake) +IF (CMAKE_ANSI_FOR_SCOPE) + MESSAGE("Compiler supports ansi for") +ELSE(CMAKE_ANSI_FOR_SCOPE) + MESSAGE("Compiler does not support ansi for scope") +ENDIF(CMAKE_ANSI_FOR_SCOPE) + +MESSAGE("Testing try_compile project mode") +TRY_COMPILE(TEST_INNER + ${TryCompile_BINARY_DIR}/CMakeFiles/Inner + ${TryCompile_SOURCE_DIR}/Inner + TryCompileInner innerexe + OUTPUT_VARIABLE output) +TEST_ASSERT(TEST_INNER "try_compile project mode failed:\n${output}") + +ADD_EXECUTABLE(TryCompile pass.c) + +###################################### + +# now two tests for TRY_RUN + +# try to run a file that should compile and run without error +# also check that OUTPUT_VARIABLE contains both the compile output +# and the run output +TRY_RUN(SHOULD_RUN SHOULD_COMPILE + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/exit_success.c + OUTPUT_VARIABLE TRY_OUT) +IF(NOT SHOULD_COMPILE) + MESSAGE(SEND_ERROR "exit_success failed compiling: ${TRY_OUT}") +ENDIF(NOT SHOULD_COMPILE) +IF(NOT "${SHOULD_RUN}" STREQUAL "0") + MESSAGE(SEND_ERROR "exit_success failed running with exit code ${SHOULD_RUN}") +ENDIF(NOT "${SHOULD_RUN}" STREQUAL "0") +# check the compile output for the filename +IF(NOT "${TRY_OUT}" MATCHES "exit_success") + MESSAGE(SEND_ERROR " TRY_OUT didn't contain \"exit_success\": \"${TRY_OUT}\"") +ENDIF(NOT "${TRY_OUT}" MATCHES "exit_success") +# check the run output +IF(NOT "${TRY_OUT}" MATCHES "hello world") + MESSAGE(SEND_ERROR " TRY_OUT didn't contain \"hello world\": \"${TRY_OUT}\"") +ENDIF(NOT "${TRY_OUT}" MATCHES "hello world") + +TRY_RUN(ARG_TEST_RUN ARG_TEST_COMPILE + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/expect_arg.c + OUTPUT_VARIABLE TRY_OUT + ARGS arg1 arg2) +IF(NOT ARG_TEST_COMPILE) + MESSAGE(SEND_ERROR "expect_arg failed compiling: ${TRY_OUT}") +ENDIF(NOT ARG_TEST_COMPILE) +IF(NOT "${ARG_TEST_RUN}" STREQUAL "0") + MESSAGE(SEND_ERROR "expect_arg failed running with exit code ${ARG_TEST_RUN} ${TRY_OUT}") +ENDIF(NOT "${ARG_TEST_RUN}" STREQUAL "0") + +# try to run a file that should compile and run, but return an error +TRY_RUN(SHOULD_EXIT_WITH_ERROR SHOULD_COMPILE + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/exit_with_error.c + COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT + RUN_OUTPUT_VARIABLE RUN_OUTPUT) + +IF(NOT SHOULD_COMPILE) + MESSAGE(STATUS " exit_with_error failed compiling: ${COMPILE_OUTPUT}") +ENDIF(NOT SHOULD_COMPILE) +IF("${SHOULD_EXIT_WITH_ERROR}" STREQUAL "0") + MESSAGE(SEND_ERROR " exit_with_error passed with exit code ${SHOULD_EXIT_WITH_ERROR}") +ENDIF("${SHOULD_EXIT_WITH_ERROR}" STREQUAL "0") + +# check the compile output, it should contain the filename +IF(NOT "${COMPILE_OUTPUT}" MATCHES "exit_with_error") + MESSAGE(SEND_ERROR " COMPILE_OUT didn't contain \"exit_with_error\": \"${COMPILE_OUTPUT}\"") +ENDIF(NOT "${COMPILE_OUTPUT}" MATCHES "exit_with_error") +#... but not the run time output +IF("${COMPILE_OUTPUT}" MATCHES "hello world") + MESSAGE(SEND_ERROR " COMPILE_OUT contains the run output: \"${COMPILE_OUTPUT}\"") +ENDIF("${COMPILE_OUTPUT}" MATCHES "hello world") +# check the run output, it should stdout +IF(NOT "${RUN_OUTPUT}" MATCHES "hello world") + MESSAGE(SEND_ERROR " RUN_OUTPUT didn't contain \"hello world\": \"${RUN_OUTPUT}\"") +ENDIF(NOT "${RUN_OUTPUT}" MATCHES "hello world") + +####################################################################### +# +# also test that the CHECK_C_SOURCE_COMPILES, CHECK_CXX_SOURCE_COMPILES +# CHECK_C_SOURCE_RUNS and CHECK_CXX_SOURCE_RUNS macros work + +INCLUDE(CheckCSourceCompiles) +INCLUDE(CheckCXXSourceCompiles) +INCLUDE(CheckCSourceRuns) +INCLUDE(CheckCXXSourceRuns) + +CHECK_C_SOURCE_COMPILES("I dont build" C_BUILD_SHOULD_FAIL) +CHECK_C_SOURCE_COMPILES("int main() {return 0;}" C_BUILD_SHOULD_WORK) +CHECK_C_SOURCE_RUNS("int main() {return 1;}" C_RUN_SHOULD_FAIL) +CHECK_C_SOURCE_RUNS("int main() {return 0;}" C_RUN_SHOULD_WORK) + +TEST_FAIL(C_BUILD_SHOULD_FAIL "CHECK_C_SOURCE_COMPILES() succeeded, but should have failed") +TEST_ASSERT(C_BUILD_SHOULD_WORK "CHECK_C_SOURCE_COMPILES() failed") +TEST_FAIL(C_RUN_SHOULD_FAIL "CHECK_C_SOURCE_RUNS() succeeded, but should have failed") +TEST_ASSERT(C_RUN_SHOULD_WORK "CHECK_C_SOURCE_RUNS() failed") + +CHECK_CXX_SOURCE_COMPILES("I dont build" CXX_BUILD_SHOULD_FAIL) +CHECK_CXX_SOURCE_COMPILES("int main() {return 0;}" CXX_BUILD_SHOULD_WORK) +CHECK_CXX_SOURCE_RUNS("int main() {return 2;}" CXX_RUN_SHOULD_FAIL) +CHECK_CXX_SOURCE_RUNS("int main() {return 0;}" CXX_RUN_SHOULD_WORK) + +TEST_FAIL(CXX_BUILD_SHOULD_FAIL "CHECK_CXX_SOURCE_COMPILES() succeeded, but should have failed") +TEST_ASSERT(CXX_BUILD_SHOULD_WORK "CHECK_CXX_SOURCE_COMPILES() failed") +TEST_FAIL(CXX_RUN_SHOULD_FAIL "CHECK_CXX_SOURCE_RUNS() succeeded, but should have failed") +TEST_ASSERT(CXX_RUN_SHOULD_WORK "CHECK_CXX_SOURCE_RUNS() failed") + +FOREACH(lang C CXX) + IF(NOT "${CMAKE_${lang}_COMPILER_ID}" MATCHES "^(PathScale)$") + SET(${lang}_DD --) + ENDIF() +ENDFOREACH() + +UNSET(C_BOGUS_FLAG CACHE) +INCLUDE(CheckCCompilerFlag) +CHECK_C_COMPILER_FLAG(${C_DD}-_this_is_not_a_flag_ C_BOGUS_FLAG) +TEST_FAIL(C_BOGUS_FLAG "CHECK_C_COMPILER_FLAG() succeeded, but should have failed") + +UNSET(CXX_BOGUS_FLAG CACHE) +INCLUDE(CheckCXXCompilerFlag) +CHECK_CXX_COMPILER_FLAG(${CXX_DD}-_this_is_not_a_flag_ CXX_BOGUS_FLAG) +TEST_FAIL(CXX_BOGUS_FLAG "CHECK_CXX_COMPILER_FLAG() succeeded, but should have failed") + +IF("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") + UNSET(C_STRICT_PROTOTYPES CACHE) + CHECK_C_COMPILER_FLAG("-Werror;-Wstrict-prototypes" C_STRICT_PROTOTYPES) + TEST_ASSERT(C_STRICT_PROTOTYPES "CHECK_C_COMPILER_FLAG failed -Werror -Wstrict-prototypes") +ENDIF() + +####################################################################### +# +# also test that the check_prototype_definition macro works + +include(CheckPrototypeDefinition) + +check_prototype_definition(remove + "int remove(const char *pathname)" + "0" + "stdio.h" + TEST_REMOVE_PROTO) +test_assert(TEST_REMOVE_PROTO "check_prototype_definition for remove() failed") diff --git a/Tests/TryCompile/Inner/CMakeLists.txt b/Tests/TryCompile/Inner/CMakeLists.txt new file mode 100644 index 000000000..d62bcc4dd --- /dev/null +++ b/Tests/TryCompile/Inner/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.6) +project(TryCompileInner C) + +try_compile(SHOULD_PASS + ${TryCompileInner_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompileInner_SOURCE_DIR}/../pass.c + OUTPUT_VARIABLE TRY_OUT + ) +if(NOT SHOULD_PASS) + message(FATAL_ERROR "Inner try-compile SHOULD_PASS failed!") +endif() + +add_library(innerlib innerlib.c) +add_executable(innerexe innerexe.c) +target_link_libraries(innerexe innerlib) diff --git a/Tests/TryCompile/Inner/innerexe.c b/Tests/TryCompile/Inner/innerexe.c new file mode 100644 index 000000000..9b121a17d --- /dev/null +++ b/Tests/TryCompile/Inner/innerexe.c @@ -0,0 +1,2 @@ +extern int innerlib(void); +int main() { return innerlib(); } diff --git a/Tests/TryCompile/Inner/innerlib.c b/Tests/TryCompile/Inner/innerlib.c new file mode 100644 index 000000000..0ce11799b --- /dev/null +++ b/Tests/TryCompile/Inner/innerlib.c @@ -0,0 +1 @@ +int innerlib(void) { return 0; } diff --git a/Tests/TryCompile/exit_success.c b/Tests/TryCompile/exit_success.c new file mode 100644 index 000000000..82f5b5f82 --- /dev/null +++ b/Tests/TryCompile/exit_success.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main() +{ + printf("hello world\n"); + return 0; +} diff --git a/Tests/TryCompile/exit_with_error.c b/Tests/TryCompile/exit_with_error.c new file mode 100644 index 000000000..f3c523d37 --- /dev/null +++ b/Tests/TryCompile/exit_with_error.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main() +{ + printf("hello world\n"); + return -1; +} diff --git a/Tests/TryCompile/expect_arg.c b/Tests/TryCompile/expect_arg.c new file mode 100644 index 000000000..7ca49aa43 --- /dev/null +++ b/Tests/TryCompile/expect_arg.c @@ -0,0 +1,22 @@ +#include <stdio.h> +#include <string.h> +int main(int ac, char*av[]) +{ + int i; + printf("ac = [%d]\n", ac); + for(i =0; i < ac; i++) + { + printf("arg[%d] = %s\n", i, av[i]); + } + if(ac == 3) + { + if(strcmp(av[1], "arg1") ==0 + && strcmp(av[2], "arg2") ==0) + { + printf("arg1 and arg2 present and accounted for!\n"); + return 0; + } + } + printf("arg1 and arg2 missing!\n"); + return -1; +} diff --git a/Tests/TryCompile/fail.c b/Tests/TryCompile/fail.c new file mode 100644 index 000000000..b915ebe4c --- /dev/null +++ b/Tests/TryCompile/fail.c @@ -0,0 +1 @@ +asdflkjasdlj diff --git a/Tests/TryCompile/pass.c b/Tests/TryCompile/pass.c new file mode 100644 index 000000000..40bc5e2dd --- /dev/null +++ b/Tests/TryCompile/pass.c @@ -0,0 +1,6 @@ +int main() +{ + return 0; +} + + diff --git a/Tests/Tutorial/Step1/CMakeLists.txt b/Tests/Tutorial/Step1/CMakeLists.txt new file mode 100644 index 000000000..e461d3c8b --- /dev/null +++ b/Tests/Tutorial/Step1/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required (VERSION 2.6) +project (Tutorial) + +# The version number. +set (Tutorial_VERSION_MAJOR 1) +set (Tutorial_VERSION_MINOR 0) + +# configure a header file to pass some of the CMake settings +# to the source code +configure_file ( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +include_directories("${PROJECT_BINARY_DIR}") + +# add the executable +add_executable(Tutorial tutorial.cxx) diff --git a/Tests/Tutorial/Step1/TutorialConfig.h.in b/Tests/Tutorial/Step1/TutorialConfig.h.in new file mode 100644 index 000000000..5395a0671 --- /dev/null +++ b/Tests/Tutorial/Step1/TutorialConfig.h.in @@ -0,0 +1,4 @@ +// the configured options and settings for Tutorial +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ + diff --git a/Tests/Tutorial/Step1/tutorial.cxx b/Tests/Tutorial/Step1/tutorial.cxx new file mode 100644 index 000000000..8ab6dc306 --- /dev/null +++ b/Tests/Tutorial/Step1/tutorial.cxx @@ -0,0 +1,23 @@ +// A simple program that computes the square root of a number +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "TutorialConfig.h" + +int main (int argc, char *argv[]) +{ + if (argc < 2) + { + fprintf(stdout,"%s Version %d.%d\n", + argv[0], + Tutorial_VERSION_MAJOR, + Tutorial_VERSION_MINOR); + fprintf(stdout,"Usage: %s number\n",argv[0]); + return 1; + } + double inputValue = atof(argv[1]); + double outputValue = sqrt(inputValue); + fprintf(stdout,"The square root of %g is %g\n", + inputValue, outputValue); + return 0; +} diff --git a/Tests/Tutorial/Step2/CMakeLists.txt b/Tests/Tutorial/Step2/CMakeLists.txt new file mode 100644 index 000000000..c82b7df98 --- /dev/null +++ b/Tests/Tutorial/Step2/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required (VERSION 2.6) +project (Tutorial) + +# The version number. +set (Tutorial_VERSION_MAJOR 1) +set (Tutorial_VERSION_MINOR 0) + +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) + +# configure a header file to pass some of the CMake settings +# to the source code +configure_file ( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +include_directories ("${PROJECT_BINARY_DIR}") + +# add the MathFunctions library? +if (USE_MYMATH) + include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") + add_subdirectory (MathFunctions) + set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) +endif (USE_MYMATH) + +# add the executable +add_executable (Tutorial tutorial.cxx) +target_link_libraries (Tutorial ${EXTRA_LIBS}) diff --git a/Tests/Tutorial/Step2/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step2/MathFunctions/CMakeLists.txt new file mode 100644 index 000000000..8b443a659 --- /dev/null +++ b/Tests/Tutorial/Step2/MathFunctions/CMakeLists.txt @@ -0,0 +1 @@ +add_library(MathFunctions mysqrt.cxx) diff --git a/Tests/Tutorial/Step2/MathFunctions/MathFunctions.h b/Tests/Tutorial/Step2/MathFunctions/MathFunctions.h new file mode 100644 index 000000000..cd36bccff --- /dev/null +++ b/Tests/Tutorial/Step2/MathFunctions/MathFunctions.h @@ -0,0 +1 @@ +double mysqrt(double x); diff --git a/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx new file mode 100644 index 000000000..76b8e2d9d --- /dev/null +++ b/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx @@ -0,0 +1,29 @@ +#include <stdio.h> +#include "MathFunctions.h" + +// a hack square root calculation using simple operations +double mysqrt(double x) +{ + if (x <= 0) + { + return 0; + } + + double result; + double delta; + result = x; + + // do ten iterations + int i; + for (i = 0; i < 10; ++i) + { + if (result <= 0) + { + result = 0.1; + } + delta = x - (result*result); + result = result + 0.5*delta/result; + fprintf(stdout,"Computing sqrt of %g to be %g\n",x,result); + } + return result; +} diff --git a/Tests/Tutorial/Step2/TutorialConfig.h.in b/Tests/Tutorial/Step2/TutorialConfig.h.in new file mode 100644 index 000000000..25a06020a --- /dev/null +++ b/Tests/Tutorial/Step2/TutorialConfig.h.in @@ -0,0 +1,5 @@ +// the configured options and settings for Tutorial +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ +#cmakedefine USE_MYMATH + diff --git a/Tests/Tutorial/Step2/tutorial.cxx b/Tests/Tutorial/Step2/tutorial.cxx new file mode 100644 index 000000000..82b416f11 --- /dev/null +++ b/Tests/Tutorial/Step2/tutorial.cxx @@ -0,0 +1,34 @@ +// A simple program that computes the square root of a number +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "TutorialConfig.h" + +#ifdef USE_MYMATH +#include "MathFunctions.h" +#endif + +int main (int argc, char *argv[]) +{ + if (argc < 2) + { + fprintf(stdout,"%s Version %d.%d\n", + argv[0], + Tutorial_VERSION_MAJOR, + Tutorial_VERSION_MINOR); + fprintf(stdout,"Usage: %s number\n",argv[0]); + return 1; + } + + double inputValue = atof(argv[1]); + +#ifdef USE_MYMATH + double outputValue = mysqrt(inputValue); +#else + double outputValue = sqrt(inputValue); +#endif + + fprintf(stdout,"The square root of %g is %g\n", + inputValue, outputValue); + return 0; +} diff --git a/Tests/Tutorial/Step3/CMakeLists.txt b/Tests/Tutorial/Step3/CMakeLists.txt new file mode 100644 index 000000000..0b05fd737 --- /dev/null +++ b/Tests/Tutorial/Step3/CMakeLists.txt @@ -0,0 +1,68 @@ +cmake_minimum_required (VERSION 2.6) +project (Tutorial) + +# The version number. +set (Tutorial_VERSION_MAJOR 1) +set (Tutorial_VERSION_MINOR 0) + +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) + +# configure a header file to pass some of the CMake settings +# to the source code +configure_file ( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +include_directories ("${PROJECT_BINARY_DIR}") + +# add the MathFunctions library? +if (USE_MYMATH) + include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") + add_subdirectory (MathFunctions) + set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) +endif (USE_MYMATH) + +# add the executable +add_executable (Tutorial tutorial.cxx) +target_link_libraries (Tutorial ${EXTRA_LIBS}) + +# add the install targets +install (TARGETS Tutorial DESTINATION bin) +install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include) + + +# enable testing +enable_testing () + +# does the application run +add_test (TutorialRuns Tutorial 25) + +# does it sqrt of 25 +add_test (TutorialComp25 Tutorial 25) +set_tests_properties (TutorialComp25 + PROPERTIES PASS_REGULAR_EXPRESSION "25 is 5" + ) + +# does it handle negative numbers +add_test (TutorialNegative Tutorial -25) +set_tests_properties (TutorialNegative + PROPERTIES PASS_REGULAR_EXPRESSION "-25 is 0" + ) + +# does it handle small numbers +add_test (TutorialSmall Tutorial 0.0001) +set_tests_properties (TutorialSmall + PROPERTIES PASS_REGULAR_EXPRESSION "0.0001 is 0.01" + ) + +# does the usage message work? +add_test (TutorialUsage Tutorial) +set_tests_properties (TutorialUsage + PROPERTIES + PASS_REGULAR_EXPRESSION "Usage:.*number" + ) diff --git a/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt new file mode 100644 index 000000000..f386036c3 --- /dev/null +++ b/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(MathFunctions mysqrt.cxx) + +install (TARGETS MathFunctions DESTINATION bin) +install (FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step3/MathFunctions/MathFunctions.h b/Tests/Tutorial/Step3/MathFunctions/MathFunctions.h new file mode 100644 index 000000000..cd36bccff --- /dev/null +++ b/Tests/Tutorial/Step3/MathFunctions/MathFunctions.h @@ -0,0 +1 @@ +double mysqrt(double x); diff --git a/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx new file mode 100644 index 000000000..76b8e2d9d --- /dev/null +++ b/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx @@ -0,0 +1,29 @@ +#include <stdio.h> +#include "MathFunctions.h" + +// a hack square root calculation using simple operations +double mysqrt(double x) +{ + if (x <= 0) + { + return 0; + } + + double result; + double delta; + result = x; + + // do ten iterations + int i; + for (i = 0; i < 10; ++i) + { + if (result <= 0) + { + result = 0.1; + } + delta = x - (result*result); + result = result + 0.5*delta/result; + fprintf(stdout,"Computing sqrt of %g to be %g\n",x,result); + } + return result; +} diff --git a/Tests/Tutorial/Step3/TutorialConfig.h.in b/Tests/Tutorial/Step3/TutorialConfig.h.in new file mode 100644 index 000000000..25a06020a --- /dev/null +++ b/Tests/Tutorial/Step3/TutorialConfig.h.in @@ -0,0 +1,5 @@ +// the configured options and settings for Tutorial +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ +#cmakedefine USE_MYMATH + diff --git a/Tests/Tutorial/Step3/tutorial.cxx b/Tests/Tutorial/Step3/tutorial.cxx new file mode 100644 index 000000000..82b416f11 --- /dev/null +++ b/Tests/Tutorial/Step3/tutorial.cxx @@ -0,0 +1,34 @@ +// A simple program that computes the square root of a number +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "TutorialConfig.h" + +#ifdef USE_MYMATH +#include "MathFunctions.h" +#endif + +int main (int argc, char *argv[]) +{ + if (argc < 2) + { + fprintf(stdout,"%s Version %d.%d\n", + argv[0], + Tutorial_VERSION_MAJOR, + Tutorial_VERSION_MINOR); + fprintf(stdout,"Usage: %s number\n",argv[0]); + return 1; + } + + double inputValue = atof(argv[1]); + +#ifdef USE_MYMATH + double outputValue = mysqrt(inputValue); +#else + double outputValue = sqrt(inputValue); +#endif + + fprintf(stdout,"The square root of %g is %g\n", + inputValue, outputValue); + return 0; +} diff --git a/Tests/Tutorial/Step4/CMakeLists.txt b/Tests/Tutorial/Step4/CMakeLists.txt new file mode 100644 index 000000000..3b24b4416 --- /dev/null +++ b/Tests/Tutorial/Step4/CMakeLists.txt @@ -0,0 +1,68 @@ +cmake_minimum_required (VERSION 2.6) +project (Tutorial) + +# The version number. +set (Tutorial_VERSION_MAJOR 1) +set (Tutorial_VERSION_MINOR 0) + +# does this system provide the log and exp functions? +include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) +check_function_exists (log HAVE_LOG) +check_function_exists (exp HAVE_EXP) + +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) + +# configure a header file to pass some of the CMake settings +# to the source code +configure_file ( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +include_directories ("${PROJECT_BINARY_DIR}") + +# add the MathFunctions library? +if (USE_MYMATH) + include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") + add_subdirectory (MathFunctions) + set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) +endif (USE_MYMATH) + +# add the executable +add_executable (Tutorial tutorial.cxx) +target_link_libraries (Tutorial ${EXTRA_LIBS}) + +# add the install targets +install (TARGETS Tutorial DESTINATION bin) +install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include) + +# enable testing +enable_testing () + +# does the application run +add_test (TutorialRuns Tutorial 25) + +# does the usage message work? +add_test (TutorialUsage Tutorial) +set_tests_properties (TutorialUsage + PROPERTIES + PASS_REGULAR_EXPRESSION "Usage:.*number" + ) + +#define a macro to simplify adding tests +macro (do_test arg result) + add_test (TutorialComp${arg} Tutorial ${arg}) + set_tests_properties (TutorialComp${arg} + PROPERTIES PASS_REGULAR_EXPRESSION ${result} + ) +endmacro (do_test) + +# do a bunch of result based tests +do_test (25 "25 is 5") +do_test (-25 "-25 is 0") +do_test (0.0001 "0.0001 is 0.01") + diff --git a/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt new file mode 100644 index 000000000..f386036c3 --- /dev/null +++ b/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(MathFunctions mysqrt.cxx) + +install (TARGETS MathFunctions DESTINATION bin) +install (FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step4/MathFunctions/MathFunctions.h b/Tests/Tutorial/Step4/MathFunctions/MathFunctions.h new file mode 100644 index 000000000..cd36bccff --- /dev/null +++ b/Tests/Tutorial/Step4/MathFunctions/MathFunctions.h @@ -0,0 +1 @@ +double mysqrt(double x); diff --git a/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx new file mode 100644 index 000000000..0cf7db480 --- /dev/null +++ b/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx @@ -0,0 +1,39 @@ +#include <stdio.h> +#include "MathFunctions.h" +#include "TutorialConfig.h" + +#include <math.h> + +// a hack square root calculation using simple operations +double mysqrt(double x) +{ + if (x <= 0) + { + return 0; + } + + double result; + + // if we have both log and exp then use them +#if defined(HAVE_LOG) && defined (HAVE_EXP) + result = exp(log(x)*0.5); + fprintf(stdout,"Computing sqrt of %g to be %g using log\n",x,result); +#else + double delta; + result = x; + + // do ten iterations + int i; + for (i = 0; i < 10; ++i) + { + if (result <= 0) + { + result = 0.1; + } + delta = x - (result*result); + result = result + 0.5*delta/result; + fprintf(stdout,"Computing sqrt of %g to be %g\n",x,result); + } +#endif + return result; +} diff --git a/Tests/Tutorial/Step4/TutorialConfig.h.in b/Tests/Tutorial/Step4/TutorialConfig.h.in new file mode 100644 index 000000000..a0912656a --- /dev/null +++ b/Tests/Tutorial/Step4/TutorialConfig.h.in @@ -0,0 +1,9 @@ +// the configured options and settings for Tutorial +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ +#cmakedefine USE_MYMATH + +// does the platform provide exp and log functions? +#cmakedefine HAVE_LOG +#cmakedefine HAVE_EXP + diff --git a/Tests/Tutorial/Step4/tutorial.cxx b/Tests/Tutorial/Step4/tutorial.cxx new file mode 100644 index 000000000..82b416f11 --- /dev/null +++ b/Tests/Tutorial/Step4/tutorial.cxx @@ -0,0 +1,34 @@ +// A simple program that computes the square root of a number +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "TutorialConfig.h" + +#ifdef USE_MYMATH +#include "MathFunctions.h" +#endif + +int main (int argc, char *argv[]) +{ + if (argc < 2) + { + fprintf(stdout,"%s Version %d.%d\n", + argv[0], + Tutorial_VERSION_MAJOR, + Tutorial_VERSION_MINOR); + fprintf(stdout,"Usage: %s number\n",argv[0]); + return 1; + } + + double inputValue = atof(argv[1]); + +#ifdef USE_MYMATH + double outputValue = mysqrt(inputValue); +#else + double outputValue = sqrt(inputValue); +#endif + + fprintf(stdout,"The square root of %g is %g\n", + inputValue, outputValue); + return 0; +} diff --git a/Tests/Tutorial/Step5/CMakeLists.txt b/Tests/Tutorial/Step5/CMakeLists.txt new file mode 100644 index 000000000..3002ea084 --- /dev/null +++ b/Tests/Tutorial/Step5/CMakeLists.txt @@ -0,0 +1,72 @@ +cmake_minimum_required (VERSION 2.6) +project (Tutorial) + +# The version number. +set (Tutorial_VERSION_MAJOR 1) +set (Tutorial_VERSION_MINOR 0) + +# does this system provide the log and exp functions? +include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) +check_function_exists (log HAVE_LOG) +check_function_exists (exp HAVE_EXP) + +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) + +# configure a header file to pass some of the CMake settings +# to the source code +configure_file ( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +include_directories ("${PROJECT_BINARY_DIR}") + +# add the MathFunctions library? +if (USE_MYMATH) + include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") + add_subdirectory (MathFunctions) + set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) +endif (USE_MYMATH) + +# add the executable +add_executable (Tutorial tutorial.cxx) +target_link_libraries (Tutorial ${EXTRA_LIBS}) + +# add the install targets +install (TARGETS Tutorial DESTINATION bin) +install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include) + +# enable testing +enable_testing () + +# does the application run +add_test (TutorialRuns Tutorial 25) + +# does the usage message work? +add_test (TutorialUsage Tutorial) +set_tests_properties (TutorialUsage + PROPERTIES + PASS_REGULAR_EXPRESSION "Usage:.*number" + ) + +#define a macro to simplify adding tests +macro (do_test arg result) + add_test (TutorialComp${arg} Tutorial ${arg}) + set_tests_properties (TutorialComp${arg} + PROPERTIES PASS_REGULAR_EXPRESSION ${result} + ) +endmacro (do_test) + +# do a bunch of result based tests +do_test (4 "4 is 2") +do_test (9 "9 is 3") +do_test (5 "5 is 2.236") +do_test (7 "7 is 2.645") +do_test (25 "25 is 5") +do_test (-25 "-25 is 0") +do_test (0.0001 "0.0001 is 0.01") + diff --git a/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt new file mode 100644 index 000000000..453a46332 --- /dev/null +++ b/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt @@ -0,0 +1,17 @@ +# first we add the executable that generates the table +# add the binary tree directory to the search path for include files +include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) + +add_executable(MakeTable MakeTable.cxx ) +# add the command to generate the source code +add_custom_command ( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h + DEPENDS MakeTable + ) + +# add the main library +add_library(MathFunctions mysqrt.cxx ${CMAKE_CURRENT_BINARY_DIR}/Table.h ) + +install (TARGETS MathFunctions DESTINATION bin) +install (FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx new file mode 100644 index 000000000..540254271 --- /dev/null +++ b/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx @@ -0,0 +1,35 @@ +// A simple program that builds a sqrt table +#include <stdio.h> +#include <math.h> + +int main (int argc, char *argv[]) +{ + int i; + double result; + + // make sure we have enough arguments + if (argc < 2) + { + return 1; + } + + // open the output file + FILE *fout = fopen(argv[1],"w"); + if (!fout) + { + return 1; + } + + // create a source file with a table of square roots + fprintf(fout,"double sqrtTable[] = {\n"); + for (i = 0; i < 10; ++i) + { + result = sqrt(static_cast<double>(i)); + fprintf(fout,"%g,\n",result); + } + + // close the table with a zero + fprintf(fout,"0};\n"); + fclose(fout); + return 0; +} diff --git a/Tests/Tutorial/Step5/MathFunctions/MathFunctions.h b/Tests/Tutorial/Step5/MathFunctions/MathFunctions.h new file mode 100644 index 000000000..cd36bccff --- /dev/null +++ b/Tests/Tutorial/Step5/MathFunctions/MathFunctions.h @@ -0,0 +1 @@ +double mysqrt(double x); diff --git a/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx new file mode 100644 index 000000000..33659b740 --- /dev/null +++ b/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx @@ -0,0 +1,44 @@ +#include <stdio.h> +#include "MathFunctions.h" +#include "TutorialConfig.h" + +// include the generated table +#include "Table.h" + +#include <math.h> + +// a hack square root calculation using simple operations +double mysqrt(double x) +{ + if (x <= 0) + { + return 0; + } + + double result; + + // if we have both log and exp then use them + double delta; + + // use the table to help find an initial value + result = x; + if (x >= 1 && x < 10) + { + result = sqrtTable[static_cast<int>(x)]; + } + + // do ten iterations + int i; + for (i = 0; i < 10; ++i) + { + if (result <= 0) + { + result = 0.1; + } + delta = x - (result*result); + result = result + 0.5*delta/result; + fprintf(stdout,"Computing sqrt of %g to be %g\n",x,result); + } + + return result; +} diff --git a/Tests/Tutorial/Step5/TutorialConfig.h.in b/Tests/Tutorial/Step5/TutorialConfig.h.in new file mode 100644 index 000000000..a0912656a --- /dev/null +++ b/Tests/Tutorial/Step5/TutorialConfig.h.in @@ -0,0 +1,9 @@ +// the configured options and settings for Tutorial +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ +#cmakedefine USE_MYMATH + +// does the platform provide exp and log functions? +#cmakedefine HAVE_LOG +#cmakedefine HAVE_EXP + diff --git a/Tests/Tutorial/Step5/tutorial.cxx b/Tests/Tutorial/Step5/tutorial.cxx new file mode 100644 index 000000000..82b416f11 --- /dev/null +++ b/Tests/Tutorial/Step5/tutorial.cxx @@ -0,0 +1,34 @@ +// A simple program that computes the square root of a number +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "TutorialConfig.h" + +#ifdef USE_MYMATH +#include "MathFunctions.h" +#endif + +int main (int argc, char *argv[]) +{ + if (argc < 2) + { + fprintf(stdout,"%s Version %d.%d\n", + argv[0], + Tutorial_VERSION_MAJOR, + Tutorial_VERSION_MINOR); + fprintf(stdout,"Usage: %s number\n",argv[0]); + return 1; + } + + double inputValue = atof(argv[1]); + +#ifdef USE_MYMATH + double outputValue = mysqrt(inputValue); +#else + double outputValue = sqrt(inputValue); +#endif + + fprintf(stdout,"The square root of %g is %g\n", + inputValue, outputValue); + return 0; +} diff --git a/Tests/Tutorial/Step6/CMakeLists.txt b/Tests/Tutorial/Step6/CMakeLists.txt new file mode 100644 index 000000000..4f70f4fc4 --- /dev/null +++ b/Tests/Tutorial/Step6/CMakeLists.txt @@ -0,0 +1,78 @@ +cmake_minimum_required (VERSION 2.6) +project (Tutorial) + +# The version number. +set (Tutorial_VERSION_MAJOR 1) +set (Tutorial_VERSION_MINOR 0) + +# does this system provide the log and exp functions? +include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) +check_function_exists (log HAVE_LOG) +check_function_exists (exp HAVE_EXP) + +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) + +# configure a header file to pass some of the CMake settings +# to the source code +configure_file ( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +include_directories ("${PROJECT_BINARY_DIR}") + +# add the MathFunctions library? +if (USE_MYMATH) + include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") + add_subdirectory (MathFunctions) + set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) +endif (USE_MYMATH) + +# add the executable +add_executable (Tutorial tutorial.cxx) +target_link_libraries (Tutorial ${EXTRA_LIBS}) + +# add the install targets +install (TARGETS Tutorial DESTINATION bin) +install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include) + +# enable testing +enable_testing () + +# does the application run +add_test (TutorialRuns Tutorial 25) + +# does the usage message work? +add_test (TutorialUsage Tutorial) +set_tests_properties (TutorialUsage + PROPERTIES + PASS_REGULAR_EXPRESSION "Usage:.*number" + ) + +#define a macro to simplify adding tests +macro (do_test arg result) + add_test (TutorialComp${arg} Tutorial ${arg}) + set_tests_properties (TutorialComp${arg} + PROPERTIES PASS_REGULAR_EXPRESSION ${result} + ) +endmacro (do_test) + +# do a bunch of result based tests +do_test (4 "4 is 2") +do_test (9 "9 is 3") +do_test (5 "5 is 2.236") +do_test (7 "7 is 2.645") +do_test (25 "25 is 5") +do_test (-25 "-25 is 0") +do_test (0.0001 "0.0001 is 0.01") + +# build a CPack driven installer package +include (InstallRequiredSystemLibraries) +set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") +set (CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") +set (CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") +include (CPack) diff --git a/Tests/Tutorial/Step6/License.txt b/Tests/Tutorial/Step6/License.txt new file mode 100644 index 000000000..673d72453 --- /dev/null +++ b/Tests/Tutorial/Step6/License.txt @@ -0,0 +1,2 @@ +This is the open source License.txt file introduced in +CMake/Tests/Tutorial/Step6... diff --git a/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt new file mode 100644 index 000000000..d606ac03e --- /dev/null +++ b/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt @@ -0,0 +1,26 @@ +# first we add the executable that generates the table +add_executable(MakeTable MakeTable.cxx) + +get_target_property(MakeTableLocation MakeTable LOCATION) + +# add the command to generate the source code +add_custom_command ( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + DEPENDS MakeTable + COMMAND ${MakeTableLocation} + ARGS ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + +set_source_files_properties ( + mysqrt.cxx PROPERTIES + OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + +# add the binary tree directory to the search path for include files +include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) + +# add the main library +add_library(MathFunctions mysqrt.cxx) + +install (TARGETS MathFunctions DESTINATION bin) +install (FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx new file mode 100644 index 000000000..540254271 --- /dev/null +++ b/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx @@ -0,0 +1,35 @@ +// A simple program that builds a sqrt table +#include <stdio.h> +#include <math.h> + +int main (int argc, char *argv[]) +{ + int i; + double result; + + // make sure we have enough arguments + if (argc < 2) + { + return 1; + } + + // open the output file + FILE *fout = fopen(argv[1],"w"); + if (!fout) + { + return 1; + } + + // create a source file with a table of square roots + fprintf(fout,"double sqrtTable[] = {\n"); + for (i = 0; i < 10; ++i) + { + result = sqrt(static_cast<double>(i)); + fprintf(fout,"%g,\n",result); + } + + // close the table with a zero + fprintf(fout,"0};\n"); + fclose(fout); + return 0; +} diff --git a/Tests/Tutorial/Step6/MathFunctions/MathFunctions.h b/Tests/Tutorial/Step6/MathFunctions/MathFunctions.h new file mode 100644 index 000000000..cd36bccff --- /dev/null +++ b/Tests/Tutorial/Step6/MathFunctions/MathFunctions.h @@ -0,0 +1 @@ +double mysqrt(double x); diff --git a/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx new file mode 100644 index 000000000..33659b740 --- /dev/null +++ b/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx @@ -0,0 +1,44 @@ +#include <stdio.h> +#include "MathFunctions.h" +#include "TutorialConfig.h" + +// include the generated table +#include "Table.h" + +#include <math.h> + +// a hack square root calculation using simple operations +double mysqrt(double x) +{ + if (x <= 0) + { + return 0; + } + + double result; + + // if we have both log and exp then use them + double delta; + + // use the table to help find an initial value + result = x; + if (x >= 1 && x < 10) + { + result = sqrtTable[static_cast<int>(x)]; + } + + // do ten iterations + int i; + for (i = 0; i < 10; ++i) + { + if (result <= 0) + { + result = 0.1; + } + delta = x - (result*result); + result = result + 0.5*delta/result; + fprintf(stdout,"Computing sqrt of %g to be %g\n",x,result); + } + + return result; +} diff --git a/Tests/Tutorial/Step6/TutorialConfig.h.in b/Tests/Tutorial/Step6/TutorialConfig.h.in new file mode 100644 index 000000000..a0912656a --- /dev/null +++ b/Tests/Tutorial/Step6/TutorialConfig.h.in @@ -0,0 +1,9 @@ +// the configured options and settings for Tutorial +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ +#cmakedefine USE_MYMATH + +// does the platform provide exp and log functions? +#cmakedefine HAVE_LOG +#cmakedefine HAVE_EXP + diff --git a/Tests/Tutorial/Step6/tutorial.cxx b/Tests/Tutorial/Step6/tutorial.cxx new file mode 100644 index 000000000..82b416f11 --- /dev/null +++ b/Tests/Tutorial/Step6/tutorial.cxx @@ -0,0 +1,34 @@ +// A simple program that computes the square root of a number +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "TutorialConfig.h" + +#ifdef USE_MYMATH +#include "MathFunctions.h" +#endif + +int main (int argc, char *argv[]) +{ + if (argc < 2) + { + fprintf(stdout,"%s Version %d.%d\n", + argv[0], + Tutorial_VERSION_MAJOR, + Tutorial_VERSION_MINOR); + fprintf(stdout,"Usage: %s number\n",argv[0]); + return 1; + } + + double inputValue = atof(argv[1]); + +#ifdef USE_MYMATH + double outputValue = mysqrt(inputValue); +#else + double outputValue = sqrt(inputValue); +#endif + + fprintf(stdout,"The square root of %g is %g\n", + inputValue, outputValue); + return 0; +} diff --git a/Tests/Tutorial/Step7/CMakeLists.txt b/Tests/Tutorial/Step7/CMakeLists.txt new file mode 100644 index 000000000..42f73f221 --- /dev/null +++ b/Tests/Tutorial/Step7/CMakeLists.txt @@ -0,0 +1,82 @@ +cmake_minimum_required (VERSION 2.6) +project (Tutorial) + +# The version number. +set (Tutorial_VERSION_MAJOR 1) +set (Tutorial_VERSION_MINOR 0) + +# does this system provide the log and exp functions? +include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) +check_function_exists (log HAVE_LOG) +check_function_exists (exp HAVE_EXP) + +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) + +# configure a header file to pass some of the CMake settings +# to the source code +configure_file ( + "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" + "${PROJECT_BINARY_DIR}/TutorialConfig.h" + ) + +# add the binary tree to the search path for include files +# so that we will find TutorialConfig.h +include_directories ("${PROJECT_BINARY_DIR}") + +# add the MathFunctions library? +if (USE_MYMATH) + include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions") + add_subdirectory (MathFunctions) + set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions) +endif (USE_MYMATH) + +# add the executable +add_executable (Tutorial tutorial.cxx) +target_link_libraries (Tutorial ${EXTRA_LIBS}) + +# add the install targets +install (TARGETS Tutorial DESTINATION bin) +install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" + DESTINATION include) + +# enable testing +enable_testing () + +# does the application run +add_test (TutorialRuns Tutorial 25) + +# does the usage message work? +add_test (TutorialUsage Tutorial) +set_tests_properties (TutorialUsage + PROPERTIES + PASS_REGULAR_EXPRESSION "Usage:.*number" + ) + +#define a macro to simplify adding tests +macro (do_test arg result) + add_test (TutorialComp${arg} Tutorial ${arg}) + set_tests_properties (TutorialComp${arg} + PROPERTIES PASS_REGULAR_EXPRESSION ${result} + ) +endmacro (do_test) + +# do a bunch of result based tests +do_test (4 "4 is 2") +do_test (9 "9 is 3") +do_test (5 "5 is 2.236") +do_test (7 "7 is 2.645") +do_test (25 "25 is 5") +do_test (-25 "-25 is 0") +do_test (0.0001 "0.0001 is 0.01") + +# build a CPack driven installer package +include (InstallRequiredSystemLibraries) +set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") +set (CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") +set (CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") +set (CPACK_PACKAGE_CONTACT "foo@bar.org") +include (CPack) + +# enable dashboard scripting +include (CTest) diff --git a/Tests/Tutorial/Step7/CTestConfig.cmake b/Tests/Tutorial/Step7/CTestConfig.cmake new file mode 100644 index 000000000..d8f5c4491 --- /dev/null +++ b/Tests/Tutorial/Step7/CTestConfig.cmake @@ -0,0 +1 @@ +set (CTEST_PROJECT_NAME "Tutorial") diff --git a/Tests/Tutorial/Step7/License.txt b/Tests/Tutorial/Step7/License.txt new file mode 100644 index 000000000..673d72453 --- /dev/null +++ b/Tests/Tutorial/Step7/License.txt @@ -0,0 +1,2 @@ +This is the open source License.txt file introduced in +CMake/Tests/Tutorial/Step6... diff --git a/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt new file mode 100644 index 000000000..d606ac03e --- /dev/null +++ b/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt @@ -0,0 +1,26 @@ +# first we add the executable that generates the table +add_executable(MakeTable MakeTable.cxx) + +get_target_property(MakeTableLocation MakeTable LOCATION) + +# add the command to generate the source code +add_custom_command ( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h + DEPENDS MakeTable + COMMAND ${MakeTableLocation} + ARGS ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + +set_source_files_properties ( + mysqrt.cxx PROPERTIES + OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Table.h + ) + +# add the binary tree directory to the search path for include files +include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) + +# add the main library +add_library(MathFunctions mysqrt.cxx) + +install (TARGETS MathFunctions DESTINATION bin) +install (FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx new file mode 100644 index 000000000..540254271 --- /dev/null +++ b/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx @@ -0,0 +1,35 @@ +// A simple program that builds a sqrt table +#include <stdio.h> +#include <math.h> + +int main (int argc, char *argv[]) +{ + int i; + double result; + + // make sure we have enough arguments + if (argc < 2) + { + return 1; + } + + // open the output file + FILE *fout = fopen(argv[1],"w"); + if (!fout) + { + return 1; + } + + // create a source file with a table of square roots + fprintf(fout,"double sqrtTable[] = {\n"); + for (i = 0; i < 10; ++i) + { + result = sqrt(static_cast<double>(i)); + fprintf(fout,"%g,\n",result); + } + + // close the table with a zero + fprintf(fout,"0};\n"); + fclose(fout); + return 0; +} diff --git a/Tests/Tutorial/Step7/MathFunctions/MathFunctions.h b/Tests/Tutorial/Step7/MathFunctions/MathFunctions.h new file mode 100644 index 000000000..cd36bccff --- /dev/null +++ b/Tests/Tutorial/Step7/MathFunctions/MathFunctions.h @@ -0,0 +1 @@ +double mysqrt(double x); diff --git a/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx new file mode 100644 index 000000000..33659b740 --- /dev/null +++ b/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx @@ -0,0 +1,44 @@ +#include <stdio.h> +#include "MathFunctions.h" +#include "TutorialConfig.h" + +// include the generated table +#include "Table.h" + +#include <math.h> + +// a hack square root calculation using simple operations +double mysqrt(double x) +{ + if (x <= 0) + { + return 0; + } + + double result; + + // if we have both log and exp then use them + double delta; + + // use the table to help find an initial value + result = x; + if (x >= 1 && x < 10) + { + result = sqrtTable[static_cast<int>(x)]; + } + + // do ten iterations + int i; + for (i = 0; i < 10; ++i) + { + if (result <= 0) + { + result = 0.1; + } + delta = x - (result*result); + result = result + 0.5*delta/result; + fprintf(stdout,"Computing sqrt of %g to be %g\n",x,result); + } + + return result; +} diff --git a/Tests/Tutorial/Step7/TutorialConfig.h.in b/Tests/Tutorial/Step7/TutorialConfig.h.in new file mode 100644 index 000000000..a0912656a --- /dev/null +++ b/Tests/Tutorial/Step7/TutorialConfig.h.in @@ -0,0 +1,9 @@ +// the configured options and settings for Tutorial +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ +#cmakedefine USE_MYMATH + +// does the platform provide exp and log functions? +#cmakedefine HAVE_LOG +#cmakedefine HAVE_EXP + diff --git a/Tests/Tutorial/Step7/build1.cmake b/Tests/Tutorial/Step7/build1.cmake new file mode 100644 index 000000000..039d5569b --- /dev/null +++ b/Tests/Tutorial/Step7/build1.cmake @@ -0,0 +1,5 @@ +SET(CTEST_SOURCE_DIRECTORY "$ENV{HOME}/Dashboards/My Tests/CMake/Tests/Tutorial/Step7") +SET(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}-build1") + +SET(CTEST_CMAKE_COMMAND "cmake") +SET(CTEST_COMMAND "ctest -D Experimental") diff --git a/Tests/Tutorial/Step7/build2.cmake b/Tests/Tutorial/Step7/build2.cmake new file mode 100644 index 000000000..5112355b2 --- /dev/null +++ b/Tests/Tutorial/Step7/build2.cmake @@ -0,0 +1,9 @@ +SET(CTEST_SOURCE_DIRECTORY "$ENV{HOME}/Dashboards/My Tests/CMake/Tests/Tutorial/Step7") +SET(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}-build2") +SET(CTEST_CMAKE_GENERATOR "Visual Studio 8 2005") + +CTEST_START("Experimental") +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}") +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}") +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}") +CTEST_SUBMIT() diff --git a/Tests/Tutorial/Step7/tutorial.cxx b/Tests/Tutorial/Step7/tutorial.cxx new file mode 100644 index 000000000..82b416f11 --- /dev/null +++ b/Tests/Tutorial/Step7/tutorial.cxx @@ -0,0 +1,34 @@ +// A simple program that computes the square root of a number +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "TutorialConfig.h" + +#ifdef USE_MYMATH +#include "MathFunctions.h" +#endif + +int main (int argc, char *argv[]) +{ + if (argc < 2) + { + fprintf(stdout,"%s Version %d.%d\n", + argv[0], + Tutorial_VERSION_MAJOR, + Tutorial_VERSION_MINOR); + fprintf(stdout,"Usage: %s number\n",argv[0]); + return 1; + } + + double inputValue = atof(argv[1]); + +#ifdef USE_MYMATH + double outputValue = mysqrt(inputValue); +#else + double outputValue = sqrt(inputValue); +#endif + + fprintf(stdout,"The square root of %g is %g\n", + inputValue, outputValue); + return 0; +} diff --git a/Tests/Unset/CMakeLists.txt b/Tests/Unset/CMakeLists.txt new file mode 100644 index 000000000..bacb6d21f --- /dev/null +++ b/Tests/Unset/CMakeLists.txt @@ -0,0 +1,55 @@ +cmake_minimum_required(VERSION 2.6) +project(Unset C) + +# Local variable +set(x 42) +if(NOT x EQUAL 42) + message(FATAL_ERROR "x!=42") +endif(NOT x EQUAL 42) + +if(NOT DEFINED x) + message(FATAL_ERROR "x should be defined!") +endif(NOT DEFINED x) + +unset(x) +if(DEFINED x) + message(FATAL_ERROR "x should be undefined now!") +endif(DEFINED x) + +# Local variable test unset via set() +set(x 43) +if(NOT x EQUAL 43) + message(FATAL_ERROR "x!=43") +endif(NOT x EQUAL 43) +set(x) +if(DEFINED x) + message(FATAL_ERROR "x should be undefined now!") +endif(DEFINED x) + +# Cache variable +set(BAR "test" CACHE STRING "documentation") +if(NOT DEFINED BAR) + message(FATAL_ERROR "BAR not defined") +endif(NOT DEFINED BAR) + +# Test interaction of cache entries with variables. +set(BAR "test-var") +if(NOT "$CACHE{BAR}" STREQUAL "test") + message(FATAL_ERROR "\$CACHE{BAR} changed by variable BAR") +endif(NOT "$CACHE{BAR}" STREQUAL "test") +if(NOT "${BAR}" STREQUAL "test-var") + message(FATAL_ERROR "\${BAR} not separate from \$CACHE{BAR}") +endif(NOT "${BAR}" STREQUAL "test-var") +unset(BAR) +if(NOT "${BAR}" STREQUAL "test") + message(FATAL_ERROR "\${BAR} does not fall through to \$CACHE{BAR}") +endif(NOT "${BAR}" STREQUAL "test") + +# Test unsetting of CACHE entry. +unset(BAR CACHE) +if(DEFINED BAR) + message(FATAL_ERROR "BAR still defined") +endif(DEFINED BAR) + + +add_executable(Unset unset.c) diff --git a/Tests/Unset/unset.c b/Tests/Unset/unset.c new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/Unset/unset.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/VSExternalInclude/CMakeLists.txt b/Tests/VSExternalInclude/CMakeLists.txt new file mode 100644 index 000000000..a2fd61973 --- /dev/null +++ b/Tests/VSExternalInclude/CMakeLists.txt @@ -0,0 +1,60 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(VSExternalInclude) + +IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") + SET(PROJECT_EXT dsp) +ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") + SET(PROJECT_EXT vcproj) +ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") +IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[01]") + SET(PROJECT_EXT vcxproj) +ENDIF() + +# make sure directories exists +SET(LIB1_BINARY_DIR ${VSExternalInclude_BINARY_DIR}/Lib1) +MAKE_DIRECTORY("${LIB1_BINARY_DIR}") + +SET(LIB2_BINARY_DIR ${VSExternalInclude_BINARY_DIR}/Lib2) +MAKE_DIRECTORY("${LIB2_BINARY_DIR}") + +# generate lib1 +EXEC_PROGRAM("${CMAKE_COMMAND}" "${LIB1_BINARY_DIR}" ARGS -G\"${CMAKE_GENERATOR}\" + \"${VSExternalInclude_SOURCE_DIR}/Lib1\" OUTPUT_VARIABLE OUT) +MESSAGE("CMAKE Ran with the following output:\n\"${OUT}\"") + +# generate lib2 +EXEC_PROGRAM("${CMAKE_COMMAND}" "${LIB2_BINARY_DIR}" ARGS -G\"${CMAKE_GENERATOR}\" + \"${VSExternalInclude_SOURCE_DIR}/Lib2\" OUTPUT_VARIABLE OUT) +MESSAGE("CMAKE Ran with the following output:\n\"${OUT}\"") + + +INCLUDE_EXTERNAL_MSPROJECT(lib1 ${VSExternalInclude_BINARY_DIR}/Lib1/LIB1.${PROJECT_EXT}) +# lib2 depends on lib1 +INCLUDE_EXTERNAL_MSPROJECT(lib2 ${VSExternalInclude_BINARY_DIR}/Lib2/LIB2.${PROJECT_EXT} lib1) + +INCLUDE_DIRECTORIES(${VSExternalInclude_SOURCE_DIR}/Lib2 ${VSExternalInclude_SOURCE_DIR}/Lib1) + +SET(SOURCES main.cpp) + +ADD_EXECUTABLE(VSExternalInclude ${SOURCES}) + +# target depends on lib2 +ADD_DEPENDENCIES(VSExternalInclude lib2) +# VS 10 vcxproj files have depends in them +# Since lib1 and lib2 do not depend on each other +# then the vcxproj files do not depend on each other +# and the sln file can no longer be the only source +# of that depend. So, for VS 10 make the executable +# depend on lib1 and lib2 +IF(MSVC10 OR MSVC11) + 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) diff --git a/Tests/VSExternalInclude/Lib1/CMakeLists.txt b/Tests/VSExternalInclude/Lib1/CMakeLists.txt new file mode 100644 index 000000000..72ffcedc1 --- /dev/null +++ b/Tests/VSExternalInclude/Lib1/CMakeLists.txt @@ -0,0 +1,5 @@ +PROJECT(LIB1) + +SET(SOURCES lib1.cpp) + +ADD_LIBRARY(lib1 ${SOURCES}) diff --git a/Tests/VSExternalInclude/Lib1/lib1.cpp b/Tests/VSExternalInclude/Lib1/lib1.cpp new file mode 100644 index 000000000..690eb740f --- /dev/null +++ b/Tests/VSExternalInclude/Lib1/lib1.cpp @@ -0,0 +1,7 @@ + +#include "lib1.h" + +int add1(int num) +{ + return num + 1; +} diff --git a/Tests/VSExternalInclude/Lib1/lib1.h b/Tests/VSExternalInclude/Lib1/lib1.h new file mode 100644 index 000000000..543e71e02 --- /dev/null +++ b/Tests/VSExternalInclude/Lib1/lib1.h @@ -0,0 +1,8 @@ + +#ifndef LIB1_HPP +#define LIB1_HPP + +int add1(int num); + + +#endif diff --git a/Tests/VSExternalInclude/Lib2/CMakeLists.txt b/Tests/VSExternalInclude/Lib2/CMakeLists.txt new file mode 100644 index 000000000..31e40e4e1 --- /dev/null +++ b/Tests/VSExternalInclude/Lib2/CMakeLists.txt @@ -0,0 +1,7 @@ +PROJECT(VSEXTERNAL_LIB2) + +INCLUDE_DIRECTORIES(${VSEXTERNAL_LIB2_SOURCE_DIR}/../Lib1) + +SET(SOURCES lib2.cpp) + +ADD_LIBRARY(lib2 ${SOURCES}) diff --git a/Tests/VSExternalInclude/Lib2/lib2.cpp b/Tests/VSExternalInclude/Lib2/lib2.cpp new file mode 100644 index 000000000..adc2d29af --- /dev/null +++ b/Tests/VSExternalInclude/Lib2/lib2.cpp @@ -0,0 +1,9 @@ + +#include "lib2.h" +#include "lib1.h" + +int add1_and_mult2(int num) +{ + int tmp = add1(num); + return tmp * 2; +} diff --git a/Tests/VSExternalInclude/Lib2/lib2.h b/Tests/VSExternalInclude/Lib2/lib2.h new file mode 100644 index 000000000..48bda468d --- /dev/null +++ b/Tests/VSExternalInclude/Lib2/lib2.h @@ -0,0 +1,10 @@ + + +#ifndef LIB2_HPP +#define LIB2_HPP + +#include "lib1.h" + +int add1_and_mult2(int num); + +#endif diff --git a/Tests/VSExternalInclude/main.cpp b/Tests/VSExternalInclude/main.cpp new file mode 100644 index 000000000..ea1047cb6 --- /dev/null +++ b/Tests/VSExternalInclude/main.cpp @@ -0,0 +1,9 @@ + +#include "lib2.h" + +int main(int argc, char** argv) +{ + int num = add1_and_mult2(4); + + return 0; +} diff --git a/Tests/VSGNUFortran/CMakeLists.txt b/Tests/VSGNUFortran/CMakeLists.txt new file mode 100644 index 000000000..229c3156c --- /dev/null +++ b/Tests/VSGNUFortran/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 2.8) +project(VSGNUFortran) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") + +# force the executable to be put out of Debug/Release dir +# because gmake build of fortran will not be in a config +# directory, and for easier testing we want the exe and .dll +# to be in the same directory. +if(CMAKE_CONFIGURATION_TYPES) + foreach(config ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${config}" config) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${config} + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + endforeach() +endif() + +add_subdirectory(subdir) +include_directories(${VSGNUFortran_BINARY_DIR}/subdir/fortran) +add_subdirectory(c_code) +# use a cmake script to run the executable so that PATH +# can be set with the MinGW/bin in it, and the fortran +# runtime libraries can be found. +configure_file(runtest.cmake.in runtest.cmake @ONLY) diff --git a/Tests/VSGNUFortran/c_code/CMakeLists.txt b/Tests/VSGNUFortran/c_code/CMakeLists.txt new file mode 100644 index 000000000..27d22fd35 --- /dev/null +++ b/Tests/VSGNUFortran/c_code/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(c_using_fortran main.c) +target_link_libraries(c_using_fortran hello) diff --git a/Tests/VSGNUFortran/c_code/main.c b/Tests/VSGNUFortran/c_code/main.c new file mode 100644 index 000000000..9157cc5f3 --- /dev/null +++ b/Tests/VSGNUFortran/c_code/main.c @@ -0,0 +1,7 @@ +#include <HelloWorldFCMangle.h> /* created by FortranCInterface */ +extern void FC_hello(void); +int main() +{ + FC_hello(); + return 0; +} diff --git a/Tests/VSGNUFortran/runtest.cmake.in b/Tests/VSGNUFortran/runtest.cmake.in new file mode 100644 index 000000000..987207bc4 --- /dev/null +++ b/Tests/VSGNUFortran/runtest.cmake.in @@ -0,0 +1,23 @@ +get_filename_component(MINGW_PATH "@MINGW_GFORTRAN@" PATH) +if(NOT EXISTS "${MINGW_PATH}") + set(test_exe + "@VSGNUFortran_BINARY_DIR@/bin/c_using_fortran@CMAKE_EXECUTABLE_SUFFIX@") + message("run: ${test_exe}") + execute_process(COMMAND "${test_exe}" + RESULT_VARIABLE res) + if(NOT "${res}" EQUAL 0) + message(FATAL_ERROR "${test_exe} returned a non 0 value") + endif() + return() +endif() +file(TO_NATIVE_PATH "${MINGW_PATH}" MINGW_PATH) +string(REPLACE "\\" "\\\\" MINGW_PATH "${MINGW_PATH}") +message("${MINGW_PATH}") +set(test_exe "@VSGNUFortran_BINARY_DIR@/bin/c_using_fortran.exe") +set(ENV{PATH} "${MINGW_PATH}";$ENV{PATH}) +message("run ${test_exe}") +execute_process(COMMAND "${test_exe}" + RESULT_VARIABLE res) +if(NOT "${res}" EQUAL 0) + message(FATAL_ERROR "${test_exe} returned a non 0 value") +endif() diff --git a/Tests/VSGNUFortran/subdir/CMakeLists.txt b/Tests/VSGNUFortran/subdir/CMakeLists.txt new file mode 100644 index 000000000..0b9919953 --- /dev/null +++ b/Tests/VSGNUFortran/subdir/CMakeLists.txt @@ -0,0 +1,16 @@ +include(CMakeAddFortranSubdirectory) +# add the fortran subdirectory as a fortran project +# the subdir is fortran, the project is FortranHello +cmake_add_fortran_subdirectory(fortran + PROJECT FortranHello # project name in toplevel CMakeLists.txt + ARCHIVE_DIR ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} + RUNTIME_DIR bin # ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + LIBRARIES hello world # target libraries created + CMAKE_COMMAND_LINE + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + LINK_LIBRARIES # link interface libraries + LINK_LIBS hello world # hello needs world to link + NO_EXTERNAL_INSTALL + ) diff --git a/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt b/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt new file mode 100644 index 000000000..3ee1855c3 --- /dev/null +++ b/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required(VERSION 2.8) +project(FortranHello Fortran C) + +# add a function to test for -lsunquad on sunpro sun systems. +function(test_sunquad result) + set( TEST_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/sunq") + file(WRITE "${TEST_DIR}/testsunq.f" " + PROGRAM TEST + END + ") + file(WRITE ${TEST_DIR}/CMakeLists.txt " +project(sunq Fortran) +add_library(sunq SHARED testsunq.f) +target_link_libraries(sunq sunquad) +") + message(STATUS "looking for -lsunquad") + try_compile(RESULT "${TEST_DIR}" "${TEST_DIR}" sunq OUTPUT_VARIABLE OUT) + if("${RESULT}") + message(STATUS "-lsunquad found") + else() + message(STATUS "-lsunquad not found") + endif() + message(STATUS + "looking for sunquad:\nRESULT=[${RESULT}]\nOUTPUT=[\n${OUT}\n]") + set(${result} "${RESULT}" PARENT_SCOPE) +endfunction() + +# check for the fortran c interface mangling +include(FortranCInterface) +FortranCInterface_HEADER(HelloWorldFCMangle.h + MACRO_NAMESPACE "FC_" + SYMBOL_NAMESPACE "FC_" + SYMBOLS hello world) +add_library(hello SHARED hello.f) +add_library(world SHARED world.f) +target_link_libraries(hello world) +if(CMAKE_Fortran_COMPILER_ID MATCHES SunPro) + target_link_libraries(hello fsu) + if(CMAKE_Fortran_PLATFORM_ID MATCHES SunOS) + target_link_libraries(hello sunmath m) + test_sunquad(CMAKE_HAS_SUNQUAD) + if(CMAKE_HAS_SUNQUAD) + target_link_libraries(hello sunquad) + endif() + endif() +endif() diff --git a/Tests/VSGNUFortran/subdir/fortran/hello.f b/Tests/VSGNUFortran/subdir/fortran/hello.f new file mode 100644 index 000000000..e52119add --- /dev/null +++ b/Tests/VSGNUFortran/subdir/fortran/hello.f @@ -0,0 +1,7 @@ +!DEC$ ATTRIBUTES DLLEXPORT :: HELLO + SUBROUTINE HELLO + + PRINT *, 'Hello' + CALL WORLD + + END diff --git a/Tests/VSGNUFortran/subdir/fortran/world.f b/Tests/VSGNUFortran/subdir/fortran/world.f new file mode 100644 index 000000000..0598eeea6 --- /dev/null +++ b/Tests/VSGNUFortran/subdir/fortran/world.f @@ -0,0 +1,6 @@ +!DEC$ ATTRIBUTES DLLEXPORT :: WORLD + SUBROUTINE WORLD + + PRINT *, 'World!' + + END diff --git a/Tests/VSMidl/CMakeLists.txt b/Tests/VSMidl/CMakeLists.txt new file mode 100644 index 000000000..432506c3b --- /dev/null +++ b/Tests/VSMidl/CMakeLists.txt @@ -0,0 +1,81 @@ +# This CMakeLists.txt file exists solely to drive the one found in the "src" +# subdir as an ExternalProject build. The project in "src" cannot build when +# there is a space in the directory name, so we copy that directory to a place +# guaranteed not to have a space in the name, build it there, and then copy the +# resulting output directory back up here into this CMake test's build tree. +# +if(NOT DEFINED CMAKE_BUILDNAME) + string(REGEX REPLACE "^.*/([^/]+)/[^/]+/([^/]+)$" "\\1" CMAKE_BUILDNAME "${CMAKE_CURRENT_BINARY_DIR}") + string(REGEX REPLACE "^.*/([^/]+)/[^/]+/([^/]+)$" "\\2" THIS_TESTNAME "${CMAKE_CURRENT_BINARY_DIR}") + string(REPLACE " " "_" CMAKE_BUILDNAME "${CMAKE_BUILDNAME}") +endif() +message(STATUS "CMAKE_BUILDNAME='${CMAKE_BUILDNAME}'") +message(STATUS "THIS_TESTNAME='${THIS_TESTNAME}'") + +cmake_minimum_required(VERSION 2.8) +project(${THIS_TESTNAME}) + +include(ExternalProject) + +if(NOT DEFINED HOME) + if(DEFINED ENV{CTEST_REAL_HOME}) + set(HOME "$ENV{CTEST_REAL_HOME}") + else() + set(HOME "$ENV{HOME}") + endif() + + if(NOT HOME AND WIN32) + # Try for USERPROFILE as HOME equivalent: + string(REPLACE "\\" "/" HOME "$ENV{USERPROFILE}") + endif() + + # But just use root of SystemDrive if HOME contains any spaces: + # (Default on XP and earlier...) + if(HOME MATCHES " " AND WIN32) + string(REPLACE "\\" "/" HOME "$ENV{SystemDrive}") + endif() + if(HOME MATCHES " ") + set(HOME "") + endif() +endif() +message(STATUS "HOME='${HOME}'") + +if(NOT DEFINED url) + set(url "${CMAKE_CURRENT_SOURCE_DIR}/src") +endif() +message(STATUS "url='${url}'") + +set(base_dir "${HOME}/.cmake/Dashboards/${CMAKE_BUILDNAME}/${THIS_TESTNAME}") +set(binary_dir "${base_dir}/build") +set(source_dir "${base_dir}/src") + +# Source dir for this project exists in the CMake source tree, but we cannot +# use it in-place since there might be a space in its directory name. +# Source dir is therefore copied under a '.cmake/Dashboards' +# dir in your HOME directory to give it a name with no spaces. +# +ExternalProject_Add(clean-${PROJECT_NAME} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${source_dir}" + BUILD_COMMAND ${CMAKE_COMMAND} -E remove_directory "${binary_dir}" + INSTALL_COMMAND "" + ) + +ExternalProject_Add(download-${PROJECT_NAME} + URL "${url}" + SOURCE_DIR "${source_dir}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + DEPENDS clean-${PROJECT_NAME} + ) + +ExternalProject_Add(build-${PROJECT_NAME} + DOWNLOAD_COMMAND "" + SOURCE_DIR "${source_dir}" + BINARY_DIR "${binary_dir}" + INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory + "${binary_dir}/${CMAKE_CFG_INTDIR}" + "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" + DEPENDS download-${PROJECT_NAME} + ) diff --git a/Tests/VSMidl/src/CMakeLists.txt b/Tests/VSMidl/src/CMakeLists.txt new file mode 100644 index 000000000..86c04ed98 --- /dev/null +++ b/Tests/VSMidl/src/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 2.8) +project(VSMidl) + +if(MSVC_VERSION GREATER 1200) + include_directories("${CMAKE_CURRENT_BINARY_DIR}/\$(IntDir)") +else() + # midl generated headers end up directly in CMAKE_CURRENT_BINARY_DIR with + # VS6 builds. + include_directories("${CMAKE_CURRENT_BINARY_DIR}") +endif() + +add_executable(VSMidl main.cpp test.idl) diff --git a/Tests/VSMidl/src/main.cpp b/Tests/VSMidl/src/main.cpp new file mode 100644 index 000000000..6b78fcc7f --- /dev/null +++ b/Tests/VSMidl/src/main.cpp @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <test.h> +#include <test_i.c> + +int main(int argc, char** argv) +{ + IID libid = LIBID_CMakeMidlTestLib; + CLSID clsid = CLSID_CMakeMidlTest; + IID iid = IID_ICMakeMidlTest; + + printf("Running '%s'\n", argv[0]); + printf(" libid starts with '0x%08lx'\n", (long) libid.Data1); + printf(" clsid starts with '0x%08lx'\n", (long) clsid.Data1); + printf(" iid starts with '0x%08lx'\n", (long) iid.Data1); + + return 0; +} diff --git a/Tests/VSMidl/src/test.idl b/Tests/VSMidl/src/test.idl new file mode 100644 index 000000000..fd755c789 --- /dev/null +++ b/Tests/VSMidl/src/test.idl @@ -0,0 +1,30 @@ +import "oaidl.idl"; +import "ocidl.idl"; + +[ + object, + uuid(258CCEBE-8EE4-4A48-B78C-AC53BCD59E28), + dual, + nonextensible, + helpstring("ICMakeTest Interface"), + pointer_default(unique) +] +interface ICMakeMidlTest : IUnknown +{ + [id(1), helpstring("method Method")] HRESULT Method(); +} + +[ + uuid(0537BA59-7EEC-48F8-BD4B-369BC7D9807E), +] +library CMakeMidlTestLib +{ + [ + uuid(D2A90807-019A-46E5-BF47-FF4FA4352D2A), + helpstring("CMakeMidlTest Class") + ] + coclass CMakeMidlTest + { + [default] interface ICMakeMidlTest; + }; +} diff --git a/Tests/VSResource/CMakeLists.txt b/Tests/VSResource/CMakeLists.txt new file mode 100644 index 000000000..c5cb336ae --- /dev/null +++ b/Tests/VSResource/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 2.8.4) +project(VSResource) + +string(REPLACE "/INCREMENTAL:YES" "" + CMAKE_EXE_LINKER_FLAGS_DEBUG + "${CMAKE_EXE_LINKER_FLAGS_DEBUG}") + +message(STATUS "CMAKE_RC_COMPILER='${CMAKE_RC_COMPILER}'") + +# Because of the following avoidance techniques required for windres and VS6, +# we recommend using a configured header file, and defining preprocessor +# symbols via #define code and including that header in the rc file. Using +# add_definitions is fine for simple definitions (with no spaces and no +# quoting), but requires avoidance or work-arounds beyond that... + +if(CMAKE_RC_COMPILER MATCHES windres) + # windres rc compiler does not properly define quoted /D values as strings + message(STATUS "CMAKE_RC_COMPILER MATCHES windres") + add_definitions(/DCMAKE_RCDEFINE=test.txt) + add_definitions(/DCMAKE_RCDEFINE_NO_QUOTED_STRINGS) +elseif(MSVC60) + # VS6 rc compiler does not deal well with spaces in a "/D" value, but it can + # handle the quoting + message(STATUS "MSVC60") + add_definitions(/DCMAKE_RCDEFINE="test.txt") +else() + # expected case -- rc compiler is "capable enough" + message(STATUS + "rc compiler handles quoted strings with spaces in values via /D") + set(TEXTFILE_FROM_SOURCE_DIR "textfile, spaces in name, from binary dir") + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test.txt + "${CMAKE_CURRENT_BINARY_DIR}/test with spaces.txt" @ONLY) + include_directories(${CMAKE_CURRENT_BINARY_DIR}) + add_definitions(/DCMAKE_RCDEFINE="test with spaces.txt") +endif() + +add_executable(VSResource main.cpp test.rc) + +set_property(TARGET VSResource + PROPERTY VS_GLOBAL_CMakeTestVsGlobalVariable "test val") diff --git a/Tests/VSResource/main.cpp b/Tests/VSResource/main.cpp new file mode 100644 index 000000000..7ee0c74fa --- /dev/null +++ b/Tests/VSResource/main.cpp @@ -0,0 +1,80 @@ +#include <windows.h> +#include <stdio.h> + +struct x +{ + const char *txt; +}; + +int main(int argc, char** argv) +{ + int ret = 1; + + fprintf(stdout, "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)\n"); + +#ifdef CMAKE_RCDEFINE + fprintf(stdout, "CMAKE_RCDEFINE defined\n"); +#endif + +#ifdef CMAKE_RCDEFINE_NO_QUOTED_STRINGS + // Expect CMAKE_RCDEFINE to preprocess to exactly test.txt + x test; + test.txt = "*exactly* test.txt"; + fprintf(stdout, "CMAKE_RCDEFINE_NO_QUOTED_STRINGS defined\n"); + fprintf(stdout, "CMAKE_RCDEFINE is %s, and is *not* a string constant\n", + CMAKE_RCDEFINE); +#else + // Expect CMAKE_RCDEFINE to be a string: + fprintf(stdout, "CMAKE_RCDEFINE='%s', and is a string constant\n", + CMAKE_RCDEFINE); +#endif + + HRSRC hello = ::FindResource(NULL, MAKEINTRESOURCE(1025), "TEXTFILE"); + if(hello) + { + fprintf(stdout, "FindResource worked\n"); + HGLOBAL hgbl = ::LoadResource(NULL, hello); + int datasize = (int) ::SizeofResource(NULL, hello); + if(hgbl && datasize>0) + { + fprintf(stdout, "LoadResource worked\n"); + fprintf(stdout, "SizeofResource returned datasize='%d'\n", datasize); + void *data = ::LockResource(hgbl); + if (data) + { + fprintf(stdout, "LockResource worked\n"); + char *str = (char *) malloc(datasize+4); + if (str) + { + memcpy(str, data, datasize); + str[datasize] = 'E'; + str[datasize+1] = 'O'; + str[datasize+2] = 'R'; + str[datasize+3] = 0; + fprintf(stdout, "str='%s'\n", str); + free(str); + + ret = 0; + +#ifdef CMAKE_RCDEFINE_NO_QUOTED_STRINGS + fprintf(stdout, "LoadString skipped\n"); +#else + char buf[256]; + if (::LoadString(NULL, 1026, buf, sizeof(buf)) > 0) + { + fprintf(stdout, "LoadString worked\n"); + fprintf(stdout, "buf='%s'\n", buf); + } + else + { + fprintf(stdout, "LoadString failed\n"); + ret = 1; + } +#endif + } + } + } + } + + return ret; +} diff --git a/Tests/VSResource/test.rc b/Tests/VSResource/test.rc new file mode 100644 index 000000000..4ce4b5312 --- /dev/null +++ b/Tests/VSResource/test.rc @@ -0,0 +1,17 @@ +#ifdef CMAKE_RCDEFINE + +// This line can compile with either an unquoted or a quoted string +1025 TEXTFILE CMAKE_RCDEFINE + +#ifndef CMAKE_RCDEFINE_NO_QUOTED_STRINGS +// This block can only be compiled if CMAKE_RCDEFINE preprocesses +// to a double quoted string +STRINGTABLE +BEGIN + 1026 CMAKE_RCDEFINE +END +#endif + +#else +#error "resource compiler did not get defines from command line!" +#endif diff --git a/Tests/VSResource/test.txt b/Tests/VSResource/test.txt new file mode 100644 index 000000000..c27c68d1a --- /dev/null +++ b/Tests/VSResource/test.txt @@ -0,0 +1 @@ +Hello World! (@TEXTFILE_FROM_SOURCE_DIR@) diff --git a/Tests/VariableUnusedViaSet/CMakeLists.txt b/Tests/VariableUnusedViaSet/CMakeLists.txt new file mode 100644 index 000000000..0123ab221 --- /dev/null +++ b/Tests/VariableUnusedViaSet/CMakeLists.txt @@ -0,0 +1,4 @@ +set(UNUSED_VARIABLE) +# Warning should occur here +set(UNUSED_VARIABLE "Usage") +message(STATUS "${UNUSED_VARIABLE}") diff --git a/Tests/VariableUnusedViaUnset/CMakeLists.txt b/Tests/VariableUnusedViaUnset/CMakeLists.txt new file mode 100644 index 000000000..4b4031da3 --- /dev/null +++ b/Tests/VariableUnusedViaUnset/CMakeLists.txt @@ -0,0 +1,8 @@ +# NOTE: Changing lines in here changes the test results since the first +# instance shouldn't warn, but the second should and they have the same message + +# A warning should NOT be issued for this line: +set(UNUSED_VARIABLE) +# Warning should occur here: +set(UNUSED_VARIABLE) +message(STATUS "${UNUSED_VARIABLE}") diff --git a/Tests/VariableUsage/CMakeLists.txt b/Tests/VariableUsage/CMakeLists.txt new file mode 100644 index 000000000..4da1f56c7 --- /dev/null +++ b/Tests/VariableUsage/CMakeLists.txt @@ -0,0 +1 @@ +message(STATUS "${USED_VARIABLE}") diff --git a/Tests/Wrapping/CMakeLists.txt b/Tests/Wrapping/CMakeLists.txt new file mode 100644 index 000000000..c84dedc47 --- /dev/null +++ b/Tests/Wrapping/CMakeLists.txt @@ -0,0 +1,107 @@ +# +# Wrapping +# +cmake_minimum_required (VERSION 2.6) +PROJECT (Wrapping) + +# Disable cleaning of custom command outputs to preserve the hacks +# used to generate the files using CONFIGURE_FILE. +SET_DIRECTORY_PROPERTIES(PROPERTIES CLEAN_NO_CUSTOM 1) + +# +# Lib and exe path +# +SET (LIBRARY_OUTPUT_PATH + ${Wrapping_BINARY_DIR}/bin/ CACHE INTERNAL + "Single output directory for building all libraries.") + +SET (EXECUTABLE_OUTPUT_PATH + ${Wrapping_BINARY_DIR}/bin/ CACHE INTERNAL + "Single output directory for building all executables.") + +# +# Where will executable tests be written ? +# +IF (EXECUTABLE_OUTPUT_PATH) + SET (CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH}) +ELSE (EXECUTABLE_OUTPUT_PATH) + SET (CXX_TEST_PATH .) +ENDIF (EXECUTABLE_OUTPUT_PATH) + +# +# Add exe +# +ADD_EXECUTABLE (wrapping wrapping.cxx) + +ADD_EXECUTABLE (Wrap Wrap.c) +IF(WIN32) + SET(EXE_EXT ".exe") +ENDIF(WIN32) +SET(WRAP ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/Wrap${EXE_EXT}) + +# +# QT Wrappers +# + +SET (QT_WRAP_CPP "On") +SET (QT_MOC_EXE "echo") +INCLUDE( FindQt3 ) + +IF (QT_FOUND AND QT_WRAP_UI) + message("found qt 3 test it...") + INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} ) + INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ) + + + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/foo.ui.in + ${CMAKE_CURRENT_BINARY_DIR}/foo.ui IMMEDIATE) + + SET (QT_WRAP_UI "On") + SET (QT_UIC_EXE "${QT_UIC_EXECUTABLE}") + + + SET (QTUI_SRCS + qtwrapping.ui + ${CMAKE_CURRENT_BINARY_DIR}/foo.ui + ) + QT_WRAP_UI (myqtlib QTUI_H_SRCS QTUI_S_SRCS ${QTUI_SRCS}) + QT_WRAP_CPP (myqtlib QT_MOC_SRCS ${SRCS} vtkTestMoc.h) + + MESSAGE("QT files are ${QTUI_S_SRCS}") + MESSAGE("QT other files are ${QTUI_H_SRCS}") + ADD_DEFINITIONS(${QT_DEFINITIONS}) + ADD_LIBRARY(myqtlib ${QTUI_S_SRCS} ${QT_MOC_SRCS}) + ADD_EXECUTABLE (qtwrapping qtwrappingmain.cxx) + TARGET_LINK_LIBRARIES(qtwrapping myqtlib) + + TARGET_LINK_LIBRARIES( qtwrapping ${QT_LIBRARIES} ) +ELSE (QT_FOUND AND QT_WRAP_UI) + ADD_EXECUTABLE (qtwrapping qtnoqtmain.cxx) +ENDIF (QT_FOUND AND QT_WRAP_UI) + +# +# FLTK Wrappers +# +# Since FLTK_FLUID_EXE is supposed to create a .cxx/.h from a .fl/.fld, +# create an empty one so that the dependencies can be met. +# +SET (FLTK_SRCS + fltk1.fl + ) +ADD_EXECUTABLE(fakefluid fakefluid.cxx) +GET_TARGET_PROPERTY(FLUID_LOC fakefluid LOCATION) +SET (FLTK_WRAP_UI "On") +SET (FLTK_FLUID_EXECUTABLE "${FLUID_LOC}") +FLTK_WRAP_UI (wraplibFLTK ${FLTK_SRCS}) +ADD_LIBRARY(wraplibFLTK ${wraplibFLTK_FLTK_UI_SRCS}) +ADD_DEPENDENCIES(wraplibFLTK fakefluid) +ADD_DEPENDENCIES(fakefluid Wrap) +# +# Mangled Mesa +# +CONFIGURE_FILE( + ${Wrapping_SOURCE_DIR}/dummy + ${Wrapping_BINARY_DIR}/gl.h + COPYONLY IMMEDIATE) +USE_MANGLED_MESA (${Wrapping_BINARY_DIR} ${Wrapping_BINARY_DIR}/mangled_mesa) + diff --git a/Tests/Wrapping/Wrap.c b/Tests/Wrapping/Wrap.c new file mode 100644 index 000000000..0a1ff501e --- /dev/null +++ b/Tests/Wrapping/Wrap.c @@ -0,0 +1,23 @@ +#include <stdio.h> + +#ifdef __CLASSIC_C__ +int main(argc, argv) + int argc; + char ** argv; +#else +int main(int argc, const char* argv[]) +#endif +{ + FILE* fout = fopen(argv[argc-1], "w"); + printf("Wrap creating \"%s\"\n", argv[argc-1]); + if(fout) + { + fprintf(fout, "int foo() { return 0; }\n"); + fclose(fout); + } + else + { + return -1; + } + return 0; +} diff --git a/Tests/Wrapping/dummy b/Tests/Wrapping/dummy new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/Wrapping/dummy diff --git a/Tests/Wrapping/fakefluid.cxx b/Tests/Wrapping/fakefluid.cxx new file mode 100644 index 000000000..af4467997 --- /dev/null +++ b/Tests/Wrapping/fakefluid.cxx @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <string.h> +int main(int ac, char** av) +{ + for(int i =0; i < ac; ++i) + { + if(strcmp(av[i], "-o") == 0 || + strcmp(av[i], "-h") == 0) + { + fprintf(stdout, "fakefluid is creating file \"%s\"\n", av[i+1]); + FILE* file = fopen(av[i+1], "w"); + fprintf(file, "// hello\n"); + fclose(file); + } + } + return 0; +} diff --git a/Tests/Wrapping/fltk1.fl b/Tests/Wrapping/fltk1.fl new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/Wrapping/fltk1.fl diff --git a/Tests/Wrapping/foo.ui.in b/Tests/Wrapping/foo.ui.in new file mode 100644 index 000000000..4f57b5db1 --- /dev/null +++ b/Tests/Wrapping/foo.ui.in @@ -0,0 +1,44 @@ +<!DOCTYPE UI><UI> +<class>foo</class> +<widget> + <class>QDialog</class> + <property stdset="1"> + <name>name</name> + <cstring>qtwrapping</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>229</width> + <height>38</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>QTWrapUI Test program</string> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>This is a test for QTWrapUI.</string> + </property> + </widget> + </vbox> +</widget> +</UI> diff --git a/Tests/Wrapping/hints b/Tests/Wrapping/hints new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/Wrapping/hints diff --git a/Tests/Wrapping/itkWrapperConfig.cxx b/Tests/Wrapping/itkWrapperConfig.cxx new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/Wrapping/itkWrapperConfig.cxx diff --git a/Tests/Wrapping/qtnoqtmain.cxx b/Tests/Wrapping/qtnoqtmain.cxx new file mode 100644 index 000000000..8b7334a18 --- /dev/null +++ b/Tests/Wrapping/qtnoqtmain.cxx @@ -0,0 +1,5 @@ +int main(int ac, char** av) +{ + return 0; +} + diff --git a/Tests/Wrapping/qtwrapping.ui b/Tests/Wrapping/qtwrapping.ui new file mode 100644 index 000000000..67dcb9fbc --- /dev/null +++ b/Tests/Wrapping/qtwrapping.ui @@ -0,0 +1,44 @@ +<!DOCTYPE UI><UI> +<class>qtwrapping</class> +<widget> + <class>QDialog</class> + <property stdset="1"> + <name>name</name> + <cstring>qtwrapping</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>229</width> + <height>38</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>QTWrapUI Test program</string> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>This is a test for QTWrapUI.</string> + </property> + </widget> + </vbox> +</widget> +</UI> diff --git a/Tests/Wrapping/qtwrappingmain.cxx b/Tests/Wrapping/qtwrappingmain.cxx new file mode 100644 index 000000000..fabecfc72 --- /dev/null +++ b/Tests/Wrapping/qtwrappingmain.cxx @@ -0,0 +1,29 @@ +#include <qapplication.h> +#include "qtwrapping.h" + +#ifndef _WIN32 +# include <stdlib.h> +# include <stdio.h> +#endif + +int main(int argc, char *argv[]) +{ +#ifndef _WIN32 + const char* display = getenv("DISPLAY"); + if ( display && strlen(display)>0 ) + { +#endif + QApplication app(argc,argv); + + qtwrapping qtw; + app.setMainWidget(&qtw); +#ifndef _WIN32 + } + else + { + printf("Environment variable DISPLAY is not set. I will pretend like the test passed, but you should really set it.\n"); + } +#endif + + return 0; +} diff --git a/Tests/Wrapping/vtkExcluded.cxx b/Tests/Wrapping/vtkExcluded.cxx new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/Wrapping/vtkExcluded.cxx diff --git a/Tests/Wrapping/vtkExcluded.h b/Tests/Wrapping/vtkExcluded.h new file mode 100644 index 000000000..835f61a3e --- /dev/null +++ b/Tests/Wrapping/vtkExcluded.h @@ -0,0 +1,2 @@ +// A comment +// Another comment diff --git a/Tests/Wrapping/vtkIncluded.cxx b/Tests/Wrapping/vtkIncluded.cxx new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Tests/Wrapping/vtkIncluded.cxx diff --git a/Tests/Wrapping/vtkIncluded.h b/Tests/Wrapping/vtkIncluded.h new file mode 100644 index 000000000..a1c4aba26 --- /dev/null +++ b/Tests/Wrapping/vtkIncluded.h @@ -0,0 +1,2 @@ +// A comment +// Another comment (force coverage) diff --git a/Tests/Wrapping/vtkTestMoc.h b/Tests/Wrapping/vtkTestMoc.h new file mode 100644 index 000000000..f11a927f0 --- /dev/null +++ b/Tests/Wrapping/vtkTestMoc.h @@ -0,0 +1,8 @@ +#include <qapplication.h> + +class Foo : public QApplication +{ + Q_OBJECT +public: + Foo(); +}; diff --git a/Tests/Wrapping/wrapping.cxx b/Tests/Wrapping/wrapping.cxx new file mode 100644 index 000000000..1482f27e5 --- /dev/null +++ b/Tests/Wrapping/wrapping.cxx @@ -0,0 +1,4 @@ +int main () +{ + return 0; +} diff --git a/Tests/X11/CMakeLists.txt b/Tests/X11/CMakeLists.txt new file mode 100644 index 000000000..03aa09578 --- /dev/null +++ b/Tests/X11/CMakeLists.txt @@ -0,0 +1,40 @@ +# a simple C only test case +cmake_minimum_required (VERSION 2.6) +PROJECT (UseX11 CXX C) + +INCLUDE (${CMAKE_ROOT}/Modules/FindX11.cmake) +MESSAGE("X11_FOUND: ${X11_FOUND}") + +ADD_EXECUTABLE (UseX11 X11.c) +install(TARGETS UseX11 DESTINATION bin) + +# so for universal binaries this test will fail if +# +IF(APPLE) + LIST(LENGTH CMAKE_OSX_ARCHITECTURES NUMARCH) + IF(NUMARCH GREATER 1) + IF(NOT EXISTS /usr/X11R6/lib//libSM.6.dylib) + SET(X11_FOUND FALSE) + MESSAGE("disable X11, because of universal binary and sysroot") + ENDIF(NOT EXISTS /usr/X11R6/lib//libSM.6.dylib) + ENDIF(NUMARCH GREATER 1) +ENDIF(APPLE) + +IF(X11_FOUND) + ADD_DEFINITIONS(-DCMAKE_HAS_X) + INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR}) + TARGET_LINK_LIBRARIES(UseX11 ${X11_LIBRARIES}) + IF(APPLE) + ADD_EXECUTABLE(HelloWorldX11 HelloWorldX11.cxx) + TARGET_LINK_LIBRARIES(HelloWorldX11 ${X11_LIBRARIES}) + install(TARGETS HelloWorldX11 DESTINATION bin) + + set(CPACK_BINARY_OSXX11 ON CACHE BOOL "" FORCE) + set(CPACK_BINARY_PACKAGEMAKER OFF CACHE BOOL "" FORCE ) + set(CPACK_PACKAGE_NAME HelloWorldX11Package) + set(CPACK_PACKAGE_EXECUTABLES HelloWorldX11 HelloWorldX11) + ENDIF(APPLE) +ENDIF(X11_FOUND) + +# build a CPack driven installer package +include(CPack) diff --git a/Tests/X11/HelloWorldX11.cxx b/Tests/X11/HelloWorldX11.cxx new file mode 100644 index 000000000..e3c9dd9cf --- /dev/null +++ b/Tests/X11/HelloWorldX11.cxx @@ -0,0 +1,146 @@ + +/*** START MAIN.H ***/ +/* http://www.geocities.com/jeff_louie/x11/helloworld.htm* */ +/* + * main.h + * TestX + * + * Created by Jeff Louie on Tue Feb 03 2004. + * Copyright (c) 2004 __MyCompanyName__. All rights reserved. + * + */ + + +#ifndef MAIN_H +#define MAIN_H 1 + +#include <iostream> +#include <stdlib.h> + +/* include the X library headers */ +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/Xos.h> + +class Main { + +public: + // constructor + Main(int argc, char * const argv[]); + //virtual ~Main(); + + +private: + + + /* here are our X variables */ + Display *dis; + int screen; + Window win; + GC gc; + + /* here are our X routines declared! */ + void init_x(); + void close_x(); + void redraw(); + int delay(int i); + +}; + +#endif + +/*** END MAIN.H ***/ + +/*** START MAIN.CPP ***/ + +// modified from Brian Hammond's Howdy program at +// http://www.insanityengine.com/doc/x11/xintro.html +// jeff louie 02.05.2004 + + + +int main (int argc, char * const argv[]) { + Main m(argc, argv); + return 0; +} + +//Main::~Main() {;}; +Main::Main (int argc, char * const argv[]) { + XEvent event; // XEvent declaration + KeySym key; // KeyPress Events + char text[255]; // char buffer for KeyPress Events + + init_x(); + + // event loop + while(1) { + // get the next event and stuff it into our event variable. + // Note: only events we set the mask for are detected! + XNextEvent(dis, &event); + + + switch (event.type) { + int x; + int y; + case Expose: + if (event.xexpose.count==0) { + redraw(); + } + break; + case KeyPress: + if (XLookupString(&event.xkey,text,255,&key,0)==1) { + // use the XLookupString routine to convert the invent + // KeyPress data into regular text. Weird but necessary... + if ((text[0]=='q') || (text[0]=='Q')) { + close_x(); + } + else { + // echo key press + printf("You pressed the %c key!\n",text[0]); + } + } + break; + case ButtonPress: + // get cursor position + x= event.xbutton.x; + y= event.xbutton.y; + strcpy(text,"X is FUN!"); + XSetForeground(dis,gc,rand()%event.xbutton.x%255); + // draw text at cursor + XDrawString(dis,win,gc,x,y, text, strlen(text)); + break; + default: + printf("Unhandled event.\n"); + } + } +} + +void Main::init_x() { + unsigned long black,white; + + dis=XOpenDisplay(NULL); + screen=DefaultScreen(dis); + black=BlackPixel(dis,screen), + white=WhitePixel(dis, screen); + win=XCreateSimpleWindow(dis,DefaultRootWindow(dis),0,0, + 300, 300, 5,black, white); + XSetStandardProperties(dis,win,"Hello World","Hi",None,NULL,0,NULL); + XSelectInput(dis, win, ExposureMask|ButtonPressMask|KeyPressMask); + // get Graphics Context + gc=XCreateGC(dis, win, 0,0); + XSetBackground(dis,gc,white); + XSetForeground(dis,gc,black); + XClearWindow(dis, win); + XMapRaised(dis, win); +}; + +void Main::close_x() { + XFreeGC(dis, gc); + XDestroyWindow(dis,win); + XCloseDisplay(dis); + exit(1); +}; + +void Main::redraw() { + XClearWindow(dis, win); +}; diff --git a/Tests/X11/X11.c b/Tests/X11/X11.c new file mode 100644 index 000000000..b802ed8b9 --- /dev/null +++ b/Tests/X11/X11.c @@ -0,0 +1,21 @@ +#include "stdio.h" +#ifdef CMAKE_HAS_X + +#include <X11/Xlib.h> +#include <X11/Xutil.h> + +int main() +{ + printf("There is X on this computer\n"); + return 0; +} + +#else + +int main() +{ + printf("No X on this computer\n"); + return 0; +} + +#endif diff --git a/Tests/bootstrap.bat.in b/Tests/bootstrap.bat.in new file mode 100644 index 000000000..aeb24b1ca --- /dev/null +++ b/Tests/bootstrap.bat.in @@ -0,0 +1,2 @@ +@echo off +sh "@CMake_SOURCE_DIR@/bootstrap" %* diff --git a/Tests/iOSNavApp/CMakeLists.txt b/Tests/iOSNavApp/CMakeLists.txt new file mode 100644 index 000000000..12c3ada35 --- /dev/null +++ b/Tests/iOSNavApp/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 2.8.5) +project(NavApp3) + +set(CMAKE_OSX_SYSROOT iphoneos4.3) +set(CMAKE_OSX_ARCHITECTURES "armv6;armv7;i386") +set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator") + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/Classes + ) + +add_library(Functions STATIC TotalFunction.c TotalFunction.h) + +set(M_SRCS main.m Classes/NavApp3AppDelegate.m Classes/RootViewController.m) +set(HEADERS Classes/NavApp3AppDelegate.h Classes/RootViewController.h) +set(RESOURCES MainWindow.xib RootViewController.xib) + +add_executable(NavApp3 MACOSX_BUNDLE ${M_SRCS} ${HEADERS} ${RESOURCES}) + +target_link_libraries(NavApp3 + Functions + "-framework CoreGraphics" + "-framework Foundation" + "-framework UIKit" + ) + +set_target_properties(NavApp3 PROPERTIES + MACOSX_BUNDLE_GUI_IDENTIFIER "com.yourcompany.NavApp3" + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in + RESOURCE "${RESOURCES}" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer" + XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym" + XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER YES + XCODE_ATTRIBUTE_GCC_PREFIX_HEADER ${CMAKE_CURRENT_LIST_DIR}/NavApp3_Prefix.pch + XCODE_ATTRIBUTE_INFOPLIST_PREPROCESS YES + XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 3.0 + ) diff --git a/Tests/iOSNavApp/Classes/NavApp3AppDelegate.h b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.h new file mode 100644 index 000000000..f1234fe8b --- /dev/null +++ b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.h @@ -0,0 +1,20 @@ +// +// NavApp3AppDelegate.h +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import <UIKit/UIKit.h> + +@interface NavApp3AppDelegate : NSObject <UIApplicationDelegate> { + + UIWindow *window; + UINavigationController *navigationController; +} + +@property (nonatomic, retain) IBOutlet UIWindow *window; +@property (nonatomic, retain) IBOutlet UINavigationController *navigationController; + +@end diff --git a/Tests/iOSNavApp/Classes/NavApp3AppDelegate.m b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.m new file mode 100644 index 000000000..c82204c11 --- /dev/null +++ b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.m @@ -0,0 +1,88 @@ +// +// NavApp3AppDelegate.m +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import "NavApp3AppDelegate.h" +#import "RootViewController.h" + + +@implementation NavApp3AppDelegate + +@synthesize window; +@synthesize navigationController; + + +#pragma mark - +#pragma mark Application lifecycle + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + // Override point for customization after application launch. + // Add the navigation controller's view to the window and display. + [self.window addSubview:navigationController.view]; + [self.window makeKeyAndVisible]; + + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + /* + Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + */ +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + /* + Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + If your application supports background execution, called instead of applicationWillTerminate: when the user quits. + */ +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + /* + Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. + */ +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + /* + Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + */ +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + /* + Called when the application is about to terminate. + See also applicationDidEnterBackground:. + */ +} + + +#pragma mark - +#pragma mark Memory management + +- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { + /* + Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. + */ +} + + +- (void)dealloc { + [navigationController release]; + [window release]; + [super dealloc]; +} + + +@end diff --git a/Tests/iOSNavApp/Classes/RootViewController.h b/Tests/iOSNavApp/Classes/RootViewController.h new file mode 100644 index 000000000..c5e9c1148 --- /dev/null +++ b/Tests/iOSNavApp/Classes/RootViewController.h @@ -0,0 +1,14 @@ +// +// RootViewController.h +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import <UIKit/UIKit.h> + +@interface RootViewController : UITableViewController { +} + +@end diff --git a/Tests/iOSNavApp/Classes/RootViewController.m b/Tests/iOSNavApp/Classes/RootViewController.m new file mode 100644 index 000000000..8a20d89db --- /dev/null +++ b/Tests/iOSNavApp/Classes/RootViewController.m @@ -0,0 +1,168 @@ +// +// RootViewController.m +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import "RootViewController.h" + +#include "TotalFunction.h" + + +@implementation RootViewController + + +#pragma mark - +#pragma mark View lifecycle + +/* +- (void)viewDidLoad { + [super viewDidLoad]; + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem; +} +*/ + +/* +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; +} +*/ +/* +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; +} +*/ +/* +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; +} +*/ +/* +- (void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; +} +*/ + +/* + // Override to allow orientations other than the default portrait orientation. +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations. + return (interfaceOrientation == UIInterfaceOrientationPortrait); +} + */ + + +#pragma mark - +#pragma mark Table view data source + +// Customize the number of sections in the table view. +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + + +// Customize the number of rows in the table view. +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + int n = Total("numberOfRows"); + return n; +} + + +// Customize the appearance of table view cells. +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; + } + + // Configure the cell. + cell.textLabel.text = [NSString stringWithFormat:@"%d", [indexPath row]]; + + return cell; +} + + +/* +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; +} +*/ + + +/* +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source. + [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } + else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. + } +} +*/ + + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +} +*/ + + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + + +#pragma mark - +#pragma mark Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + + /* + <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; + // ... + // Pass the selected object to the new view controller. + [self.navigationController pushViewController:detailViewController animated:YES]; + [detailViewController release]; + */ +} + + +#pragma mark - +#pragma mark Memory management + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Relinquish ownership any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand. + // For example: self.myOutlet = nil; +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/Tests/iOSNavApp/Info.plist.in b/Tests/iOSNavApp/Info.plist.in new file mode 100644 index 000000000..6ea0f00ee --- /dev/null +++ b/Tests/iOSNavApp/Info.plist.in @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleDisplayName</key> + <string>NavApp3</string> + <key>CFBundleExecutable</key> + <string>NavApp3</string> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundleIdentifier</key> + <string>com.yourcompany.NavApp3</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>NavApp3</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>LSRequiresIPhoneOS</key> + <true/> + <key>NSMainNibFile</key> + <string>MainWindow</string> + <key>UISupportedInterfaceOrientations</key> + <array/> +</dict> +</plist> diff --git a/Tests/iOSNavApp/MainWindow.xib b/Tests/iOSNavApp/MainWindow.xib new file mode 100644 index 000000000..1ff5f67fc --- /dev/null +++ b/Tests/iOSNavApp/MainWindow.xib @@ -0,0 +1,542 @@ +<?xml version="1.0" encoding="UTF-8"?> +<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10"> + <data> + <int key="IBDocument.SystemTarget">1024</int> + <string key="IBDocument.SystemVersion">10D571</string> + <string key="IBDocument.InterfaceBuilderVersion">786</string> + <string key="IBDocument.AppKitVersion">1038.29</string> + <string key="IBDocument.HIToolboxVersion">460.00</string> + <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> + <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="NS.object.0">112</string> + </object> + <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> + <bool key="EncodedWithXMLCoder">YES</bool> + <integer value="13"/> + </object> + <object class="NSArray" key="IBDocument.PluginDependencies"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + </object> + <object class="NSMutableDictionary" key="IBDocument.Metadata"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys" id="0"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBProxyObject" id="841351856"> + <string key="IBProxiedObjectIdentifier">IBFilesOwner</string> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + </object> + <object class="IBProxyObject" id="302016328"> + <string key="IBProxiedObjectIdentifier">IBFirstResponder</string> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + </object> + <object class="IBUICustomObject" id="664661524"> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + </object> + <object class="IBUIWindow" id="380026005"> + <nil key="NSNextResponder"/> + <int key="NSvFlags">1316</int> + <object class="NSPSMatrix" key="NSFrameMatrix"/> + <string key="NSFrameSize">{320, 480}</string> + <object class="NSColor" key="IBUIBackgroundColor"> + <int key="NSColorSpace">1</int> + <bytes key="NSRGB">MSAxIDEAA</bytes> + </object> + <bool key="IBUIOpaque">NO</bool> + <bool key="IBUIClearsContextBeforeDrawing">NO</bool> + <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + <bool key="IBUIResizesToFullScreen">YES</bool> + </object> + <object class="IBUINavigationController" id="701001926"> + <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/> + <object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics"> + <int key="interfaceOrientation">1</int> + </object> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + <bool key="IBUIHorizontal">NO</bool> + <object class="IBUINavigationBar" key="IBUINavigationBar" id="207850653"> + <nil key="NSNextResponder"/> + <int key="NSvFlags">256</int> + <string key="NSFrameSize">{0, 0}</string> + <bool key="IBUIOpaque">NO</bool> + <bool key="IBUIClipsSubviews">YES</bool> + <bool key="IBUIMultipleTouchEnabled">YES</bool> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + </object> + <object class="NSMutableArray" key="IBUIViewControllers"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBUIViewController" id="619226028"> + <object class="IBUINavigationItem" key="IBUINavigationItem" id="394667715"> + <reference key="IBUINavigationBar"/> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + </object> + <reference key="IBUIParentViewController" ref="701001926"/> + <string key="IBUINibName">RootViewController</string> + <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/> + <object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics"> + <int key="interfaceOrientation">1</int> + </object> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + <bool key="IBUIHorizontal">NO</bool> + </object> + </object> + </object> + </object> + <object class="IBObjectContainer" key="IBDocument.Objects"> + <object class="NSMutableArray" key="connectionRecords"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchOutletConnection" key="connection"> + <string key="label">delegate</string> + <reference key="source" ref="841351856"/> + <reference key="destination" ref="664661524"/> + </object> + <int key="connectionID">4</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchOutletConnection" key="connection"> + <string key="label">window</string> + <reference key="source" ref="664661524"/> + <reference key="destination" ref="380026005"/> + </object> + <int key="connectionID">5</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchOutletConnection" key="connection"> + <string key="label">navigationController</string> + <reference key="source" ref="664661524"/> + <reference key="destination" ref="701001926"/> + </object> + <int key="connectionID">15</int> + </object> + </object> + <object class="IBMutableOrderedSet" key="objectRecords"> + <object class="NSArray" key="orderedObjects"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBObjectRecord"> + <int key="objectID">0</int> + <reference key="object" ref="0"/> + <reference key="children" ref="1000"/> + <nil key="parent"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">2</int> + <reference key="object" ref="380026005"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + <reference key="parent" ref="0"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-1</int> + <reference key="object" ref="841351856"/> + <reference key="parent" ref="0"/> + <string key="objectName">File's Owner</string> + </object> + <object class="IBObjectRecord"> + <int key="objectID">3</int> + <reference key="object" ref="664661524"/> + <reference key="parent" ref="0"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-2</int> + <reference key="object" ref="302016328"/> + <reference key="parent" ref="0"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">9</int> + <reference key="object" ref="701001926"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="207850653"/> + <reference ref="619226028"/> + </object> + <reference key="parent" ref="0"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">11</int> + <reference key="object" ref="207850653"/> + <reference key="parent" ref="701001926"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">13</int> + <reference key="object" ref="619226028"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="394667715"/> + </object> + <reference key="parent" ref="701001926"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">14</int> + <reference key="object" ref="394667715"/> + <reference key="parent" ref="619226028"/> + </object> + </object> + </object> + <object class="NSMutableDictionary" key="flattenedProperties"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>-1.CustomClassName</string> + <string>-2.CustomClassName</string> + <string>11.IBPluginDependency</string> + <string>13.CustomClassName</string> + <string>13.IBPluginDependency</string> + <string>2.IBAttributePlaceholdersKey</string> + <string>2.IBEditorWindowLastContentRect</string> + <string>2.IBPluginDependency</string> + <string>3.CustomClassName</string> + <string>3.IBPluginDependency</string> + <string>9.IBEditorWindowLastContentRect</string> + <string>9.IBPluginDependency</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>UIApplication</string> + <string>UIResponder</string> + <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string>RootViewController</string> + <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <object class="NSMutableDictionary"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference key="dict.sortedKeys" ref="0"/> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <string>{{673, 376}, {320, 480}}</string> + <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string>NavApp3AppDelegate</string> + <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string>{{186, 376}, {320, 480}}</string> + <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + </object> + </object> + <object class="NSMutableDictionary" key="unlocalizedProperties"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference key="dict.sortedKeys" ref="0"/> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <nil key="activeLocalization"/> + <object class="NSMutableDictionary" key="localizations"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference key="dict.sortedKeys" ref="0"/> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <nil key="sourceID"/> + <int key="maxID">16</int> + </object> + <object class="IBClassDescriber" key="IBDocument.Classes"> + <object class="NSMutableArray" key="referencedPartialClassDescriptions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">RootViewController</string> + <string key="superclassName">UITableViewController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Classes/RootViewController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIWindow</string> + <string key="superclassName">UIView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBUserSource</string> + <string key="minorKey"/> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NavApp3AppDelegate</string> + <string key="superclassName">NSObject</string> + <object class="NSMutableDictionary" key="outlets"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>navigationController</string> + <string>window</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>UINavigationController</string> + <string>UIWindow</string> + </object> + </object> + <object class="NSMutableDictionary" key="toOneOutletInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>navigationController</string> + <string>window</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBToOneOutletInfo"> + <string key="name">navigationController</string> + <string key="candidateClassName">UINavigationController</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">window</string> + <string key="candidateClassName">UIWindow</string> + </object> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Classes/NavApp3AppDelegate.h</string> + </object> + </object> + </object> + <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSError.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSObject.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSThread.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURL.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIAccessibility.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UINibLoading.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="48103097"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIResponder.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIApplication</string> + <string key="superclassName">UIResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIApplication.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIBarButtonItem</string> + <string key="superclassName">UIBarItem</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIBarButtonItem.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIBarItem</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIBarItem.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UINavigationBar</string> + <string key="superclassName">UIView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="193736137"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UINavigationBar.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UINavigationController</string> + <string key="superclassName">UIViewController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="720195805"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UINavigationController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UINavigationItem</string> + <string key="superclassName">NSObject</string> + <reference key="sourceIdentifier" ref="193736137"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIResponder</string> + <string key="superclassName">NSObject</string> + <reference key="sourceIdentifier" ref="48103097"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UISearchBar</string> + <string key="superclassName">UIView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UISearchBar.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UISearchDisplayController</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UISearchDisplayController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UITableViewController</string> + <string key="superclassName">UIViewController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UITableViewController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UITextField.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIView</string> + <string key="superclassName">UIResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIViewController</string> + <reference key="sourceIdentifier" ref="720195805"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIViewController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIPopoverController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIViewController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UISplitViewController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIViewController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UITabBarController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIViewController</string> + <string key="superclassName">UIResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIViewController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIWindow</string> + <string key="superclassName">UIView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIWindow.h</string> + </object> + </object> + </object> + </object> + <int key="IBDocument.localizationMode">0</int> + <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string> + <integer value="1024" key="NS.object.0"/> + </object> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string> + <integer value="3100" key="NS.object.0"/> + </object> + <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> + <string key="IBDocument.LastKnownRelativeProjectPath">NavApp3.xcodeproj</string> + <int key="IBDocument.defaultPropertyAccessControl">3</int> + <string key="IBCocoaTouchPluginVersion">112</string> + </data> +</archive> diff --git a/Tests/iOSNavApp/NavApp3_Prefix.pch b/Tests/iOSNavApp/NavApp3_Prefix.pch new file mode 100644 index 000000000..9919f3076 --- /dev/null +++ b/Tests/iOSNavApp/NavApp3_Prefix.pch @@ -0,0 +1,14 @@ +// +// Prefix header for all source files of the 'NavApp3' target in the 'NavApp3' project +// +#import <Availability.h> + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iPhone SDK 3.0 and later." +#endif + + +#ifdef __OBJC__ + #import <Foundation/Foundation.h> + #import <UIKit/UIKit.h> +#endif diff --git a/Tests/iOSNavApp/RootViewController.xib b/Tests/iOSNavApp/RootViewController.xib new file mode 100644 index 000000000..12a4831f2 --- /dev/null +++ b/Tests/iOSNavApp/RootViewController.xib @@ -0,0 +1,384 @@ +<?xml version="1.0" encoding="UTF-8"?> +<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10"> + <data> + <int key="IBDocument.SystemTarget">784</int> + <string key="IBDocument.SystemVersion">10D541</string> + <string key="IBDocument.InterfaceBuilderVersion">760</string> + <string key="IBDocument.AppKitVersion">1038.29</string> + <string key="IBDocument.HIToolboxVersion">460.00</string> + <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> + <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="NS.object.0">81</string> + </object> + <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> + <bool key="EncodedWithXMLCoder">YES</bool> + <integer value="2"/> + </object> + <object class="NSArray" key="IBDocument.PluginDependencies"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + </object> + <object class="NSMutableDictionary" key="IBDocument.Metadata"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys" id="0"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBProxyObject" id="841351856"> + <string key="IBProxiedObjectIdentifier">IBFilesOwner</string> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + </object> + <object class="IBProxyObject" id="371349661"> + <string key="IBProxiedObjectIdentifier">IBFirstResponder</string> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + </object> + <object class="IBUITableView" id="709618507"> + <reference key="NSNextResponder"/> + <int key="NSvFlags">274</int> + <string key="NSFrameSize">{320, 247}</string> + <reference key="NSSuperview"/> + <object class="NSColor" key="IBUIBackgroundColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MQA</bytes> + </object> + <bool key="IBUIOpaque">NO</bool> + <bool key="IBUIClipsSubviews">YES</bool> + <bool key="IBUIClearsContextBeforeDrawing">NO</bool> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + <bool key="IBUIBouncesZoom">NO</bool> + <int key="IBUISeparatorStyle">1</int> + <int key="IBUISectionIndexMinimumDisplayRowCount">0</int> + <bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool> + <float key="IBUIRowHeight">44</float> + <float key="IBUISectionHeaderHeight">22</float> + <float key="IBUISectionFooterHeight">22</float> + </object> + </object> + <object class="IBObjectContainer" key="IBDocument.Objects"> + <object class="NSMutableArray" key="connectionRecords"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchOutletConnection" key="connection"> + <string key="label">view</string> + <reference key="source" ref="841351856"/> + <reference key="destination" ref="709618507"/> + </object> + <int key="connectionID">3</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchOutletConnection" key="connection"> + <string key="label">dataSource</string> + <reference key="source" ref="709618507"/> + <reference key="destination" ref="841351856"/> + </object> + <int key="connectionID">4</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchOutletConnection" key="connection"> + <string key="label">delegate</string> + <reference key="source" ref="709618507"/> + <reference key="destination" ref="841351856"/> + </object> + <int key="connectionID">5</int> + </object> + </object> + <object class="IBMutableOrderedSet" key="objectRecords"> + <object class="NSArray" key="orderedObjects"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBObjectRecord"> + <int key="objectID">0</int> + <reference key="object" ref="0"/> + <reference key="children" ref="1000"/> + <nil key="parent"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-1</int> + <reference key="object" ref="841351856"/> + <reference key="parent" ref="0"/> + <string key="objectName">File's Owner</string> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-2</int> + <reference key="object" ref="371349661"/> + <reference key="parent" ref="0"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">2</int> + <reference key="object" ref="709618507"/> + <reference key="parent" ref="0"/> + </object> + </object> + </object> + <object class="NSMutableDictionary" key="flattenedProperties"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>-1.CustomClassName</string> + <string>-2.CustomClassName</string> + <string>2.IBEditorWindowLastContentRect</string> + <string>2.IBPluginDependency</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>RootViewController</string> + <string>UIResponder</string> + <string>{{144, 609}, {320, 247}}</string> + <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + </object> + </object> + <object class="NSMutableDictionary" key="unlocalizedProperties"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference key="dict.sortedKeys" ref="0"/> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <nil key="activeLocalization"/> + <object class="NSMutableDictionary" key="localizations"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference key="dict.sortedKeys" ref="0"/> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <nil key="sourceID"/> + <int key="maxID">5</int> + </object> + <object class="IBClassDescriber" key="IBDocument.Classes"> + <object class="NSMutableArray" key="referencedPartialClassDescriptions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">RootViewController</string> + <string key="superclassName">UITableViewController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Classes/RootViewController.h</string> + </object> + </object> + </object> + <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSError.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSNetServices.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSObject.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSPort.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSStream.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSThread.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURL.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSXMLParser.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIAccessibility.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UINibLoading.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="654420027"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIResponder.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIResponder</string> + <string key="superclassName">NSObject</string> + <reference key="sourceIdentifier" ref="654420027"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIScrollView</string> + <string key="superclassName">UIView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIScrollView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UISearchBar</string> + <string key="superclassName">UIView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UISearchBar.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UISearchDisplayController</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UISearchDisplayController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UITableView</string> + <string key="superclassName">UIScrollView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UITableView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UITableViewController</string> + <string key="superclassName">UIViewController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UITableViewController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UITextField.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIView</string> + <string key="superclassName">UIResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIViewController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UINavigationController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIViewController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UITabBarController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">UIViewController</string> + <string key="superclassName">UIResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">UIKit.framework/Headers/UIViewController.h</string> + </object> + </object> + </object> + </object> + <int key="IBDocument.localizationMode">0</int> + <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string> + <integer value="784" key="NS.object.0"/> + </object> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string> + <integer value="3100" key="NS.object.0"/> + </object> + <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> + <string key="IBDocument.LastKnownRelativeProjectPath">NavApp3.xcodeproj</string> + <int key="IBDocument.defaultPropertyAccessControl">3</int> + <string key="IBCocoaTouchPluginVersion">81</string> + </data> +</archive> diff --git a/Tests/iOSNavApp/TotalFunction.c b/Tests/iOSNavApp/TotalFunction.c new file mode 100644 index 000000000..0965a88ac --- /dev/null +++ b/Tests/iOSNavApp/TotalFunction.c @@ -0,0 +1,14 @@ +// +// TotalFunction.c +// NavApp3 +// +// Created by David Cole on 8/10/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#include "TotalFunction.h" + +int Total(const char *context) +{ + return 22; +} diff --git a/Tests/iOSNavApp/TotalFunction.h b/Tests/iOSNavApp/TotalFunction.h new file mode 100644 index 000000000..1301c3d64 --- /dev/null +++ b/Tests/iOSNavApp/TotalFunction.h @@ -0,0 +1,14 @@ +// +// TotalFunction.h +// NavApp3 +// +// Created by David Cole on 8/10/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#ifndef NavApp3_TotalFunction_h +#define NavApp3_TotalFunction_h + +int Total(const char *context); + +#endif diff --git a/Tests/iOSNavApp/main.m b/Tests/iOSNavApp/main.m new file mode 100644 index 000000000..8070c4727 --- /dev/null +++ b/Tests/iOSNavApp/main.m @@ -0,0 +1,17 @@ +// +// main.m +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import <UIKit/UIKit.h> + +int main(int argc, char *argv[]) { + + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + int retVal = UIApplicationMain(argc, argv, nil, nil); + [pool release]; + return retVal; +} diff --git a/Tests/test_clean.cmake.in b/Tests/test_clean.cmake.in new file mode 100644 index 000000000..ce5e62b79 --- /dev/null +++ b/Tests/test_clean.cmake.in @@ -0,0 +1,2 @@ +SET(TEST_BUILD_DIRS "@TEST_BUILD_DIRS@") +FILE(REMOVE_RECURSE ${TEST_BUILD_DIRS}) |