mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 08:15:18 -04:00
CMake: Use CMAKE_FIND_PACKAGE_PREFER_CONFIG
to control find_package
override
This commit is contained in:
parent
74e9c610d3
commit
b00d7b23bc
@ -483,24 +483,28 @@ endfunction(export_targets)
|
|||||||
#
|
#
|
||||||
# find_package
|
# find_package
|
||||||
#
|
#
|
||||||
# This override is necessary because CMake's default behavior is to run
|
# This override implements CMAKE_FIND_PACKAGE_PREFER_CONFIG on versions of
|
||||||
# find_package in MODULE mode, *then* in CONFIG mode. This is silly! CONFIG
|
# CMake too old to include it.
|
||||||
# mode makes more sense to be done first, since any system config file will
|
|
||||||
# know vastly more about the package's configuration than a module can hope to
|
|
||||||
# guess.
|
|
||||||
#
|
#
|
||||||
macro(find_package name)
|
if(CMAKE_VERSION VERSION_LESS "3.15")
|
||||||
if(";${ARGN};" MATCHES ";(CONFIG|MODULE|NO_MODULE);")
|
macro(find_package name)
|
||||||
# Caller explicitly asking for a certain mode; so be it.
|
if(";${ARGN};" MATCHES ";(CONFIG|MODULE|NO_MODULE);")
|
||||||
_find_package(${ARGV})
|
# Caller explicitly asking for a certain mode; so be it.
|
||||||
|
_find_package(${ARGV})
|
||||||
|
|
||||||
else()
|
elseif(CMAKE_FIND_PACKAGE_PREFER_CONFIG)
|
||||||
# Try CONFIG
|
# Try CONFIG
|
||||||
_find_package("${name}" CONFIG ${ARGN})
|
_find_package("${name}" CONFIG ${ARGN})
|
||||||
|
|
||||||
|
if(NOT ${name}_FOUND)
|
||||||
|
# CONFIG didn't work, fall back to MODULE
|
||||||
|
_find_package("${name}" MODULE ${ARGN})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
else()
|
||||||
|
# Default behavior
|
||||||
|
_find_package(${ARGV})
|
||||||
|
|
||||||
if(NOT ${name}_FOUND)
|
|
||||||
# CONFIG didn't work, fall back to MODULE
|
|
||||||
_find_package("${name}" MODULE ${ARGN})
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endmacro(find_package)
|
||||||
endmacro(find_package)
|
endif()
|
||||||
|
@ -67,6 +67,7 @@ endif()
|
|||||||
# Set certain CMake flags we expect
|
# Set certain CMake flags we expect
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
|
||||||
|
|
||||||
# Set up the output directory structure, mimicking that of makepanda
|
# Set up the output directory structure, mimicking that of makepanda
|
||||||
set(CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR}/cmake")
|
set(CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR}/cmake")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user