diff --git a/modules/FindCorrade.cmake b/modules/FindCorrade.cmake index 7d2e725..9af261b 100644 --- a/modules/FindCorrade.cmake +++ b/modules/FindCorrade.cmake @@ -118,8 +118,13 @@ # CORRADE_*_LIBRARY_DEBUG - Debug version of given library, if found # CORRADE_*_LIBRARY_RELEASE - Release version of given library, if found # CORRADE_*_EXECUTABLE - Location of given executable, if found +# CORRADE_*_EXECUTABLE_EMULATOR - Emulator to run CORRADE_*_EXECUTABLE, if a +# non-native version was found when cross-compiling # CORRADE_USE_MODULE - Path to UseCorrade.cmake module (included # automatically) +# CORRADE_DEPENDENCY_MODULE_DIR - Path to Find modules for dependencies used +# internally by Corrade. Defined only if any such modules are expected to +# exist on given platform. # CORRADE_TESTSUITE_XCTEST_RUNNER - Path to XCTestRunner.mm.in file # CORRADE_TESTSUITE_ADB_RUNNER - Path to AdbRunner.sh file # CORRADE_UTILITY_JS - Path to CorradeUtility.js file @@ -272,7 +277,7 @@ # This file is part of Corrade. # # Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, -# 2017, 2018, 2019, 2020, 2021, 2022, 2023 +# 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -355,6 +360,12 @@ find_path(_CORRADE_MODULE_DIR NAMES UseCorrade.cmake CorradeLibSuffix.cmake PATH_SUFFIXES share/cmake/Corrade) mark_as_advanced(_CORRADE_MODULE_DIR) +if(CORRADE_TARGET_EMSCRIPTEN) + find_path(CORRADE_DEPENDENCY_MODULE_DIR + NAMES FindNodeJs.cmake + PATH_SUFFIXES share/cmake/Corrade/dependencies) + mark_as_advanced(CORRADE_DEPENDENCY_MODULE_DIR) +endif() set(CORRADE_USE_MODULE ${_CORRADE_MODULE_DIR}/UseCorrade.cmake) set(CORRADE_LIB_SUFFIX_MODULE ${_CORRADE_MODULE_DIR}/CorradeLibSuffix.cmake) @@ -407,6 +418,11 @@ if(Corrade_FIND_COMPONENTS) list(REMOVE_DUPLICATES Corrade_FIND_COMPONENTS) endif() +# Special cases of include paths. Libraries not listed here have a path suffix +# and include name derived from the library name in the loop below. +set(_CORRADE_MAIN_INCLUDE_PATH_SUFFIX Corrade) +set(_CORRADE_MAIN_INCLUDE_PATH_NAMES Corrade.h) + # Find all components foreach(_component ${Corrade_FIND_COMPONENTS}) string(TOUPPER ${_component} _COMPONENT) @@ -417,7 +433,16 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) if(TARGET Corrade::${_component}) set(Corrade_${_component}_FOUND TRUE) else() - unset(Corrade_${_component}_FOUND) + # Default include path names to look for for library / header-only + # components, unless set above already + if(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS) + if(NOT _CORRADE_${_COMPONENT}_INCLUDE_PATH_SUFFIX) + set(_CORRADE_${_COMPONENT}_INCLUDE_PATH_SUFFIX Corrade/${_component}) + endif() + if(NOT _CORRADE_${_COMPONENT}_INCLUDE_PATH_NAMES) + set(_CORRADE_${_COMPONENT}_INCLUDE_PATH_NAMES ${_component}.h) + endif() + endif() # Library (and not header-only) components if(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS AND NOT _component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS) @@ -428,20 +453,6 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) find_library(CORRADE_${_COMPONENT}_LIBRARY_RELEASE Corrade${_component}) mark_as_advanced(CORRADE_${_COMPONENT}_LIBRARY_DEBUG CORRADE_${_COMPONENT}_LIBRARY_RELEASE) - - if(CORRADE_${_COMPONENT}_LIBRARY_RELEASE) - set_property(TARGET Corrade::${_component} APPEND PROPERTY - IMPORTED_CONFIGURATIONS RELEASE) - set_property(TARGET Corrade::${_component} PROPERTY - IMPORTED_LOCATION_RELEASE ${CORRADE_${_COMPONENT}_LIBRARY_RELEASE}) - endif() - - if(CORRADE_${_COMPONENT}_LIBRARY_DEBUG) - set_property(TARGET Corrade::${_component} APPEND PROPERTY - IMPORTED_CONFIGURATIONS DEBUG) - set_property(TARGET Corrade::${_component} PROPERTY - IMPORTED_LOCATION_DEBUG ${CORRADE_${_COMPONENT}_LIBRARY_DEBUG}) - endif() endif() # Header-only library components @@ -449,13 +460,6 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) add_library(Corrade::${_component} INTERFACE IMPORTED) endif() - # Default include path names to look for for library / header-only - # components - if(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS) - set(_CORRADE_${_COMPONENT}_INCLUDE_PATH_SUFFIX Corrade/${_component}) - set(_CORRADE_${_COMPONENT}_INCLUDE_PATH_NAMES ${_component}.h) - endif() - # Executable components if(_component IN_LIST _CORRADE_EXECUTABLE_COMPONENTS) add_executable(Corrade::${_component} IMPORTED) @@ -463,12 +467,72 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) find_program(CORRADE_${_COMPONENT}_EXECUTABLE corrade-${_component}) mark_as_advanced(CORRADE_${_COMPONENT}_EXECUTABLE) + # If the executable wasn't found, we're cross-compiling, an + # emulator is set and we're on CMake 3.6+ that actually uses + # CMAKE_CROSSCOMPILING_EMULATOR in add_custom_command((), try to + # find the cross-compiled version as a (slower) fallback. This + # assumes the toolchain sets CMAKE_FIND_ROOT_PATH_MODE_PROGRAM to + # NEVER, i.e. that the search is restricted to native executables + # by default. + if(NOT CORRADE_${_COMPONENT}_EXECUTABLE AND CMAKE_CROSSCOMPILING AND CMAKE_CROSSCOMPILING_EMULATOR AND NOT CMAKE_VERSION VERSION_LESS 3.6) + # Additionally, there are no CMAKE_FIND_PROGRAM_SUFFIXES akin + # to CMAKE_FIND_LIBRARY_SUFFIXES for libraries, so we have to + # try manually. + if(CORRADE_TARGET_EMSCRIPTEN) + set(_CORRADE_PROGRAM_EXTENSION .js) + endif() + find_program(CORRADE_${_COMPONENT}_EXECUTABLE + NAMES + corrade-${_component} + corrade-${_component}${_CORRADE_PROGRAM_EXTENSION} + ONLY_CMAKE_FIND_ROOT_PATH) + if(CORRADE_${_COMPONENT}_EXECUTABLE) + set(CORRADE_${_COMPONENT}_EXECUTABLE_EMULATOR ${CMAKE_CROSSCOMPILING_EMULATOR} CACHE PATH "Emulator for running a cross-compiled corrade-${_component} executable") + mark_as_advanced(CORRADE_${_COMPONENT}_EXECUTABLE_EMULATOR) + endif() + endif() + if(CORRADE_${_COMPONENT}_EXECUTABLE) set_property(TARGET Corrade::${_component} PROPERTY IMPORTED_LOCATION ${CORRADE_${_COMPONENT}_EXECUTABLE}) endif() endif() + # Find library includes + if(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS) + find_path(_CORRADE_${_COMPONENT}_INCLUDE_DIR + NAMES ${_CORRADE_${_COMPONENT}_INCLUDE_PATH_NAMES} + HINTS ${CORRADE_INCLUDE_DIR}/${_CORRADE_${_COMPONENT}_INCLUDE_PATH_SUFFIX}) + mark_as_advanced(_CORRADE_${_COMPONENT}_INCLUDE_DIR) + endif() + + # Decide if the component was found. If not, skip the rest, which + # populates the target properties and finds additional dependencies. If + # found, the _FOUND variable may still get reset by something below. + if((_component IN_LIST _CORRADE_LIBRARY_COMPONENTS AND _CORRADE_${_COMPONENT}_INCLUDE_DIR AND (_component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS OR CORRADE_${_COMPONENT}_LIBRARY_RELEASE OR CORRADE_${_COMPONENT}_LIBRARY_DEBUG)) OR (_component IN_LIST _CORRADE_EXECUTABLE_COMPONENTS AND CORRADE_${_COMPONENT}_EXECUTABLE)) + set(Corrade_${_component}_FOUND TRUE) + else() + set(Corrade_${_component}_FOUND FALSE) + continue() + endif() + + # Library location for (non-header-only) libraries + if(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS AND NOT _component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS) + if(CORRADE_${_COMPONENT}_LIBRARY_RELEASE) + set_property(TARGET Corrade::${_component} APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_property(TARGET Corrade::${_component} PROPERTY + IMPORTED_LOCATION_RELEASE ${CORRADE_${_COMPONENT}_LIBRARY_RELEASE}) + endif() + + if(CORRADE_${_COMPONENT}_LIBRARY_DEBUG) + set_property(TARGET Corrade::${_component} APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_property(TARGET Corrade::${_component} PROPERTY + IMPORTED_LOCATION_DEBUG ${CORRADE_${_COMPONENT}_LIBRARY_DEBUG}) + endif() + endif() + # No special setup for Containers library # Interconnect library @@ -488,9 +552,6 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) # Main library elseif(_component STREQUAL Main) - set(_CORRADE_${_COMPONENT}_INCLUDE_PATH_SUFFIX Corrade) - set(_CORRADE_${_COMPONENT}_INCLUDE_PATH_NAMES Corrade.h) - if(CORRADE_TARGET_WINDOWS) if(NOT MINGW) # Abusing INTERFACE_LINK_LIBRARIES because @@ -551,6 +612,16 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) set_property(TARGET Corrade::${_component} APPEND PROPERTY COMPATIBLE_INTERFACE_NUMBER_MAX CORRADE_CXX_STANDARD) + # -fno-strict-aliasing is set in UseCorrade.cmake for everyone who + # enables CORRADE_USE_PEDANTIC_FLAGS. Not all projects linking to + # Corrade enable it (or can't enable it), but this flag is + # essential to prevent insane bugs and random breakages, so force + # it for anyone linking to Corrade::Utility. Similar code is in + # Corrade/Utility/CMakeLists.txt. + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang" AND NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") OR CORRADE_TARGET_EMSCRIPTEN) + set_property(TARGET Corrade::${_component} APPEND PROPERTY INTERFACE_COMPILE_OPTIONS -fno-strict-aliasing) + endif() + # Path::libraryLocation() needs this if(CORRADE_TARGET_UNIX) set_property(TARGET Corrade::${_component} APPEND PROPERTY @@ -572,14 +643,6 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) endif() endif() - # Find library includes - if(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS) - find_path(_CORRADE_${_COMPONENT}_INCLUDE_DIR - NAMES ${_CORRADE_${_COMPONENT}_INCLUDE_PATH_NAMES} - HINTS ${CORRADE_INCLUDE_DIR}/${_CORRADE_${_COMPONENT}_INCLUDE_PATH_SUFFIX}) - mark_as_advanced(_CORRADE_${_COMPONENT}_INCLUDE_DIR) - endif() - # Add inter-library dependencies if(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS OR _component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS) foreach(_dependency ${_CORRADE_${_component}_DEPENDENCIES}) @@ -589,16 +652,6 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) endif() endforeach() endif() - - # Decide if the component was found, unless the _FOUND is already set - # by something above. - if(NOT DEFINED Corrade_${_component}_FOUND) - if((_component IN_LIST _CORRADE_LIBRARY_COMPONENTS AND _CORRADE_${_COMPONENT}_INCLUDE_DIR AND (_component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS OR CORRADE_${_COMPONENT}_LIBRARY_RELEASE OR CORRADE_${_COMPONENT}_LIBRARY_DEBUG)) OR (_component IN_LIST _CORRADE_EXECUTABLE_COMPONENTS AND CORRADE_${_COMPONENT}_EXECUTABLE)) - set(Corrade_${_component}_FOUND TRUE) - else() - set(Corrade_${_component}_FOUND FALSE) - endif() - endif() endif() endforeach() diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 5662389..1c9c521 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -135,9 +135,9 @@ # globals unique even across different shared libraries # MAGNUM_TARGET_GL - Defined if compiled with OpenGL interop # MAGNUM_TARGET_GLES - Defined if compiled for OpenGL ES -# MAGNUM_TARGET_GLES2 - Defined if compiled for OpenGL ES 2.0 -# MAGNUM_TARGET_GLES3 - Defined if compiled for OpenGL ES 3.0 # MAGNUM_TARGET_WEBGL - Defined if compiled for WebGL +# MAGNUM_TARGET_GLES2 - Defined if compiled for OpenGL ES 2.0 / WebGL +# 1 instead of OpenGL ES 3.0+ / WebGL 2 # MAGNUM_TARGET_EGL - Defined if compiled for EGL instead of a # platform-specific OpenGL support library like CGL, EAGL, GLX or WGL # MAGNUM_TARGET_VK - Defined if compiled with Vulkan interop @@ -152,6 +152,8 @@ # Android, Emscripten or Windows RT. Use MAGNUM_TARGET_EGL instead. # MAGNUM_TARGET_DESKTOP_GLES` - Defined if compiled for OpenGL ES but # GLX / WGL is used instead of EGL. Use MAGNUM_TARGET_EGL instead. +# MAGNUM_TARGET_GLES3 - Defined if compiled for OpenGL ES 3.0+ / +# WebGL 2. Use an inverse of the MAGNUM_TARGET_GLES2 variable instead. # # Additionally these variables are defined for internal usage: # @@ -206,7 +208,8 @@ # This file is part of Magnum. # # Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, -# 2020, 2021, 2022, 2023 Vladimír Vondruš +# 2020, 2021, 2022, 2023, 2024 +# Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -291,7 +294,6 @@ set(_magnumFlags TARGET_GL TARGET_GLES TARGET_GLES2 - TARGET_GLES3 TARGET_WEBGL TARGET_EGL TARGET_VK) @@ -316,6 +318,33 @@ if(MAGNUM_BUILD_DEPRECATED) set(MAGNUM_TARGET_DESKTOP_GLES 1) endif() endif() + if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_GLES2) + set(MAGNUM_TARGET_GLES3 1) + endif() +endif() + +# CMake module dir for dependencies. It might not be present at all if no +# feature that needs them is enabled, in which case it'll be left at NOTFOUND. +# But in that case it should also not be subsequently needed for any +# find_package(). If this is called from a superproject, the +# _MAGNUM_DEPENDENCY_MODULE_DIR is already set by modules/CMakeLists.txt. +find_path(_MAGNUM_DEPENDENCY_MODULE_DIR + NAMES + FindEGL.cmake FindGLFW.cmake FindOpenAL.cmake FindOpenGLES2.cmake + FindOpenGLES3.cmake FindSDL2.cmake FindVulkan.cmake + PATH_SUFFIXES share/cmake/Magnum/dependencies) +mark_as_advanced(_MAGNUM_DEPENDENCY_MODULE_DIR) + +# If the module dir is found and is not present in CMAKE_MODULE_PATH already +# (such as when someone explicitly added it, or if it's the Magnum's modules/ +# dir in case of a superproject), add it as the first before all other. Set a +# flag to remove it again at the end, so the modules don't clash with Find +# modules of the same name from other projects. +if(_MAGNUM_DEPENDENCY_MODULE_DIR AND NOT _MAGNUM_DEPENDENCY_MODULE_DIR IN_LIST CMAKE_MODULE_PATH) + set(CMAKE_MODULE_PATH ${_MAGNUM_DEPENDENCY_MODULE_DIR} ${CMAKE_MODULE_PATH}) + set(_MAGNUM_REMOVE_DEPENDENCY_MODULE_DIR_FROM_CMAKE_PATH ON) +else() + unset(_MAGNUM_REMOVE_DEPENDENCY_MODULE_DIR_FROM_CMAKE_PATH) endif() # Base Magnum library @@ -558,6 +587,15 @@ if(Magnum_FIND_COMPONENTS) list(REMOVE_DUPLICATES Magnum_FIND_COMPONENTS) endif() +# Special cases of include paths. Libraries not listed here have a path suffix +# and include name derived from the library name in the loop below. +set(_MAGNUM_MATERIALTOOLS_INCLUDE_PATH_NAMES PhongToPbrMetallicRoughness.h) +set(_MAGNUM_MESHTOOLS_INCLUDE_PATH_NAMES CompressIndices.h) +set(_MAGNUM_OPENGLTESTER_INCLUDE_PATH_SUFFIX Magnum/GL) +set(_MAGNUM_VULKANTESTER_INCLUDE_PATH_SUFFIX Magnum/Vk) +set(_MAGNUM_PRIMITIVES_INCLUDE_PATH_NAMES Cube.h) +set(_MAGNUM_SCENETOOLS_INCLUDE_PATH_NAMES Hierarchy.h) + # Find all components. Maintain a list of components that'll need to have # their optional dependencies checked. set(_MAGNUM_OPTIONAL_DEPENDENCIES_TO_ADD ) @@ -574,9 +612,20 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) if(_component IN_LIST _MAGNUM_LIBRARY_COMPONENTS) add_library(Magnum::${_component} UNKNOWN IMPORTED) - # Set library defaults, find the library - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/${_component}) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES ${_component}.h) + # Include path names to find, unless specified above already. + # Application and context libraries are a special case as well. + if(_component MATCHES ".+Application") + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform) + elseif(_component MATCHES ".+Context") + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES GLContext.h) + endif() + if(NOT _MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/${_component}) + endif() + if(NOT _MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES ${_component}.h) + endif() # Try to find both debug and release version find_library(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG Magnum${_component}-d) @@ -595,7 +644,9 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # Audio importer class is Audio::*Importer, thus we need to # convert *AudioImporter.h to *Importer.h string(REPLACE "AudioImporter" "Importer" _MAGNUM_${_COMPONENT}_HEADER_NAME "${_component}") - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES ${_MAGNUM_${_COMPONENT}_HEADER_NAME}.h) + if(NOT _MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES ${_MAGNUM_${_COMPONENT}_HEADER_NAME}.h) + endif() # ShaderConverter plugin specific name suffixes elseif(_component MATCHES ".+ShaderConverter$") @@ -622,8 +673,10 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) set(_MAGNUM_${_COMPONENT}_PATH_SUFFIX fontconverters) endif() - # Don't override the exception for *AudioImporter plugins - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX MagnumPlugins/${_component}) + # Include path names to find, unless specified above + if(NOT _MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX MagnumPlugins/${_component}) + endif() if(NOT _MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES ${_component}.h) endif() @@ -671,6 +724,26 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) continue() endif() + # Find library/plugin includes + if(_component IN_LIST _MAGNUM_LIBRARY_COMPONENTS OR _component IN_LIST _MAGNUM_PLUGIN_COMPONENTS) + find_path(_MAGNUM_${_COMPONENT}_INCLUDE_DIR + NAMES ${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES} + HINTS ${MAGNUM_INCLUDE_DIR}/${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX}) + mark_as_advanced(_MAGNUM_${_COMPONENT}_INCLUDE_DIR) + endif() + + # Decide if the library was found. If not, skip the rest, which + # populates the target properties and finds additional dependencies. + # This means that the rest can also rely on that e.g. FindEGL.cmake is + # present in _MAGNUM_DEPENDENCY_MODULE_DIR -- given that the library + # needing EGL was found, it likely also installed FindEGL for itself. + if(((_component IN_LIST _MAGNUM_LIBRARY_COMPONENTS OR _component IN_LIST _MAGNUM_PLUGIN_COMPONENTS) AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR AND (MAGNUM_${_COMPONENT}_LIBRARY_DEBUG OR MAGNUM_${_COMPONENT}_LIBRARY_RELEASE)) OR (_component IN_LIST _MAGNUM_EXECUTABLE_COMPONENTS AND MAGNUM_${_COMPONENT}_EXECUTABLE)) + set(Magnum_${_component}_FOUND TRUE) + else() + set(Magnum_${_component}_FOUND FALSE) + continue() + endif() + # Library location for libraries/plugins if(_component IN_LIST _MAGNUM_LIBRARY_COMPONENTS OR _component IN_LIST _MAGNUM_PLUGIN_COMPONENTS) if(MAGNUM_${_COMPONENT}_LIBRARY_RELEASE) @@ -690,8 +763,6 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # Applications if(_component MATCHES ".+Application") - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform) - # Android application dependencies if(_component STREQUAL AndroidApplication) find_package(EGL) @@ -854,9 +925,6 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # Context libraries elseif(_component MATCHES ".+Context") - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES GLContext.h) - # GLX context dependencies if(_component STREQUAL GlxContext) # With GLVND (since CMake 3.10) we need to explicitly link to @@ -917,46 +985,23 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) find_package(OpenGLES2 REQUIRED) set_property(TARGET Magnum::${_component} APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenGLES2::OpenGLES2) - elseif(MAGNUM_TARGET_GLES3) + else() find_package(OpenGLES3 REQUIRED) set_property(TARGET Magnum::${_component} APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenGLES3::OpenGLES3) endif() - # MaterialTools library - elseif(_component STREQUAL MaterialTools) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES PhongToPbrMetallicRoughness.h) - - # MeshTools library - elseif(_component STREQUAL MeshTools) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES CompressIndices.h) - - # OpenGLTester library - elseif(_component STREQUAL OpenGLTester) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/GL) - - # VulkanTester library - elseif(_component STREQUAL VulkanTester) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Vk) - - # Primitives library - elseif(_component STREQUAL Primitives) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Cube.h) - + # No special setup for MaterialTools library + # No special setup for MeshTools library + # No special setup for OpenGLTester library + # No special setup for VulkanTester library + # No special setup for Primitives library # No special setup for SceneGraph library - - # SceneTools library - elseif(_component STREQUAL SceneTools) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Hierarchy.h) - + # No special setup for SceneTools library # No special setup for ShaderTools library # No special setup for Shaders library # No special setup for Text library - - # TextureTools library - elseif(_component STREQUAL TextureTools) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Atlas.h) - + # No special setup for TextureTools library # No special setup for Trade library # Vk library @@ -977,14 +1022,6 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # No special setup for TgaImporter plugin # No special setup for WavAudioImporter plugin - # Find library/plugin includes - if(_component IN_LIST _MAGNUM_LIBRARY_COMPONENTS OR _component IN_LIST _MAGNUM_PLUGIN_COMPONENTS) - find_path(_MAGNUM_${_COMPONENT}_INCLUDE_DIR - NAMES ${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES} - HINTS ${MAGNUM_INCLUDE_DIR}/${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX}) - mark_as_advanced(_MAGNUM_${_COMPONENT}_INCLUDE_DIR) - endif() - # Automatic import of static plugins. Skip in case the include dir was # not found -- that'll fail later with a proper message. Skip it also # if the include dir doesn't contain the generated configure.h, which @@ -1026,13 +1063,6 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) list(APPEND _MAGNUM_OPTIONAL_DEPENDENCIES_TO_ADD ${_component}) endif() endif() - - # Decide if the library was found - if(((_component IN_LIST _MAGNUM_LIBRARY_COMPONENTS OR _component IN_LIST _MAGNUM_PLUGIN_COMPONENTS) AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR AND (MAGNUM_${_COMPONENT}_LIBRARY_DEBUG OR MAGNUM_${_COMPONENT}_LIBRARY_RELEASE)) OR (_component IN_LIST _MAGNUM_EXECUTABLE_COMPONENTS AND MAGNUM_${_COMPONENT}_EXECUTABLE)) - set(Magnum_${_component}_FOUND TRUE) - else() - set(Magnum_${_component}_FOUND FALSE) - endif() endif() # Global aliases for Windowless*Application, *Application and *Context @@ -1109,6 +1139,13 @@ if(NOT CMAKE_VERSION VERSION_LESS 3.16) set(_MAGNUM_REASON_FAILURE_MESSAGE REASON_FAILURE_MESSAGE "${_MAGNUM_REASON_FAILURE_MESSAGE}") endif() +# Remove Magnum's dependency module dir from CMAKE_MODULE_PATH again. Do it +# before the FPHSA call which may exit early in case of a failure. +if(_MAGNUM_REMOVE_DEPENDENCY_MODULE_DIR_FROM_CMAKE_PATH) + list(REMOVE_ITEM CMAKE_MODULE_PATH ${_MAGNUM_DEPENDENCY_MODULE_DIR}) + unset(_MAGNUM_REMOVE_DEPENDENCY_MODULE_DIR_FROM_CMAKE_PATH) +endif() + # Complete the check with also all components include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Magnum