File tree Expand file tree Collapse file tree 2 files changed +23
-18
lines changed
Expand file tree Collapse file tree 2 files changed +23
-18
lines changed Original file line number Diff line number Diff line change @@ -483,24 +483,28 @@ endfunction(export_targets)
483483#
484484# find_package
485485#
486- # This override is necessary because CMake 's default behavior is to run
487- # find_package in MODULE mode , *then * in CONFIG mode . This is silly ! CONFIG
488- # mode makes more sense to be done first , since any system config file will
489- # know vastly more about the package 's configuration than a module can hope to
490- # guess .
491- #
492- macro (find_package name )
493- if (";${ARGN} ;" MATCHES ";(CONFIG |MODULE |NO_MODULE );")
494- # Caller explicitly asking for a certain mode ; so be it .
495- _find_package (${ARGV} )
486+ # This override implements CMAKE_FIND_PACKAGE_PREFER_CONFIG on versions of
487+ # CMake too old to include it .
488+ #
489+ if (CMAKE_VERSION VERSION_LESS "3.15")
490+ macro (find_package name )
491+ if (";${ARGN} ;" MATCHES ";(CONFIG |MODULE |NO_MODULE );")
492+ # Caller explicitly asking for a certain mode ; so be it .
493+ _find_package (${ARGV} )
494+
495+ elseif (CMAKE_FIND_PACKAGE_PREFER_CONFIG )
496+ # Try CONFIG
497+ _find_package ("${name} " CONFIG ${ARGN} )
498+
499+ if (NOT ${name} _FOUND )
500+ # CONFIG didn 't work , fall back to MODULE
501+ _find_package ("${name} " MODULE ${ARGN} )
502+ endif ()
496503
497- else ()
498- # Try CONFIG
499- _find_package (" ${name} " CONFIG ${ARGN } )
504+ else ()
505+ # Default behavior
506+ _find_package (${ARGV } )
500507
501- if (NOT ${name} _FOUND )
502- # CONFIG didn 't work , fall back to MODULE
503- _find_package ("${name} " MODULE ${ARGN} )
504508 endif ()
505- endif ( )
506- endmacro ( find_package )
509+ endmacro ( find_package )
510+ endif ( )
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ endif()
6767# Set certain CMake flags we expect
6868set (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON )
6969set (CMAKE_INCLUDE_CURRENT_DIR ON )
70+ set (CMAKE_FIND_PACKAGE_PREFER_CONFIG ON )
7071
7172# Set up the output directory structure, mimicking that of makepanda
7273set (CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR} /cmake" )
You can’t perform that action at this time.
0 commit comments