mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 20:19:53 +00:00
Merge topic 'find_package-fix-NO_MODULE'
f2edccea66
find_package: Fix NO_MODULE under CMAKE_FIND_PACKAGE_PREFER_CONFIG
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3557
This commit is contained in:
commit
3f84ff212c
@ -823,8 +823,9 @@ bool cmFindPackageCommand::HandlePackageMode(
|
||||
}
|
||||
}
|
||||
|
||||
if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_PREFER_CONFIG") && !found &&
|
||||
handlePackageModeType == HandlePackageModeType::Config) {
|
||||
if (this->UseFindModules && !found &&
|
||||
handlePackageModeType == HandlePackageModeType::Config &&
|
||||
this->Makefile->IsOn("CMAKE_FIND_PACKAGE_PREFER_CONFIG")) {
|
||||
// Config mode failed. Allow Module case.
|
||||
result = false;
|
||||
}
|
||||
|
@ -607,6 +607,26 @@ endif()
|
||||
|
||||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF)
|
||||
set(CMAKE_PREFIX_PATH)
|
||||
set(CMAKE_MODULE_PATH)
|
||||
|
||||
############################################################################
|
||||
##Test FIND_PACKAGE CMAKE_FIND_PACKAGE_PREFER_CONFIG - Do not recurse
|
||||
|
||||
# No CMAKE_PREFIX_PATH
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfigRecurse)
|
||||
|
||||
# Now prefer config mode
|
||||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
|
||||
unset(ACME_FOUND)
|
||||
unset(ACME_CONFIG)
|
||||
|
||||
find_package(ACME)
|
||||
if(ACME_FOUND AND ACME_CONFIG)
|
||||
message(SEND_ERROR "Incorrectly found ACME in CONFIG mode, from the MODULE package")
|
||||
endif()
|
||||
|
||||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF)
|
||||
set(CMAKE_MODULE_PATH)
|
||||
|
||||
############################################################################
|
||||
##Test find_package CMAKE_FIND_PACKAGE_PREFER_CONFIG with module fallback
|
||||
@ -620,3 +640,16 @@ find_package(ACME REQUIRED)
|
||||
if(NOT ACME_FOUND)
|
||||
message(SEND_ERROR "Did not find ACME package")
|
||||
endif()
|
||||
|
||||
############################################################################
|
||||
##Test find_package CMAKE_FIND_PACKAGE_PREFER_CONFIG with NO_MODULE
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfigOnlyModule)
|
||||
|
||||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
|
||||
|
||||
find_package(ACME NO_MODULE)
|
||||
|
||||
if(ACME_FOUND)
|
||||
message(SEND_ERROR "Should not find ACME package")
|
||||
endif()
|
||||
|
@ -0,0 +1 @@
|
||||
set(ACME_FOUND TRUE)
|
1
Tests/FindPackageTest/PreferConfigRecurse/FindACME.cmake
Normal file
1
Tests/FindPackageTest/PreferConfigRecurse/FindACME.cmake
Normal file
@ -0,0 +1 @@
|
||||
find_package(ACME NO_MODULE)
|
Loading…
Reference in New Issue
Block a user