mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
CMake: Look for packages by CONFIG first
This requires a macro to override find_package, as the default behavior in CMake is to fall back from MODULE onto CONFIG. Note that Bullet is given a specific override not to look for a CONFIG, since Bullet tends to use weird paths in its CONFIG script.
This commit is contained in:
parent
968ca123d4
commit
bd187643f3
@ -256,3 +256,31 @@ function(show_packages)
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
#
|
||||||
|
# find_package
|
||||||
|
#
|
||||||
|
# This override is necessary because CMake's default behavior is to run
|
||||||
|
# find_package in MODULE mode, *then* in CONFIG mode. This is silly! CONFIG
|
||||||
|
# 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(";${ARGN};" MATCHES ";(CONFIG|MODULE|NO_MODULE);")
|
||||||
|
# Caller explicitly asking for a certain mode; so be it.
|
||||||
|
_find_package(${ARGV})
|
||||||
|
else()
|
||||||
|
string(TOUPPER "${name}" __pkgname_upper)
|
||||||
|
|
||||||
|
# Try CONFIG
|
||||||
|
_find_package("${name}" CONFIG ${ARGN})
|
||||||
|
if(NOT ${name}_FOUND)
|
||||||
|
# CONFIG didn't work, fall back to MODULE
|
||||||
|
_find_package("${name}" MODULE ${ARGN})
|
||||||
|
else()
|
||||||
|
# Case-sensitivity
|
||||||
|
set(${__pkgname_upper}_FOUND 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endmacro(find_package)
|
||||||
|
@ -296,7 +296,7 @@ package_option(GTK2)
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Bullet
|
# Bullet
|
||||||
find_package(Bullet QUIET)
|
find_package(Bullet MODULE QUIET)
|
||||||
|
|
||||||
package_option(BULLET
|
package_option(BULLET
|
||||||
"Enable this option to support game dynamics with the Bullet physics library.")
|
"Enable this option to support game dynamics with the Bullet physics library.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user