summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-11-22 13:40:50 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-11-22 13:40:50 (GMT)
commit3013a118269a854fb5b7ef078c778099b991dd7d (patch)
tree35e2f751a805edf944ed0bb79aaa57b64e05c3d3 /Tests
parented0b342603fff46534dbb956f4a4354f05be2c16 (diff)
parent7521da2852a2fce16919b2640bcc0fa2f0c55b7d (diff)
downloadCMake-3013a118269a854fb5b7ef078c778099b991dd7d.zip
CMake-3013a118269a854fb5b7ef078c778099b991dd7d.tar.gz
CMake-3013a118269a854fb5b7ef078c778099b991dd7d.tar.bz2
Merge topic 'cross-compiling-toolchain-variables'
7521da2 Introduce CMAKE_STAGING_PREFIX variable.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt1
-rw-r--r--Tests/StagingPrefix/CMakeLists.txt89
-rw-r--r--Tests/StagingPrefix/Consumer/CMakeLists.txt22
-rw-r--r--Tests/StagingPrefix/Consumer/cmake/FindBar.cmake6
-rw-r--r--Tests/StagingPrefix/Consumer/main.cpp10
-rw-r--r--Tests/StagingPrefix/Producer/CMakeLists.txt26
-rw-r--r--Tests/StagingPrefix/Producer/bar.cpp7
-rw-r--r--Tests/StagingPrefix/Producer/bar.h10
-rw-r--r--Tests/StagingPrefix/Producer/foo.cpp7
-rw-r--r--Tests/StagingPrefix/Producer/foo.h10
-rw-r--r--Tests/StagingPrefix/main.cpp5
11 files changed, 193 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 48abfae..f7a320a 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -269,6 +269,7 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(CompileOptions CompileOptions)
ADD_TEST_MACRO(CompatibleInterface CompatibleInterface)
ADD_TEST_MACRO(AliasTarget AliasTarget)
+ ADD_TEST_MACRO(StagingPrefix StagingPrefix)
ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary)
set_tests_properties(EmptyLibrary PROPERTIES
PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test")
diff --git a/Tests/StagingPrefix/CMakeLists.txt b/Tests/StagingPrefix/CMakeLists.txt
new file mode 100644
index 0000000..922776d
--- /dev/null
+++ b/Tests/StagingPrefix/CMakeLists.txt
@@ -0,0 +1,89 @@
+
+cmake_minimum_required(VERSION 2.8.12)
+project(StagingPrefix)
+
+# Wipe out the install tree
+add_custom_command(
+ OUTPUT ${CMAKE_BINARY_DIR}/CleanupProject
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ConsumerBuild
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ProducerBuild
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/stage
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/prefix
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ignored
+ )
+add_custom_target(CleanupTarget ALL DEPENDS ${CMAKE_BINARY_DIR}/CleanupProject)
+set_property(
+ SOURCE ${CMAKE_BINARY_DIR}/CleanupProject
+ PROPERTY SYMBOLIC 1
+ )
+
+if(CMAKE_CONFIGURATION_TYPES)
+ set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}")
+else()
+ if(CMAKE_BUILD_TYPE)
+ set(NESTED_CONFIG_TYPE -C "${CMAKE_BUILD_TYPE}")
+ else()
+ set(NESTED_CONFIG_TYPE)
+ endif()
+endif()
+
+# Build and install the producer.
+add_custom_command(
+ OUTPUT ${CMAKE_BINARY_DIR}/ProducerProject
+ COMMAND ${CMAKE_CTEST_COMMAND} ${NESTED_CONFIG_TYPE}
+ --build-and-test
+ ${CMAKE_SOURCE_DIR}/Producer
+ ${CMAKE_BINARY_DIR}/ProducerBuild
+ --build-noclean
+ --build-project Producer
+ --build-target install
+ --build-generator ${CMAKE_GENERATOR}
+ --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
+ --build-options
+ -DCMAKE_VERBOSE_MAKEFILE=1
+ "-DCMAKE_STAGING_PREFIX=${CMAKE_BINARY_DIR}/stage"
+ "-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/prefix"
+ VERBATIM
+ )
+
+add_custom_target(ProducerTarget ALL DEPENDS ${CMAKE_BINARY_DIR}/ProducerProject)
+add_dependencies(ProducerTarget CleanupTarget)
+set_property(
+ SOURCE ${CMAKE_BINARY_DIR}/ProducerProject
+ PROPERTY SYMBOLIC 1
+ )
+
+if(NOT WIN32)
+ file(WRITE
+ "${CMAKE_BINARY_DIR}/ignored/${CMAKE_BINARY_DIR}/stage/include/ignored.h"
+ "#define IGNORED\n"
+ )
+endif()
+
+# Build and install the consumer.
+add_custom_command(
+ OUTPUT ${CMAKE_BINARY_DIR}/ConsumerProject
+ COMMAND ${CMAKE_CTEST_COMMAND} ${NESTED_CONFIG_TYPE}
+ --build-and-test
+ ${CMAKE_SOURCE_DIR}/Consumer
+ ${CMAKE_BINARY_DIR}/ConsumerBuild
+ --build-noclean
+ --build-project Consumer
+ --build-target install
+ --build-generator ${CMAKE_GENERATOR}
+ --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
+ --build-options
+ "-DCMAKE_FIND_ROOT_PATH=${CMAKE_BINARY_DIR}/ignored"
+ "-DCMAKE_STAGING_PREFIX=${CMAKE_BINARY_DIR}/stage"
+ -DCMAKE_VERBOSE_MAKEFILE=1
+ VERBATIM
+ )
+add_custom_target(ConsumerTarget ALL DEPENDS ${CMAKE_BINARY_DIR}/ConsumerProject)
+add_dependencies(ConsumerTarget ProducerTarget)
+set_property(
+ SOURCE ${CMAKE_BINARY_DIR}/ConsumerProject
+ PROPERTY SYMBOLIC 1
+ )
+
+add_executable(StagingPrefix main.cpp)
+add_dependencies(StagingPrefix ConsumerTarget)
diff --git a/Tests/StagingPrefix/Consumer/CMakeLists.txt b/Tests/StagingPrefix/Consumer/CMakeLists.txt
new file mode 100644
index 0000000..a230441
--- /dev/null
+++ b/Tests/StagingPrefix/Consumer/CMakeLists.txt
@@ -0,0 +1,22 @@
+
+cmake_minimum_required (VERSION 2.8.12)
+project(Consumer)
+
+
+add_executable(executable main.cpp)
+find_package(Foo CONFIG REQUIRED)
+target_link_libraries(executable Foo::foo)
+
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
+find_package(Bar MODULE REQUIRED)
+include_directories(${Bar_INCLUDE_DIRS})
+target_link_libraries(executable ${Bar_LIBRARIES})
+
+install(TARGETS executable DESTINATION bin)
+
+if(NOT WIN32)
+ find_path(IGNORED_INCLUDE_DIR ignored.h)
+ if (IGNORED_INCLUDE_DIR)
+ message(SEND_ERROR "Should not find this file. The search path should be excluded.")
+ endif()
+endif()
diff --git a/Tests/StagingPrefix/Consumer/cmake/FindBar.cmake b/Tests/StagingPrefix/Consumer/cmake/FindBar.cmake
new file mode 100644
index 0000000..29e4478
--- /dev/null
+++ b/Tests/StagingPrefix/Consumer/cmake/FindBar.cmake
@@ -0,0 +1,6 @@
+
+find_path(_inc_prefix bar.h PATH_SUFFIXES bar)
+set(Bar_INCLUDE_DIRS ${_inc_prefix})
+
+find_library(Bar_LIBRARY bar)
+set(Bar_LIBRARIES ${Bar_LIBRARY})
diff --git a/Tests/StagingPrefix/Consumer/main.cpp b/Tests/StagingPrefix/Consumer/main.cpp
new file mode 100644
index 0000000..612ee05
--- /dev/null
+++ b/Tests/StagingPrefix/Consumer/main.cpp
@@ -0,0 +1,10 @@
+
+#include "foo.h"
+#include "bar.h"
+
+int main(int, char **)
+{
+ Foo f;
+ Bar b;
+ return f.foo() + b.bar();
+}
diff --git a/Tests/StagingPrefix/Producer/CMakeLists.txt b/Tests/StagingPrefix/Producer/CMakeLists.txt
new file mode 100644
index 0000000..eb3d98f
--- /dev/null
+++ b/Tests/StagingPrefix/Producer/CMakeLists.txt
@@ -0,0 +1,26 @@
+
+cmake_minimum_required (VERSION 2.8.12)
+project(Producer)
+
+add_library(foo SHARED foo.cpp)
+
+install(TARGETS foo EXPORT fooTargets
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ INCLUDES DESTINATION include/foo
+)
+install(FILES foo.h DESTINATION include/foo)
+install(EXPORT fooTargets
+ FILE FooConfig.cmake
+ NAMESPACE Foo::
+ DESTINATION lib/cmake/Foo
+)
+
+add_library(bar SHARED bar.cpp)
+install(TARGETS bar
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
+install(FILES bar.h DESTINATION include/bar)
diff --git a/Tests/StagingPrefix/Producer/bar.cpp b/Tests/StagingPrefix/Producer/bar.cpp
new file mode 100644
index 0000000..6bb8abe
--- /dev/null
+++ b/Tests/StagingPrefix/Producer/bar.cpp
@@ -0,0 +1,7 @@
+
+#include "bar.h"
+
+int Bar::bar()
+{
+ return 0;
+}
diff --git a/Tests/StagingPrefix/Producer/bar.h b/Tests/StagingPrefix/Producer/bar.h
new file mode 100644
index 0000000..acd1fae
--- /dev/null
+++ b/Tests/StagingPrefix/Producer/bar.h
@@ -0,0 +1,10 @@
+
+class
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+Bar
+{
+public:
+ int bar();
+};
diff --git a/Tests/StagingPrefix/Producer/foo.cpp b/Tests/StagingPrefix/Producer/foo.cpp
new file mode 100644
index 0000000..64ad7cd
--- /dev/null
+++ b/Tests/StagingPrefix/Producer/foo.cpp
@@ -0,0 +1,7 @@
+
+#include "foo.h"
+
+int Foo::foo()
+{
+ return 0;
+}
diff --git a/Tests/StagingPrefix/Producer/foo.h b/Tests/StagingPrefix/Producer/foo.h
new file mode 100644
index 0000000..614093d
--- /dev/null
+++ b/Tests/StagingPrefix/Producer/foo.h
@@ -0,0 +1,10 @@
+
+class
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+Foo
+{
+public:
+ int foo();
+};
diff --git a/Tests/StagingPrefix/main.cpp b/Tests/StagingPrefix/main.cpp
new file mode 100644
index 0000000..341aaaf
--- /dev/null
+++ b/Tests/StagingPrefix/main.cpp
@@ -0,0 +1,5 @@
+
+int main(int, char **)
+{
+ return 0;
+}