diff --git a/modules/FindCorrade.cmake b/modules/FindCorrade.cmake index 8a5fd6f..1747711 100644 --- a/modules/FindCorrade.cmake +++ b/modules/FindCorrade.cmake @@ -79,7 +79,7 @@ # globals unique even across different shared libraries. Enabled by default # for static builds. # CORRADE_BUILD_MULTITHREADED - Defined if compiled in a way that makes it -# possible to safely use certain Corrade features simultaenously in multiple +# possible to safely use certain Corrade features simultaneously in multiple # threads # CORRADE_TARGET_UNIX - Defined if compiled for some Unix flavor # (Linux, BSD, macOS) @@ -123,15 +123,10 @@ # CORRADE_PEDANTIC_COMPILER_DEFINITIONS - List of pedantic compiler # definitions used for targets with :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS` # enabled -# -# Workflows without :prop_tgt:`IMPORTED` targets are deprecated and the -# following variables are included just for backwards compatibility and only if -# :variable:`CORRADE_BUILD_DEPRECATED` is enabled: -# -# CORRADE_CXX_FLAGS - Pedantic compile flags. Use -# :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS` property or -# :variable:`CORRADE_PEDANTIC_COMPILER_DEFINITIONS` / -# :variable:`CORRADE_PEDANTIC_COMPILER_OPTIONS` list variables instead. +# CORRADE_CXX{11,14,17,20}_STANDARD_FLAG - Compiler flag to use for targeting +# C++11, 14, 17 or 20 in cases where it's not possible to use +# :prop_tgt:`CORRADE_CXX_STANDARD`. Not defined if a standard switch is +# already present in :variable:`CMAKE_CXX_FLAGS`. # # Corrade provides these macros and functions: # @@ -272,7 +267,8 @@ # This file is part of Corrade. # # Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, -# 2017, 2018, 2019, 2020 Vladimír Vondruš +# 2017, 2018, 2019, 2020, 2021 +# 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"), @@ -355,40 +351,47 @@ mark_as_advanced(_CORRADE_MODULE_DIR) set(CORRADE_USE_MODULE ${_CORRADE_MODULE_DIR}/UseCorrade.cmake) set(CORRADE_LIB_SUFFIX_MODULE ${_CORRADE_MODULE_DIR}/CorradeLibSuffix.cmake) +# Component distinction (listing them explicitly to avoid mistakes with finding +# unknown components) +set(_CORRADE_LIBRARY_COMPONENTS + Containers Interconnect Main PluginManager TestSuite Utility) +set(_CORRADE_HEADER_ONLY_COMPONENTS Containers) +if(NOT CORRADE_TARGET_WINDOWS) + # CorradeMain is a real library only on windows, a dummy target elsewhere + list(APPEND _CORRADE_HEADER_ONLY_COMPONENTS Main) +endif() +set(_CORRADE_EXECUTABLE_COMPONENTS rc) +# Currently everything is enabled implicitly. Keep in sync with Corrade's root +# CMakeLists.txt. +set(_CORRADE_IMPLICITLY_ENABLED_COMPONENTS + Containers Interconnect Main PluginManager TestSuite Utility rc) + +# Inter-component dependencies +set(_CORRADE_Containers_DEPENDENCIES Utility) +set(_CORRADE_Interconnect_DEPENDENCIES Containers Utility) +set(_CORRADE_PluginManager_DEPENDENCIES Containers Utility rc) +set(_CORRADE_TestSuite_DEPENDENCIES Containers Utility Main) # see below +set(_CORRADE_Utility_DEPENDENCIES Containers rc) + # Ensure that all inter-component dependencies are specified as well foreach(_component ${Corrade_FIND_COMPONENTS}) - string(TOUPPER ${_component} _COMPONENT) - - if(_component STREQUAL Containers) - set(_CORRADE_${_COMPONENT}_DEPENDENCIES Utility) - elseif(_component STREQUAL Interconnect) - set(_CORRADE_${_COMPONENT}_DEPENDENCIES Utility) - elseif(_component STREQUAL PluginManager) - set(_CORRADE_${_COMPONENT}_DEPENDENCIES Containers Utility rc) - elseif(_component STREQUAL TestSuite) - set(_CORRADE_${_COMPONENT}_DEPENDENCIES Utility Main) # see below - elseif(_component STREQUAL Utility) - set(_CORRADE_${_COMPONENT}_DEPENDENCIES Containers rc) - endif() - # Mark the dependencies as required if the component is also required if(Corrade_FIND_REQUIRED_${_component}) - foreach(_dependency ${_CORRADE_${_COMPONENT}_DEPENDENCIES}) + foreach(_dependency ${_CORRADE_${_component}_DEPENDENCIES}) set(Corrade_FIND_REQUIRED_${_dependency} TRUE) endforeach() endif() - list(APPEND _CORRADE_ADDITIONAL_COMPONENTS ${_CORRADE_${_COMPONENT}_DEPENDENCIES}) - - # Main is linked only in corrade_add_test(), not to everything that depends - # on TestSuite, so remove it from the list again once we filled the above - # variables - if(_component STREQUAL TestSuite) - set(_CORRADE_${_COMPONENT}_DEPENDENCIES Utility) - endif() + list(APPEND _CORRADE_ADDITIONAL_COMPONENTS ${_CORRADE_${_component}_DEPENDENCIES}) endforeach() +# Main is linked only in corrade_add_test(), not to everything that depends on +# TestSuite, so remove it from the list again once we filled the above +# variables +set(_CORRADE_TestSuite_DEPENDENCIES Containers Utility) + # Join the lists, remove duplicate components +set(_CORRADE_ORIGINAL_FIND_COMPONENTS ${Corrade_FIND_COMPONENTS}) if(_CORRADE_ADDITIONAL_COMPONENTS) list(INSERT Corrade_FIND_COMPONENTS 0 ${_CORRADE_ADDITIONAL_COMPONENTS}) endif() @@ -396,16 +399,6 @@ if(Corrade_FIND_COMPONENTS) list(REMOVE_DUPLICATES Corrade_FIND_COMPONENTS) endif() -# Component distinction -set(_CORRADE_LIBRARY_COMPONENTS "^(Containers|Interconnect|Main|PluginManager|TestSuite|Utility)$") -if(CORRADE_TARGET_WINDOWS) - # CorradeMain is a real library only on windows, a dummy target elsewhere - set(_CORRADE_HEADER_ONLY_COMPONENTS "^(Containers)$") -else() - set(_CORRADE_HEADER_ONLY_COMPONENTS "^(Containers|Main)$") -endif() -set(_CORRADE_EXECUTABLE_COMPONENTS "^(rc)$") - # Find all components foreach(_component ${Corrade_FIND_COMPONENTS}) string(TOUPPER ${_component} _COMPONENT) @@ -417,7 +410,7 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) set(Corrade_${_component}_FOUND TRUE) else() # Library (and not header-only) components - if(_component MATCHES ${_CORRADE_LIBRARY_COMPONENTS} AND NOT _component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS}) + if(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS AND NOT _component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS) add_library(Corrade::${_component} UNKNOWN IMPORTED) # Try to find both debug and release version @@ -442,19 +435,19 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) endif() # Header-only library components - if(_component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS}) + if(_component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS) add_library(Corrade::${_component} INTERFACE IMPORTED) endif() # Default include path names to look for for library / header-only # components - if(_component MATCHES ${_CORRADE_LIBRARY_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 MATCHES ${_CORRADE_EXECUTABLE_COMPONENTS}) + if(_component IN_LIST _CORRADE_EXECUTABLE_COMPONENTS) add_executable(Corrade::${_component} IMPORTED) find_program(CORRADE_${_COMPONENT}_EXECUTABLE corrade-${_component}) @@ -552,7 +545,7 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) endif() # Find library includes - if(_component MATCHES ${_CORRADE_LIBRARY_COMPONENTS}) + 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}) @@ -560,9 +553,9 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) endif() # Add inter-library dependencies - if(_component MATCHES ${_CORRADE_LIBRARY_COMPONENTS} OR _component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS}) - foreach(_dependency ${_CORRADE_${_COMPONENT}_DEPENDENCIES}) - if(_dependency MATCHES ${_CORRADE_LIBRARY_COMPONENTS} OR _dependency MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS}) + if(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS OR _component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS) + foreach(_dependency ${_CORRADE_${_component}_DEPENDENCIES}) + if(_dependency IN_LIST _CORRADE_LIBRARY_COMPONENTS OR _dependency IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS) set_property(TARGET Corrade::${_component} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Corrade::${_dependency}) endif() @@ -570,7 +563,7 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) endif() # Decide if the component was found - if((_component MATCHES ${_CORRADE_LIBRARY_COMPONENTS} AND _CORRADE_${_COMPONENT}_INCLUDE_DIR AND (_component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS} OR CORRADE_${_COMPONENT}_LIBRARY_RELEASE OR CORRADE_${_COMPONENT}_LIBRARY_DEBUG)) OR (_component MATCHES ${_CORRADE_EXECUTABLE_COMPONENTS} AND CORRADE_${_COMPONENT}_EXECUTABLE)) + 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) @@ -578,6 +571,39 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) endif() endforeach() +# For CMake 3.16+ with REASON_FAILURE_MESSAGE, provide additional potentially +# useful info about the failed components. +if(NOT CMAKE_VERSION VERSION_LESS 3.16) + set(_CORRADE_REASON_FAILURE_MESSAGE ) + # Go only through the originally specified find_package() components, not + # the dependencies added by us afterwards + foreach(_component ${_CORRADE_ORIGINAL_FIND_COMPONENTS}) + if(Corrade_${_component}_FOUND) + continue() + endif() + + # If it's not known at all, tell the user -- it might be a new library + # and an old Find module, or something platform-specific. + if(NOT _component IN_LIST _CORRADE_LIBRARY_COMPONENTS AND NOT _component IN_LIST _CORRADE_EXECUTABLE_COMPONENTS) + list(APPEND _CORRADE_REASON_FAILURE_MESSAGE "${_component} is not a known component on this platform.") + # Otherwise, if it's not among implicitly built components, hint that + # the user may need to enable it. + # TODO: currently, the _FOUND variable doesn't reflect if dependencies + # were found. When it will, this needs to be updated to avoid + # misleading messages. + elseif(NOT _component IN_LIST _CORRADE_IMPLICITLY_ENABLED_COMPONENTS) + string(TOUPPER ${_component} _COMPONENT) + list(APPEND _CORRADE_REASON_FAILURE_MESSAGE "${_component} is not built by default. Make sure you enabled WITH_${_COMPONENT} when building Corrade.") + # Otherwise we have no idea. Better be silent than to print something + # misleading. + else() + endif() + endforeach() + + string(REPLACE ";" " " _CORRADE_REASON_FAILURE_MESSAGE "${_CORRADE_REASON_FAILURE_MESSAGE}") + set(_CORRADE_REASON_FAILURE_MESSAGE REASON_FAILURE_MESSAGE "${_CORRADE_REASON_FAILURE_MESSAGE}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Corrade REQUIRED_VARS CORRADE_INCLUDE_DIR @@ -586,7 +612,8 @@ find_package_handle_standard_args(Corrade REQUIRED_VARS ${CORRADE_TESTSUITE_XCTEST_RUNNER_NEEDED} ${CORRADE_TESTSUITE_ADB_RUNNER_NEEDED} ${CORRADE_TESTSUITE_EMSCRIPTEN_RUNNER_NEEDED} - HANDLE_COMPONENTS) + HANDLE_COMPONENTS + ${_CORRADE_REASON_FAILURE_MESSAGE}) # Finalize the finding process include(${CORRADE_USE_MODULE}) diff --git a/modules/FindEGL.cmake b/modules/FindEGL.cmake index cc4210e..82409c2 100644 --- a/modules/FindEGL.cmake +++ b/modules/FindEGL.cmake @@ -17,7 +17,7 @@ # This file is part of Magnum. # # Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, -# 2020 Vladimír Vondruš +# 2020, 2021 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"), diff --git a/modules/FindGLFW.cmake b/modules/FindGLFW.cmake index 3d7d99b..3017f18 100644 --- a/modules/FindGLFW.cmake +++ b/modules/FindGLFW.cmake @@ -21,7 +21,7 @@ # This file is part of Magnum. # # Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, -# 2020 Vladimír Vondruš +# 2020, 2021 Vladimír Vondruš # Copyright © 2016 Jonathan Hale # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 8761448..a05edf0 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -64,6 +64,7 @@ # Primitives - Primitives library # SceneGraph - SceneGraph library # Shaders - Shaders library +# ShaderTools - ShaderTools library # Text - Text library # TextureTools - TextureTools library # Trade - Trade library @@ -85,6 +86,7 @@ # GlxContext - GLX context # WglContext - WGL context # OpenGLTester - OpenGLTester class +# VulkanTester - VulkanTester class # MagnumFont - Magnum bitmap font plugin # MagnumFontConverter - Magnum bitmap font converter plugin # ObjImporter - OBJ importer plugin @@ -95,7 +97,9 @@ # fontconverter - magnum-fontconverter executable # imageconverter - magnum-imageconverter executable # sceneconverterter - magnum-sceneconverter executable +# shaderconverterter - magnum-shaderconverter executable # gl-info - magnum-gl-info executable +# vk-info - magnum-vk-info executable # al-info - magnum-al-info executable # # Example usage with specifying additional components is:: @@ -164,6 +168,10 @@ # installation directory # MAGNUM_PLUGINS_[DEBUG|RELEASE]_LIBRARY_INSTALL_DIR - Plugin library # installation directory +# MAGNUM_PLUGINS_SHADERCONVERTER_[DEBUG|RELEASE]_BINARY_INSTALL_DIR - Shader +# converter plugin binary installation directory +# MAGNUM_PLUGINS_SHADERCONVERTER_[DEBUG|RELEASE]_LIBRARY_INSTALL_DIR - Shader +# converter plugin library installation directory # MAGNUM_PLUGINS_FONT_[DEBUG|RELEASE]_BINARY_INSTALL_DIR - Font plugin binary # installation directory # MAGNUM_PLUGINS_FONT_[DEBUG|RELEASE]_LIBRARY_INSTALL_DIR - Font plugin @@ -196,7 +204,7 @@ # This file is part of Magnum. # # Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, -# 2020 Vladimír Vondruš +# 2020, 2021 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"), @@ -224,7 +232,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # Unrolling the transitive dependencies here so this doesn't need to be # after resolving inter-component dependencies. Listing also all plugins. - if(_component MATCHES "^(Audio|DebugTools|MeshTools|Primitives|Text|TextureTools|Trade|.+Importer|.+ImageConverter|.+Font)$") + if(_component MATCHES "^(Audio|DebugTools|MeshTools|Primitives|ShaderTools|Text|TextureTools|Trade|.+Importer|.+ImageConverter|.+Font|.+ShaderConverter)$") set(_MAGNUM_${_COMPONENT}_CORRADE_DEPENDENCIES PluginManager) endif() @@ -338,12 +346,6 @@ if(NOT TARGET Magnum::Magnum) # Include directories set_property(TARGET Magnum::Magnum APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MAGNUM_INCLUDE_DIR}) - # Some deprecated APIs use headers (but not externally defined symbols) - # from the GL library, link those includes as well - if(MAGNUM_BUILD_DEPRECATED AND MAGNUM_TARGET_GL) - set_property(TARGET Magnum::Magnum APPEND PROPERTY - INTERFACE_INCLUDE_DIRECTORIES ${MAGNUM_INCLUDE_DIR}/MagnumExternal/OpenGL) - endif() # Dependent libraries set_property(TARGET Magnum::Magnum APPEND PROPERTY INTERFACE_LINK_LIBRARIES @@ -354,22 +356,53 @@ endif() # Component distinction (listing them explicitly to avoid mistakes with finding # components from other repositories) -set(_MAGNUM_LIBRARY_COMPONENT_LIST - Audio DebugTools GL MeshTools Primitives SceneGraph Shaders Text - TextureTools Trade Vk - AndroidApplication EmscriptenApplication GlfwApplication GlxApplication - Sdl2Application XEglApplication WindowlessCglApplication - WindowlessEglApplication WindowlessGlxApplication WindowlessIosApplication - WindowlessWglApplication WindowlessWindowsEglApplication - CglContext EglContext GlxContext WglContext - OpenGLTester) -set(_MAGNUM_PLUGIN_COMPONENT_LIST +set(_MAGNUM_LIBRARY_COMPONENTS + Audio DebugTools GL MeshTools Primitives SceneGraph Shaders ShaderTools + Text TextureTools Trade + WindowlessEglApplication EglContext OpenGLTester) +set(_MAGNUM_PLUGIN_COMPONENTS AnyAudioImporter AnyImageConverter AnyImageImporter AnySceneConverter AnySceneImporter MagnumFont MagnumFontConverter ObjImporter TgaImageConverter TgaImporter WavAudioImporter) -set(_MAGNUM_EXECUTABLE_COMPONENT_LIST - distancefieldconverter fontconverter imageconverter sceneconverter gl-info - al-info) +set(_MAGNUM_EXECUTABLE_COMPONENTS + imageconverter sceneconverter shaderconverter gl-info al-info) +# Audio and Vk libs aren't enabled by default, and none of the Context, +# Application, Tester libs nor plugins are. Keep in sync with Magnum's root +# CMakeLists.txt. +set(_MAGNUM_IMPLICITLY_ENABLED_COMPONENTS + DebugTools MeshTools SceneGraph Shaders ShaderTools Text TextureTools Trade + GL Primitives) +if(NOT CORRADE_TARGET_EMSCRIPTEN) + list(APPEND _MAGNUM_LIBRARY_COMPONENTS Vk VulkanTester) + list(APPEND _MAGNUM_EXECUTABLE_COMPONENTS vk-info) +endif() +if(NOT CORRADE_TARGET_ANDROID) + list(APPEND _MAGNUM_LIBRARY_COMPONENTS Sdl2Application) +endif() +if(NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_EMSCRIPTEN) + list(APPEND _MAGNUM_LIBRARY_COMPONENTS GlfwApplication) +endif() +if(CORRADE_TARGET_ANDROID) + list(APPEND _MAGNUM_LIBRARY_COMPONENTS AndroidApplication) +endif() +if(CORRADE_TARGET_EMSCRIPTEN) + list(APPEND _MAGNUM_LIBRARY_COMPONENTS EmscriptenApplication) +endif() +if(CORRADE_TARGET_IOS) + list(APPEND _MAGNUM_LIBRARY_COMPONENTS WindowlessIosApplication) +endif() +if(CORRADE_TARGET_APPLE AND NOT CORRADE_TARGET_IOS) + list(APPEND _MAGNUM_LIBRARY_COMPONENTS WindowlessCglApplication CglContext) +endif() +if(CORRADE_TARGET_UNIX AND NOT CORRADE_TARGET_APPLE) + list(APPEND _MAGNUM_LIBRARY_COMPONENTS GlxApplication XEglApplication WindowlessGlxApplication GlxContext) +endif() +if(CORRADE_TARGET_WINDOWS) + list(APPEND _MAGNUM_LIBRARY_COMPONENTS WindowlessWglApplication WglContext WindowlessWindowsEglApplication) +endif() +if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_WINDOWS) + list(APPEND _MAGNUM_EXECUTABLE_COMPONENTS fontconverter distancefieldconverter) +endif() # Inter-component dependencies set(_MAGNUM_Audio_DEPENDENCIES ) @@ -434,6 +467,7 @@ if(MAGNUM_TARGET_GL) endif() set(_MAGNUM_Trade_DEPENDENCIES ) +set(_MAGNUM_VulkanTester_DEPENDENCIES Vk) set(_MAGNUM_AndroidApplication_DEPENDENCIES GL) set(_MAGNUM_EmscriptenApplication_DEPENDENCIES) if(MAGNUM_TARGET_GL) @@ -467,9 +501,11 @@ set(_MAGNUM_WglContext_DEPENDENCIES GL) set(_MAGNUM_MagnumFont_DEPENDENCIES Trade TgaImporter GL) # and below set(_MAGNUM_MagnumFontConverter_DEPENDENCIES Trade TgaImageConverter) # and below set(_MAGNUM_ObjImporter_DEPENDENCIES MeshTools) # and below -foreach(_component ${_MAGNUM_PLUGIN_COMPONENT_LIST}) +foreach(_component ${_MAGNUM_PLUGIN_COMPONENTS}) if(_component MATCHES ".+AudioImporter") list(APPEND _MAGNUM_${_component}_DEPENDENCIES Audio) + elseif(_component MATCHES ".+ShaderConverter") + list(APPEND _MAGNUM_${_component}_DEPENDENCIES ShaderTools) elseif(_component MATCHES ".+(Importer|ImageConverter|SceneConverter)") list(APPEND _MAGNUM_${_component}_DEPENDENCIES Trade) elseif(_component MATCHES ".+(Font|FontConverter)") @@ -495,6 +531,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) endforeach() # Join the lists, remove duplicate components +set(_MAGNUM_ORIGINAL_FIND_COMPONENTS ${Magnum_FIND_COMPONENTS}) if(_MAGNUM_ADDITIONAL_COMPONENTS) list(INSERT Magnum_FIND_COMPONENTS 0 ${_MAGNUM_ADDITIONAL_COMPONENTS}) endif() @@ -502,13 +539,6 @@ if(Magnum_FIND_COMPONENTS) list(REMOVE_DUPLICATES Magnum_FIND_COMPONENTS) endif() -# Convert components lists to regular expressions so I can use if(MATCHES). -# TODO: Drop this once CMake 3.3 and if(IN_LIST) can be used -foreach(_WHAT LIBRARY PLUGIN EXECUTABLE) - string(REPLACE ";" "|" _MAGNUM_${_WHAT}_COMPONENTS "${_MAGNUM_${_WHAT}_COMPONENT_LIST}") - set(_MAGNUM_${_WHAT}_COMPONENTS "^(${_MAGNUM_${_WHAT}_COMPONENTS})$") -endforeach() - # Find all components. Maintain a list of components that'll need to have # their optional dependencies checked. set(_MAGNUM_OPTIONAL_DEPENDENCIES_TO_ADD ) @@ -522,7 +552,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) set(Magnum_${_component}_FOUND TRUE) else() # Library components - if(_component MATCHES ${_MAGNUM_LIBRARY_COMPONENTS}) + if(_component IN_LIST _MAGNUM_LIBRARY_COMPONENTS) add_library(Magnum::${_component} UNKNOWN IMPORTED) # Set library defaults, find the library @@ -534,10 +564,9 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) find_library(MAGNUM_${_COMPONENT}_LIBRARY_RELEASE Magnum${_component}) mark_as_advanced(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG MAGNUM_${_COMPONENT}_LIBRARY_RELEASE) - endif() # Plugin components - if(_component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS}) + elseif(_component IN_LIST _MAGNUM_PLUGIN_COMPONENTS) add_library(Magnum::${_component} UNKNOWN IMPORTED) # AudioImporter plugin specific name suffixes @@ -549,6 +578,10 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) string(REPLACE "AudioImporter" "Importer" _MAGNUM_${_COMPONENT}_HEADER_NAME "${_component}") set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES ${_MAGNUM_${_COMPONENT}_HEADER_NAME}.h) + # ShaderConverter plugin specific name suffixes + elseif(_component MATCHES ".+ShaderConverter$") + set(_MAGNUM_${_COMPONENT}_PATH_SUFFIX shaderconverters) + # Importer plugin specific name suffixes elseif(_component MATCHES ".+Importer$") set(_MAGNUM_${_COMPONENT}_PATH_SUFFIX importers) @@ -601,10 +634,26 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # Reset back set(CMAKE_FIND_LIBRARY_PREFIXES "${_tmp_prefixes}") + + # Executables + elseif(_component IN_LIST _MAGNUM_EXECUTABLE_COMPONENTS) + add_executable(Magnum::${_component} IMPORTED) + + find_program(MAGNUM_${_COMPONENT}_EXECUTABLE magnum-${_component}) + mark_as_advanced(MAGNUM_${_COMPONENT}_EXECUTABLE) + + if(MAGNUM_${_COMPONENT}_EXECUTABLE) + set_property(TARGET Magnum::${_component} PROPERTY + IMPORTED_LOCATION ${MAGNUM_${_COMPONENT}_EXECUTABLE}) + endif() + + # Something unknown, skip. FPHSA will take care of handling this below. + else() + continue() endif() # Library location for libraries/plugins - if(_component MATCHES ${_MAGNUM_LIBRARY_COMPONENTS} OR _component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS}) + if(_component IN_LIST _MAGNUM_LIBRARY_COMPONENTS OR _component IN_LIST _MAGNUM_PLUGIN_COMPONENTS) if(MAGNUM_${_COMPONENT}_LIBRARY_RELEASE) set_property(TARGET Magnum::${_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) @@ -620,19 +669,6 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) endif() endif() - # Executables - if(_component MATCHES ${_MAGNUM_EXECUTABLE_COMPONENTS}) - add_executable(Magnum::${_component} IMPORTED) - - find_program(MAGNUM_${_COMPONENT}_EXECUTABLE magnum-${_component}) - mark_as_advanced(MAGNUM_${_COMPONENT}_EXECUTABLE) - - if(MAGNUM_${_COMPONENT}_EXECUTABLE) - set_property(TARGET Magnum::${_component} PROPERTY - IMPORTED_LOCATION ${MAGNUM_${_COMPONENT}_EXECUTABLE}) - endif() - endif() - # Applications if(_component MATCHES ".+Application") set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform) @@ -857,11 +893,21 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) 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 SceneGraph library + + # ShaderTools library + elseif(_component STREQUAL ShaderTools) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES Corrade::PluginManager) + # No special setup for Shaders library # Text library @@ -880,7 +926,6 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # Vk library elseif(_component STREQUAL Vk) - set(Vulkan_INCLUDE_DIR ${MAGNUM_INCLUDE_DIR}/MagnumExternal/Vulkan) find_package(Vulkan REQUIRED) set_property(TARGET Magnum::${_component} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Vulkan::Vulkan) @@ -898,7 +943,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # No special setup for WavAudioImporter plugin # Find library/plugin includes - if(_component MATCHES ${_MAGNUM_LIBRARY_COMPONENTS} OR _component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS}) + 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}) @@ -907,7 +952,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # Automatic import of static plugins. Skip in case the include dir was # not found -- that'll fail later with a proper message. - if(_component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS} AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR) + if(_component IN_LIST _MAGNUM_PLUGIN_COMPONENTS AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR) # Automatic import of static plugins file(READ ${_MAGNUM_${_COMPONENT}_INCLUDE_DIR}/configure.h _magnum${_component}Configure) string(FIND "${_magnum${_component}Configure}" "#define MAGNUM_${_COMPONENT}_BUILD_STATIC" _magnum${_component}_BUILD_STATIC) @@ -920,7 +965,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # Link to core Magnum library, add inter-library dependencies. If there # are optional dependencies, defer adding them to later once we know if # they were found or not. - if(_component MATCHES ${_MAGNUM_LIBRARY_COMPONENTS} OR _component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS}) + if(_component IN_LIST _MAGNUM_LIBRARY_COMPONENTS OR _component IN_LIST _MAGNUM_PLUGIN_COMPONENTS) set_property(TARGET Magnum::${_component} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Magnum::Magnum) set(_MAGNUM_${component}_OPTIONAL_DEPENDENCIES_TO_ADD ) @@ -939,7 +984,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) endif() # Decide if the library was found - if(((_component MATCHES ${_MAGNUM_LIBRARY_COMPONENTS} OR _component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS}) AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR AND (MAGNUM_${_COMPONENT}_LIBRARY_DEBUG OR MAGNUM_${_COMPONENT}_LIBRARY_RELEASE)) OR (_component MATCHES ${_MAGNUM_EXECUTABLE_COMPONENTS} AND MAGNUM_${_COMPONENT}_EXECUTABLE)) + 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) @@ -1001,11 +1046,45 @@ if(CORRADE_TARGET_EMSCRIPTEN) endif() endif() +# For CMake 3.16+ with REASON_FAILURE_MESSAGE, provide additional potentially +# useful info about the failed components. +if(NOT CMAKE_VERSION VERSION_LESS 3.16) + set(_MAGNUM_REASON_FAILURE_MESSAGE ) + # Go only through the originally specified find_package() components, not + # the dependencies added by us afterwards + foreach(_component ${_MAGNUM_ORIGINAL_FIND_COMPONENTS}) + if(Magnum_${_component}_FOUND) + continue() + endif() + + # If it's not known at all, tell the user -- it might be a new library + # and an old Find module, or something platform-specific. + if(NOT _component IN_LIST _MAGNUM_LIBRARY_COMPONENTS AND NOT _component IN_LIST _MAGNUM_PLUGIN_COMPONENTS AND NOT _component IN_LIST _MAGNUM_EXECUTABLE_COMPONENTS) + list(APPEND _MAGNUM_REASON_FAILURE_MESSAGE "${_component} is not a known component on this platform.") + # Otherwise, if it's not among implicitly built components, hint that + # the user may need to enable it + # TODO: currently, the _FOUND variable doesn't reflect if dependencies + # were found. When it will, this needs to be updated to avoid + # misleading messages. + elseif(NOT _component IN_LIST _MAGNUM_IMPLICITLY_ENABLED_COMPONENTS) + string(TOUPPER ${_component} _COMPONENT) + list(APPEND _MAGNUM_REASON_FAILURE_MESSAGE "${_component} is not built by default. Make sure you enabled WITH_${_COMPONENT} when building Magnum.") + # Otherwise we have no idea. Better be silent than to print something + # misleading. + else() + endif() + endforeach() + + string(REPLACE ";" " " _MAGNUM_REASON_FAILURE_MESSAGE "${_MAGNUM_REASON_FAILURE_MESSAGE}") + set(_MAGNUM_REASON_FAILURE_MESSAGE REASON_FAILURE_MESSAGE "${_MAGNUM_REASON_FAILURE_MESSAGE}") +endif() + # Complete the check with also all components include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Magnum REQUIRED_VARS MAGNUM_INCLUDE_DIR MAGNUM_LIBRARY ${MAGNUM_EXTRAS_NEEDED} - HANDLE_COMPONENTS) + HANDLE_COMPONENTS + ${_MAGNUM_REASON_FAILURE_MESSAGE}) # Components with optional dependencies -- add them once we know if they were # found or not. @@ -1117,6 +1196,10 @@ set(MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_BINARY_INSTALL_DIR}/magnum- set(MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_LIBRARY_INSTALL_DIR}/magnum-d) set(MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_BINARY_INSTALL_DIR}/magnum) set(MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_LIBRARY_INSTALL_DIR}/magnum) +set(MAGNUM_PLUGINS_SHADERCONVERTER_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/shaderconverters) +set(MAGNUM_PLUGINS_SHADERCONVERTER_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR}/shaderconverters) +set(MAGNUM_PLUGINS_SHADERCONVERTER_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/shaderconverters) +set(MAGNUM_PLUGINS_SHADERCONVERTER_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR}/shaderconverters) set(MAGNUM_PLUGINS_FONT_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/fonts) set(MAGNUM_PLUGINS_FONT_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR}/fonts) set(MAGNUM_PLUGINS_FONT_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR}/fonts) diff --git a/modules/FindOpenGLES2.cmake b/modules/FindOpenGLES2.cmake index b629449..aae0050 100644 --- a/modules/FindOpenGLES2.cmake +++ b/modules/FindOpenGLES2.cmake @@ -20,7 +20,7 @@ # This file is part of Magnum. # # Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, -# 2020 Vladimír Vondruš +# 2020, 2021 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"), diff --git a/modules/FindOpenGLES3.cmake b/modules/FindOpenGLES3.cmake index 38a1bff..65cf2e1 100644 --- a/modules/FindOpenGLES3.cmake +++ b/modules/FindOpenGLES3.cmake @@ -20,7 +20,7 @@ # This file is part of Magnum. # # Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, -# 2020 Vladimír Vondruš +# 2020, 2021 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"), diff --git a/modules/FindSDL2.cmake b/modules/FindSDL2.cmake index c7e3527..6222588 100644 --- a/modules/FindSDL2.cmake +++ b/modules/FindSDL2.cmake @@ -20,7 +20,7 @@ # This file is part of Magnum. # # Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, -# 2020 Vladimír Vondruš +# 2020, 2021 Vladimír Vondruš # Copyright © 2018 Jonathan Hale # # Permission is hereby granted, free of charge, to any person obtaining a @@ -118,7 +118,7 @@ if(CORRADE_TARGET_WINDOWS) endif() # (Static) macOS / iOS dependencies -if(CORRADE_TARGET_APPLE AND SDL2_LIBRARY MATCHES ".*libSDL2.a$") +if(CORRADE_TARGET_APPLE AND SDL2_LIBRARY MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$") if(CORRADE_TARGET_IOS) set(_SDL2_FRAMEWORKS AudioToolbox