diff options
author | Sehong Na <sehong.na@samsung.com> | 2014-05-31 12:34:34 +0900 |
---|---|---|
committer | Sehong Na <sehong.na@samsung.com> | 2014-05-31 12:34:34 +0900 |
commit | cc1a12d36421addf6726f86a5b24f913024d8b3a (patch) | |
tree | 253958b9b8d3ffe9120c78cf3bd5389b8e4a0ea0 /Tests | |
download | cmake-cc1a12d36421addf6726f86a5b24f913024d8b3a.tar.gz cmake-cc1a12d36421addf6726f86a5b24f913024d8b3a.tar.bz2 cmake-cc1a12d36421addf6726f86a5b24f913024d8b3a.zip |
Initialize Tizen 2.3tizen_2.3_releasesubmit/tizen_2.3/20150202.102300submit/tizen_2.3/20140531.0637312.3a_releasetizen_2.3
Diffstat (limited to 'Tests')
1094 files changed, 32938 insertions, 0 deletions
diff --git a/Tests/.NoDartCoverage b/Tests/.NoDartCoverage new file mode 100644 index 0000000..3c99729 --- /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 0000000..bc767fe --- /dev/null +++ b/Tests/Architecture/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 2.8) +project(Architecture C) + +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() +endif() +set_property(TARGET foo PROPERTY OSX_ARCHITECTURES i386) +set_property(TARGET foo PROPERTY OSX_ARCHITECTURES_DEBUG ppc) + +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 ppc) +set_property(TARGET bar PROPERTY OSX_ARCHITECTURES_DEBUG i386) diff --git a/Tests/Architecture/bar.c b/Tests/Architecture/bar.c new file mode 100644 index 0000000..923c89c --- /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 0000000..e35694b --- /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 0000000..a24636f --- /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 0000000..ad27e57 --- /dev/null +++ b/Tests/Assembler/CMakeLists.txt @@ -0,0 +1,32 @@ +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) + 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 0000000..da8e845 --- /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 0000000..95de0b5 --- /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 0000000..31392b5 --- /dev/null +++ b/Tests/BuildDepends/CMakeLists.txt @@ -0,0 +1,219 @@ +# 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) + +# 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}") + +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) + 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 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 0000000..70a2f37 --- /dev/null +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -0,0 +1,87 @@ +cmake_minimum_required(VERSION 2.6) +project(testRebuild) +if(APPLE) + # only use multi-arch if the sysroot exists on this machine + if(EXISTS "${CMAKE_OSX_SYSROOT}") + set(CMAKE_OSX_ARCHITECTURES "ppc;i386") + endif(EXISTS "${CMAKE_OSX_SYSROOT}") +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 0000000..25d8bd2 --- /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 0000000..6cfebe3 --- /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 0000000..b6ac548 --- /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 0000000..92a122d --- /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 0000000..f8b643a --- /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 0000000..775fd3b --- /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 0000000..733a4b3 --- /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 0000000..182ee16 --- /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 0000000..8808dd6 --- /dev/null +++ b/Tests/BundleGeneratorTest/BundleIcon.icns diff --git a/Tests/BundleGeneratorTest/CMakeLists.txt b/Tests/BundleGeneratorTest/CMakeLists.txt new file mode 100644 index 0000000..e1fc2c1 --- /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 0000000..3862a51 --- /dev/null +++ b/Tests/BundleGeneratorTest/CustomVolumeIcon.icns diff --git a/Tests/BundleGeneratorTest/Executable.cxx b/Tests/BundleGeneratorTest/Executable.cxx new file mode 100644 index 0000000..8107f78 --- /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 0000000..e5a7d00 --- /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 0000000..1403c68 --- /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 0000000..5bc5ad2 --- /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 0000000..b68ee25 --- /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 0000000..322b2a7 --- /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 0000000..a66d601 --- /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 0000000..5342f49 --- /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 0000000..e69de29 --- /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 0000000..cfe3222 --- /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 0000000..6209c8f --- /dev/null +++ b/Tests/BundleUtilities/CMakeLists.txt @@ -0,0 +1,84 @@ +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) diff --git a/Tests/BundleUtilities/bundleutils.cmake b/Tests/BundleUtilities/bundleutils.cmake new file mode 100644 index 0000000..46765e7 --- /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 0000000..abda195 --- /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 0000000..bdd10f0 --- /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 0000000..ee1b542 --- /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 0000000..0659bc7 --- /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 0000000..e5e7dc5 --- /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 0000000..3588fb8 --- /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 0000000..84af5d0 --- /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 0000000..d53546c --- /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 0000000..23d3cbd --- /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 0000000..319be89 --- /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/CFBundleTest/CMakeLists.txt b/Tests/CFBundleTest/CMakeLists.txt new file mode 100644 index 0000000..8fd9efd --- /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 0000000..31d6f64 --- /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 0000000..638002f --- /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 0000000..790ead0 --- /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 0000000..e988e26 --- /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 0000000..cbf3523 --- /dev/null +++ b/Tests/CFBundleTest/Localized.rsrc diff --git a/Tests/CFBundleTest/PluginConfig.cmake b/Tests/CFBundleTest/PluginConfig.cmake new file mode 100644 index 0000000..763ddcc --- /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 0000000..86c1463 --- /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 0000000..e622900 --- /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 0000000..78004d0 --- /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 0000000..9c3002b --- /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/COnly") +else(CMAKE_CONFIGURATION_TYPES) + set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/COnly") +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 COnly") +endif(RESULT) + +# build it again with clean and only COnly target +execute_process(COMMAND "${CMAKE_COMMAND}" + --build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug + --clean-first --target COnly + 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 COnly after clean ") +endif(RESULT) diff --git a/Tests/CMakeCommands/build_command/CMakeLists.txt b/Tests/CMakeCommands/build_command/CMakeLists.txt new file mode 100644 index 0000000..990ac90 --- /dev/null +++ b/Tests/CMakeCommands/build_command/CMakeLists.txt @@ -0,0 +1,58 @@ +# 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. +# +cmake_minimum_required(VERSION 2.8) +project(test_build_command) + +set(cmd "initial") + +message("CTEST_FULL_OUTPUT") +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/CMakeCommands/build_command/RunCMake.cmake b/Tests/CMakeCommands/build_command/RunCMake.cmake new file mode 100644 index 0000000..55d9359 --- /dev/null +++ b/Tests/CMakeCommands/build_command/RunCMake.cmake @@ -0,0 +1,86 @@ +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)") + +# Run cmake: +# +function(run_cmake build_dir extra_args expected_result expected_output expected_error) + message(STATUS "run_cmake build_dir='${build_dir}' extra_args='${extra_args}'") + + # Ensure build_dir exists: + # + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${build_dir}) + + # Run cmake: + # + execute_process(COMMAND ${CMAKE_COMMAND} + ${extra_args} + -G ${gen} ${CMake_SOURCE_DIR}/Tests/CMakeCommands/build_command + RESULT_VARIABLE result + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + WORKING_DIRECTORY ${build_dir} + ) + + message(STATUS "result='${result}'") + message(STATUS "stdout='${stdout}'") + message(STATUS "stderr='${stderr}'") + message(STATUS "") + + # Verify result and output match expectations: + # + if("0" STREQUAL "${expected_result}") + if(NOT "${result}" STREQUAL "0") + message(FATAL_ERROR + "error: result='${result}' is non-zero and different than expected_result='${expected_result}'") + endif() + else() + if("${result}" STREQUAL "0") + message(FATAL_ERROR + "error: result='${result}' is zero and different than expected_result='${expected_result}'") + endif() + endif() + + foreach(e ${expected_output}) + if(NOT stdout MATCHES "${e}") + message(FATAL_ERROR + "error: stdout does not match expected_output item e='${e}'") + else() + message(STATUS "info: stdout matches '${e}'") + endif() + endforeach() + + foreach(e ${expected_error}) + if(NOT stderr MATCHES "${e}") + message(FATAL_ERROR + "error: stderr does not match expected_error item e='${e}'") + else() + message(STATUS "info: stderr matches '${e}'") + endif() + endforeach() + + message(STATUS "result, stdout and stderr match all expectations: test passes") + message(STATUS "") +endfunction() + + +# Expect this case to succeed: +run_cmake("${dir}/b1" "" 0 + "Build files have been written to:" + "skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF") + + +# Expect this one to fail: +run_cmake("${dir}/b2" "-DTEST_ERROR_CONDITIONS:BOOL=ON" 1 + "Configuring incomplete, errors occurred!" + "build_command requires at least one argument naming a CMake variable;build_command unknown argument ") diff --git a/Tests/CMakeInstall.cmake b/Tests/CMakeInstall.cmake new file mode 100644 index 0000000..5f814d9 --- /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 0000000..41bf034 --- /dev/null +++ b/Tests/CMakeLib/CMakeLists.txt @@ -0,0 +1,37 @@ +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMake_BINARY_DIR}/Source + ${CMake_SOURCE_DIR}/Source + ) + +set(CMakeLib_TESTS + 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 0000000..3f141c5 --- /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"); + 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.clear(); + if(!Expect('"')) return; + while (!Expect('"')) + { + Expect('\\'); + this->String.push_back(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/testUTF8.cxx b/Tests/CMakeLib/testUTF8.cxx new file mode 100644 index 0000000..4ab96cf --- /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 0000000..54ed5dc --- /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 0000000..da0b275 --- /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 0000000..5a13f07 --- /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 0000000..60442fa --- /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 0000000..2ad9a77 --- /dev/null +++ b/Tests/CMakeLists.txt @@ -0,0 +1,2078 @@ +# 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) + +# 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") + SET(TEST_CompileCommandOutput 1) + ENDIF() + + ADD_SUBDIRECTORY(CMakeLib) + + # 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") + 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(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}) + + + # 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") + endif() + endif() + + SET(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/COnly") + SET(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/CMakeBuildCOnly") + 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}) + + ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize) + + 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 + ) + # 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/foo" + "${CMake_BINARY_DIR}/Tests/SubProject/foo" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-nocmake + --build-project foo + --build-target 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(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}) + + 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) + 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 (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 ".* .*") + if (RPMBUILD) + list(APPEND GENLST "RPM") + endif(RPMBUILD) + if (CMAKE_SYSTEM_NAME MATCHES "Linux") + find_program(DPKG NAMES dpkg) + if (DPKG) + list(APPEND GENLST "DEB") + endif(DPKG) + endif(CMAKE_SYSTEM_NAME MATCHES "Linux") + # 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") + + # Como does not seem to support shared libraries. + GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_CXX_COMPILER} NAME_WE) + IF(CMAKE_BASE_NAME MATCHES "^como$") + SET(COMPILER_IS_COMO 1) + ENDIF(CMAKE_BASE_NAME MATCHES "^como$") + IF(NOT COMPILER_IS_COMO) + SET(COMPLEX_TEST_CMAKELIB 1) + IF(CMAKE_TEST_DIFFERENT_GENERATOR OR CMAKE_TEST_SYSTEM_LIBRARIES) + SET(COMPLEX_TEST_CMAKELIB 0) + ENDIF(CMAKE_TEST_DIFFERENT_GENERATOR OR CMAKE_TEST_SYSTEM_LIBRARIES) + IF(BORLAND) + SET(COMPLEX_TEST_CMAKELIB 0) + ENDIF(BORLAND) + 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 + -DCOMPLEX_TEST_CMAKELIB:BOOL=${COMPLEX_TEST_CMAKELIB} + -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 + -DCOMPLEX_TEST_CMAKELIB:BOOL=${COMPLEX_TEST_CMAKELIB} + -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) + +# This fails on VS 70 +# works on Xcode and makefiles +# ADD_TEST(ConvLibrary ${CMAKE_CTEST_COMMAND} +# --build-and-test +# "${CMake_SOURCE_DIR}/Tests/ConvLibrary" +# "${CMake_BINARY_DIR}/Tests/ConvLibrary" +# --build-two-config +# --build-generator ${CMAKE_TEST_GENERATOR} +# --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} +# --build-project ConvLibrary +# --test-command bartest) + + +# ADD_TEST(complexRelativePaths ${CMAKE_CTEST_COMMAND} +# --build-and-test +# "${CMake_SOURCE_DIR}/Tests/ComplexRelativePaths" +# "${CMake_BINARY_DIR}/Tests/ComplexRelativePaths" +# --build-generator ${CMAKE_TEST_GENERATOR} +# --build-project complex +# --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} +# --build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexRelativePaths/bin" +# --build-options -DCMAKE_USE_RELATIVE_PATHS:BOOL=ON +# --test-command complex) + + ENDIF(NOT COMPILER_IS_COMO) + + 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") + + 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(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio") + 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 AND CMAKE_COMPILER_IS_GNUCXX) + 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 (APPLE AND CMAKE_COMPILER_IS_GNUCXX) + + 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") + + # 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) + + add_test(CMakeCommands.build_command ${CMAKE_CMAKE_COMMAND} + -DCMake_SOURCE_DIR=${CMake_SOURCE_DIR} + -Ddir=${CMake_BINARY_DIR}/Tests/CMakeCommands/build_command + -Dgen=${CMAKE_TEST_GENERATOR} + -P "${CMake_SOURCE_DIR}/Tests/CMakeCommands/build_command/RunCMake.cmake" + ) + + 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 "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() + + # fortran does not work for IDE builds because + # CMAKE_STANDARD_LIBRARIES needs to be per language + IF(CMAKE_TEST_GENERATOR MATCHES "Make|KDevelop") + INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake) + 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") + ENDIF() + ENDIF() + ENDIF() + + find_package(Java QUIET) + IF(JAVA_COMPILE AND JAVA_RUNTIME AND JAVA_ARCHIVE 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") + +ENDIF(BUILD_TESTING) + +SUBDIRS(CMakeTests) diff --git a/Tests/CMakeTestAllGenerators/RunCMake.cmake b/Tests/CMakeTestAllGenerators/RunCMake.cmake new file mode 100644 index 0000000..dcf4a23 --- /dev/null +++ b/Tests/CMakeTestAllGenerators/RunCMake.cmake @@ -0,0 +1,95 @@ +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}'") + +# 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 0000000..08549cc --- /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 0000000..19391d7 --- /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/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 0000000..2392aee --- /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 0000000..5cb50c9 --- /dev/null +++ b/Tests/CMakeTests/CMakeLists.txt @@ -0,0 +1,67 @@ +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(If "") +AddCMakeTest(String "") +AddCMakeTest(Math "") +AddCMakeTest(CMakeMinimumRequired "") +AddCMakeTest(CompilerIdVendor "") +AddCMakeTest(ProcessorCount "") + +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(do_cvs_tests OR GIT_EXECUTABLE) + string(REPLACE "\\" "/" ENV_HOME "$ENV{HOME}") + set(CheckSourceTree_PreArgs + "-DCMake_BINARY_DIR:PATH=${CMake_BINARY_DIR}" + "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}" + "-DCVS_EXECUTABLE:STRING=${CVS_EXECUTABLE}" + "-DGIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}" + "-DHOME:STRING=${ENV_HOME}" + ) + AddCMakeTest(CheckSourceTree "${CheckSourceTree_PreArgs}") +endif(do_cvs_tests OR GIT_EXECUTABLE) diff --git a/Tests/CMakeTests/CMakeMinimumRequiredTest.cmake.in b/Tests/CMakeTests/CMakeMinimumRequiredTest.cmake.in new file mode 100644 index 0000000..b83a779 --- /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 0000000..d434d29 --- /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 0000000..2e4fedd --- /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 0000000..73f8b01 --- /dev/null +++ b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in @@ -0,0 +1,434 @@ +# 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("CVS_EXECUTABLE='${CVS_EXECUTABLE}'") +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 or CVS 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() + +set(is_cvs_checkout 0) +if(EXISTS "${CMake_SOURCE_DIR}/CVS/Root") + set(is_cvs_checkout 1) +endif() + +message("is_git_checkout='${is_git_checkout}'") +message("is_cvs_checkout='${is_cvs_checkout}'") +message("") + +if(NOT is_cvs_checkout) +if(NOT is_git_checkout) + message("source tree is neither git nor CVS checkout... test passes by early return...") + return() +endif() +endif() + +if(is_cvs_checkout) +if(is_git_checkout) + message("warning: source tree has both git *and* CVS file system bits???") + # should this condition be a FATAL_ERROR test failure...? +endif() +endif() + + +# This test looks for the following types of changes in the source tree: +# +set(additions 0) +set(conflicts 0) +set(modifications 0) +set(nonadditions 0) + +# ov == output variable... conditionally filled in by either cvs or git below: +# +set(cmd "") +set(ov "") +set(ev "") +set(rv "") + + +if(is_cvs_checkout AND CVS_EXECUTABLE) + # Check with "cvs -q -n up -dP" if there are any local modifications to the + # CMake source tree: + # + message("=============================================================================") + message("This is a cvs checkout, using cvs to verify source tree....") + message("") + + execute_process(COMMAND ${CVS_EXECUTABLE} --version + WORKING_DIRECTORY ${CMake_SOURCE_DIR} + OUTPUT_VARIABLE version_output + OUTPUT_STRIP_TRAILING_WHITESPACE) + message("=== output of 'cvs --version' ===") + message("${version_output}") + message("=== end output ===") + message("") + + file(READ "${CMake_SOURCE_DIR}/CVS/Root" contents) + message("=== content of CVS/Root ===") + message("${contents}") + message("=== end content ===") + message("") + + file(READ "${CMake_SOURCE_DIR}/CVS/Repository" contents) + message("=== content of CVS/Repository ===") + message("${contents}") + message("=== end content ===") + message("") + + message("Copy/paste this command to reproduce:") + message("cd \"${CMake_SOURCE_DIR}\" && \"${CVS_EXECUTABLE}\" -q -n up -dP") + message("") + + set(cmd ${CVS_EXECUTABLE} -q -n up -dP) +endif() + + +# If no GIT_EXECUTABLE, see if we can figure out which git was used +# for the ctest_update step on this dashboard... +# +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 cvs/git so it can + # find its .cvspass or 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_cvs_checkout) + if(line MATCHES "^A ") + message(" locally added file/directory detected...") + set(additions 1) + endif() + + if(line MATCHES "^C ") + message(" conflict detected...") + set(conflicts 1) + endif() + + if(line MATCHES "^M ") + message(" locally modified file detected...") + set(modifications 1) + endif() + + if(line MATCHES "^\\? ") + message(" locally non-added file/directory detected...") + set(nonadditions 1) + endif() + endif() + + if(is_git_checkout) + if(line MATCHES "^#[ \t]*modified:") + message(" locally modified file detected...") + 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 0000000..68f6462 --- /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 0000000..769fae1 --- /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 0000000..920ea28 --- /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 0000000..d682a2d --- /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-Relative.cmake b/Tests/CMakeTests/ConfigureFile-Relative.cmake new file mode 100644 index 0000000..532580a --- /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 0000000..c78a470 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFileTest.cmake.in @@ -0,0 +1,16 @@ +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") + +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") +check_cmake_test(ConfigureFile + DirInput + DirOutput + Relative + BadArg + ) diff --git a/Tests/CMakeTests/DummyToolchain.cmake b/Tests/CMakeTests/DummyToolchain.cmake new file mode 100644 index 0000000..6a60201 --- /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 0000000..803ac43 --- /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 0000000..d04aaf7 --- /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 0000000..a21e3ea --- /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 0000000..bbe2551 --- /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 0000000..0271abb --- /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 0000000..de5dd50 --- /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 0000000..9f40818 --- /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 0000000..c71585a --- /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 0000000..91952fc --- /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 0000000..b5cc42f --- /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 0000000..41340f6 --- /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 0000000..03993de --- /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 0000000..43d2168 --- /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 0000000..f6c6c6d --- /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 0000000..d5853d3 --- /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/FileDownloadInput.png b/Tests/CMakeTests/FileDownloadInput.png Binary files differnew file mode 100644 index 0000000..7bbcee4 --- /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 0000000..9dc2ebb --- /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 0000000..b6dcaa6 --- /dev/null +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -0,0 +1,44 @@ +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") + +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 + ) + +# 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 0000000..9a43569 --- /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 0000000..8577aef --- /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 0000000..47c1692 --- /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 0000000..7adc240 --- /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 0000000..daf467b --- /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/IfTest.cmake.in b/Tests/CMakeTests/IfTest.cmake.in new file mode 100644 index 0000000..e5211b4 --- /dev/null +++ b/Tests/CMakeTests/IfTest.cmake.in @@ -0,0 +1,158 @@ +# 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("") diff --git a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in new file mode 100644 index 0000000..dbe9500 --- /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 0000000..eca679b --- /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 0000000..cf6f91a --- /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 0000000..91cd922 --- /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 0000000..1b7f8a6 --- /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 0000000..a9833b9 --- /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 0000000..c56f88e --- /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 0000000..8ecebd3 --- /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 0000000..98f6ab1 --- /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/SeparateArgumentsTest.cmake.in b/Tests/CMakeTests/SeparateArgumentsTest.cmake.in new file mode 100644 index 0000000..48964b8 --- /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/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in new file mode 100644 index 0000000..6bb60f4 --- /dev/null +++ b/Tests/CMakeTests/StringTest.cmake.in @@ -0,0 +1,18 @@ +# 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 0000000..7a264a0 --- /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 0000000..e4a2e48 --- /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 0000000..bdb4f7e --- /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 0000000..215bb2b --- /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/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 0000000..2392aee --- /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 0000000..bcae8af --- /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 0000000..7742055 --- /dev/null +++ b/Tests/COnly/CMakeLists.txt @@ -0,0 +1,21 @@ +# 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") diff --git a/Tests/COnly/conly.c b/Tests/COnly/conly.c new file mode 100644 index 0000000..7214fe1 --- /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 0000000..e4faf38 --- /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 0000000..ad4a9af --- /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 0000000..b01e1e1 --- /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 0000000..84c94a9 --- /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 0000000..0fd8956 --- /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 0000000..a99d898 --- /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/CPackComponents/CMakeLists.txt b/Tests/CPackComponents/CMakeLists.txt new file mode 100644 index 0000000..58f5bdf --- /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 0000000..12df2c8 --- /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 0000000..850ec00 --- /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 0000000..8ddac19 --- /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 0000000..5d0a822 --- /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 0000000..a438ac7 --- /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 0000000..5449d09 --- /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 0000000..1d203c8 --- /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 0000000..d82943f --- /dev/null +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.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) +#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 0000000..1e1a410 --- /dev/null +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in @@ -0,0 +1,26 @@ +# +# 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") + +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 0000000..e2d343d --- /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 0000000..8ddac19 --- /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 0000000..5d0a822 --- /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 0000000..a438ac7 --- /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 0000000..5eeb7e9 --- /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 0000000..e0c241e --- /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 0000000..f46d89a --- /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 0000000..49c5324 --- /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/dashboard.cmake.in b/Tests/CTestConfig/dashboard.cmake.in new file mode 100644 index 0000000..c7ac210 --- /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 0000000..5ceb7c3 --- /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 0000000..0c4394f --- /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 0000000..85cb30c --- /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 0000000..6e17464 --- /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 0000000..a8930cf --- /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 0000000..8ea5e40 --- /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 0000000..eac5eab --- /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 0000000..b58b639 --- /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 0000000..8a925b6 --- /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 0000000..1d46ea3 --- /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 0000000..f2a0aa4 --- /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 0000000..5d22d35 --- /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 0000000..8413544 --- /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/CTestTestCostSerial/CMakeLists.txt b/Tests/CTestTestCostSerial/CMakeLists.txt new file mode 100644 index 0000000..a9a5c25 --- /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 0000000..05c20eb --- /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 0000000..cb9f87a --- /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 0000000..ca216e3 --- /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 0000000..0ac6ba0 --- /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 0000000..e1c5b1b --- /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 0000000..bc9e096 --- /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 0000000..5cec594 --- /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 0000000..6ba6b8c --- /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 0000000..43e9986 --- /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 0000000..766b775 --- /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 0000000..201f604 --- /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 0000000..26367a6 --- /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 0000000..e3af7dd --- /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 0000000..766b775 --- /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 0000000..36a1ebf --- /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 0000000..b0e1632 --- /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 0000000..690fbfc --- /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 0000000..fd8d97a --- /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 0000000..b410f0a --- /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 0000000..7bc921a --- /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 0000000..59c18d7 --- /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 0000000..fc53f68 --- /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 0000000..c3c5038 --- /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 0000000..6a6a889 --- /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 0000000..83845de --- /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 0000000..1041ef1 --- /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 0000000..5fb560b --- /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 0000000..a6a4dc0 --- /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 0000000..98c5901 --- /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 0000000..140df1e --- /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 0000000..8301a56 --- /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 0000000..882988f --- /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 0000000..7da8f6f --- /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 0000000..9631a68 --- /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 0000000..505bd7c --- /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 0000000..5fe30d3 --- /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 0000000..129db4d --- /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 0000000..b793306 --- /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 0000000..b589647 --- /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 0000000..2d03686 --- /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 0000000..5400ee8 --- /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 0000000..4b848aa --- /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 0000000..b40d316 --- /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 0000000..8488f4e --- /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 0000000..23f8e07 --- /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 0000000..8488f4e --- /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 0000000..9a44b12 --- /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 0000000..8488f4e --- /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 0000000..f240473 --- /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 0000000..0fd1ceb --- /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 0000000..76d62ad --- /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 0000000..b16f2aa --- /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 0000000..8a8dc24 --- /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 0000000..370ab22 --- /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 0000000..198cc97 --- /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 0000000..bc164b1 --- /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 0000000..89c5b94 --- /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 0000000..b589647 --- /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 0000000..acfa233 --- /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 0000000..8a5246d --- /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 0000000..f8e0609 --- /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 0000000..d40d59d --- /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 0000000..56bae9d --- /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 0000000..c654f47 --- /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 0000000..a04673e --- /dev/null +++ b/Tests/CTestUpdateCVS.cmake.in @@ -0,0 +1,159 @@ +# 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) +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 0000000..a52cb14 --- /dev/null +++ b/Tests/CTestUpdateCommon.cmake @@ -0,0 +1,232 @@ +#----------------------------------------------------------------------------- +# 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}") + + # 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 4096 + ) + 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 4096 + ) + 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 4096) + 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 0000000..793b987 --- /dev/null +++ b/Tests/CTestUpdateGIT.cmake.in @@ -0,0 +1,314 @@ +# 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} 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 0000000..e7586d6 --- /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 0000000..543ddd9 --- /dev/null +++ b/Tests/CTestUpdateHG.cmake.in @@ -0,0 +1,163 @@ +# 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 + ) +set(REPO file://${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 0000000..97b2a07 --- /dev/null +++ b/Tests/CTestUpdateSVN.cmake.in @@ -0,0 +1,140 @@ +# 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) + +#----------------------------------------------------------------------------- +# Initialize the testing directory. +message("Creating test directory...") +init_testing() + +#----------------------------------------------------------------------------- +# Create the repository. +message("Creating repository...") +file(MAKE_DIRECTORY ${TOP}/repo) +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 ${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 0000000..8095a1c --- /dev/null +++ b/Tests/CheckCompilerRelatedVariables/CMakeLists.txt @@ -0,0 +1,86 @@ +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() + +echo_var(MSVC) +echo_var(MSVC60) +echo_var(MSVC70) +echo_var(MSVC71) +echo_var(MSVC80) +echo_var(MSVC90) +echo_var(MSVC10) + +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 0000000..ebbb426 --- /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 0000000..0493a0c --- /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 0000000..f8b643a --- /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 0000000..87284af --- /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 0000000..bd8e305 --- /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 0000000..145a064 --- /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 0000000..554e176 --- /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 0000000..4f42ccf --- /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 0000000..0d73e31 --- /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 0000000..eae11e2 --- /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 0000000..ddfe551 --- /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 0000000..8d6029a --- /dev/null +++ b/Tests/Complex/CMakeLists.txt @@ -0,0 +1,381 @@ +# +# 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) + +# Choose whether to test CMakeLib. +OPTION(COMPLEX_TEST_CMAKELIB "Test CMakeLib" 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 + ${Complex_SOURCE_DIR}/../../Source + ${Complex_BINARY_DIR}/../../Source +) + +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/Complex/Cache/CMakeCache.txt b/Tests/Complex/Cache/CMakeCache.txt new file mode 100644 index 0000000..17c55aa --- /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 0000000..0cc995a --- /dev/null +++ b/Tests/Complex/Executable/A.cxx @@ -0,0 +1,7 @@ +// Include code from a header that should not be compiled separately. +#include "A.hh" + +int main() +{ + return A(); +} diff --git a/Tests/Complex/Executable/A.h b/Tests/Complex/Executable/A.h new file mode 100644 index 0000000..25c45fc --- /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 0000000..e6bab02 --- /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 0000000..8ee9462 --- /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 0000000..08cc7d4 --- /dev/null +++ b/Tests/Complex/Executable/CMakeLists.txt @@ -0,0 +1,190 @@ +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") + +IF(COMPLEX_TEST_CMAKELIB) + # Link to CMake lib + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source/kwsys) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmexpat) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmzlib) + # prefer the new curl if it is around + IF(EXISTS ${Complex_BINARY_DIR}/../../Utilities/cmcurl-7.19.0) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmcurl-7.19.0/lib) + ENDIF(EXISTS ${Complex_BINARY_DIR}/../../Utilities/cmcurl-7.19.0) + IF(EXISTS ${Complex_BINARY_DIR}/../../Utilities/cmcurl) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmcurl) + ENDIF(EXISTS ${Complex_BINARY_DIR}/../../Utilities/cmcurl) + LINK_DIRECTORIES( + ${Complex_BINARY_DIR}/../../Utilities/cmlibarchive/libarchive + ${Complex_BINARY_DIR}/../../Utilities/cmbzip2 + ) +ENDIF(COMPLEX_TEST_CMAKELIB) + +# 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) + +ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt) +ADD_EXECUTABLE(complex complex testcflags.c ) +# Sub1/NameConflictTest.c Sub2/NameConflictTest.c) +ADD_EXECUTABLE(complex.file complex.file.cxx complex_nobuild.cxx + complex_nobuild.c) +IF(COMPLEX_TEST_CMAKELIB) + TARGET_LINK_LIBRARIES(complex CMakeLib cmsys cmexpat cmzlib cmlibarchive cmbzip2 cmcurl) +ENDIF(COMPLEX_TEST_CMAKELIB) + +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 0000000..2d1ea3e --- /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 0000000..8720386 --- /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 0000000..4a32572 --- /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 0000000..f009550 --- /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 0000000..de7522d --- /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 0000000..0ecd8fe --- /dev/null +++ b/Tests/Complex/Executable/complex.cxx @@ -0,0 +1,1226 @@ +#include "cmTestConfigure.h" +#include "cmTestConfigureEscape.h" +#include "cmTestGeneratedHeader.h" +#include "cmVersion.h" +#include "ExtraSources/file1.h" +#include "file2.h" +#include "sharedFile.h" +extern "C" { +#include "testConly.h" +} +#ifdef COMPLEX_TEST_CMAKELIB +#include "cmStandardIncludes.h" +#include "cmSystemTools.h" +#include "cmDynamicLoader.h" +#include "cmSystemTools.h" +#include "cmGeneratedFileStream.h" +#include <cmsys/DynamicLoader.hxx> +#else +#include <vector> +#include <string> +#include <iostream> +#include <string.h> +#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 + +#ifdef COMPLEX_TEST_CMAKELIB +// ====================================================================== + +void TestAndRemoveFile(const char* filename) +{ + if (!cmSystemTools::FileExists(filename)) + { + cmFailed("Could not find file: ", filename); + } + else + { + if (!cmSystemTools::RemoveFile(filename)) + { + 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) +{ + if (!cmSystemTools::FileExists(filename)) + { + cmFailed("Could not find dir: ", filename); + } + else + { + if (!cmSystemTools::FileIsDirectory(filename)) + { + cmFailed("Unable to check if file is a directory: ", filename); + } + else + { + cmPassed("Find dir: ", filename); + } + } +} + +// ====================================================================== + +void TestCMGeneratedFileSTream() +{ + cmGeneratedFileStream gm; + std::string file1 = std::string(BINARY_DIR) + std::string("/generatedFile1"); + std::string file2 = std::string(BINARY_DIR) + std::string("/generatedFile2"); + std::string file3 = std::string(BINARY_DIR) + std::string("/generatedFile3"); + std::string file4 = std::string(BINARY_DIR) + std::string("/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 + { + cmPassed("cmGeneratedFileStream works."); + } + } + 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(file1tmp.c_str()); + cmSystemTools::RemoveFile(file2tmp.c_str()); + cmSystemTools::RemoveFile(file3tmp.c_str()); +} +#endif + +// 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() +{ + std::string lib = BINARY_DIR; + lib += "/lib/"; +#ifdef CMAKE_INTDIR + lib += CMAKE_INTDIR; + lib += "/"; +#endif + std::string exe = BINARY_DIR; + exe += "/bin/"; +#ifdef CMAKE_INTDIR + exe += CMAKE_INTDIR; + exe += "/"; +#endif + +#ifdef COMPLEX_TEST_CMAKELIB + // Test a single character executable to test a: in makefiles + exe += "A"; + exe += cmSystemTools::GetExecutableExtension(); + int ret; + std::string errorMessage; + exe = cmSystemTools::ConvertToRunCommandPath(exe.c_str()); + if(cmSystemTools::RunSingleCommand(exe.c_str(), 0, &ret)) + { + if(ret != 10) + { + errorMessage += exe; + errorMessage += " did not return 10"; + } + } + else + { + errorMessage += exe; + errorMessage += ": failed to run."; + } + if(errorMessage.size()) + { + cmFailed(errorMessage.c_str()); + } + else + { + cmPassed("run Single Character executable A returned 10 as expected."); + } + + lib += CMAKE_SHARED_MODULE_PREFIX; + lib += "CMakeTestModule"; + lib += CMAKE_SHARED_MODULE_SUFFIX; + cmsys::DynamicLoader::LibraryHandle handle = cmDynamicLoader::OpenLibrary(lib.c_str()); + if(!handle) + { + std::string err = "Can not open CMakeTestModule:\n"; + err += lib; + cmFailed(err.c_str()); + } + else + { + cmsys::DynamicLoader::SymbolPointer fun = + cmsys::DynamicLoader::GetSymbolAddress(handle, "ModuleFunction"); + if(!fun) + { + fun = cmsys::DynamicLoader::GetSymbolAddress(handle, "_ModuleFunction"); + } + typedef int (*TEST_FUNCTION)(); + TEST_FUNCTION testFun = (TEST_FUNCTION)fun; + if(!testFun) + { + cmFailed("Could not find symbol ModuleFunction in library "); + } + else + { + int ret = (*testFun)(); + if(!ret) + { + cmFailed("ModuleFunction call did not return valid return."); + } + cmPassed("Module loaded and ModuleFunction called correctly."); + } + } + cmDynamicLoader::FlushCache(); // fix memory leaks + if(sharedFunction() != 1) + { + cmFailed("Call to sharedFunction from shared library failed."); + } + else + { + cmPassed("Call to sharedFunction from shared library worked."); + } + if(CsharedFunction() != 1) + { + cmFailed("Call to C sharedFunction from shared library failed."); + } + else + { + cmPassed("Call to C sharedFunction from shared library worked."); + } + + // ---------------------------------------------------------------------- + // 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"); + } +#endif +#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) || + (strcmp(FILENAME_VAR_PATH_NAME, "ComplexRelativePaths") == 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) || + (strcmp(PATH_VAR_NAME, "ComplexRelativePaths") == 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 + +#ifdef COMPLEX_TEST_CMAKELIB + // ---------------------------------------------------------------------- + // 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"); +#endif + + // ---------------------------------------------------------------------- + // 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_CMAKELIB + // Test the generated file stream. + TestCMGeneratedFileSTream(); +#endif + +#ifdef COMPLEX_TEST_LINK_STATIC + if(TestLinkGetType()) + { + cmPassed("Link to static over shared worked."); + } + else + { + cmFailed("Link to static over shared 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 0000000..e873fa6 --- /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 0000000..6b3c2c1 --- /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 0000000..6b3c2c1 --- /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 0000000..70275cd --- /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 0000000..e4815c6 --- /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 0000000..f4d5848 --- /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 0000000..281e48a --- /dev/null +++ b/Tests/Complex/Library/CMakeLists.txt @@ -0,0 +1,141 @@ +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}) +ADD_LIBRARY(CMakeTestModule MODULE moduleFile.c) +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 0000000..e22812e --- /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 0000000..ce0d818 --- /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 0000000..73be353 --- /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 0000000..25dee08 --- /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 0000000..d415519 --- /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 0000000..e69de29 --- /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 0000000..e69de29 --- /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 0000000..863fcaa --- /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 0000000..dea4b80 --- /dev/null +++ b/Tests/Complex/Library/file2.h @@ -0,0 +1 @@ +int file2(); diff --git a/Tests/Complex/Library/moduleFile.c b/Tests/Complex/Library/moduleFile.c new file mode 100644 index 0000000..608d750 --- /dev/null +++ b/Tests/Complex/Library/moduleFile.c @@ -0,0 +1,6 @@ +#include "moduleFile.h" + +int ModuleFunction() +{ + return 1; +} diff --git a/Tests/Complex/Library/moduleFile.h b/Tests/Complex/Library/moduleFile.h new file mode 100644 index 0000000..6b561e1 --- /dev/null +++ b/Tests/Complex/Library/moduleFile.h @@ -0,0 +1,12 @@ +#if defined(_WIN32) || defined(WIN32) /* Win32 version */ +#ifdef CMakeTestModule_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +#else +# define CMakeTest_EXPORT __declspec(dllimport) +#endif +#else +/* unix needs nothing */ +#define CMakeTest_EXPORT +#endif + +CMakeTest_EXPORT int ModuleFunction(); diff --git a/Tests/Complex/Library/notInAllLib.cxx b/Tests/Complex/Library/notInAllLib.cxx new file mode 100644 index 0000000..5d928f4 --- /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 0000000..cafac68 --- /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 0000000..65ac2e2 --- /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 0000000..2d83f77 --- /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 0000000..f1470a8 --- /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 0000000..d2d9fc6 --- /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 0000000..c146d1b --- /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 0000000..d7952da --- /dev/null +++ b/Tests/Complex/cmTestConfigure.h.in @@ -0,0 +1,87 @@ +// Test SET, VARIABLE_REQUIRES + +#cmakedefine ONE_VAR +#cmakedefine ONE_VAR_IS_DEFINED +#cmakedefine ZERO_VAR + +#cmakedefine COMPLEX_TEST_CMAKELIB + +#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 0000000..39a8bd6 --- /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 0000000..0e9dd3f --- /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 0000000..8d6029a --- /dev/null +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -0,0 +1,381 @@ +# +# 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) + +# Choose whether to test CMakeLib. +OPTION(COMPLEX_TEST_CMAKELIB "Test CMakeLib" 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 + ${Complex_SOURCE_DIR}/../../Source + ${Complex_BINARY_DIR}/../../Source +) + +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 0000000..17c55aa --- /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 0000000..0cc995a --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/A.cxx @@ -0,0 +1,7 @@ +// Include code from a header that should not be compiled separately. +#include "A.hh" + +int main() +{ + return A(); +} diff --git a/Tests/ComplexOneConfig/Executable/A.h b/Tests/ComplexOneConfig/Executable/A.h new file mode 100644 index 0000000..25c45fc --- /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 0000000..e6bab02 --- /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 0000000..8ee9462 --- /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 0000000..98b29bb --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt @@ -0,0 +1,183 @@ +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") + +IF(COMPLEX_TEST_CMAKELIB) + # Link to CMake lib + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source/kwsys) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmexpat) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmzlib) + # prefer the new curl if it is around + IF(EXISTS ${Complex_BINARY_DIR}/../../Utilities/cmcurl-7.19.0) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmcurl-7.19.0/lib) + ENDIF(EXISTS ${Complex_BINARY_DIR}/../../Utilities/cmcurl-7.19.0) + IF(EXISTS ${Complex_BINARY_DIR}/../../Utilities/cmcurl) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmcurl) + ENDIF(EXISTS ${Complex_BINARY_DIR}/../../Utilities/cmcurl) + LINK_DIRECTORIES( + ${Complex_BINARY_DIR}/../../Utilities/cmlibarchive/libarchive + ${Complex_BINARY_DIR}/../../Utilities/cmbzip2 + ) +ENDIF(COMPLEX_TEST_CMAKELIB) + +# 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) + +ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt) +ADD_EXECUTABLE(complex complex testcflags.c ) +# Sub1/NameConflictTest.c Sub2/NameConflictTest.c) +ADD_EXECUTABLE(complex.file complex.file.cxx complex_nobuild.cxx) +IF(COMPLEX_TEST_CMAKELIB) + TARGET_LINK_LIBRARIES(complex CMakeLib cmsys cmexpat cmzlib cmlibarchive cmbzip2 cmcurl) +ENDIF(COMPLEX_TEST_CMAKELIB) + +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 0000000..2d1ea3e --- /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 0000000..8720386 --- /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 0000000..4a32572 --- /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 0000000..f009550 --- /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 0000000..de7522d --- /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 0000000..0ecd8fe --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -0,0 +1,1226 @@ +#include "cmTestConfigure.h" +#include "cmTestConfigureEscape.h" +#include "cmTestGeneratedHeader.h" +#include "cmVersion.h" +#include "ExtraSources/file1.h" +#include "file2.h" +#include "sharedFile.h" +extern "C" { +#include "testConly.h" +} +#ifdef COMPLEX_TEST_CMAKELIB +#include "cmStandardIncludes.h" +#include "cmSystemTools.h" +#include "cmDynamicLoader.h" +#include "cmSystemTools.h" +#include "cmGeneratedFileStream.h" +#include <cmsys/DynamicLoader.hxx> +#else +#include <vector> +#include <string> +#include <iostream> +#include <string.h> +#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 + +#ifdef COMPLEX_TEST_CMAKELIB +// ====================================================================== + +void TestAndRemoveFile(const char* filename) +{ + if (!cmSystemTools::FileExists(filename)) + { + cmFailed("Could not find file: ", filename); + } + else + { + if (!cmSystemTools::RemoveFile(filename)) + { + 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) +{ + if (!cmSystemTools::FileExists(filename)) + { + cmFailed("Could not find dir: ", filename); + } + else + { + if (!cmSystemTools::FileIsDirectory(filename)) + { + cmFailed("Unable to check if file is a directory: ", filename); + } + else + { + cmPassed("Find dir: ", filename); + } + } +} + +// ====================================================================== + +void TestCMGeneratedFileSTream() +{ + cmGeneratedFileStream gm; + std::string file1 = std::string(BINARY_DIR) + std::string("/generatedFile1"); + std::string file2 = std::string(BINARY_DIR) + std::string("/generatedFile2"); + std::string file3 = std::string(BINARY_DIR) + std::string("/generatedFile3"); + std::string file4 = std::string(BINARY_DIR) + std::string("/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 + { + cmPassed("cmGeneratedFileStream works."); + } + } + 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(file1tmp.c_str()); + cmSystemTools::RemoveFile(file2tmp.c_str()); + cmSystemTools::RemoveFile(file3tmp.c_str()); +} +#endif + +// 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() +{ + std::string lib = BINARY_DIR; + lib += "/lib/"; +#ifdef CMAKE_INTDIR + lib += CMAKE_INTDIR; + lib += "/"; +#endif + std::string exe = BINARY_DIR; + exe += "/bin/"; +#ifdef CMAKE_INTDIR + exe += CMAKE_INTDIR; + exe += "/"; +#endif + +#ifdef COMPLEX_TEST_CMAKELIB + // Test a single character executable to test a: in makefiles + exe += "A"; + exe += cmSystemTools::GetExecutableExtension(); + int ret; + std::string errorMessage; + exe = cmSystemTools::ConvertToRunCommandPath(exe.c_str()); + if(cmSystemTools::RunSingleCommand(exe.c_str(), 0, &ret)) + { + if(ret != 10) + { + errorMessage += exe; + errorMessage += " did not return 10"; + } + } + else + { + errorMessage += exe; + errorMessage += ": failed to run."; + } + if(errorMessage.size()) + { + cmFailed(errorMessage.c_str()); + } + else + { + cmPassed("run Single Character executable A returned 10 as expected."); + } + + lib += CMAKE_SHARED_MODULE_PREFIX; + lib += "CMakeTestModule"; + lib += CMAKE_SHARED_MODULE_SUFFIX; + cmsys::DynamicLoader::LibraryHandle handle = cmDynamicLoader::OpenLibrary(lib.c_str()); + if(!handle) + { + std::string err = "Can not open CMakeTestModule:\n"; + err += lib; + cmFailed(err.c_str()); + } + else + { + cmsys::DynamicLoader::SymbolPointer fun = + cmsys::DynamicLoader::GetSymbolAddress(handle, "ModuleFunction"); + if(!fun) + { + fun = cmsys::DynamicLoader::GetSymbolAddress(handle, "_ModuleFunction"); + } + typedef int (*TEST_FUNCTION)(); + TEST_FUNCTION testFun = (TEST_FUNCTION)fun; + if(!testFun) + { + cmFailed("Could not find symbol ModuleFunction in library "); + } + else + { + int ret = (*testFun)(); + if(!ret) + { + cmFailed("ModuleFunction call did not return valid return."); + } + cmPassed("Module loaded and ModuleFunction called correctly."); + } + } + cmDynamicLoader::FlushCache(); // fix memory leaks + if(sharedFunction() != 1) + { + cmFailed("Call to sharedFunction from shared library failed."); + } + else + { + cmPassed("Call to sharedFunction from shared library worked."); + } + if(CsharedFunction() != 1) + { + cmFailed("Call to C sharedFunction from shared library failed."); + } + else + { + cmPassed("Call to C sharedFunction from shared library worked."); + } + + // ---------------------------------------------------------------------- + // 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"); + } +#endif +#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) || + (strcmp(FILENAME_VAR_PATH_NAME, "ComplexRelativePaths") == 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) || + (strcmp(PATH_VAR_NAME, "ComplexRelativePaths") == 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 + +#ifdef COMPLEX_TEST_CMAKELIB + // ---------------------------------------------------------------------- + // 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"); +#endif + + // ---------------------------------------------------------------------- + // 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_CMAKELIB + // Test the generated file stream. + TestCMGeneratedFileSTream(); +#endif + +#ifdef COMPLEX_TEST_LINK_STATIC + if(TestLinkGetType()) + { + cmPassed("Link to static over shared worked."); + } + else + { + cmFailed("Link to static over shared 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 0000000..e873fa6 --- /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.cxx b/Tests/ComplexOneConfig/Executable/complex_nobuild.cxx new file mode 100644 index 0000000..6b3c2c1 --- /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 0000000..70275cd --- /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 0000000..e4815c6 --- /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 0000000..f4d5848 --- /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 0000000..281e48a --- /dev/null +++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt @@ -0,0 +1,141 @@ +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}) +ADD_LIBRARY(CMakeTestModule MODULE moduleFile.c) +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 0000000..e22812e --- /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 0000000..ce0d818 --- /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 0000000..73be353 --- /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 0000000..25dee08 --- /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 0000000..d415519 --- /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 0000000..e69de29 --- /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 0000000..e69de29 --- /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 0000000..863fcaa --- /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 0000000..dea4b80 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/file2.h @@ -0,0 +1 @@ +int file2(); diff --git a/Tests/ComplexOneConfig/Library/moduleFile.c b/Tests/ComplexOneConfig/Library/moduleFile.c new file mode 100644 index 0000000..608d750 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/moduleFile.c @@ -0,0 +1,6 @@ +#include "moduleFile.h" + +int ModuleFunction() +{ + return 1; +} diff --git a/Tests/ComplexOneConfig/Library/moduleFile.h b/Tests/ComplexOneConfig/Library/moduleFile.h new file mode 100644 index 0000000..6b561e1 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/moduleFile.h @@ -0,0 +1,12 @@ +#if defined(_WIN32) || defined(WIN32) /* Win32 version */ +#ifdef CMakeTestModule_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +#else +# define CMakeTest_EXPORT __declspec(dllimport) +#endif +#else +/* unix needs nothing */ +#define CMakeTest_EXPORT +#endif + +CMakeTest_EXPORT int ModuleFunction(); diff --git a/Tests/ComplexOneConfig/Library/notInAllLib.cxx b/Tests/ComplexOneConfig/Library/notInAllLib.cxx new file mode 100644 index 0000000..5d928f4 --- /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 0000000..cafac68 --- /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 0000000..65ac2e2 --- /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 0000000..2d83f77 --- /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 0000000..f1470a8 --- /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 0000000..d2d9fc6 --- /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 0000000..c146d1b --- /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 0000000..d7952da --- /dev/null +++ b/Tests/ComplexOneConfig/cmTestConfigure.h.in @@ -0,0 +1,87 @@ +// Test SET, VARIABLE_REQUIRES + +#cmakedefine ONE_VAR +#cmakedefine ONE_VAR_IS_DEFINED +#cmakedefine ZERO_VAR + +#cmakedefine COMPLEX_TEST_CMAKELIB + +#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 0000000..39a8bd6 --- /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 0000000..0e9dd3f --- /dev/null +++ b/Tests/ComplexOneConfig/cmTestGeneratedHeader.h.in @@ -0,0 +1 @@ +#define GENERATED_HEADER_INCLUDED diff --git a/Tests/ComplexRelativePaths/CMakeLists.txt b/Tests/ComplexRelativePaths/CMakeLists.txt new file mode 100644 index 0000000..8d6029a --- /dev/null +++ b/Tests/ComplexRelativePaths/CMakeLists.txt @@ -0,0 +1,381 @@ +# +# 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) + +# Choose whether to test CMakeLib. +OPTION(COMPLEX_TEST_CMAKELIB "Test CMakeLib" 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 + ${Complex_SOURCE_DIR}/../../Source + ${Complex_BINARY_DIR}/../../Source +) + +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/ComplexRelativePaths/Cache/CMakeCache.txt b/Tests/ComplexRelativePaths/Cache/CMakeCache.txt new file mode 100644 index 0000000..17c55aa --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/Executable/A.cxx b/Tests/ComplexRelativePaths/Executable/A.cxx new file mode 100644 index 0000000..0cc995a --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/A.cxx @@ -0,0 +1,7 @@ +// Include code from a header that should not be compiled separately. +#include "A.hh" + +int main() +{ + return A(); +} diff --git a/Tests/ComplexRelativePaths/Executable/A.h b/Tests/ComplexRelativePaths/Executable/A.h new file mode 100644 index 0000000..25c45fc --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/Executable/A.hh b/Tests/ComplexRelativePaths/Executable/A.hh new file mode 100644 index 0000000..e6bab02 --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/Executable/A.txt b/Tests/ComplexRelativePaths/Executable/A.txt new file mode 100644 index 0000000..8ee9462 --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/A.txt @@ -0,0 +1 @@ +This file should not be compiled! diff --git a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt new file mode 100644 index 0000000..98b29bb --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt @@ -0,0 +1,183 @@ +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") + +IF(COMPLEX_TEST_CMAKELIB) + # Link to CMake lib + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source/kwsys) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmexpat) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmzlib) + # prefer the new curl if it is around + IF(EXISTS ${Complex_BINARY_DIR}/../../Utilities/cmcurl-7.19.0) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmcurl-7.19.0/lib) + ENDIF(EXISTS ${Complex_BINARY_DIR}/../../Utilities/cmcurl-7.19.0) + IF(EXISTS ${Complex_BINARY_DIR}/../../Utilities/cmcurl) + LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmcurl) + ENDIF(EXISTS ${Complex_BINARY_DIR}/../../Utilities/cmcurl) + LINK_DIRECTORIES( + ${Complex_BINARY_DIR}/../../Utilities/cmlibarchive/libarchive + ${Complex_BINARY_DIR}/../../Utilities/cmbzip2 + ) +ENDIF(COMPLEX_TEST_CMAKELIB) + +# 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) + +ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt) +ADD_EXECUTABLE(complex complex testcflags.c ) +# Sub1/NameConflictTest.c Sub2/NameConflictTest.c) +ADD_EXECUTABLE(complex.file complex.file.cxx complex_nobuild.cxx) +IF(COMPLEX_TEST_CMAKELIB) + TARGET_LINK_LIBRARIES(complex CMakeLib cmsys cmexpat cmzlib cmlibarchive cmbzip2 cmcurl) +ENDIF(COMPLEX_TEST_CMAKELIB) + +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/ComplexRelativePaths/Executable/Included.cmake b/Tests/ComplexRelativePaths/Executable/Included.cmake new file mode 100644 index 0000000..2d1ea3e --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/Included.cmake @@ -0,0 +1,2 @@ +GET_DIRECTORY_PROPERTY(LF_VALUE LISTFILE_STACK) + diff --git a/Tests/ComplexRelativePaths/Executable/Sub1/NameConflictTest.c b/Tests/ComplexRelativePaths/Executable/Sub1/NameConflictTest.c new file mode 100644 index 0000000..8720386 --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/Sub1/NameConflictTest.c @@ -0,0 +1,4 @@ +int NameConflictTest1() +{ + return 0; +} diff --git a/Tests/ComplexRelativePaths/Executable/Sub2/NameConflictTest.c b/Tests/ComplexRelativePaths/Executable/Sub2/NameConflictTest.c new file mode 100644 index 0000000..4a32572 --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/Sub2/NameConflictTest.c @@ -0,0 +1,4 @@ +int NameConflictTest2() +{ + return 0; +} diff --git a/Tests/ComplexRelativePaths/Executable/Temp/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/Temp/CMakeLists.txt new file mode 100644 index 0000000..f009550 --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/Executable/cmVersion.h.in b/Tests/ComplexRelativePaths/Executable/cmVersion.h.in new file mode 100644 index 0000000..de7522d --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/cmVersion.h.in @@ -0,0 +1 @@ +#define CMAKE_MINIMUM_REQUIRED_VERSION "${CMAKE_MINIMUM_REQUIRED_VERSION}" diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx new file mode 100644 index 0000000..0ecd8fe --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/complex.cxx @@ -0,0 +1,1226 @@ +#include "cmTestConfigure.h" +#include "cmTestConfigureEscape.h" +#include "cmTestGeneratedHeader.h" +#include "cmVersion.h" +#include "ExtraSources/file1.h" +#include "file2.h" +#include "sharedFile.h" +extern "C" { +#include "testConly.h" +} +#ifdef COMPLEX_TEST_CMAKELIB +#include "cmStandardIncludes.h" +#include "cmSystemTools.h" +#include "cmDynamicLoader.h" +#include "cmSystemTools.h" +#include "cmGeneratedFileStream.h" +#include <cmsys/DynamicLoader.hxx> +#else +#include <vector> +#include <string> +#include <iostream> +#include <string.h> +#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 + +#ifdef COMPLEX_TEST_CMAKELIB +// ====================================================================== + +void TestAndRemoveFile(const char* filename) +{ + if (!cmSystemTools::FileExists(filename)) + { + cmFailed("Could not find file: ", filename); + } + else + { + if (!cmSystemTools::RemoveFile(filename)) + { + 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) +{ + if (!cmSystemTools::FileExists(filename)) + { + cmFailed("Could not find dir: ", filename); + } + else + { + if (!cmSystemTools::FileIsDirectory(filename)) + { + cmFailed("Unable to check if file is a directory: ", filename); + } + else + { + cmPassed("Find dir: ", filename); + } + } +} + +// ====================================================================== + +void TestCMGeneratedFileSTream() +{ + cmGeneratedFileStream gm; + std::string file1 = std::string(BINARY_DIR) + std::string("/generatedFile1"); + std::string file2 = std::string(BINARY_DIR) + std::string("/generatedFile2"); + std::string file3 = std::string(BINARY_DIR) + std::string("/generatedFile3"); + std::string file4 = std::string(BINARY_DIR) + std::string("/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 + { + cmPassed("cmGeneratedFileStream works."); + } + } + 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(file1tmp.c_str()); + cmSystemTools::RemoveFile(file2tmp.c_str()); + cmSystemTools::RemoveFile(file3tmp.c_str()); +} +#endif + +// 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() +{ + std::string lib = BINARY_DIR; + lib += "/lib/"; +#ifdef CMAKE_INTDIR + lib += CMAKE_INTDIR; + lib += "/"; +#endif + std::string exe = BINARY_DIR; + exe += "/bin/"; +#ifdef CMAKE_INTDIR + exe += CMAKE_INTDIR; + exe += "/"; +#endif + +#ifdef COMPLEX_TEST_CMAKELIB + // Test a single character executable to test a: in makefiles + exe += "A"; + exe += cmSystemTools::GetExecutableExtension(); + int ret; + std::string errorMessage; + exe = cmSystemTools::ConvertToRunCommandPath(exe.c_str()); + if(cmSystemTools::RunSingleCommand(exe.c_str(), 0, &ret)) + { + if(ret != 10) + { + errorMessage += exe; + errorMessage += " did not return 10"; + } + } + else + { + errorMessage += exe; + errorMessage += ": failed to run."; + } + if(errorMessage.size()) + { + cmFailed(errorMessage.c_str()); + } + else + { + cmPassed("run Single Character executable A returned 10 as expected."); + } + + lib += CMAKE_SHARED_MODULE_PREFIX; + lib += "CMakeTestModule"; + lib += CMAKE_SHARED_MODULE_SUFFIX; + cmsys::DynamicLoader::LibraryHandle handle = cmDynamicLoader::OpenLibrary(lib.c_str()); + if(!handle) + { + std::string err = "Can not open CMakeTestModule:\n"; + err += lib; + cmFailed(err.c_str()); + } + else + { + cmsys::DynamicLoader::SymbolPointer fun = + cmsys::DynamicLoader::GetSymbolAddress(handle, "ModuleFunction"); + if(!fun) + { + fun = cmsys::DynamicLoader::GetSymbolAddress(handle, "_ModuleFunction"); + } + typedef int (*TEST_FUNCTION)(); + TEST_FUNCTION testFun = (TEST_FUNCTION)fun; + if(!testFun) + { + cmFailed("Could not find symbol ModuleFunction in library "); + } + else + { + int ret = (*testFun)(); + if(!ret) + { + cmFailed("ModuleFunction call did not return valid return."); + } + cmPassed("Module loaded and ModuleFunction called correctly."); + } + } + cmDynamicLoader::FlushCache(); // fix memory leaks + if(sharedFunction() != 1) + { + cmFailed("Call to sharedFunction from shared library failed."); + } + else + { + cmPassed("Call to sharedFunction from shared library worked."); + } + if(CsharedFunction() != 1) + { + cmFailed("Call to C sharedFunction from shared library failed."); + } + else + { + cmPassed("Call to C sharedFunction from shared library worked."); + } + + // ---------------------------------------------------------------------- + // 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"); + } +#endif +#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) || + (strcmp(FILENAME_VAR_PATH_NAME, "ComplexRelativePaths") == 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) || + (strcmp(PATH_VAR_NAME, "ComplexRelativePaths") == 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 + +#ifdef COMPLEX_TEST_CMAKELIB + // ---------------------------------------------------------------------- + // 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"); +#endif + + // ---------------------------------------------------------------------- + // 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_CMAKELIB + // Test the generated file stream. + TestCMGeneratedFileSTream(); +#endif + +#ifdef COMPLEX_TEST_LINK_STATIC + if(TestLinkGetType()) + { + cmPassed("Link to static over shared worked."); + } + else + { + cmFailed("Link to static over shared 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/ComplexRelativePaths/Executable/complex.file.cxx b/Tests/ComplexRelativePaths/Executable/complex.file.cxx new file mode 100644 index 0000000..e873fa6 --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/complex.file.cxx @@ -0,0 +1,8 @@ +#if 0 +#include "cmMissingHeader.h" +#endif + +int main(int , char**) +{ + return 0; +} diff --git a/Tests/ComplexRelativePaths/Executable/complex_nobuild.cxx b/Tests/ComplexRelativePaths/Executable/complex_nobuild.cxx new file mode 100644 index 0000000..6b3c2c1 --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/complex_nobuild.cxx @@ -0,0 +1 @@ +#error "This file should not be compiled." diff --git a/Tests/ComplexRelativePaths/Executable/notInAllExe.cxx b/Tests/ComplexRelativePaths/Executable/notInAllExe.cxx new file mode 100644 index 0000000..70275cd --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/Executable/testSystemDir.cxx b/Tests/ComplexRelativePaths/Executable/testSystemDir.cxx new file mode 100644 index 0000000..e4815c6 --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/testSystemDir.cxx @@ -0,0 +1,3 @@ +#include <testSystemDir.h> + +int main() { return foo(); } diff --git a/Tests/ComplexRelativePaths/Executable/testcflags.c b/Tests/ComplexRelativePaths/Executable/testcflags.c new file mode 100644 index 0000000..f4d5848 --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/Library/CMakeLists.txt b/Tests/ComplexRelativePaths/Library/CMakeLists.txt new file mode 100644 index 0000000..281e48a --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/CMakeLists.txt @@ -0,0 +1,141 @@ +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}) +ADD_LIBRARY(CMakeTestModule MODULE moduleFile.c) +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/ComplexRelativePaths/Library/ExtraSources/file1.cxx b/Tests/ComplexRelativePaths/Library/ExtraSources/file1.cxx new file mode 100644 index 0000000..e22812e --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/ExtraSources/file1.cxx @@ -0,0 +1,4 @@ +int file1() +{ + return 1; +} diff --git a/Tests/ComplexRelativePaths/Library/ExtraSources/file1.h b/Tests/ComplexRelativePaths/Library/ExtraSources/file1.h new file mode 100644 index 0000000..ce0d818 --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/ExtraSources/file1.h @@ -0,0 +1 @@ +int file1(); diff --git a/Tests/ComplexRelativePaths/Library/SystemDir/testSystemDir.h b/Tests/ComplexRelativePaths/Library/SystemDir/testSystemDir.h new file mode 100644 index 0000000..73be353 --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/Library/TestLink.c b/Tests/ComplexRelativePaths/Library/TestLink.c new file mode 100644 index 0000000..25dee08 --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/TestLink.c @@ -0,0 +1,8 @@ +int TestLinkGetType() +{ +#ifdef CMakeTestLinkShared_EXPORTS + return 0; +#else + return 1; +#endif +} diff --git a/Tests/ComplexRelativePaths/Library/create_file.cxx b/Tests/ComplexRelativePaths/Library/create_file.cxx new file mode 100644 index 0000000..d415519 --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/Library/dummy b/Tests/ComplexRelativePaths/Library/dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/dummy diff --git a/Tests/ComplexRelativePaths/Library/empty.h b/Tests/ComplexRelativePaths/Library/empty.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/empty.h diff --git a/Tests/ComplexRelativePaths/Library/file2.cxx b/Tests/ComplexRelativePaths/Library/file2.cxx new file mode 100644 index 0000000..863fcaa --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/Library/file2.h b/Tests/ComplexRelativePaths/Library/file2.h new file mode 100644 index 0000000..dea4b80 --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/file2.h @@ -0,0 +1 @@ +int file2(); diff --git a/Tests/ComplexRelativePaths/Library/moduleFile.c b/Tests/ComplexRelativePaths/Library/moduleFile.c new file mode 100644 index 0000000..608d750 --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/moduleFile.c @@ -0,0 +1,6 @@ +#include "moduleFile.h" + +int ModuleFunction() +{ + return 1; +} diff --git a/Tests/ComplexRelativePaths/Library/moduleFile.h b/Tests/ComplexRelativePaths/Library/moduleFile.h new file mode 100644 index 0000000..6b561e1 --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/moduleFile.h @@ -0,0 +1,12 @@ +#if defined(_WIN32) || defined(WIN32) /* Win32 version */ +#ifdef CMakeTestModule_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +#else +# define CMakeTest_EXPORT __declspec(dllimport) +#endif +#else +/* unix needs nothing */ +#define CMakeTest_EXPORT +#endif + +CMakeTest_EXPORT int ModuleFunction(); diff --git a/Tests/ComplexRelativePaths/Library/notInAllLib.cxx b/Tests/ComplexRelativePaths/Library/notInAllLib.cxx new file mode 100644 index 0000000..5d928f4 --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/Library/sharedFile.cxx b/Tests/ComplexRelativePaths/Library/sharedFile.cxx new file mode 100644 index 0000000..cafac68 --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/sharedFile.cxx @@ -0,0 +1,6 @@ +#include "sharedFile.h" + +int sharedFunction() +{ + return 1; +} diff --git a/Tests/ComplexRelativePaths/Library/sharedFile.h b/Tests/ComplexRelativePaths/Library/sharedFile.h new file mode 100644 index 0000000..65ac2e2 --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/Library/testConly.c b/Tests/ComplexRelativePaths/Library/testConly.c new file mode 100644 index 0000000..2d83f77 --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/Library/testConly.h b/Tests/ComplexRelativePaths/Library/testConly.h new file mode 100644 index 0000000..f1470a8 --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/Library/test_preprocess.cmake b/Tests/ComplexRelativePaths/Library/test_preprocess.cmake new file mode 100644 index 0000000..d2d9fc6 --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/VarTests.cmake b/Tests/ComplexRelativePaths/VarTests.cmake new file mode 100644 index 0000000..c146d1b --- /dev/null +++ b/Tests/ComplexRelativePaths/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/ComplexRelativePaths/cmTestConfigure.h.in b/Tests/ComplexRelativePaths/cmTestConfigure.h.in new file mode 100644 index 0000000..d7952da --- /dev/null +++ b/Tests/ComplexRelativePaths/cmTestConfigure.h.in @@ -0,0 +1,87 @@ +// Test SET, VARIABLE_REQUIRES + +#cmakedefine ONE_VAR +#cmakedefine ONE_VAR_IS_DEFINED +#cmakedefine ZERO_VAR + +#cmakedefine COMPLEX_TEST_CMAKELIB + +#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/ComplexRelativePaths/cmTestConfigureEscape.h.in b/Tests/ComplexRelativePaths/cmTestConfigureEscape.h.in new file mode 100644 index 0000000..39a8bd6 --- /dev/null +++ b/Tests/ComplexRelativePaths/cmTestConfigureEscape.h.in @@ -0,0 +1 @@ +#define STRING_WITH_QUOTES "${STRING_WITH_QUOTES}" diff --git a/Tests/ComplexRelativePaths/cmTestGeneratedHeader.h.in b/Tests/ComplexRelativePaths/cmTestGeneratedHeader.h.in new file mode 100644 index 0000000..0e9dd3f --- /dev/null +++ b/Tests/ComplexRelativePaths/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 0000000..79ed669 --- /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 0000000..cc29502 --- /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 0000000..dacb704 --- /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 0000000..a7aae27 --- /dev/null +++ b/Tests/Contracts/Trilinos-10-6/Patch.cmake @@ -0,0 +1,20 @@ +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}") diff --git a/Tests/Contracts/Trilinos-10-6/RunTest.cmake b/Tests/Contracts/Trilinos-10-6/RunTest.cmake new file mode 100644 index 0000000..30124d8 --- /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 0000000..04bbf21 --- /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 0000000..9134210 --- /dev/null +++ b/Tests/Contracts/cse-snapshot/CMakeLists.txt @@ -0,0 +1,114 @@ +cmake_minimum_required(VERSION 2.8) +project(cse-snapshot) + +include(ExternalProject) + +include("${CMAKE_CURRENT_SOURCE_DIR}/LocalOverrides.cmake" OPTIONAL) +include("${CMAKE_CURRENT_BINARY_DIR}/LocalOverrides.cmake" OPTIONAL) + +if(NOT DEFINED HOME) + if(DEFINED ENV{CTEST_REAL_HOME}) + set(HOME "$ENV{CTEST_REAL_HOME}") + else() + set(HOME "$ENV{HOME}") + endif() +endif() +message(STATUS "HOME='${HOME}'") + +if(NOT DEFINED repo) + set(repo "git://public.kitware.com/cse.git") +endif() +message(STATUS "repo='${repo}'") + +if(NOT DEFINED tag) + set(tag "cc1dcb95439a21ab1d58f444d93481598414196e") +endif() +message(STATUS "tag='${tag}'") + +string(SUBSTRING "${tag}" 0 8 shorttag) + +set(base_dir "${HOME}/.cmake/Contracts/${PROJECT_NAME}/${shorttag}") +set(binary_dir "${base_dir}/build") +set(script_dir "${base_dir}") +set(source_dir "${base_dir}/src") + +if(NOT DEFINED BUILDNAME) + set(BUILDNAME "CMakeContract-${shorttag}") +endif() +message(STATUS "BUILDNAME='${BUILDNAME}'") + +if(NOT DEFINED SITE) + site_name(SITE) +endif() +message(STATUS "SITE='${SITE}'") + +if(NOT DEFINED PROCESSOR_COUNT) + # Unknown: + set(PROCESSOR_COUNT 0) + + # Linux: + set(cpuinfo_file "/proc/cpuinfo") + if(EXISTS "${cpuinfo_file}") + file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$") + list(LENGTH procs PROCESSOR_COUNT) + endif() + + # Mac: + if(APPLE) + find_program(cmd_sysctl "sysctl") + if(cmd_sysctl) + execute_process(COMMAND ${cmd_sysctl} -n hw.ncpu + OUTPUT_VARIABLE PROCESSOR_COUNT + OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() + endif() + + # Windows: + if(WIN32) + set(PROCESSOR_COUNT "$ENV{NUMBER_OF_PROCESSORS}") + endif() +endif() +message(STATUS "PROCESSOR_COUNT='${PROCESSOR_COUNT}'") + +find_package(Git) +if(NOT GIT_EXECUTABLE) + message(FATAL_ERROR "error: could not find git") + # adjust PATH to find git, or set GIT_EXECUTABLE in LocalOverrides.cmake +endif() +message(STATUS "GIT_EXECUTABLE='${GIT_EXECUTABLE}'") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/Dashboard.cmake.in" + "${script_dir}/Dashboard.cmake" + @ONLY) + +# Source dir for this project exists outside the CMake build tree because it +# is absolutely huge. +# +if(EXISTS "${source_dir}/.git") + # If it exists already, download is a complete no-op: + ExternalProject_Add(download-${PROJECT_NAME} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +else() + # If it does not yet exist, download clones the git repository: + ExternalProject_Add(download-${PROJECT_NAME} + SOURCE_DIR "${source_dir}" + GIT_REPOSITORY "${repo}" + GIT_TAG "${tag}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +endif() + +ExternalProject_Add(build-${PROJECT_NAME} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND ${CMAKE_CTEST_COMMAND} -S "${script_dir}/Dashboard.cmake" + INSTALL_COMMAND "" + DEPENDS download-${PROJECT_NAME} + ) diff --git a/Tests/Contracts/cse-snapshot/Dashboard.cmake.in b/Tests/Contracts/cse-snapshot/Dashboard.cmake.in new file mode 100644 index 0000000..138eb3f --- /dev/null +++ b/Tests/Contracts/cse-snapshot/Dashboard.cmake.in @@ -0,0 +1,76 @@ +# This "ctest -S" script may be configured to drive a nightly dashboard on any +# Linux machine. +# +set(CTEST_BINARY_DIRECTORY "@binary_dir@") +set(CTEST_BUILD_NAME "@BUILDNAME@") +set(CTEST_SITE "@SITE@") +set(CTEST_SOURCE_DIRECTORY "@source_dir@") +set(PROCESSOR_COUNT "@PROCESSOR_COUNT@") + +# Assume a Linux build, with a make that supports -j. Modify this script if +# assumption is ever invalid. +# +if(PROCESSOR_COUNT) + set(CTEST_BUILD_FLAGS "-j${PROCESSOR_COUNT}") +endif() + +set(CTEST_CMAKE_GENERATOR "Unix Makefiles") +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +message("Cleaning binary dir '${CTEST_BINARY_DIRECTORY}'") +ctest_empty_binary_directory("${CTEST_BINARY_DIRECTORY}") + +# Intentionally no ctest_update step in this script. This script is run as a +# "Contract" test on a CMake dashboard submission using the just-built ctest +# as the driver. The download step in the Contract CMakeLists file takes care +# of setting up the source tree before calling this ctest -S script. The idea +# is that the source tree will be the same every day, so there should not be +# an "update" step for this build. + +message("Configuring CSE in binary dir '${CTEST_BINARY_DIRECTORY}'") +set_property(GLOBAL PROPERTY SubProject "CSE-toplevel") +set_property(GLOBAL PROPERTY Label "CSE-toplevel") + +ctest_start("Experimental") + +set(CSE_TOPLEVEL_OPTIONS + -DEXTERNAL_PROJECT_DASHBOARD_BUILD:BOOL=ON + -DEXTERNAL_PROJECT_TESTS:BOOL=ON + -DCSE_INSTALL_PREFIX:PATH=${CTEST_BINARY_DIRECTORY}/built + -DCSE_SUBSET:STRING=ALL + -DCTEST_SITE:STRING=${CTEST_SITE} +) + +ctest_configure(OPTIONS "${CSE_TOPLEVEL_OPTIONS}") + +# The configure step produces a file listing the CSE packages and dependencies. +# This file also generates Project.xml and stores it in ${PROJECT_XML}. +# +set(subprojects "") +if(EXISTS "${CTEST_BINARY_DIRECTORY}/CSEBuildtimeDepends.cmake") + message("Including CSEBuildtimeDepends.cmake") + include("${CTEST_BINARY_DIRECTORY}/CSEBuildtimeDepends.cmake") + set(subprojects ${CSE_ALL_SORTED}) + message("Submitting Project.xml") + ctest_submit(FILES ${PROJECT_XML}) +endif() + +message("Submitting CSE configure results") +ctest_submit() + +if(subprojects) + message("Building by looping over subprojects...") + foreach(subproject ${subprojects}) + message("########## ${subproject} ##########") + set_property(GLOBAL PROPERTY SubProject "${subproject}") + set_property(GLOBAL PROPERTY Label "${subproject}") + ctest_build(TARGET "${subproject}" APPEND) + message("Submitting ${subproject} build results") + ctest_submit(PARTS build) + endforeach() +else() + message("Building all...") + ctest_build(APPEND) + message("Submitting build results") + ctest_submit(PARTS build) +endif() diff --git a/Tests/Contracts/cse-snapshot/RunTest.cmake b/Tests/Contracts/cse-snapshot/RunTest.cmake new file mode 100644 index 0000000..7eb6301 --- /dev/null +++ b/Tests/Contracts/cse-snapshot/RunTest.cmake @@ -0,0 +1,3 @@ +set(exe "$ENV{HOME}/.cmake/Contracts/cse-snapshot/510345e4/build/built/Release/git-1.6.5.2/bin/git") +set(args help clone) +set(cse-snapshot_RUN_TEST ${exe} ${args}) diff --git a/Tests/Contracts/vtk542/CMakeLists.txt b/Tests/Contracts/vtk542/CMakeLists.txt new file mode 100644 index 0000000..cfb8b16 --- /dev/null +++ b/Tests/Contracts/vtk542/CMakeLists.txt @@ -0,0 +1,30 @@ +# The VTK external project for CMake +# --------------------------------------------------------------------------- +cmake_minimum_required(VERSION 2.8) +project(vtk542) +include(ExternalProject) + + +set(vtk_source "${CMAKE_CURRENT_BINARY_DIR}/VTK-source") +set(vtk_binary "${CMAKE_CURRENT_BINARY_DIR}/VTK-build") + +ExternalProject_Add(VTK + DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR} + URL "http://www.vtk.org/files/release/5.4/vtk-5.4.2.tar.gz" + URL_MD5 c2c797091d4b2128d9a1bd32c4b78227 + SOURCE_DIR ${vtk_source} + BINARY_DIR ${vtk_binary} + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS + -DBUILD_EXAMPLES:BOOL=ON + -DBUILD_TESTING:BOOL=ON + INSTALL_COMMAND "" + ) +# make it so that each build will run make in the VTK build tree +ExternalProject_Add_Step(VTK forcebuild + COMMAND ${CMAKE_COMMAND} + -E remove ${CMAKE_CURRENT_BUILD_DIR}/VTK-prefix/src/VTK-stamp/VTK-build + DEPENDEES configure + DEPENDERS build + ALWAYS 1 + ) diff --git a/Tests/Contracts/vtk542/RunTest.cmake b/Tests/Contracts/vtk542/RunTest.cmake new file mode 100644 index 0000000..4f48e5c --- /dev/null +++ b/Tests/Contracts/vtk542/RunTest.cmake @@ -0,0 +1 @@ +SET(vtk542_RUN_TEST VTK-build/bin/CommonCxxTests otherArrays) diff --git a/Tests/ConvLibrary/CMakeLists.txt b/Tests/ConvLibrary/CMakeLists.txt new file mode 100644 index 0000000..afc1cb6 --- /dev/null +++ b/Tests/ConvLibrary/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required (VERSION 2.6) +project(ConvLibrary) + +# create a source list +set(foo_sources foo.cxx bar.c sub1/car.cxx) +# create a library foo from the sources +add_library(foo ${foo_sources}) +# get the object files from the target +get_target_property(OBJECT_FILES foo OBJECT_FILES) +message("${OBJECT_FILES}") +# set the object files as generated +set_source_files_properties(${OBJECT_FILES} PROPERTIES GENERATED true) +# create a library bar that contains the object files from foo +add_library(bar ${OBJECT_FILES}) +# set the linker language since bar only has .obj +set_target_properties(bar PROPERTIES LINKER_LANGUAGE CXX) +# make sure foo is built before bar +add_dependencies(bar foo) +add_executable(bartest bartest.cxx) +target_link_libraries(bartest bar) diff --git a/Tests/ConvLibrary/bar.c b/Tests/ConvLibrary/bar.c new file mode 100644 index 0000000..d063082 --- /dev/null +++ b/Tests/ConvLibrary/bar.c @@ -0,0 +1,4 @@ +int bar() +{ + return 20; +} diff --git a/Tests/ConvLibrary/bartest.cxx b/Tests/ConvLibrary/bartest.cxx new file mode 100644 index 0000000..ab95773 --- /dev/null +++ b/Tests/ConvLibrary/bartest.cxx @@ -0,0 +1,37 @@ +extern "C" int bar(); +int foo(); +int car(); + +#include <stdio.h> +int main() +{ + if(foo() == 10) + { + printf("foo is 10!\n"); + } + else + { + printf("foo is not 10 error!\n"); + return -1; + } + if(bar() == 20) + { + printf("bar is 20!\n"); + } + else + { + printf("bar is not 20 error!\n"); + return -1; + } + if(car() == 30) + { + printf("car is 30!\n"); + } + else + { + printf("car is not 30 error!\n"); + return -1; + } + printf("Test past\n"); + return 0; +} diff --git a/Tests/ConvLibrary/foo.cxx b/Tests/ConvLibrary/foo.cxx new file mode 100644 index 0000000..1f46ef4 --- /dev/null +++ b/Tests/ConvLibrary/foo.cxx @@ -0,0 +1,4 @@ +int foo() +{ + return 10; +} diff --git a/Tests/ConvLibrary/sub1/car.cxx b/Tests/ConvLibrary/sub1/car.cxx new file mode 100644 index 0000000..aa66726 --- /dev/null +++ b/Tests/ConvLibrary/sub1/car.cxx @@ -0,0 +1,4 @@ +int car() +{ + return 30; +} diff --git a/Tests/CrossCompile/CMakeLists.txt b/Tests/CrossCompile/CMakeLists.txt new file mode 100644 index 0000000..96a57a0 --- /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 0000000..8488f4e --- /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 0000000..d526684 --- /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 0000000..d462c9b --- /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 0000000..3c204f8 --- /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 0000000..b7c9ea2 --- /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 0000000..2d47d87 --- /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 0000000..ae6f64c --- /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 0000000..1b3e85f --- /dev/null +++ b/Tests/CustomCommand/GeneratedHeader/main.cpp @@ -0,0 +1,5 @@ +#include "generated.h" +int main() +{ + return 0; +} diff --git a/Tests/CustomCommand/GeneratorInExtraDir/CMakeLists.txt b/Tests/CustomCommand/GeneratorInExtraDir/CMakeLists.txt new file mode 100644 index 0000000..195a477 --- /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 0000000..e0e0d21 --- /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 0000000..8b0551f --- /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 0000000..86c97bd --- /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 0000000..e6b6ccb --- /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 0000000..d7721a2 --- /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 0000000..08c559d --- /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 0000000..8dd8f43 --- /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 0000000..cceac07 --- /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 0000000..600e751 --- /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 0000000..89e3cb0 --- /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 0000000..fa882cb --- /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 0000000..93cb079 --- /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 0000000..36d32e4 --- /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 0000000..8dbf0d4 --- /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 0000000..cf75bd1 --- /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 0000000..5d27890 --- /dev/null +++ b/Tests/CxxOnly/CMakeLists.txt @@ -0,0 +1,11 @@ +# 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) diff --git a/Tests/CxxOnly/cxxonly.cxx b/Tests/CxxOnly/cxxonly.cxx new file mode 100644 index 0000000..9cf6f2d --- /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 0000000..da18019 --- /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 0000000..9452a64 --- /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 0000000..453039c --- /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 0000000..5dd84f6 --- /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 0000000..8a3cde2 --- /dev/null +++ b/Tests/CxxOnly/test.CPP @@ -0,0 +1 @@ +int testCPP; diff --git a/Tests/Dependency/1/CMakeLists.txt b/Tests/Dependency/1/CMakeLists.txt new file mode 100644 index 0000000..b50b2e9 --- /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 0000000..9801c25 --- /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 0000000..86e128f --- /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 0000000..4c5fc20 --- /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 0000000..d702db1 --- /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 0000000..6bdfafa --- /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 0000000..f37e1bb --- /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 0000000..c180a59 --- /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 0000000..4cf4426 --- /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 0000000..ea5457d --- /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 0000000..1e5f6d4 --- /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 0000000..21caaad --- /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 0000000..6108fba --- /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 0000000..b9a2360 --- /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 0000000..73e8556 --- /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 0000000..5f1f8ac --- /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 0000000..e2b6dc3 --- /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 0000000..1dcca58 --- /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 0000000..6019236 --- /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 0000000..34d6944 --- /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 0000000..dbc54de --- /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 0000000..dacef6a --- /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 0000000..ca25fd8 --- /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 0000000..0ad65fe --- /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 0000000..f25b493 --- /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 0000000..f01dd05 --- /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 0000000..62959c1 --- /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 0000000..5f1f8ac --- /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 0000000..6ae3bab --- /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 0000000..33dbbfc --- /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 0000000..a71049d --- /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 0000000..d0bb0c4 --- /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 0000000..9fe07f8 --- /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 0000000..5d8e756 --- /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 0000000..7bfa481 --- /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 0000000..97fffe7 --- /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 0000000..d2f551c --- /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 0000000..ee0c74d --- /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 0000000..d08a796 --- /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 0000000..b33e732 --- /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 0000000..d08a796 --- /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 0000000..6fcb153 --- /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 0000000..3f53573 --- /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 0000000..27f6a1f --- /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 0000000..33d8ad7 --- /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 0000000..df0f162 --- /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 0000000..23a66a4 --- /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 0000000..cedf185 --- /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 0000000..8c4072b --- /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 0000000..0d69f68 --- /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 0000000..ddc71c5 --- /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 0000000..88b29ba --- /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 0000000..b478c59 --- /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 0000000..51a38d8 --- /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 0000000..e1f3329 --- /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 0000000..d0abdd6 --- /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 0000000..7ea3711 --- /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 0000000..92f9607 --- /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 0000000..6b20dcb --- /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 0000000..9c77f17 --- /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 0000000..587c848 --- /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 0000000..ac31dcf --- /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 0000000..0b3366b --- /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 0000000..8c6a7f7 --- /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 0000000..837328e --- /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 0000000..2263cbd --- /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/EmptyLibrary/CMakeLists.txt b/Tests/EmptyLibrary/CMakeLists.txt new file mode 100644 index 0000000..baddbbf --- /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 0000000..e273f8d --- /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 0000000..8511f53 --- /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 0000000..c9028a3 --- /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 0000000..2b18d24 --- /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 0000000..2e1bf4c --- /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 0000000..2e01c50 --- /dev/null +++ b/Tests/ExportImport/CMakeLists.txt @@ -0,0 +1,70 @@ +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) + +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 0000000..235a1d2 --- /dev/null +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -0,0 +1,132 @@ +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) + +add_library(testLib3Imp SHARED testLib3Imp.c) +set_property(TARGET testLib3Imp PROPERTY LIBRARY_OUTPUT_DIRECTORY impl) +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 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 + 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 0000000..e00fac7 --- /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 0000000..7ad48a3 --- /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 0000000..f7d9345 --- /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 0000000..1991439 --- /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 0000000..f5a23af --- /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 0000000..895e2fc --- /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 0000000..35bb1e5 --- /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 0000000..aabc0d3 --- /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 0000000..31cec94 --- /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 0000000..fb4c13f --- /dev/null +++ b/Tests/ExportImport/Export/testLib3Imp.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) || defined(__CYGWIN__) +# define testLib3Imp_EXPORT __declspec(dllexport) +#else +# define testLib3Imp_EXPORT +#endif + +testLib3Imp_EXPORT int testLib3Imp(void) { return 0; } diff --git a/Tests/ExportImport/Export/testLib4.c b/Tests/ExportImport/Export/testLib4.c new file mode 100644 index 0000000..846b438 --- /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 0000000..bf3c11e --- /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 0000000..453f262 --- /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 0000000..cc56cf9 --- /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 0000000..605edd0 --- /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 0000000..d9b5587 --- /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 0000000..20a8215 --- /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 0000000..338e639 --- /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 0000000..493ca07 --- /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 0000000..3db9e53 --- /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 0000000..29ad46d --- /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 0000000..565447b --- /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 0000000..36cb7b0 --- /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 0000000..ff12093 --- /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 0000000..ca8d470 --- /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 0000000..e65e362 --- /dev/null +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -0,0 +1,139 @@ +# 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) diff --git a/Tests/ExportImport/Import/A/imp_lib1.c b/Tests/ExportImport/Import/A/imp_lib1.c new file mode 100644 index 0000000..5b3215e --- /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 0000000..579d949 --- /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 0000000..451998a --- /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 0000000..3fc78a2 --- /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 0000000..360a112 --- /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 0000000..f920b1f --- /dev/null +++ b/Tests/ExportImport/InitialCache.cmake.in @@ -0,0 +1,14 @@ +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") diff --git a/Tests/ExportImport/main.c b/Tests/ExportImport/main.c new file mode 100644 index 0000000..f8b643a --- /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 0000000..f12de11 --- /dev/null +++ b/Tests/ExternalOBJ/CMakeLists.txt @@ -0,0 +1,61 @@ +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}) diff --git a/Tests/ExternalOBJ/Object/CMakeLists.txt b/Tests/ExternalOBJ/Object/CMakeLists.txt new file mode 100644 index 0000000..6f1d7e3 --- /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 0000000..f8b643a --- /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 0000000..5b4adaf --- /dev/null +++ b/Tests/ExternalOBJ/Object/external_object.cxx @@ -0,0 +1,4 @@ +int external_object_function() +{ + return 0; +} diff --git a/Tests/ExternalOBJ/executable.cxx b/Tests/ExternalOBJ/executable.cxx new file mode 100644 index 0000000..f9ec61d --- /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 0000000..4a542d7 --- /dev/null +++ b/Tests/ExternalProject/CMakeLists.txt @@ -0,0 +1,580 @@ +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") + + # 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) + execute_process(COMMAND ${Subversion_SVN_EXECUTABLE} --version + OUTPUT_VARIABLE Subversion_VERSION_SVN + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*" + "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}") + message(STATUS "Subversion_VERSION_SVN='${Subversion_VERSION_SVN}'") + + 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 0000000..2cadd7d --- /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 -D CMAKE_INSTALL_PREFIX=<INSTALL_DIR> + BUILD_COMMAND "" +) diff --git a/Tests/ExternalProject/Step1.tar b/Tests/ExternalProject/Step1.tar Binary files differnew file mode 100644 index 0000000..3711f07 --- /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 0000000..49b5f23 --- /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 0000000..d9b4cd2 --- /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 0000000..49dac24 --- /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 0000000..03664b8 --- /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 0000000..92eb480 --- /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 0000000..71a2d81 --- /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 0000000..b42d318 --- /dev/null +++ b/Tests/ExternalProject/Step1NoDir.zip diff --git a/Tests/ExternalProject/Step1Patch.cmake b/Tests/ExternalProject/Step1Patch.cmake new file mode 100644 index 0000000..35e09d9 --- /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 0000000..de069eb --- /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 0000000..baba6d3 --- /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 0000000..0a84bda --- /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 0000000..b848416 --- /dev/null +++ b/Tests/ExternalProject/svnrepo.tgz diff --git a/Tests/FindModulesExecuteAll/CMakeLists.txt b/Tests/FindModulesExecuteAll/CMakeLists.txt new file mode 100644 index 0000000..df51626 --- /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 0000000..c13815c --- /dev/null +++ b/Tests/FindModulesExecuteAll/main.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/FindPackageTest/A/wibble-config.cmake b/Tests/FindPackageTest/A/wibble-config.cmake new file mode 100644 index 0000000..deffa57 --- /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 0000000..deffa57 --- /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 0000000..deffa57 --- /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 0000000..321fa11 --- /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 0000000..deffa57 --- /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 0000000..4576809 --- /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 0000000..87fe84e --- /dev/null +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -0,0 +1,302 @@ +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) + +#----------------------------------------------------------------------------- +# 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 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 + ${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) +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 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(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(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() + 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) diff --git a/Tests/FindPackageTest/Exporter/CMakeLists.txt b/Tests/FindPackageTest/Exporter/CMakeLists.txt new file mode 100644 index 0000000..d25a2e7 --- /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 0000000..deffa57 --- /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 0000000..ff450a1 --- /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 0000000..76e8197 --- /dev/null +++ b/Tests/FindPackageTest/Exporter/dummy.c @@ -0,0 +1 @@ +int main() { return 0; } diff --git a/Tests/FindPackageTest/FindPackageHandleStandardArgs.cmake b/Tests/FindPackageTest/FindPackageHandleStandardArgs.cmake new file mode 100644 index 0000000..7e41c96 --- /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 0000000..f8b643a --- /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 0000000..3af7e99 --- /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 0000000..c609ab1 --- /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 0000000..018cc73 --- /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 0000000..55c67e2 --- /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 0000000..03173c6 --- /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 0000000..1344cbc --- /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 0000000..d3e3f50 --- /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/SystemPackage/CMakeTestSystemPackageConfig.cmake b/Tests/FindPackageTest/SystemPackage/CMakeTestSystemPackageConfig.cmake new file mode 100644 index 0000000..deffa57 --- /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 0000000..deffa57 --- /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 0000000..deffa57 --- /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 0000000..deffa57 --- /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 0000000..deffa57 --- /dev/null +++ b/Tests/FindPackageTest/TFramework.framework/Versions/A/Resources/tframework-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/include/foo.h b/Tests/FindPackageTest/include/foo.h new file mode 100644 index 0000000..2392aee --- /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 0000000..deffa57 --- /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 0000000..deffa57 --- /dev/null +++ b/Tests/FindPackageTest/lib/Bar/cmake/bar-config.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 0000000..eff4d4f --- /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 0000000..cbf0603 --- /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 0000000..deffa57 --- /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 0000000..2f768e8 --- /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 0000000..deffa57 --- /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 0000000..deffa57 --- /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 0000000..13763ad --- /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 0000000..deffa57 --- /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 0000000..bee2f0e --- /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 0000000..2fbd525 --- /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 0000000..606945f --- /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 0000000..deffa57 --- /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 0000000..deffa57 --- /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 0000000..deffa57 --- /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 0000000..deffa57 --- /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 0000000..5c3bdde --- /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 0000000..deffa57 --- /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 0000000..10ac53d --- /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 0000000..deffa57 --- /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 0000000..af57cfa --- /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 0000000..deffa57 --- /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 0000000..b54d94c --- /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 0000000..deffa57 --- /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 0000000..2a6be86 --- /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 0000000..442b8a4 --- /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 0000000..5c02ebb --- /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 0000000..af898f4 --- /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 0000000..2c1cb7b --- /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 0000000..e47524d --- /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 0000000..c216529 --- /dev/null +++ b/Tests/Fortran/CMakeLists.txt @@ -0,0 +1,226 @@ +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}" MATCHES "Intel") + AND + ("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC") + ) + set(COMPATABLE_COMPILERS TRUE) +endif() +if("${CMAKE_Fortran_COMPILER_ID}:${CMAKE_C_COMPILER_ID}" MATCHES "Absoft:GNU") + set(COMPATABLE_COMPILERS TRUE) +endif() +if(COMPATABLE_COMPILERS + 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) + add_executable(test_use_in_comment_freeform + test_use_in_comment_freeform.f90) + + 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 0000000..55f21ad --- /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 0000000..f21156c --- /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 0000000..0eb1cfe --- /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 0000000..2be73c5 --- /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 0000000..fe1368a --- /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 0000000..3031c07 --- /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 0000000..ae1edcb --- /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 0000000..2385408 --- /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 0000000..dbbb3a4 --- /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 0000000..aa0de77 --- /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 0000000..28bcf36 --- /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 0000000..1064d74 --- /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 0000000..29ac4b6 --- /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 0000000..9efafc5 --- /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 0000000..d35ea7e --- /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 0000000..efd9b68 --- /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 0000000..bf04062 --- /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 0000000..4b108e3 --- /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 0000000..de3cb57 --- /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 0000000..dd0f35c --- /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 0000000..6ac97fa --- /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 0000000..e4f1fbe --- /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 0000000..39f486b --- /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 0000000..c992a04 --- /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 0000000..abf6c6d --- /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 0000000..0487dff --- /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 0000000..1617798 --- /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 0000000..ead7710 --- /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 0000000..f335583 --- /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 0000000..0b82f0e --- /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 0000000..f3d93dc --- /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/Framework/CMakeLists.txt b/Tests/Framework/CMakeLists.txt new file mode 100644 index 0000000..29f9838 --- /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 0000000..37c132a --- /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 0000000..b249ce3 --- /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 0000000..d959c81 --- /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 0000000..2431d79 --- /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 0000000..5a0f330 --- /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 0000000..3fc4108 --- /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 0000000..5122750 --- /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 0000000..04736a1 --- /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 0000000..dc8cb34 --- /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 0000000..ac97b92 --- /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 0000000..f0469de --- /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 0000000..972d989 --- /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 0000000..ce5c3eb --- /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 0000000..5d4f42d --- /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 0000000..4a53d2c --- /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 0000000..f0c73b5 --- /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 0000000..e0ced6a --- /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 0000000..595e4f5 --- /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 0000000..60b8c22 --- /dev/null +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -0,0 +1,47 @@ +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() diff --git a/Tests/IncludeDirectories/main.cpp b/Tests/IncludeDirectories/main.cpp new file mode 100644 index 0000000..a59d27c --- /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 0000000..a0f590e --- /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 0000000..5768ab5 --- /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 0000000..e34b704 --- /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 0000000..b0dfaa5 --- /dev/null +++ b/Tests/Java/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(hello Java) +SET(CMAKE_VERBOSE_MAKEFILE 1) + +IF("${hello_SOURCE_DIR}" STREQUAL "${hello_BINARY_DIR}") + MESSAGE("In Source, building Java using ADD_CUSTOM_COMMAND()") + SET(OLD_CUSTOM_COMMAND_WAY 1) +ELSE("${hello_SOURCE_DIR}" STREQUAL "${hello_BINARY_DIR}") + MESSAGE("Out of source, using built-in Java support") + SET(OLD_CUSTOM_COMMAND_WAY ) +ENDIF("${hello_SOURCE_DIR}" STREQUAL "${hello_BINARY_DIR}") + +IF(NOT OLD_CUSTOM_COMMAND_WAY) + + INCLUDE_DIRECTORIES(${hello_SOURCE_DIR} + ${hello_BINARY_DIR} ) + ADD_LIBRARY(hello A.java HelloWorld.java) + +ELSE(NOT OLD_CUSTOM_COMMAND_WAY) + + ADD_CUSTOM_COMMAND( + OUTPUT ${hello_BINARY_DIR}/A.class + MAIN_DEPENDENCY ${hello_SOURCE_DIR}/A.java + COMMAND ${CMAKE_Java_COMPILER} ARGS -classpath . -d ${hello_BINARY_DIR} ${hello_SOURCE_DIR}/A.java) + ADD_CUSTOM_COMMAND( + OUTPUT ${hello_BINARY_DIR}/HelloWorld.class + MAIN_DEPENDENCY ${hello_SOURCE_DIR}/HelloWorld.java + DEPENDS ${hello_BINARY_DIR}/A.class + COMMAND ${CMAKE_Java_COMPILER} ARGS -classpath . -d ${hello_BINARY_DIR} ${hello_SOURCE_DIR}/HelloWorld.java) + ADD_CUSTOM_COMMAND( + OUTPUT ${hello_BINARY_DIR}/hello.jar + DEPENDS ${hello_BINARY_DIR}/A.class ${hello_BINARY_DIR}/HelloWorld.class + COMMAND ${CMAKE_COMMAND} + ARGS -E chdir ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_Java_ARCHIVE} + -cvf hello.jar *.class) + + ADD_CUSTOM_TARGET(hello_jar ALL + DEPENDS ${hello_BINARY_DIR}/hello.jar) + +ENDIF(NOT OLD_CUSTOM_COMMAND_WAY) + diff --git a/Tests/Java/HelloWorld.java b/Tests/Java/HelloWorld.java new file mode 100644 index 0000000..54246ec --- /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 0000000..4bdafd0 --- /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 0000000..7658b7e --- /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 0000000..7a050c7 --- /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 0000000..2f78c50 --- /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 0000000..4440577 --- /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 0000000..f500058 --- /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 0000000..23e70c0 --- /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 0000000..1f92eb9 --- /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 0000000..81badcd --- /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 0000000..3dca0b0 --- /dev/null +++ b/Tests/LibName/CMakeLists.txt @@ -0,0 +1,13 @@ +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) diff --git a/Tests/LibName/bar.c b/Tests/LibName/bar.c new file mode 100644 index 0000000..9607180 --- /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 0000000..a689704 --- /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 0000000..73b4b41 --- /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 0000000..7356b27 --- /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 0000000..f7c840f --- /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 0000000..6ef1ebe --- /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 0000000..890a089 --- /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 0000000..090cc6c --- /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 0000000..e06020c --- /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 0000000..78f2de1 --- /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 0000000..123587a --- /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 0000000..9d8d088 --- /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 0000000..b4e5392 --- /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 0000000..cf1557c --- /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 0000000..5321c2d --- /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 0000000..c8f0ecf --- /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 0000000..807a7a8 --- /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 0000000..167f07d --- /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 0000000..0db73a8 --- /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 0000000..21a5022 --- /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 0000000..9bbf0f6 --- /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 0000000..91b8575 --- /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 0000000..76f97bc --- /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 0000000..fa89ae9 --- /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 0000000..f05d962 --- /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 0000000..e1ba749 --- /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 0000000..8311cb8 --- /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 0000000..c895dd1 --- /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 0000000..1e6a4ae --- /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 0000000..045e570 --- /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 0000000..b23b1ec --- /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 0000000..6bffaa8 --- /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 0000000..2062c43 --- /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 0000000..3600977 --- /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 0000000..953d05c --- /dev/null +++ b/Tests/LoadCommand/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/LoadCommand/CMakeCommands/cmTestCommand.c b/Tests/LoadCommand/CMakeCommands/cmTestCommand.c new file mode 100644 index 0000000..6b4f48f --- /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 0000000..e99105a --- /dev/null +++ b/Tests/LoadCommand/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/LoadCommand/LoadedCommand.cxx.in b/Tests/LoadCommand/LoadedCommand.cxx.in new file mode 100644 index 0000000..c58bcf1 --- /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 0000000..7a0a15d --- /dev/null +++ b/Tests/LoadCommand/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/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt b/Tests/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt new file mode 100644 index 0000000..953d05c --- /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 0000000..6b4f48f --- /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 0000000..e99105a --- /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 0000000..c58bcf1 --- /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 0000000..7a0a15d --- /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/MacroTest/CMakeLists.txt b/Tests/MacroTest/CMakeLists.txt new file mode 100644 index 0000000..ef673fd --- /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 0000000..f4d7035 --- /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 0000000..e0ced6a --- /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 0000000..97d3554 --- /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 0000000..50facad --- /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 0000000..10d11c3 --- /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 0000000..f8b643a --- /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 0000000..5bc4ab8 --- /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 0000000..d1e5b1a --- /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 0000000..5b94602 --- /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 0000000..39c6861 --- /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 0000000..a7206c8 --- /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 0000000..45e9f67 --- /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 0000000..602c834 --- /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 0000000..b5bfbf6 --- /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/ModuleDefinition/CMakeLists.txt b/Tests/ModuleDefinition/CMakeLists.txt new file mode 100644 index 0000000..b463a3c --- /dev/null +++ b/Tests/ModuleDefinition/CMakeLists.txt @@ -0,0 +1,23 @@ +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 /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_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 0000000..88b3904 --- /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 0000000..df64fb3 --- /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 0000000..9d79acd --- /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 0000000..8eba7f9 --- /dev/null +++ b/Tests/ModuleDefinition/example_dll_2.def @@ -0,0 +1,2 @@ +EXPORTS +example_dll_2_function diff --git a/Tests/ModuleDefinition/example_exe.c b/Tests/ModuleDefinition/example_exe.c new file mode 100644 index 0000000..c521b3a --- /dev/null +++ b/Tests/ModuleDefinition/example_exe.c @@ -0,0 +1,14 @@ +extern int __declspec(dllimport) example_dll_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() + +#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 0000000..2a0df1f --- /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 0000000..4e2f9ba --- /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/NewlineArgs/CMakeLists.txt b/Tests/NewlineArgs/CMakeLists.txt new file mode 100644 index 0000000..a182304 --- /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 0000000..05d55e4 --- /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 0000000..72f171d --- /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 0000000..ea094d7 --- /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 0000000..bdf9cfa --- /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 0000000..c892bd0 --- /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 0000000..b7ec4b5 --- /dev/null +++ b/Tests/ObjC++/objc++.mm @@ -0,0 +1,22 @@ +#import <iostream.h> +#import <Cocoa/Cocoa.h> + +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/OutDir/CMakeLists.txt b/Tests/OutDir/CMakeLists.txt new file mode 100644 index 0000000..88468c3 --- /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 0000000..53f9259 --- /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 0000000..e1e6b7f --- /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 0000000..fcf90bd --- /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 0000000..9ea579b --- /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 0000000..e250f41 --- /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 0000000..c7cc090 --- /dev/null +++ b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt @@ -0,0 +1,56 @@ +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() + + # 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 0000000..d88c311 --- /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 0000000..8339b7c --- /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 0000000..1f78bd3 --- /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 0000000..289b673 --- /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 0000000..4fc48e1 --- /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 0000000..27e79f4 --- /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 0000000..2ca99d5 --- /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 0000000..3a473b8 --- /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 0000000..b08fadc --- /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 0000000..59a6ef4 --- /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 0000000..7e1bf51 --- /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 0000000..d942d45 --- /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 0000000..6a710ca --- /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 0000000..b0942c0 --- /dev/null +++ b/Tests/Plugin/CMakeLists.txt @@ -0,0 +1,44 @@ +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) + +# TODO: +# - create a plugin that links to a static lib +# - create a plugin that links to a shared lib diff --git a/Tests/Plugin/include/example.h b/Tests/Plugin/include/example.h new file mode 100644 index 0000000..1d7e8c0 --- /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 0000000..d2c5205 --- /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 0000000..62f0d9f --- /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 0000000..1fc7338 --- /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 0000000..cee6422 --- /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 0000000..0f6d331 --- /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 0000000..8488f4e --- /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 0000000..cf1904c --- /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 0000000..e6f2edc --- /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 0000000..5b441e2 --- /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 0000000..f8b643a --- /dev/null +++ b/Tests/PolicyScope/main.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/PreOrder/CMakeLists.txt b/Tests/PreOrder/CMakeLists.txt new file mode 100644 index 0000000..29720e4 --- /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 0000000..6c011ec --- /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 0000000..281d888 --- /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 0000000..ef26e79 --- /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 0000000..d423cae --- /dev/null +++ b/Tests/PrecompiledHeader/CMakeLists.txt @@ -0,0 +1,58 @@ +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") + # 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 0000000..b10eba7 --- /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 0000000..2845cdb --- /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 0000000..c37d69a --- /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 0000000..2210cb4 --- /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 0000000..f4de601 --- /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 0000000..b4ec17c --- /dev/null +++ b/Tests/Preprocess/CMakeLists.txt @@ -0,0 +1,266 @@ +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") + +# 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) + # 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 0000000..fbf8986 --- /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 0000000..16209ac --- /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 0000000..27b6ac8 --- /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 0000000..3e1c7a0 --- /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 0000000..9df89f6 --- /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 0000000..f016d5c --- /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 0000000..e0c7522 --- /dev/null +++ b/Tests/Properties/CMakeLists.txt @@ -0,0 +1,129 @@ +# 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 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 0000000..1a27a04 --- /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 0000000..5e92831 --- /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 0000000..898fd9e --- /dev/null +++ b/Tests/Properties/properties2.h @@ -0,0 +1 @@ +#define HAVE_PROPERTIES2_H diff --git a/Tests/ReturnTest/CMakeLists.txt b/Tests/ReturnTest/CMakeLists.txt new file mode 100644 index 0000000..a08855e --- /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 0000000..7cea1fb --- /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 0000000..e0ced6a --- /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 0000000..b951092 --- /dev/null +++ b/Tests/ReturnTest/subdir/CMakeLists.txt @@ -0,0 +1,3 @@ +set (subdirreturn 1) +return() +set (subdirreturn 0) diff --git a/Tests/RuntimePath/CMakeLists.txt b/Tests/RuntimePath/CMakeLists.txt new file mode 100644 index 0000000..2164cdb --- /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 0000000..ebad8d2 --- /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 0000000..60d5e68 --- /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 0000000..27cd912 --- /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 0000000..40b4f56 --- /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 0000000..c71ee06 --- /dev/null +++ b/Tests/RuntimePath/main.c @@ -0,0 +1,5 @@ +extern int bar1(); +int main() +{ + return bar1(); +} diff --git a/Tests/SameName/CMakeLists.txt b/Tests/SameName/CMakeLists.txt new file mode 100644 index 0000000..a4b993c --- /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 0000000..3917a2f --- /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 0000000..eb62c30 --- /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 0000000..67e7f68 --- /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 0000000..b01e1e1 --- /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 0000000..84c94a9 --- /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 0000000..ab6570c --- /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 0000000..f59c318 --- /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 0000000..e7918af --- /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 0000000..dc965a7 --- /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 0000000..7bee7c0 --- /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 0000000..88fc33e --- /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 0000000..281d888 --- /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 0000000..859e07c --- /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 0000000..d0ed651 --- /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 0000000..5d8eac0 --- /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 0000000..b8cdea4 --- /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 0000000..e4df685 --- /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 0000000..baca23e --- /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 0000000..9b59fda --- /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 0000000..52fac81 --- /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 0000000..67fe06f --- /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 0000000..6aaf406 --- /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 0000000..1366dc0 --- /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 0000000..7c36ca9 --- /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 0000000..1fba212 --- /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 0000000..ea4650c --- /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 0000000..e8877df --- /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 0000000..b95d3ec --- /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 0000000..44b8c27 --- /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 0000000..bddec6f --- /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 0000000..321014b --- /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 0000000..8f83380 --- /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 0000000..564db9f --- /dev/null +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -0,0 +1,397 @@ +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) + + # 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 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) + 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 0000000..27b7725 --- /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 0000000..927cae8 --- /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 0000000..b1aecd4 --- /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 0000000..0ffea4b --- /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 0000000..3567a2f --- /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 0000000..52ea140 --- /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 0000000..2ea2f77 --- /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 0000000..4f62953 --- /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 0000000..8fc3878 --- /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 0000000..6a3c1af --- /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 0000000..0277f05 --- /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 0000000..45d5b2b --- /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 0000000..2708baf --- /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 0000000..7f2962d --- /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 0000000..c70b93a --- /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 0000000..7aa9052 --- /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 0000000..0d64e76 --- /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 0000000..dccc48b --- /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 0000000..ea5a6f7 --- /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 0000000..da8dbf9 --- /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 0000000..c250ed7 --- /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 0000000..fbfa23a --- /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 0000000..4b94ea2 --- /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 0000000..5e3db2f --- /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 0000000..d46c165 --- /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 0000000..81f9f53 --- /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 0000000..64a77b5 --- /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 0000000..564db9f --- /dev/null +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -0,0 +1,397 @@ +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) + + # 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 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) + 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 0000000..27b7725 --- /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 0000000..927cae8 --- /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 0000000..b1aecd4 --- /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 0000000..0ffea4b --- /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 0000000..3567a2f --- /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 0000000..52ea140 --- /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 0000000..2ea2f77 --- /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 0000000..4f62953 --- /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 0000000..8fc3878 --- /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 0000000..6a3c1af --- /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 0000000..0277f05 --- /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 0000000..45d5b2b --- /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 0000000..2708baf --- /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 0000000..7f2962d --- /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 0000000..c70b93a --- /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 0000000..7aa9052 --- /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 0000000..0d64e76 --- /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 0000000..dccc48b --- /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 0000000..ea5a6f7 --- /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 0000000..da8dbf9 --- /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 0000000..c250ed7 --- /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 0000000..fbfa23a --- /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 0000000..4b94ea2 --- /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 0000000..5e3db2f --- /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 0000000..d46c165 --- /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 0000000..81f9f53 --- /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 0000000..64a77b5 --- /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 0000000..c3cf38c --- /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 0000000..1a4baf5 --- /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 0000000..a2fcad5 --- /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 0000000..477f4fa --- /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 0000000..3bebc4d --- /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 0000000..212e64b --- /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 0000000..39912a7 --- /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 0000000..32588b5 --- /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 0000000..7792a35 --- /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 0000000..3e70a36 --- /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 0000000..609ebaf --- /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 0000000..c1d1dd2 --- /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 0000000..bd47c29 --- /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 0000000..18d62a1 --- /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 0000000..b7a6237 --- /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 0000000..b7a6237 --- /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 0000000..3e9e5af --- /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 0000000..34b6e7a --- /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 0000000..9cfbe25 --- /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 0000000..b0f1e89 --- /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 0000000..3036183 --- /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 0000000..3c48194 --- /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 0000000..19a5376 --- /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 0000000..60ef3c9 --- /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 0000000..d679168 --- /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 0000000..c528fb1 --- /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 0000000..b7a6237 --- /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 0000000..b7a6237 --- /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 0000000..95a66ee --- /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 0000000..d162084 --- /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 0000000..3e9e5af --- /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 0000000..a0c60f7 --- /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 0000000..a0c60f7 --- /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 0000000..b7a6237 --- /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 0000000..b7a6237 --- /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 0000000..3e9e5af --- /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 0000000..34b6e7a --- /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 0000000..879530b --- /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 0000000..d679168 --- /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 0000000..c528fb1 --- /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 0000000..d679168 --- /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 0000000..c528fb1 --- /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 0000000..b0f1e89 --- /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 0000000..3036183 --- /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 0000000..3c48194 --- /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 0000000..19a5376 --- /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 0000000..60ef3c9 --- /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 0000000..cfba916 --- /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 0000000..66568d4 --- /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 0000000..b7a6237 --- /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 0000000..b7a6237 --- /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 0000000..95a66ee --- /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 0000000..fa6c33c --- /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 0000000..3e9e5af --- /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 0000000..a0c60f7 --- /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 0000000..a0c60f7 --- /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 0000000..b669621 --- /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 0000000..c3f6a18 --- /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 0000000..95de4a3 --- /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 0000000..011178b --- /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 0000000..68fa363 --- /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 0000000..5a8e619 --- /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 0000000..1e8e203 --- /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 0000000..46d9013 --- /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 0000000..75700b3 --- /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 0000000..653ced2 --- /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 0000000..a637760 --- /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 0000000..5bfb3d8 --- /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 0000000..42a5aa3 --- /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 0000000..de73bcd --- /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 0000000..c7f4725 --- /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 0000000..88ec2f6 --- /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 0000000..c428575 --- /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 0000000..579dcbc --- /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 0000000..72d5cd1 --- /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 0000000..1055d07 --- /dev/null +++ b/Tests/SystemInformation/SystemInformation.in @@ -0,0 +1,92 @@ +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}" + +// 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}" + +// 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}" + +// 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 0000000..a3c5b31 --- /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 0000000..86f2cd1 --- /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 0000000..9729d21 --- /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 0000000..2671e3e --- /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 0000000..539d867 --- /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 0000000..51b8ce9 --- /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 0000000..40d4e2f --- /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 0000000..ea3a72c --- /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 0000000..bd5e974 --- /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 0000000..976d6eb --- /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 0000000..ac82f8a --- /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 0000000..69f0fff --- /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 0000000..0489366 --- /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 0000000..bfd073c --- /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 0000000..e755dbe --- /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 0000000..9c239d4 --- /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 0000000..9535780 --- /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 0000000..815b52b --- /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 0000000..26af720 --- /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 0000000..fb9e861 --- /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 0000000..1482f27 --- /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 0000000..1482f27 --- /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 0000000..6a6e9b6 --- /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 0000000..19f2f14 --- /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 0000000..c16b1db --- /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 0000000..938c092 --- /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 0000000..d62bcc4 --- /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 0000000..9b121a1 --- /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 0000000..0ce1179 --- /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 0000000..82f5b5f --- /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 0000000..f3c523d --- /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 0000000..7ca49aa --- /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 0000000..b915ebe --- /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 0000000..40bc5e2 --- /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 0000000..e461d3c --- /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 0000000..5395a06 --- /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 0000000..8ab6dc3 --- /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 0000000..c82b7df --- /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 0000000..8b443a6 --- /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 0000000..cd36bcc --- /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 0000000..76b8e2d --- /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 0000000..25a0602 --- /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 0000000..82b416f --- /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 0000000..0b05fd7 --- /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 0000000..f386036 --- /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 0000000..cd36bcc --- /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 0000000..76b8e2d --- /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 0000000..25a0602 --- /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 0000000..82b416f --- /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 0000000..3b24b44 --- /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 0000000..f386036 --- /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 0000000..cd36bcc --- /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 0000000..0cf7db4 --- /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 0000000..a091265 --- /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 0000000..82b416f --- /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 0000000..3002ea0 --- /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 0000000..453a463 --- /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 0000000..5402542 --- /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 0000000..cd36bcc --- /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 0000000..33659b7 --- /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 0000000..a091265 --- /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 0000000..82b416f --- /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 0000000..4f70f4f --- /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 0000000..673d724 --- /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 0000000..d606ac0 --- /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 0000000..5402542 --- /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 0000000..cd36bcc --- /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 0000000..33659b7 --- /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 0000000..a091265 --- /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 0000000..82b416f --- /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 0000000..42f73f2 --- /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 0000000..d8f5c44 --- /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 0000000..673d724 --- /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 0000000..d606ac0 --- /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 0000000..5402542 --- /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 0000000..cd36bcc --- /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 0000000..33659b7 --- /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 0000000..a091265 --- /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 0000000..039d556 --- /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 0000000..5112355 --- /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 0000000..82b416f --- /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 0000000..bacb6d2 --- /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 0000000..f8b643a --- /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 0000000..1e68968 --- /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 10") + 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) + 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 0000000..72ffced --- /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 0000000..690eb74 --- /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 0000000..543e71e --- /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 0000000..31e40e4 --- /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 0000000..adc2d29 --- /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 0000000..48bda46 --- /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 0000000..ea1047c --- /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/VSMidl/CMakeLists.txt b/Tests/VSMidl/CMakeLists.txt new file mode 100644 index 0000000..432506c --- /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 0000000..86c04ed --- /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 0000000..6b78fcc --- /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 0000000..fd755c7 --- /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 0000000..5d7d14e --- /dev/null +++ b/Tests/VSResource/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 2.8.3.20110118) +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) diff --git a/Tests/VSResource/main.cpp b/Tests/VSResource/main.cpp new file mode 100644 index 0000000..7ee0c74 --- /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 0000000..4ce4b53 --- /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 0000000..c27c68d --- /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 0000000..0123ab2 --- /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 0000000..4b4031d --- /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 0000000..4da1f56 --- /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 0000000..c84dedc --- /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 0000000..0a1ff50 --- /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 0000000..e69de29 --- /dev/null +++ b/Tests/Wrapping/dummy diff --git a/Tests/Wrapping/fakefluid.cxx b/Tests/Wrapping/fakefluid.cxx new file mode 100644 index 0000000..af44679 --- /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 0000000..e69de29 --- /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 0000000..4f57b5d --- /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 0000000..e69de29 --- /dev/null +++ b/Tests/Wrapping/hints diff --git a/Tests/Wrapping/itkWrapperConfig.cxx b/Tests/Wrapping/itkWrapperConfig.cxx new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/Wrapping/itkWrapperConfig.cxx diff --git a/Tests/Wrapping/qtnoqtmain.cxx b/Tests/Wrapping/qtnoqtmain.cxx new file mode 100644 index 0000000..8b7334a --- /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 0000000..67dcb9f --- /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 0000000..fabecfc --- /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 0000000..e69de29 --- /dev/null +++ b/Tests/Wrapping/vtkExcluded.cxx diff --git a/Tests/Wrapping/vtkExcluded.h b/Tests/Wrapping/vtkExcluded.h new file mode 100644 index 0000000..835f61a --- /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 0000000..e69de29 --- /dev/null +++ b/Tests/Wrapping/vtkIncluded.cxx diff --git a/Tests/Wrapping/vtkIncluded.h b/Tests/Wrapping/vtkIncluded.h new file mode 100644 index 0000000..a1c4aba --- /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 0000000..f11a927 --- /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 0000000..1482f27 --- /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 0000000..03aa095 --- /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 0000000..5bbc19a --- /dev/null +++ b/Tests/X11/HelloWorldX11.cxx @@ -0,0 +1,145 @@ + +/*** 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 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 0000000..b802ed8 --- /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 0000000..aeb24b1 --- /dev/null +++ b/Tests/bootstrap.bat.in @@ -0,0 +1,2 @@ +@echo off +sh "@CMake_SOURCE_DIR@/bootstrap" %* diff --git a/Tests/test_clean.cmake.in b/Tests/test_clean.cmake.in new file mode 100644 index 0000000..ce5e62b --- /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}) |