Merge topic 'multiarch-include'

da1d9ba Test find_path multiarch support (#13742)
b96f6fc Teach find_(path|file) about Linux multiarch (#13742)
This commit is contained in:
Brad King 2012-11-30 10:35:59 -05:00 committed by CMake Topic Stage
commit 1be60d6dc7
6 changed files with 38 additions and 4 deletions

View File

@ -360,13 +360,13 @@ void cmFindBase::AddPrefixPaths(std::vector<std::string> const& in_paths,
{ {
dir += "/"; dir += "/";
} }
if(subdir == "lib") if(subdir == "include" || subdir == "lib")
{ {
const char* arch = const char* arch =
this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"); this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE");
if(arch && *arch) if(arch && *arch)
{ {
this->AddPathInternal(dir+"lib/"+arch, pathType); this->AddPathInternal(dir+subdir+"/"+arch, pathType);
} }
} }
std::string add = dir + subdir; std::string add = dir + subdir;

View File

@ -45,8 +45,10 @@ void cmFindPathCommand::GenerateDocumentation()
"SEARCH_XXX", "file in a directory"); "SEARCH_XXX", "file in a directory");
cmSystemTools::ReplaceString(this->GenericDocumentation, cmSystemTools::ReplaceString(this->GenericDocumentation,
"XXX_SUBDIR", "include"); "XXX_SUBDIR", "include");
cmSystemTools::ReplaceString(this->GenericDocumentation, cmSystemTools::ReplaceString(
"XXX_EXTRA_PREFIX_ENTRY", ""); this->GenericDocumentation,
"XXX_EXTRA_PREFIX_ENTRY",
" <prefix>/include/<arch> if CMAKE_LIBRARY_ARCHITECTURE is set, and\n");
cmSystemTools::ReplaceString(this->GenericDocumentation, cmSystemTools::ReplaceString(this->GenericDocumentation,
"CMAKE_FIND_ROOT_PATH_MODE_XXX", "CMAKE_FIND_ROOT_PATH_MODE_XXX",
"CMAKE_FIND_ROOT_PATH_MODE_INCLUDE"); "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE");

View File

@ -32,6 +32,7 @@ add_CMakeOnly_test(SelectLibraryConfigurations)
add_CMakeOnly_test(TargetScope) add_CMakeOnly_test(TargetScope)
add_CMakeOnly_test(find_library) add_CMakeOnly_test(find_library)
add_CMakeOnly_test(find_path)
add_test(CMakeOnly.ProjectInclude ${CMAKE_CMAKE_COMMAND} add_test(CMakeOnly.ProjectInclude ${CMAKE_CMAKE_COMMAND}
-DTEST=ProjectInclude -DTEST=ProjectInclude

View File

@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 2.8)
project(FindPathTest NONE)
set(CMAKE_FIND_DEBUG_MODE 1)
macro(test_find_path expected)
unset(HDR CACHE)
find_path(HDR ${ARGN}
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
)
if(HDR)
# Convert to relative path for comparison to expected location.
file(RELATIVE_PATH REL_HDR "${CMAKE_CURRENT_SOURCE_DIR}" "${HDR}")
# Check and report failure.
if(NOT "${REL_HDR}" STREQUAL "${expected}")
message(SEND_ERROR "Header ${expected} found as [${REL_HDR}]")
elseif(CMAKE_FIND_DEBUG_MODE)
message(STATUS "Header ${expected} found as [${REL_HDR}]")
endif()
else()
message(SEND_ERROR "Header ${expected} NOT FOUND")
endif()
endmacro()
set(CMAKE_SYSTEM_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_LIBRARY_ARCHITECTURE arch)
test_find_path(include NAMES test1.h)
test_find_path(include/arch NAMES test1arch.h)