summaryrefslogtreecommitdiffstats
path: root/Tests/Complex
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/Complex')
-rw-r--r--Tests/Complex/CMakeLists.txt26
-rw-r--r--Tests/Complex/Executable/CMakeLists.txt4
-rw-r--r--Tests/Complex/Executable/complex.cxx104
-rw-r--r--Tests/Complex/Library/CMakeLists.txt8
-rw-r--r--Tests/Complex/Library/ExtraSources/file1.cxx4
-rw-r--r--Tests/Complex/Library/ExtraSources/file1.h1
-rw-r--r--Tests/Complex/Library/file2.cxx4
-rw-r--r--Tests/Complex/Library/file2.h1
-rw-r--r--Tests/Complex/Library/sharedFile.cxx6
-rw-r--r--Tests/Complex/Library/sharedFile.h12
-rw-r--r--Tests/Complex/VarTests.txt11
-rw-r--r--Tests/Complex/cmTestConfigure.h.in5
-rw-r--r--Tests/Complex/simple.cxx4
13 files changed, 190 insertions, 0 deletions
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt
new file mode 100644
index 0000000..c11a47b
--- /dev/null
+++ b/Tests/Complex/CMakeLists.txt
@@ -0,0 +1,26 @@
+# a simple test case
+PROJECT (Complex)
+
+ADD_DEFINITIONS(-DCMAKE_IS_FUN)
+SUBDIRS(Library Executable)
+SUBDIR_DEPENDS(Executable Library)
+
+INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
+
+CONFIGURE_FILE(
+${Complex_SOURCE_DIR}/cmTestConfigure.h.in
+${Complex_BINARY_DIR}/cmTestConfigure.h)
+
+INCLUDE_DIRECTORIES(
+${Complex_BINARY_DIR}
+${Complex_SOURCE_DIR}/Library
+${Complex_SOURCE_DIR}/../../Source
+)
+LINK_DIRECTORIES(
+${Complex_BINARY_DIR}/Library
+)
+
+INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
+
+SET (LIBRARY_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all libraries.")
+SET (EXECUTABLE_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all executables.")
diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt
new file mode 100644
index 0000000..f0df86f
--- /dev/null
+++ b/Tests/Complex/Executable/CMakeLists.txt
@@ -0,0 +1,4 @@
+ADD_EXECUTABLE(complex complex)
+TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
+TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
+
diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx
new file mode 100644
index 0000000..9af88ad
--- /dev/null
+++ b/Tests/Complex/Executable/complex.cxx
@@ -0,0 +1,104 @@
+#include "cmTestConfigure.h"
+#include "ExtraSources/file1.h"
+#include "file2.h"
+#include "sharedFile.h"
+#include "cmStandardIncludes.h"
+
+int passed = 0;
+int failed = 0;
+
+void Failed(const char* Message, const char* m2= "")
+{
+ std::cerr << "Failed: " << Message << m2 << "\n";
+ failed++;
+}
+
+void Passed(const char* Message, const char* m2="")
+{
+ std::cout << "Passed: " << Message << m2 << "\n";
+ passed++;
+}
+
+main()
+{
+ if(sharedFunction() != 1)
+ {
+ Failed("Call to sharedFunction from shared library failed.");
+ }
+ else
+ {
+ Passed("Call to sharedFunction from shared library worked.");
+ }
+
+ if(file1() != 1)
+ {
+ Failed("Call to file1 function from library failed.");
+ }
+ else
+ {
+ Passed("Call to file1 function returned 1.");
+ }
+ if(file2() != 1)
+ {
+ Failed("Call to file2 function from library failed.");
+ }
+ else
+ {
+ Passed("Call to file2 function returned 1.");
+ }
+#ifndef CMAKE_IS_FUN
+ Failed("CMake is not fun, so it is broken and should be fixed.");
+#else
+ Passed("CMAKE_IS_FUN is defined.");
+#endif
+
+#ifdef SHOULD_NOT_BE_DEFINED
+ Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
+#else
+ Passed("SHOULD_NOT_BE_DEFINED is not defined.");
+#endif
+
+#ifndef SHOULD_BE_DEFINED
+ Failed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
+#else
+ Passed("SHOULD_BE_DEFINED is defined.");
+#endif
+
+#ifndef ONE_VAR
+ Failed("cmakedefine is broken, ONE_VAR is not defined.");
+#else
+ Passed("ONE_VAR is defined.");
+#endif
+
+#ifdef ZERO_VAR
+ Failed("cmakedefine is broken, ZERO_VAR is defined.");
+#else
+ Passed("ZERO_VAR is not defined.");
+#endif
+
+
+
+#ifndef STRING_VAR
+ Failed("configureFile is broken, STRING_VAR is not defined.");
+#else
+ if(strcmp(STRING_VAR, "CMake is great") != 0)
+ {
+ Failed("CMake is not great, so the SET command,"
+ "or the configurefile comand is broken. STRING_VAR== ",
+ STRING_VAR);
+ }
+ else
+ {
+ Passed("STRING_VAR == ", STRING_VAR);
+ }
+#endif
+ std::cout << "Passed:" << passed << "\n";
+ if(failed)
+ {
+ std::cout << "Failed: " << failed << "\n";
+ return failed;
+ }
+ return 0;
+}
+
+
diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt
new file mode 100644
index 0000000..bc890eb
--- /dev/null
+++ b/Tests/Complex/Library/CMakeLists.txt
@@ -0,0 +1,8 @@
+AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
+
+SOURCE_FILES(LibrarySources file2)
+ADD_LIBRARY(CMakeTestLibrary LibrarySources)
+SOURCE_FILES(SharedLibrarySources sharedFile)
+ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
+
+
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/file2.cxx b/Tests/Complex/Library/file2.cxx
new file mode 100644
index 0000000..1351669
--- /dev/null
+++ b/Tests/Complex/Library/file2.cxx
@@ -0,0 +1,4 @@
+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/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..4cdb7a1
--- /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/VarTests.txt b/Tests/Complex/VarTests.txt
new file mode 100644
index 0000000..0ff9953
--- /dev/null
+++ b/Tests/Complex/VarTests.txt
@@ -0,0 +1,11 @@
+
+SET (ZERO_VAR 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(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
diff --git a/Tests/Complex/cmTestConfigure.h.in b/Tests/Complex/cmTestConfigure.h.in
new file mode 100644
index 0000000..759a637
--- /dev/null
+++ b/Tests/Complex/cmTestConfigure.h.in
@@ -0,0 +1,5 @@
+#cmakedefine ONE_VAR
+#cmakedefine ZERO_VAR
+#define STRING_VAR "${STRING_VAR}"
+
+
diff --git a/Tests/Complex/simple.cxx b/Tests/Complex/simple.cxx
new file mode 100644
index 0000000..1482f27
--- /dev/null
+++ b/Tests/Complex/simple.cxx
@@ -0,0 +1,4 @@
+int main ()
+{
+ return 0;
+}