From d430cb7c36e7739a70da7897465badba62be7989 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 14 May 2015 09:51:48 -0400 Subject: [PATCH] Tests: Fix failures when running under the default install prefix (#15566) Fix test cases whose behavior differs when their source or build tree is under CMAKE_INSTALL_PREFIX by setting an install prefix under the build tree. Otherwise they may fail when run under the default install prefix (e.g. /usr/local). --- Tests/FindPackageTest/CMakeLists.txt | 3 +++ Tests/RunCMake/CMP0041/RunCMakeTest.cmake | 3 +++ Tests/RunCMake/IfacePaths/RunCMakeTest.cmake | 3 +++ Tests/RunCMake/include_directories/RunCMakeTest.cmake | 3 +++ 4 files changed, 12 insertions(+) diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 8fafa3b70..fadd0feef 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required (VERSION 2.6) project(FindPackageTest) +# Protect tests from running inside the default install prefix. +set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/NotDefaultPrefix") + list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) # Look for a package which uses FindPackageHandleStandardArgs.cmake with the diff --git a/Tests/RunCMake/CMP0041/RunCMakeTest.cmake b/Tests/RunCMake/CMP0041/RunCMakeTest.cmake index a5e2114cb..e7f27a1a2 100644 --- a/Tests/RunCMake/CMP0041/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0041/RunCMakeTest.cmake @@ -1,5 +1,8 @@ include(RunCMake) +# Protect tests from running inside the default install prefix. +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/NotDefaultPrefix") + run_cmake(CMP0041-OLD) run_cmake(CMP0041-NEW) run_cmake(CMP0041-WARN) diff --git a/Tests/RunCMake/IfacePaths/RunCMakeTest.cmake b/Tests/RunCMake/IfacePaths/RunCMakeTest.cmake index 489e3dfbf..066c83e63 100644 --- a/Tests/RunCMake/IfacePaths/RunCMakeTest.cmake +++ b/Tests/RunCMake/IfacePaths/RunCMakeTest.cmake @@ -6,6 +6,9 @@ macro(run_cmake test) _run_cmake(${test}) endmacro() +# Protect tests from running inside the default install prefix. +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/NotDefaultPrefix") + run_cmake(RelativePathInInterface) run_cmake(RelativePathInGenex) run_cmake(export-NOWARN) diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake index 3f624f850..54d5e9773 100644 --- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake @@ -1,5 +1,8 @@ include(RunCMake) +# Protect tests from running inside the default install prefix. +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/NotDefaultPrefix") + run_cmake(NotFoundContent) run_cmake(DebugIncludes) run_cmake(TID-bad-target)