summaryrefslogtreecommitdiff
path: root/Tests/StagingPrefix
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-11-14 12:04:40 +0100
committerStephen Kelly <steveire@gmail.com>2013-11-21 11:48:03 +0100
commit7521da2852a2fce16919b2640bcc0fa2f0c55b7d (patch)
tree54dcfafc4f481f1bbe2b873eb11e900140a2cb9a /Tests/StagingPrefix
parente776a2dae4fe7dd6d20f15ec488019b95a9d648f (diff)
downloadcmake-7521da2852a2fce16919b2640bcc0fa2f0c55b7d.tar.gz
Introduce CMAKE_STAGING_PREFIX variable.
This variable can be useful in cross-compiling contexts where the sysroot is read-only or where the sysroot should otherwise remain pristine. If the new CMAKE_STAGING_PREFIX variable is set, it is used instead of CMAKE_INSTALL_PREFIX when generating the installation rules in cmake_install.cmake. This way, the CMAKE_INSTALL_PREFIX variable always refers to the installation prefix on the target device, regardless of whether host==target. If any -rpath paths passed to the linker contain the CMAKE_STAGING_PREFIX, the matching path fragments are replaced with the CMAKE_INSTALL_PREFIX. Matching paths in the -rpath-link are not transformed. The cross-prefix usr-move workaround is assumed not to require extension regarding CMAKE_STAGING_PREFIX. The staging area is a single prefix, so there is no scope for cross-prefix symlinks. The CMAKE_INSTALL_PREFIX is still used to determine the workaround path, and that variable remains the relevant one even if CMAKE_STAGING_PREFIX is used. If the generated export files are deployed to the target, the workaround will still be in place, and still be employed if required.
Diffstat (limited to 'Tests/StagingPrefix')
-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
10 files changed, 192 insertions, 0 deletions
diff --git a/Tests/StagingPrefix/CMakeLists.txt b/Tests/StagingPrefix/CMakeLists.txt
new file mode 100644
index 0000000000..922776d703
--- /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 0000000000..a230441e64
--- /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 0000000000..29e4478aed
--- /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 0000000000..612ee05a91
--- /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 0000000000..eb3d98f2e6
--- /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 0000000000..6bb8abecd6
--- /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 0000000000..acd1fae023
--- /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 0000000000..64ad7cd0ee
--- /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 0000000000..614093db8b
--- /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 0000000000..341aaafa0a
--- /dev/null
+++ b/Tests/StagingPrefix/main.cpp
@@ -0,0 +1,5 @@
+
+int main(int, char **)
+{
+ return 0;
+}