cmake add_custom_command(APPEND) examples

mosra/corrade modules/FindCorrade.cmake :481

            # 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 not a header-only component it's something unknown, skip. FPHSA
        # will take care of handling this below.
        elseif(NOT _component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS)
            continue()
        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
        # creates and populates the target and finds additional dependencies.
        # If found, the _FOUND variable may still get reset by something below.
        if(
            # If the component is a library, it should have the include dir
            (_component IN_LIST _CORRADE_LIBRARY_COMPONENTS AND _CORRADE_${_COMPONENT}_INCLUDE_DIR AND (
                # And it should be either header-only
                _component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS OR
                # Or have a debug library, and a DLL found if expected
                (CORRADE_${_COMPONENT}_LIBRARY_DEBUG AND (
                    NOT DEFINED CORRADE_${_COMPONENT}_DLL_DEBUG OR
                    CORRADE_${_COMPONENT}_DLL_DEBUG)) OR
                # Or have a release library, and a DLL found if expected
                (CORRADE_${_COMPONENT}_LIBRARY_RELEASE AND (
                    NOT DEFINED CORRADE_${_COMPONENT}_DLL_RELEASE OR
                    CORRADE_${_COMPONENT}_DLL_RELEASE)))) OR
            # If the component is an executable, it should have just the
            # location
            (_component IN_LIST _CORRADE_EXECUTABLE_COMPONENTS AND CORRADE_${_COMPONENT}_EXECUTABLE)
        )
            set(Corrade_${_component}_FOUND TRUE)
        else()
            set(Corrade_${_component}_FOUND FALSE)
            continue()
        endif()

        # Target for header-only library components
        if(_component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS)
            add_library(Corrade::${_component} INTERFACE IMPORTED)

        # Target and location for (non-header-only) libraries
        elseif(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS)
            if(CORRADE_BUILD_STATIC OR _component IN_LIST _CORRADE_LIBRARY_COMPONENTS_ALWAYS_STATIC)
                add_library(Corrade::${_component} STATIC IMPORTED)
            else()
                add_library(Corrade::${_component} SHARED IMPORTED)
            endif()

            foreach(_CONFIG DEBUG RELEASE)
                if(NOT CORRADE_${_COMPONENT}_LIBRARY_${_CONFIG})
                    continue()
                endif()

                set_property(TARGET Corrade::${_component} APPEND PROPERTY
                    IMPORTED_CONFIGURATIONS ${_CONFIG})
                # Unfortunately for a DLL the two properties are swapped out,
                # *.lib goes to IMPLIB, so it's duplicated like this
                if(DEFINED CORRADE_${_COMPONENT}_DLL_${_CONFIG})
                    # Quotes to "fix" KDE's higlighter
                    set_target_properties("Corrade::${_component}" PROPERTIES
                        IMPORTED_LOCATION_${_CONFIG} ${CORRADE_${_COMPONENT}_DLL_${_CONFIG}}
                        IMPORTED_IMPLIB_${_CONFIG} ${CORRADE_${_COMPONENT}_LIBRARY_${_CONFIG}})
                else()
                    set_property(TARGET Corrade::${_component} PROPERTY
                        IMPORTED_LOCATION_${_CONFIG} ${CORRADE_${_COMPONENT}_LIBRARY_${_CONFIG}})
                endif()
            endforeach()

        # Target and location for executable components
        elseif(_component IN_LIST _CORRADE_EXECUTABLE_COMPONENTS)
            add_executable(Corrade::${_component} IMPORTED)

            set_property(TARGET Corrade::${_component} PROPERTY
                IMPORTED_LOCATION ${CORRADE_${_COMPONENT}_EXECUTABLE})
        endif()

        # No special setup for Containers library

        # Interconnect library
        if(_component STREQUAL Interconnect)
            # Disable /OPT:ICF on MSVC, which merges functions with identical
            # contents and thus breaks signal comparison. Same case is for
            # clang-cl which uses the MSVC linker by default.
            if(CORRADE_TARGET_WINDOWS AND (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC"))
                if(CMAKE_VERSION VERSION_LESS 3.13)
                    set_property(TARGET Corrade::${_component} PROPERTY
                        INTERFACE_LINK_LIBRARIES "-OPT:NOICF,REF")
                else()
                    set_property(TARGET Corrade::${_component} PROPERTY
                        INTERFACE_LINK_OPTIONS "/OPT:NOICF,REF")
                endif()
            endif()

        # Main library
        elseif(_component STREQUAL Main)
            if(CORRADE_TARGET_WINDOWS)
                if(NOT MINGW)
                    # Abusing INTERFACE_LINK_LIBRARIES because
                    # INTERFACE_LINK_OPTIONS is only since 3.13. They treat
                    # things with `-` in front as linker flags and fortunately
                    # I can use `-ENTRY` instead of `/ENTRY`.
                    # https://gitlab.kitware.com/cmake/cmake/issues/16543
                    set_property(TARGET Corrade::${_component} APPEND PROPERTY
                        INTERFACE_LINK_LIBRARIES "-ENTRY:$<$<NOT:$<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>>:wmainCRTStartup>$<$<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>:wWinMainCRTStartup>")
                else()
                    set_property(TARGET Corrade::${_component} APPEND PROPERTY
                        INTERFACE_LINK_LIBRARIES "-municode")
                endif()
            endif()

        # PluginManager library
        elseif(_component STREQUAL PluginManager)
            # -ldl is handled by Utility now

        # 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)
                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)
                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)
                if(NOT CORRADE_TESTSUITE_EMSCRIPTEN_RUNNER)
                    set(Corrade_${_component}_FOUND FALSE)
                endif()
            endif()

        # Utility library (contains all setup that is used by others)
        elseif(_component STREQUAL Utility)
            # Top-level include directory
            set_property(TARGET Corrade::${_component} APPEND PROPERTY
                INTERFACE_INCLUDE_DIRECTORIES ${CORRADE_INCLUDE_DIR})

            # Require (at least) C++11 for users
            set_property(TARGET Corrade::${_component} PROPERTY
                INTERFACE_CORRADE_CXX_STANDARD 11)
            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
                    INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS})
            endif()
            # AndroidLogStreamBuffer class needs to be linked to log library
            if(CORRADE_TARGET_ANDROID)
                set_property(TARGET Corrade::${_component} APPEND PROPERTY
                    INTERFACE_LINK_LIBRARIES "log")
            endif()
            # Emscripten has various stuff implemented in JS
            if(CORRADE_TARGET_EMSCRIPTEN)
                find_file(CORRADE_UTILITY_JS CorradeUtility.js
                    PATH_SUFFIXES lib)
                set_property(TARGET Corrade::${_component} APPEND PROPERTY
                    # TODO switch to INTERFACE_LINK_OPTIONS and SHELL: once we
                    #   require CMake 3.13 unconditionally
                    INTERFACE_LINK_LIBRARIES "--js-library ${CORRADE_UTILITY_JS}")
            endif()
        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})
                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()
            endforeach()
        endif()
    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 CORRADE_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
    _CORRADE_MODULE_DIR
    _CORRADE_CONFIGURE_FILE
    HANDLE_COMPONENTS
    ${_CORRADE_REASON_FAILURE_MESSAGE})

# Finalize the finding process
include(${CORRADE_USE_MODULE})

set(CORRADE_INCLUDE_INSTALL_DIR include/Corrade)

if(CORRADE_BUILD_DEPRECATED AND CORRADE_INCLUDE_INSTALL_PREFIX AND NOT CORRADE_INCLUDE_INSTALL_PREFIX STREQUAL ".")
    message(DEPRECATION "CORRADE_INCLUDE_INSTALL_PREFIX is obsolete as its primary use was for old Android NDK versions. Please switch to the NDK r19+ layout instead of using this variable and recreate your build directory to get rid of this warning.")
    set(CORRADE_INCLUDE_INSTALL_DIR ${CORRADE_INCLUDE_INSTALL_PREFIX}/${CORRADE_INCLUDE_INSTALL_DIR})
endif()

danmar/cppcheck CMakeLists.txt :37

add_custom_command(OUTPUT validateCFG-cmd APPEND
        COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --noout --relaxng ${CMAKE_SOURCE_DIR}/cfg/cppcheck-cfg.rng ${cfg})

OSGeo/gdal swig/python/CMakeLists.txt :110

add_custom_command(
  OUTPUT ${_file}
  APPEND
  COMMAND ${CMAKE_COMMAND} ${WERROR_DEV_FLAG} "-DFILE=${_file}" -P ${CMAKE_CURRENT_SOURCE_DIR}/modify_cpp_files.cmake)

mosra/magnum modules/FindCorrade.cmake :481

            # 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 not a header-only component it's something unknown, skip. FPHSA
        # will take care of handling this below.
        elseif(NOT _component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS)
            continue()
        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
        # creates and populates the target and finds additional dependencies.
        # If found, the _FOUND variable may still get reset by something below.
        if(
            # If the component is a library, it should have the include dir
            (_component IN_LIST _CORRADE_LIBRARY_COMPONENTS AND _CORRADE_${_COMPONENT}_INCLUDE_DIR AND (
                # And it should be either header-only
                _component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS OR
                # Or have a debug library, and a DLL found if expected
                (CORRADE_${_COMPONENT}_LIBRARY_DEBUG AND (
                    NOT DEFINED CORRADE_${_COMPONENT}_DLL_DEBUG OR
                    CORRADE_${_COMPONENT}_DLL_DEBUG)) OR
                # Or have a release library, and a DLL found if expected
                (CORRADE_${_COMPONENT}_LIBRARY_RELEASE AND (
                    NOT DEFINED CORRADE_${_COMPONENT}_DLL_RELEASE OR
                    CORRADE_${_COMPONENT}_DLL_RELEASE)))) OR
            # If the component is an executable, it should have just the
            # location
            (_component IN_LIST _CORRADE_EXECUTABLE_COMPONENTS AND CORRADE_${_COMPONENT}_EXECUTABLE)
        )
            set(Corrade_${_component}_FOUND TRUE)
        else()
            set(Corrade_${_component}_FOUND FALSE)
            continue()
        endif()

        # Target for header-only library components
        if(_component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS)
            add_library(Corrade::${_component} INTERFACE IMPORTED)

        # Target and location for (non-header-only) libraries
        elseif(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS)
            if(CORRADE_BUILD_STATIC OR _component IN_LIST _CORRADE_LIBRARY_COMPONENTS_ALWAYS_STATIC)
                add_library(Corrade::${_component} STATIC IMPORTED)
            else()
                add_library(Corrade::${_component} SHARED IMPORTED)
            endif()

            foreach(_CONFIG DEBUG RELEASE)
                if(NOT CORRADE_${_COMPONENT}_LIBRARY_${_CONFIG})
                    continue()
                endif()

                set_property(TARGET Corrade::${_component} APPEND PROPERTY
                    IMPORTED_CONFIGURATIONS ${_CONFIG})
                # Unfortunately for a DLL the two properties are swapped out,
                # *.lib goes to IMPLIB, so it's duplicated like this
                if(DEFINED CORRADE_${_COMPONENT}_DLL_${_CONFIG})
                    # Quotes to "fix" KDE's higlighter
                    set_target_properties("Corrade::${_component}" PROPERTIES
                        IMPORTED_LOCATION_${_CONFIG} ${CORRADE_${_COMPONENT}_DLL_${_CONFIG}}
                        IMPORTED_IMPLIB_${_CONFIG} ${CORRADE_${_COMPONENT}_LIBRARY_${_CONFIG}})
                else()
                    set_property(TARGET Corrade::${_component} PROPERTY
                        IMPORTED_LOCATION_${_CONFIG} ${CORRADE_${_COMPONENT}_LIBRARY_${_CONFIG}})
                endif()
            endforeach()

        # Target and location for executable components
        elseif(_component IN_LIST _CORRADE_EXECUTABLE_COMPONENTS)
            add_executable(Corrade::${_component} IMPORTED)

            set_property(TARGET Corrade::${_component} PROPERTY
                IMPORTED_LOCATION ${CORRADE_${_COMPONENT}_EXECUTABLE})
        endif()

        # No special setup for Containers library

        # Interconnect library
        if(_component STREQUAL Interconnect)
            # Disable /OPT:ICF on MSVC, which merges functions with identical
            # contents and thus breaks signal comparison. Same case is for
            # clang-cl which uses the MSVC linker by default.
            if(CORRADE_TARGET_WINDOWS AND (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC"))
                if(CMAKE_VERSION VERSION_LESS 3.13)
                    set_property(TARGET Corrade::${_component} PROPERTY
                        INTERFACE_LINK_LIBRARIES "-OPT:NOICF,REF")
                else()
                    set_property(TARGET Corrade::${_component} PROPERTY
                        INTERFACE_LINK_OPTIONS "/OPT:NOICF,REF")
                endif()
            endif()

        # Main library
        elseif(_component STREQUAL Main)
            if(CORRADE_TARGET_WINDOWS)
                if(NOT MINGW)
                    # Abusing INTERFACE_LINK_LIBRARIES because
                    # INTERFACE_LINK_OPTIONS is only since 3.13. They treat
                    # things with `-` in front as linker flags and fortunately
                    # I can use `-ENTRY` instead of `/ENTRY`.
                    # https://gitlab.kitware.com/cmake/cmake/issues/16543
                    set_property(TARGET Corrade::${_component} APPEND PROPERTY
                        INTERFACE_LINK_LIBRARIES "-ENTRY:$<$<NOT:$<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>>:wmainCRTStartup>$<$<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>:wWinMainCRTStartup>")
                else()
                    set_property(TARGET Corrade::${_component} APPEND PROPERTY
                        INTERFACE_LINK_LIBRARIES "-municode")
                endif()
            endif()

        # PluginManager library
        elseif(_component STREQUAL PluginManager)
            # -ldl is handled by Utility now

        # 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)
                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)
                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)
                if(NOT CORRADE_TESTSUITE_EMSCRIPTEN_RUNNER)
                    set(Corrade_${_component}_FOUND FALSE)
                endif()
            endif()

        # Utility library (contains all setup that is used by others)
        elseif(_component STREQUAL Utility)
            # Top-level include directory
            set_property(TARGET Corrade::${_component} APPEND PROPERTY
                INTERFACE_INCLUDE_DIRECTORIES ${CORRADE_INCLUDE_DIR})

            # Require (at least) C++11 for users
            set_property(TARGET Corrade::${_component} PROPERTY
                INTERFACE_CORRADE_CXX_STANDARD 11)
            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
                    INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS})
            endif()
            # AndroidLogStreamBuffer class needs to be linked to log library
            if(CORRADE_TARGET_ANDROID)
                set_property(TARGET Corrade::${_component} APPEND PROPERTY
                    INTERFACE_LINK_LIBRARIES "log")
            endif()
            # Emscripten has various stuff implemented in JS
            if(CORRADE_TARGET_EMSCRIPTEN)
                find_file(CORRADE_UTILITY_JS CorradeUtility.js
                    PATH_SUFFIXES lib)
                set_property(TARGET Corrade::${_component} APPEND PROPERTY
                    # TODO switch to INTERFACE_LINK_OPTIONS and SHELL: once we
                    #   require CMake 3.13 unconditionally
                    INTERFACE_LINK_LIBRARIES "--js-library ${CORRADE_UTILITY_JS}")
            endif()
        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})
                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()
            endforeach()
        endif()
    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 CORRADE_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
    _CORRADE_MODULE_DIR
    _CORRADE_CONFIGURE_FILE
    HANDLE_COMPONENTS
    ${_CORRADE_REASON_FAILURE_MESSAGE})

# Finalize the finding process
include(${CORRADE_USE_MODULE})

set(CORRADE_INCLUDE_INSTALL_DIR include/Corrade)

if(CORRADE_BUILD_DEPRECATED AND CORRADE_INCLUDE_INSTALL_PREFIX AND NOT CORRADE_INCLUDE_INSTALL_PREFIX STREQUAL ".")
    message(DEPRECATION "CORRADE_INCLUDE_INSTALL_PREFIX is obsolete as its primary use was for old Android NDK versions. Please switch to the NDK r19+ layout instead of using this variable and recreate your build directory to get rid of this warning.")
    set(CORRADE_INCLUDE_INSTALL_DIR ${CORRADE_INCLUDE_INSTALL_PREFIX}/${CORRADE_INCLUDE_INSTALL_DIR})
endif()

YosysHQ/nextpnr cmake/BBAsm.cmake :84

add_custom_command(
    OUTPUT
        ${arg_OUTPUT}
    COMMAND
        ${CMAKE_COMMAND} -E copy
            ${arg_OUTPUT}
            ${EXPORT_BBA_FILES}/${arg_OUTPUT_RELATIVE}
    APPEND
    VERBATIM
)

YosysHQ/nextpnr cmake/BBAsm.cmake :157

add_custom_command(
    OUTPUT
        ${CMAKE_CURRENT_BINARY_DIR}/${arg_OUTPUT_NAME}
    COMMAND
        ${CMAKE_COMMAND} -E make_directory
        ${arg_PRODUCT_DIR}
    COMMAND
        ${CMAKE_COMMAND} -E copy
        ${CMAKE_CURRENT_BINARY_DIR}/${arg_OUTPUT_NAME}
        ${arg_PRODUCT}
    APPEND
    VERBATIM
)