summaryrefslogtreecommitdiff
path: root/Tests/OutOfSource
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-10-30 15:39:57 -0700
committerAnas Nashif <anas.nashif@intel.com>2012-10-30 15:39:57 -0700
commit035c7fabc3b82cbc9a346c11abe2e9462b4c0379 (patch)
tree7e40f5a790eae329a8c5d3e59f046451767956ff /Tests/OutOfSource
downloadcmake-035c7fabc3b82cbc9a346c11abe2e9462b4c0379.tar.gz
cmake-035c7fabc3b82cbc9a346c11abe2e9462b4c0379.tar.bz2
cmake-035c7fabc3b82cbc9a346c11abe2e9462b4c0379.zip
Imported Upstream version 2.8.9upstream/2.8.9
Diffstat (limited to 'Tests/OutOfSource')
-rw-r--r--Tests/OutOfSource/CMakeLists.txt18
-rw-r--r--Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt62
-rw-r--r--Tests/OutOfSource/OutOfSourceSubdir/simple.cxx39
-rw-r--r--Tests/OutOfSource/OutOfSourceSubdir/simple.cxx.in1
-rw-r--r--Tests/OutOfSource/OutOfSourceSubdir/testlib.cxx6
-rw-r--r--Tests/OutOfSource/OutOfSourceSubdir/testlib.h11
-rw-r--r--Tests/OutOfSource/SubDir/CMakeLists.txt8
-rw-r--r--Tests/OutOfSource/simple.cxx1
-rw-r--r--Tests/OutOfSource/testdp.h.in1
9 files changed, 147 insertions, 0 deletions
diff --git a/Tests/OutOfSource/CMakeLists.txt b/Tests/OutOfSource/CMakeLists.txt
new file mode 100644
index 000000000..e250f4177
--- /dev/null
+++ b/Tests/OutOfSource/CMakeLists.txt
@@ -0,0 +1,18 @@
+# a simple test cas
+cmake_minimum_required (VERSION 2.6)
+project (OutOfSource)
+
+add_subdirectory(SubDir)
+
+get_directory_property(ANIMAL DIRECTORY OutOfSourceSubdir DEFINITION WEASELS)
+get_directory_property(ANIMALREL DIRECTORY SubDir/../OutOfSourceSubdir DEFINITION WEASELS)
+IF(NOT "${ANIMAL}" STREQUAL "${ANIMALREL}")
+ MESSAGE(FATAL_ERROR "GET_DIRECTORY_PROPERTY does not seem to collapse paths.")
+ENDIF(NOT "${ANIMAL}" STREQUAL "${ANIMALREL}")
+
+configure_file(
+ ${OutOfSource_SOURCE_DIR}/testdp.h.in
+ ${OutOfSource_BINARY_DIR}/SubDir/OutOfSourceSubdir/testdp.h
+ )
+
+set(KEN 1)
diff --git a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt
new file mode 100644
index 000000000..c362e79ba
--- /dev/null
+++ b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt
@@ -0,0 +1,62 @@
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+
+IF ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}")
+ SET(BUILD_SHARED_LIBS 1)
+
+ # Construct a source file outside the tree whose full path is close to
+ # the path length limit. This will cause the full path to the object
+ # file in the build tree to exceed the maximum path length which will
+ # test cmLocalGenerator::CreateSafeUniqueObjectFileName.
+ GET_FILENAME_COMPONENT(DEEPDIR
+ ${OutOfSource_BINARY_DIR}/../OutOfSourceDeep/deeper ABSOLUTE)
+
+ # Test giving the generator a custom limit.
+ SET(CMAKE_OBJECT_PATH_MAX 220)
+
+ # Use a separate variable for computation.
+ SET(MAXPATH "${CMAKE_OBJECT_PATH_MAX}")
+
+ # VS8 adds "OutOfSource/SubDir/OutOfSourceSubdir/../../../" to the
+ # path of the source file for no good reason. Reduce the length
+ # limit by 46 characters to account for it. It should still be long
+ # enough to require special object file name conversion.
+ IF(${CMAKE_GENERATOR} MATCHES "Visual Studio (8|10)")
+ MATH(EXPR MAXPATH "${MAXPATH} - 46")
+ ENDIF()
+
+ # Ninja imposes a maximum path component count of 30. Permit more
+ # path components in the source path.
+ IF(${CMAKE_GENERATOR} MATCHES "Ninja")
+ MATH(EXPR MAXPATH "${MAXPATH} - 44")
+ ENDIF()
+
+ # MAXPATH less 25 for last /and/deeper/simple.cxx part and small safety
+ MATH(EXPR MAXPATH "${MAXPATH} - 25")
+ STRING(LENGTH "${DEEPDIR}" DEEPDIR_LEN)
+ WHILE("${DEEPDIR_LEN}" LESS "${MAXPATH}")
+ SET(DEEPDIR ${DEEPDIR}/and/deeper)
+ STRING(LENGTH "${DEEPDIR}" DEEPDIR_LEN)
+ ENDWHILE("${DEEPDIR_LEN}" LESS "${MAXPATH}")
+ SET(DEEPSRC ${DEEPDIR}/simple.cxx)
+ STRING(LENGTH "${DEEPSRC}" DEEPSRC_LEN)
+ CONFIGURE_FILE(simple.cxx.in ${DEEPSRC} COPYONLY)
+
+ # Watcom WMake seems to have problems with long command lines. Just
+ # disable this part of the test until it is resolved.
+ IF(${CMAKE_GENERATOR} MATCHES "Watcom WMake")
+ SET(DEEPSRC "")
+ ADD_DEFINITIONS(-DNO_DEEPSRC)
+ ENDIF(${CMAKE_GENERATOR} MATCHES "Watcom WMake")
+
+ ADD_LIBRARY(testlib testlib.cxx)
+ ADD_EXECUTABLE (simple simple.cxx ../simple.cxx ${DEEPSRC})
+ TARGET_LINK_LIBRARIES(simple testlib outlib)
+ENDIF ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}")
+
+# test getting a definition from a subdir
+SET (WEASELS SIZZLING)
+
+GET_DIRECTORY_PROPERTY(incDirs INCLUDE_DIRECTORIES)
+IF(NOT incDirs)
+ MESSAGE(FATAL_ERROR "GET_DIRECTORY_PROPERTY(INCLUDE_DIRECTORIES) returned empty list")
+ENDIF(NOT incDirs)
diff --git a/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx
new file mode 100644
index 000000000..d88c311f8
--- /dev/null
+++ b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <string.h>
+
+#include "testlib.h"
+#include "testdp.h"
+
+extern int simple();
+#ifndef NO_DEEPSRC
+extern int simple2();
+#endif
+extern "C" int outlib();
+
+int main ()
+{
+ if(simple() != 123)
+ {
+ return -3;
+ }
+ if (strcmp(animal,"SIZZLING"))
+ {
+ fprintf(stderr,"Get definitions from a subdir did not work\n");
+ return -2;
+ }
+ if(TestLib() != 1.0)
+ {
+ return -1;
+ }
+ if(outlib() != 456)
+ {
+ return -4;
+ }
+#ifndef NO_DEEPSRC
+ if(simple2() != 789)
+ {
+ return -5;
+ }
+#endif
+ return 0;
+}
diff --git a/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx.in b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx.in
new file mode 100644
index 000000000..8339b7c6e
--- /dev/null
+++ b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx.in
@@ -0,0 +1 @@
+int simple2() { return 789; }
diff --git a/Tests/OutOfSource/OutOfSourceSubdir/testlib.cxx b/Tests/OutOfSource/OutOfSourceSubdir/testlib.cxx
new file mode 100644
index 000000000..1f78bd3e0
--- /dev/null
+++ b/Tests/OutOfSource/OutOfSourceSubdir/testlib.cxx
@@ -0,0 +1,6 @@
+#include "testlib.h"
+
+float TestLib()
+{
+ return 1.0;
+}
diff --git a/Tests/OutOfSource/OutOfSourceSubdir/testlib.h b/Tests/OutOfSource/OutOfSourceSubdir/testlib.h
new file mode 100644
index 000000000..289b67361
--- /dev/null
+++ b/Tests/OutOfSource/OutOfSourceSubdir/testlib.h
@@ -0,0 +1,11 @@
+#ifdef _WIN32
+# ifdef testlib_EXPORTS
+# define CM_TEST_LIB_EXPORT __declspec( dllexport )
+# else
+# define CM_TEST_LIB_EXPORT __declspec( dllimport )
+# endif
+#else
+# define CM_TEST_LIB_EXPORT
+#endif
+
+CM_TEST_LIB_EXPORT float TestLib();
diff --git a/Tests/OutOfSource/SubDir/CMakeLists.txt b/Tests/OutOfSource/SubDir/CMakeLists.txt
new file mode 100644
index 000000000..4fc48e13d
--- /dev/null
+++ b/Tests/OutOfSource/SubDir/CMakeLists.txt
@@ -0,0 +1,8 @@
+PROJECT(ANOTHER_PROJ)
+
+# subdir to an out of source and out of binary directory
+ADD_SUBDIRECTORY(${OutOfSource_SOURCE_DIR}/../OutOfBinary
+ ${OutOfSource_BINARY_DIR}/../OutOfBinary)
+
+# subdir to a sibling dir
+ADD_SUBDIRECTORY(${OutOfSource_SOURCE_DIR}/${KEN}OutOfSourceSubdir OutOfSourceSubdir )
diff --git a/Tests/OutOfSource/simple.cxx b/Tests/OutOfSource/simple.cxx
new file mode 100644
index 000000000..27e79f4ad
--- /dev/null
+++ b/Tests/OutOfSource/simple.cxx
@@ -0,0 +1 @@
+int simple() { return 123; }
diff --git a/Tests/OutOfSource/testdp.h.in b/Tests/OutOfSource/testdp.h.in
new file mode 100644
index 000000000..2ca99d523
--- /dev/null
+++ b/Tests/OutOfSource/testdp.h.in
@@ -0,0 +1 @@
+char *animal = "${ANIMAL}";