diff --git a/modules/FindCorrade.cmake b/modules/FindCorrade.cmake index 44f6271..d7806e0 100644 --- a/modules/FindCorrade.cmake +++ b/modules/FindCorrade.cmake @@ -416,6 +416,8 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) if(TARGET Corrade::${_component}) set(Corrade_${_component}_FOUND TRUE) else() + unset(Corrade_${_component}_FOUND) + # Library (and not 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) @@ -506,25 +508,33 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) elseif(_component STREQUAL PluginManager) # -ldl is handled by Utility now - # TestSuite library has some additional files + # TestSuite library has some additional files. If those are not found, + # set the component _FOUND variable to false so it works properly both + # when the component is required and when it's optional. elseif(_component STREQUAL TestSuite) # XCTest runner file if(CORRADE_TESTSUITE_TARGET_XCTEST) find_file(CORRADE_TESTSUITE_XCTEST_RUNNER XCTestRunner.mm.in PATH_SUFFIXES share/corrade/TestSuite) - set(CORRADE_TESTSUITE_XCTEST_RUNNER_NEEDED CORRADE_TESTSUITE_XCTEST_RUNNER) + if(NOT CORRADE_TESTSUITE_XCTEST_RUNNER) + set(Corrade_${_component}_FOUND FALSE) + endif() # ADB runner file elseif(CORRADE_TARGET_ANDROID) find_file(CORRADE_TESTSUITE_ADB_RUNNER AdbRunner.sh PATH_SUFFIXES share/corrade/TestSuite) - set(CORRADE_TESTSUITE_ADB_RUNNER_NEEDED CORRADE_TESTSUITE_ADB_RUNNER) + if(NOT CORRADE_TESTSUITE_ADB_RUNNER) + set(Corrade_${_component}_FOUND FALSE) + endif() # Emscripten runner file elseif(CORRADE_TARGET_EMSCRIPTEN) find_file(CORRADE_TESTSUITE_EMSCRIPTEN_RUNNER EmscriptenRunner.html.in PATH_SUFFIXES share/corrade/TestSuite) - set(CORRADE_TESTSUITE_EMSCRIPTEN_RUNNER_NEEDED CORRADE_TESTSUITE_EMSCRIPTEN_RUNNER) + if(NOT CORRADE_TESTSUITE_EMSCRIPTEN_RUNNER) + set(Corrade_${_component}_FOUND FALSE) + endif() endif() # Utility library (contains all setup that is used by others) @@ -569,11 +579,14 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) endforeach() endif() - # Decide if the component was 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) + # 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() @@ -616,9 +629,6 @@ find_package_handle_standard_args(Corrade REQUIRED_VARS CORRADE_INCLUDE_DIR _CORRADE_MODULE_DIR _CORRADE_CONFIGURE_FILE - ${CORRADE_TESTSUITE_XCTEST_RUNNER_NEEDED} - ${CORRADE_TESTSUITE_ADB_RUNNER_NEEDED} - ${CORRADE_TESTSUITE_EMSCRIPTEN_RUNNER_NEEDED} HANDLE_COMPONENTS ${_CORRADE_REASON_FAILURE_MESSAGE}) diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 3c29b14..9fdbd6e 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -228,16 +228,26 @@ # Corrade library dependencies set(_MAGNUM_CORRADE_DEPENDENCIES ) -foreach(_component ${Magnum_FIND_COMPONENTS}) - string(TOUPPER ${_component} _COMPONENT) +foreach(_magnum_component ${Magnum_FIND_COMPONENTS}) + set(_MAGNUM_${_magnum_component}_CORRADE_DEPENDENCIES ) # 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|SceneTools|ShaderTools|Text|TextureTools|Trade|.+Importer|.+ImageConverter|.+Font|.+ShaderConverter)$") - set(_MAGNUM_${_COMPONENT}_CORRADE_DEPENDENCIES PluginManager) + if(_magnum_component MATCHES "^(Audio|DebugTools|MeshTools|Primitives|SceneTools|ShaderTools|Text|TextureTools|Trade|.+Importer|.+ImageConverter|.+Font|.+ShaderConverter)$") + list(APPEND _MAGNUM_${_magnum_component}_CORRADE_DEPENDENCIES PluginManager) + endif() + if(_magnum_component STREQUAL DebugTools) + # DebugTools depends on TestSuite optionally, so if it's not there + # assume it wasn't compiled against it. Also, all variables from the + # FindCorrade module overwrite the local variables here (in particular + # _component, _COMPONENT and such), so we need to prefix extensively. + find_package(Corrade QUIET COMPONENTS TestSuite) + if(Corrade_TestSuite_FOUND) + list(APPEND _MAGNUM_${_magnum_component}_CORRADE_DEPENDENCIES TestSuite) + endif() endif() - list(APPEND _MAGNUM_CORRADE_DEPENDENCIES ${_MAGNUM_${_COMPONENT}_CORRADE_DEPENDENCIES}) + list(APPEND _MAGNUM_CORRADE_DEPENDENCIES ${_MAGNUM_${_magnum_component}_CORRADE_DEPENDENCIES}) endforeach() find_package(Corrade REQUIRED Utility ${_MAGNUM_CORRADE_DEPENDENCIES}) @@ -854,7 +864,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) elseif(_component STREQUAL Audio) find_package(OpenAL) set_property(TARGET Magnum::${_component} APPEND PROPERTY - INTERFACE_LINK_LIBRARIES Corrade::PluginManager OpenAL::OpenAL) + INTERFACE_LINK_LIBRARIES OpenAL::OpenAL) # No special setup for DebugTools library @@ -912,26 +922,15 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) elseif(_component STREQUAL SceneTools) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Hierarchy.h) - # ShaderTools library - elseif(_component STREQUAL ShaderTools) - set_property(TARGET Magnum::${_component} APPEND PROPERTY - INTERFACE_LINK_LIBRARIES Corrade::PluginManager) - + # No special setup for ShaderTools library # No special setup for Shaders library - - # Text library - elseif(_component STREQUAL Text) - set_property(TARGET Magnum::${_component} APPEND PROPERTY - INTERFACE_LINK_LIBRARIES Corrade::PluginManager) + # No special setup for Text library # TextureTools library elseif(_component STREQUAL TextureTools) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Atlas.h) - # Trade library - elseif(_component STREQUAL Trade) - set_property(TARGET Magnum::${_component} APPEND PROPERTY - INTERFACE_LINK_LIBRARIES Corrade::PluginManager) + # No special setup for Trade library # Vk library elseif(_component STREQUAL Vk) @@ -980,6 +979,10 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) # are optional dependencies, defer adding them to later once we know if # they were found or not. if(_component IN_LIST _MAGNUM_LIBRARY_COMPONENTS OR _component IN_LIST _MAGNUM_PLUGIN_COMPONENTS) + foreach(_dependency ${_MAGNUM_${_component}_CORRADE_DEPENDENCIES}) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES Corrade::${_dependency}) + endforeach() set_property(TARGET Magnum::${_component} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Magnum::Magnum) set(_MAGNUM_${component}_OPTIONAL_DEPENDENCIES_TO_ADD )