Vendor Magnum and Corrade sources
This commit is contained in:
+46
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# This file is part of Corrade.
|
||||
#
|
||||
# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
|
||||
# 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026
|
||||
# Vladimír Vondruš <mosra@centrum.cz>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
set(Corrade_MODULES
|
||||
CorradeConfig.cmake
|
||||
CorradeLibSuffix.cmake
|
||||
FindCorrade.cmake
|
||||
UseCorrade.cmake)
|
||||
|
||||
set(Corrade_DEPENDENCY_MODULES )
|
||||
if(CORRADE_TARGET_EMSCRIPTEN)
|
||||
list(APPEND Corrade_DEPENDENCY_MODULES
|
||||
FindNodeJs.cmake)
|
||||
endif()
|
||||
|
||||
install(FILES ${Corrade_MODULES} DESTINATION ${CORRADE_CMAKE_MODULE_INSTALL_DIR})
|
||||
if(Corrade_DEPENDENCY_MODULES)
|
||||
install(FILES ${Corrade_DEPENDENCY_MODULES} DESTINATION ${CORRADE_CMAKE_MODULE_INSTALL_DIR}/dependencies)
|
||||
endif()
|
||||
|
||||
# Corrade module dirs for superprojects
|
||||
set(_CORRADE_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
|
||||
set(CORRADE_DEPENDENCY_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# This file is part of Corrade.
|
||||
#
|
||||
# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
|
||||
# 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026
|
||||
# Vladimír Vondruš <mosra@centrum.cz>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/FindCorrade.cmake)
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
# (the blank line is here so CMake doesn't generate documentation from it)
|
||||
|
||||
#
|
||||
# This file is part of Corrade.
|
||||
#
|
||||
# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
|
||||
# 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026
|
||||
# Vladimír Vondruš <mosra@centrum.cz>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
if(NOT DEFINED LIB_SUFFIX)
|
||||
# Android. Given a CMAKE_INSTALL_PREFIX, check if the expected lib
|
||||
# subdirectory exists. If it does, we assume CMAKE_INSTALL_PREFIX is
|
||||
# pointing inside the NDK and so we set LIB_SUFFIX accordingly. If it
|
||||
# doesn't, we don't attempt any desktop-system-like lib64 detection, as
|
||||
# that is irrelevant for Android.
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Android)
|
||||
if(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_ANDROID_ARCH_TRIPLE}/${CMAKE_SYSTEM_VERSION}")
|
||||
set(LIB_SUFFIX "/${CMAKE_ANDROID_ARCH_TRIPLE}/${CMAKE_SYSTEM_VERSION}")
|
||||
else()
|
||||
set(LIB_SUFFIX "")
|
||||
endif()
|
||||
|
||||
# All 32bit systems and OSX have empty lib suffix, decide based on
|
||||
# FIND_LIBRARY_USE_LIB64_PATHS on other 64bit systems
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT APPLE)
|
||||
# CMake might be right most of the time, but if /usr/lib64 is symlink
|
||||
# to somewhere else, it means that we should *really* not install there
|
||||
# (that's the case with ArchLinux)
|
||||
get_property(LIB_SUFFIX GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
|
||||
if(LIB_SUFFIX AND NOT IS_SYMLINK /usr/lib64)
|
||||
set(LIB_SUFFIX "64")
|
||||
else()
|
||||
set(LIB_SUFFIX "")
|
||||
endif()
|
||||
else()
|
||||
set(LIB_SUFFIX "")
|
||||
endif()
|
||||
|
||||
# Put the value into cache
|
||||
set(LIB_SUFFIX "${LIB_SUFFIX}" CACHE STRING "Library directory suffix (e.g. 64 for /usr/lib64).")
|
||||
|
||||
message(STATUS "LIB_SUFFIX autodetected as '${LIB_SUFFIX}', libraries will be installed into ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
|
||||
endif()
|
||||
+812
@@ -0,0 +1,812 @@
|
||||
#.rst:
|
||||
# Find Corrade
|
||||
# ------------
|
||||
#
|
||||
# Finds the Corrade library. Basic usage::
|
||||
#
|
||||
# find_package(Corrade REQUIRED)
|
||||
#
|
||||
# This module tries to find the base Corrade library and then defines the
|
||||
# following:
|
||||
#
|
||||
# Corrade_FOUND - Whether the base library was found
|
||||
# CORRADE_LIB_SUFFIX_MODULE - Path to CorradeLibSuffix.cmake module
|
||||
#
|
||||
# This command will try to find only the base library, not the optional
|
||||
# components, which are:
|
||||
#
|
||||
# Containers - Containers library
|
||||
# Interconnect - Interconnect library
|
||||
# Main - Main library
|
||||
# PluginManager - PluginManager library
|
||||
# TestSuite - TestSuite library
|
||||
# Utility - Utility library
|
||||
# rc - corrade-rc executable
|
||||
#
|
||||
# Example usage with specifying additional components is::
|
||||
#
|
||||
# find_package(Corrade REQUIRED Utility TestSuite)
|
||||
#
|
||||
# For each component is then defined:
|
||||
#
|
||||
# Corrade_*_FOUND - Whether the component was found
|
||||
# Corrade::* - Component imported target
|
||||
#
|
||||
# The package is found if either debug or release version of each library is
|
||||
# found. If both debug and release libraries are found, proper version is
|
||||
# chosen based on actual build configuration of the project (i.e. Debug build
|
||||
# is linked to debug libraries, Release build to release libraries).
|
||||
#
|
||||
# Corrade conditionally defines ``CORRADE_IS_DEBUG_BUILD`` preprocessor
|
||||
# variable in case build configuration is ``Debug`` (not Corrade itself, but
|
||||
# build configuration of the project using it). Useful e.g. for selecting
|
||||
# proper plugin directory.
|
||||
#
|
||||
# Corrade defines the following custom target properties:
|
||||
#
|
||||
# CORRADE_CXX_STANDARD - C++ standard to require when compiling given
|
||||
# target. Does nothing if :variable:`CMAKE_CXX_FLAGS` already contains
|
||||
# particular standard setting flag or if given target contains
|
||||
# :prop_tgt:`CMAKE_CXX_STANDARD` property. Allowed value is 11, 14 or 17.
|
||||
# INTERFACE_CORRADE_CXX_STANDARD - C++ standard to require when using given
|
||||
# target. Does nothing if :variable:`CMAKE_CXX_FLAGS` already contains
|
||||
# particular standard setting flag or if given target contains
|
||||
# :prop_tgt:`CMAKE_CXX_STANDARD` property. Allowed value is 11, 14 or 17.
|
||||
# CORRADE_USE_PEDANTIC_FLAGS - Enable additional compiler/linker flags.
|
||||
# Boolean.
|
||||
#
|
||||
# These properties are inherited from directory properties, meaning that if you
|
||||
# set them on directories, they get implicitly set on all targets in given
|
||||
# directory (with a possibility to do target-specific overrides). All Corrade
|
||||
# libraries have the :prop_tgt:`INTERFACE_CORRADE_CXX_STANDARD` property set to
|
||||
# 11, meaning that you will always have at least C++11 enabled once you link to
|
||||
# any Corrade library.
|
||||
#
|
||||
# Features of found Corrade library are exposed in these variables:
|
||||
#
|
||||
# CORRADE_MSVC_COMPATIBILITY - Defined if compiled with compatibility
|
||||
# mode for MSVC 2019+ without the /permissive- flag set
|
||||
# CORRADE_MSVC2017_COMPATIBILITY - Defined if compiled with compatibility
|
||||
# mode for MSVC 2017
|
||||
# CORRADE_MSVC2015_COMPATIBILITY - Defined if compiled with compatibility
|
||||
# mode for MSVC 2015
|
||||
# CORRADE_BUILD_DEPRECATED - Defined if compiled with deprecated features
|
||||
# included
|
||||
# CORRADE_BUILD_STATIC - Defined if compiled as static libraries.
|
||||
# Default are shared libraries.
|
||||
# CORRADE_BUILD_STATIC_UNIQUE_GLOBALS - Defined if static libraries keep their
|
||||
# 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 simultaneously in multiple
|
||||
# threads
|
||||
# CORRADE_BUILD_CPU_RUNTIME_DISPATCH - Defined if built with code paths
|
||||
# optimized for multiple architectres with the best matching variant selected
|
||||
# at runtime based on detected CPU features
|
||||
# CORRADE_TARGET_UNIX - Defined if compiled for some Unix flavor
|
||||
# (Linux, BSD, macOS)
|
||||
# CORRADE_TARGET_APPLE - Defined if compiled for Apple platforms
|
||||
# CORRADE_TARGET_IOS - Defined if compiled for iOS (device or
|
||||
# simulator)
|
||||
# CORRADE_TARGET_IOS_SIMULATOR - Defined if compiled for iOS Simulator
|
||||
# CORRADE_TARGET_WINDOWS - Defined if compiled for Windows
|
||||
# CORRADE_TARGET_WINDOWS_RT - Defined if compiled for Windows RT
|
||||
# CORRADE_TARGET_EMSCRIPTEN - Defined if compiled for Emscripten
|
||||
# CORRADE_TARGET_ANDROID - Defined if compiled for Android
|
||||
# CORRADE_TARGET_GCC - Defined if compiling with GCC or GCC-
|
||||
# compatible Clang
|
||||
# CORRADE_TARGET_CLANG - Defined if compiling with Clang or any of its
|
||||
# variants
|
||||
# CORRADE_TARGET_APPLE_CLANG - Defined if compiling with Apple's Clang
|
||||
# CORRADE_TARGET_CLANG_CL - Defined if compiling with Clang-CL (Clang
|
||||
# with a MSVC frontend)
|
||||
# CORRADE_TARGET_MSVC - Defined if compiling with MSVC or Clang with
|
||||
# a MSVC frontend
|
||||
# CORRADE_TARGET_MINGW - Defined if compiling under MinGW
|
||||
# CORRADE_CPU_USE_IFUNC - Defined if GNU IFUNC is allowed to be used
|
||||
# for runtime dispatch in the Cpu library
|
||||
# CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT - Defined if PluginManager
|
||||
# doesn't support dynamic plugin loading due to platform limitations
|
||||
# CORRADE_TESTSUITE_TARGET_XCTEST - Defined if TestSuite is targeting Xcode
|
||||
# XCTest
|
||||
# CORRADE_UTILITY_USE_ANSI_COLORS - Defined if ANSI escape sequences are used
|
||||
# for colored output with Utility::Debug on Windows
|
||||
#
|
||||
# Additionally these variables are defined for internal usage:
|
||||
#
|
||||
# CORRADE_INCLUDE_DIR - Root include dir
|
||||
# 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
|
||||
# CORRADE_PEDANTIC_COMPILER_OPTIONS - List of pedantic compiler options used
|
||||
# for targets with :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS` enabled
|
||||
# CORRADE_PEDANTIC_COMPILER_DEFINITIONS - List of pedantic compiler
|
||||
# definitions used for targets with :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS`
|
||||
# enabled
|
||||
# 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:
|
||||
#
|
||||
# .. command:: corrade_add_test
|
||||
#
|
||||
# Add unit test using Corrade's TestSuite::
|
||||
#
|
||||
# corrade_add_test(<test name>
|
||||
# <sources>...
|
||||
# [LIBRARIES <libraries>...]
|
||||
# [FILES <files>...]
|
||||
# [ARGUMENTS <arguments>...])
|
||||
#
|
||||
# Test name is also executable name. You can use ``LIBRARIES`` to specify
|
||||
# libraries to link with instead of using :command:`target_link_libraries()`.
|
||||
# The ``Corrade::TestSuite`` target is linked automatically to each test. Note
|
||||
# that the :command:`enable_testing()` function must be called explicitly.
|
||||
# Arguments passed after ``ARGUMENTS`` will be appended to the test
|
||||
# command line. ``ARGUMENTS`` are supported everywhere except when
|
||||
# ``CORRADE_TESTSUITE_TARGET_XCTEST`` is enabled.
|
||||
#
|
||||
# You can list files needed by the test in the ``FILES`` section. If given
|
||||
# filename is relative, it is treated relatively to `CMAKE_CURRENT_SOURCE_DIR`.
|
||||
# The files are added to the :prop_test:`REQUIRED_FILES` target property. On
|
||||
# Emscripten they are bundled to the executable and available in the virtual
|
||||
# filesystem root. On Android they are copied along the executable to the
|
||||
# target. In case of Emscripten and Android, if the file is absolute or
|
||||
# contains ``..``, only the leaf name is used. Alternatively you can have a
|
||||
# filename formatted as ``<input>@<output>``, in which case the ``<input>`` is
|
||||
# treated as local filesystem location and ``<output>`` as remote/virtual
|
||||
# filesystem location. The remote location can't be absolute or contain ``..``
|
||||
# / ``@`` characters.
|
||||
#
|
||||
# Unless :variable:`CORRADE_TESTSUITE_TARGET_XCTEST` is set, test cases on iOS
|
||||
# targets are created as bundles with bundle identifier set to CMake project
|
||||
# name by default. Use the cache variable :variable:`CORRADE_TESTSUITE_BUNDLE_IDENTIFIER_PREFIX`
|
||||
# to change it to something else.
|
||||
#
|
||||
# .. command:: corrade_add_resource
|
||||
#
|
||||
# Compile data resources into application binary::
|
||||
#
|
||||
# corrade_add_resource(<name> <resources.conf>)
|
||||
#
|
||||
# Depends on ``Corrade::rc``, which is part of Corrade utilities. This command
|
||||
# generates resource data using given configuration file in current build
|
||||
# directory. Argument name is name under which the resources can be explicitly
|
||||
# loaded. Variable ``<name>`` contains compiled resource filename, which is
|
||||
# then used for compiling library / executable. On CMake >= 3.1 the
|
||||
# `resources.conf` file can contain UTF-8-encoded filenames. Example usage::
|
||||
#
|
||||
# corrade_add_resource(app_resources resources.conf)
|
||||
# add_executable(app source1 source2 ... ${app_resources})
|
||||
#
|
||||
# .. command:: corrade_add_plugin
|
||||
#
|
||||
# Add dynamic plugin::
|
||||
#
|
||||
# corrade_add_plugin(<plugin name>
|
||||
# "<debug binary install dir>;<debug library install dir>"
|
||||
# "<release binary install dir>;<release library install dir>"
|
||||
# <metadata file>
|
||||
# <sources>...)
|
||||
#
|
||||
# The macro adds a preprocessor directive ``CORRADE_DYNAMIC_PLUGIN`` when
|
||||
# compiling ``<sources>``. Additional libraries can be linked in via
|
||||
# :command:`target_link_libraries(plugin_name ...) <target_link_libraries>`.
|
||||
# On DLL platforms, the plugin DLLs and metadata files are put into
|
||||
# ``<debug binary install dir>`` / ``<release binary install dir>`` and the
|
||||
# ``*.lib`` files into ``<debug library install dir>`` /
|
||||
# ``<release library install dir>``. On non-DLL platforms everything is put
|
||||
# into ``<debug library install dir>`` / ``<release library install dir>``.
|
||||
#
|
||||
# If the plugin interface disables plugin metadata files, the
|
||||
# ``<metadata file>`` can be set to ``""``, in which case no metadata file is
|
||||
# copied anywhere. Otherwise the metadata file is copied and renamed to
|
||||
# ``<plugin name>``, retaining its original extension.
|
||||
#
|
||||
# corrade_add_plugin(<plugin name>
|
||||
# <debug install dir>
|
||||
# <release install dir>
|
||||
# <metadata file>
|
||||
# <sources>...)
|
||||
#
|
||||
# Unlike the above version this puts everything into ``<debug install dir>`` on
|
||||
# both DLL and non-DLL platforms. If ``<debug install dir>`` is set to
|
||||
# :variable:`CMAKE_CURRENT_BINARY_DIR` (e.g. for testing purposes), the files
|
||||
# are copied directly, without the need to perform install step. Note that the
|
||||
# files are actually put into configuration-based subdirectory, i.e.
|
||||
# ``${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}``. See documentation of
|
||||
# :variable:`CMAKE_CFG_INTDIR` variable for more information.
|
||||
#
|
||||
# .. command:: corrade_add_static_plugin
|
||||
#
|
||||
# Add static plugin::
|
||||
#
|
||||
# corrade_add_static_plugin(<plugin name>
|
||||
# "<binary install dir>;<library install dir>"
|
||||
# <metadata file>
|
||||
# <sources>...)
|
||||
#
|
||||
# The macro adds a preprocessor directive ``CORRADE_STATIC_PLUGIN`` when
|
||||
# compiling ``<sources>``. Additional libraries can be linked in via
|
||||
# :command:`target_link_libraries(plugin_name ...) <target_link_libraries>`.
|
||||
# The ``<binary install dir>`` is ignored and included just for compatibility
|
||||
# with the :command:`corrade_add_plugin` command, everything is installed into
|
||||
# ``<library install dir>``. Note that plugins built in debug configuration
|
||||
# (e.g. with :variable:`CMAKE_BUILD_TYPE` set to ``Debug``) have ``"-d"``
|
||||
# suffix to make it possible to have both debug and release plugins installed
|
||||
# alongside each other.
|
||||
#
|
||||
# If the plugin interface disables plugin metadata files, the
|
||||
# ``<metadata file>`` can be set to ``""``, in which case no metadata file is
|
||||
# used. Otherwise the metadata file is bundled and renamed to
|
||||
# ``<plugin name>``, retaining its original extension.
|
||||
#
|
||||
# corrade_add_static_plugin(<plugin name>
|
||||
# <install dir>
|
||||
# <metadata file>
|
||||
# <sources>...)
|
||||
#
|
||||
# Equivalent to the above with ``<library install dir>`` set to ``<install dir>``.
|
||||
# If ``<install dir>`` is set to :variable:`CMAKE_CURRENT_BINARY_DIR` (e.g. for
|
||||
# testing purposes), no installation rules are added.
|
||||
#
|
||||
# .. command:: corrade_find_dlls_for_libs
|
||||
#
|
||||
# Find corresponding DLLs for library files::
|
||||
#
|
||||
# corrade_find_dlls_for_libs(<output variable> <libs>...)
|
||||
#
|
||||
# Available only on Windows, for all ``*.lib`` files tries to find
|
||||
# corresponding DLL file. Useful for bundling dependencies for e.g. WinRT
|
||||
# packages.
|
||||
#
|
||||
|
||||
#
|
||||
# This file is part of Corrade.
|
||||
#
|
||||
# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
|
||||
# 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026
|
||||
# Vladimír Vondruš <mosra@centrum.cz>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
# Root include dir
|
||||
find_path(CORRADE_INCLUDE_DIR
|
||||
NAMES Corrade/Corrade.h)
|
||||
mark_as_advanced(CORRADE_INCLUDE_DIR)
|
||||
|
||||
# Configuration file
|
||||
find_file(_CORRADE_CONFIGURE_FILE configure.h
|
||||
HINTS ${CORRADE_INCLUDE_DIR}/Corrade/)
|
||||
mark_as_advanced(_CORRADE_CONFIGURE_FILE)
|
||||
|
||||
# We need to open configure.h file from CORRADE_INCLUDE_DIR before we check for
|
||||
# the components. Bail out with proper error message if it wasn't found. The
|
||||
# complete check with all components is further below.
|
||||
if(NOT CORRADE_INCLUDE_DIR)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Corrade
|
||||
REQUIRED_VARS CORRADE_INCLUDE_DIR _CORRADE_CONFIGURE_FILE)
|
||||
endif()
|
||||
|
||||
# Read flags from configuration
|
||||
file(READ ${_CORRADE_CONFIGURE_FILE} _corradeConfigure)
|
||||
string(REGEX REPLACE ";" "\\\\;" _corradeConfigure "${_corradeConfigure}")
|
||||
string(REGEX REPLACE "\n" ";" _corradeConfigure "${_corradeConfigure}")
|
||||
set(_corradeFlags
|
||||
MSVC2015_COMPATIBILITY
|
||||
MSVC2017_COMPATIBILITY
|
||||
MSVC_COMPATIBILITY
|
||||
BUILD_DEPRECATED
|
||||
BUILD_STATIC
|
||||
BUILD_STATIC_UNIQUE_GLOBALS
|
||||
BUILD_MULTITHREADED
|
||||
BUILD_CPU_RUNTIME_DISPATCH
|
||||
TARGET_UNIX
|
||||
TARGET_APPLE
|
||||
TARGET_IOS
|
||||
TARGET_IOS_SIMULATOR
|
||||
TARGET_WINDOWS
|
||||
TARGET_WINDOWS_RT
|
||||
TARGET_EMSCRIPTEN
|
||||
TARGET_ANDROID
|
||||
# TARGET_X86 etc, TARGET_32BIT, TARGET_BIG_ENDIAN and TARGET_LIBCXX etc.
|
||||
# are not exposed to CMake as the meaning is unclear on platforms with
|
||||
# multi-arch binaries or when mixing different STL implementations.
|
||||
# TARGET_GCC etc are figured out via UseCorrade.cmake, as the compiler can
|
||||
# be different when compiling the lib & when using it.
|
||||
CPU_USE_IFUNC
|
||||
PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT
|
||||
TESTSUITE_TARGET_XCTEST
|
||||
UTILITY_USE_ANSI_COLORS)
|
||||
foreach(_corradeFlag ${_corradeFlags})
|
||||
list(FIND _corradeConfigure "#define CORRADE_${_corradeFlag}" _corrade_${_corradeFlag})
|
||||
if(NOT _corrade_${_corradeFlag} EQUAL -1)
|
||||
set(CORRADE_${_corradeFlag} 1)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# CMake module dir
|
||||
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)
|
||||
|
||||
# Component distinction (listing them explicitly to avoid mistakes with finding
|
||||
# unknown components)
|
||||
set(_CORRADE_LIBRARY_COMPONENTS
|
||||
Containers Interconnect Main PluginManager TestSuite Utility)
|
||||
# These libraries are excluded from DLL detection if Corrade is built as shared
|
||||
set(_CORRADE_LIBRARY_COMPONENTS_ALWAYS_STATIC
|
||||
Main)
|
||||
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})
|
||||
# Mark the dependencies as required if the component is also required
|
||||
if(Corrade_FIND_REQUIRED_${_component})
|
||||
foreach(_dependency ${_CORRADE_${_component}_DEPENDENCIES})
|
||||
set(Corrade_FIND_REQUIRED_${_dependency} TRUE)
|
||||
endforeach()
|
||||
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()
|
||||
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)
|
||||
|
||||
# Create imported target in case the library is found. If the project is
|
||||
# added as subproject to CMake, the target already exists and all the
|
||||
# required setup is already done from the build tree.
|
||||
if(TARGET "Corrade::${_component}") # Quotes to "fix" KDE's higlighter
|
||||
set(Corrade_${_component}_FOUND TRUE)
|
||||
else()
|
||||
# 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()
|
||||
|
||||
# The Main library consists of two libraries on MinGW to be able to
|
||||
# handle both console and windows apps, special-case it before any
|
||||
# other libraries. The CORRADE_MAIN{CONSOLE,WINDOWS}_LIBRARY_<CONFIG>
|
||||
# variables then get subsequently used below.
|
||||
if(MINGW AND _component STREQUAL Main)
|
||||
foreach(_mainComponent Console Windows)
|
||||
string(TOUPPER ${_mainComponent} _MAIN_COMPONENT)
|
||||
find_library(CORRADE_MAIN${_MAIN_COMPONENT}_LIBRARY_DEBUG CorradeMain${_mainComponent}-d)
|
||||
find_library(CORRADE_MAIN${_MAIN_COMPONENT}_LIBRARY_RELEASE CorradeMain${_mainComponent})
|
||||
mark_as_advanced(CORRADE_MAIN${_MAIN_COMPONENT}_LIBRARY_DEBUG
|
||||
CORRADE_MAIN${_MAIN_COMPONENT}_LIBRARY_RELEASE)
|
||||
endforeach()
|
||||
|
||||
# Library (and not header-only) components
|
||||
elseif(_component IN_LIST _CORRADE_LIBRARY_COMPONENTS AND NOT _component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS)
|
||||
# Try to find both debug and release version
|
||||
find_library(CORRADE_${_COMPONENT}_LIBRARY_DEBUG Corrade${_component}-d)
|
||||
find_library(CORRADE_${_COMPONENT}_LIBRARY_RELEASE Corrade${_component})
|
||||
mark_as_advanced(CORRADE_${_COMPONENT}_LIBRARY_DEBUG
|
||||
CORRADE_${_COMPONENT}_LIBRARY_RELEASE)
|
||||
|
||||
# On Windows, if we have a dynamic build of given library, find the
|
||||
# DLLs as well. Abuse find_program() since the DLLs should be
|
||||
# alongside usual executables. On MinGW they however have a lib
|
||||
# prefix.
|
||||
if(CORRADE_TARGET_WINDOWS AND NOT CORRADE_BUILD_STATIC AND NOT _component IN_LIST _CORRADE_LIBRARY_COMPONENTS_ALWAYS_STATIC)
|
||||
find_program(CORRADE_${_COMPONENT}_DLL_DEBUG ${CMAKE_SHARED_LIBRARY_PREFIX}Corrade${_component}-d.dll)
|
||||
find_program(CORRADE_${_COMPONENT}_DLL_RELEASE ${CMAKE_SHARED_LIBRARY_PREFIX}Corrade${_component}.dll)
|
||||
mark_as_advanced(CORRADE_${_COMPONENT}_DLL_DEBUG
|
||||
CORRADE_${_COMPONENT}_DLL_RELEASE)
|
||||
# If not on Windows or on a static build, unset the DLL variables
|
||||
# to avoid leaks when switching shared and static builds
|
||||
else()
|
||||
unset(CORRADE_${_COMPONENT}_DLL_DEBUG CACHE)
|
||||
unset(CORRADE_${_COMPONENT}_DLL_RELEASE CACHE)
|
||||
endif()
|
||||
|
||||
# Executable components
|
||||
elseif(_component IN_LIST _CORRADE_EXECUTABLE_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 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.
|
||||
#
|
||||
# The Main library consists of two libraries on MinGW to be able to
|
||||
# handle both console and windows apps. See
|
||||
# src/Corrade/CMakeLists.txt for a lengthy explanation. On non-MinGW
|
||||
# it's handled as a regular library or a header-only library.
|
||||
if(MINGW AND _component STREQUAL Main)
|
||||
if((CORRADE_MAINCONSOLE_LIBRARY_DEBUG AND CORRADE_MAINWINDOWS_LIBRARY_DEBUG) OR (CORRADE_MAINCONSOLE_LIBRARY_RELEASE AND CORRADE_MAINWINDOWS_LIBRARY_RELEASE))
|
||||
set(Corrade_Main_FOUND TRUE)
|
||||
else()
|
||||
set(Corrade_Main_FOUND FALSE)
|
||||
continue()
|
||||
endif()
|
||||
elseif(
|
||||
# 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. The Main library consists
|
||||
# of two libraries on MinGW to be able to handle both console and
|
||||
# windows apps, so there the target is INTERFACE as well, and is filled
|
||||
# with INTERFACE_LINK_LIBRARIES later below.
|
||||
if(_component IN_LIST _CORRADE_HEADER_ONLY_COMPONENTS OR (MINGW AND _component STREQUAL Main))
|
||||
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)
|
||||
# On non-Windows platforms Main is a no-op interface target
|
||||
if(CORRADE_TARGET_WINDOWS)
|
||||
# On MinGW the library consists of two libraries, for which we
|
||||
# need to add two extra targets to delegate to. See
|
||||
# src/Corrade/CMakeLists.txt for a lengthy explanation.
|
||||
if(MINGW)
|
||||
foreach(_mainComponent Console Windows)
|
||||
string(TOUPPER ${_mainComponent} _MAINCOMPONENT)
|
||||
|
||||
# Similarly as with _CORRADE_LIBRARY_COMPONENTS above,
|
||||
# just specialized for the Main library (and without
|
||||
# DLL handling, as the library is always static)
|
||||
add_library(Corrade::Main${_mainComponent} STATIC IMPORTED)
|
||||
foreach(_CONFIG DEBUG RELEASE)
|
||||
if(NOT CORRADE_MAIN${_MAINCOMPONENT}_LIBRARY_${_CONFIG})
|
||||
continue()
|
||||
endif()
|
||||
|
||||
set_property(TARGET Corrade::Main${_mainComponent} APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS ${_CONFIG})
|
||||
set_property(TARGET Corrade::Main${_mainComponent} PROPERTY
|
||||
IMPORTED_LOCATION_${_CONFIG} ${CORRADE_MAIN${_MAINCOMPONENT}_LIBRARY_${_CONFIG}})
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
# See src/Corrade/CMakeLists.txt for why -lmingw32 has to
|
||||
# be linked this way
|
||||
set_property(TARGET Corrade::${_component} APPEND PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES "-municode;$<$<NOT:$<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>>:Corrade::MainConsole>$<$<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>:-lmingw32;Corrade::MainWindows>")
|
||||
|
||||
# On MSVC and clang-cl it's simple, there's just a single
|
||||
# library that was already added above. Add just the /ENTRY
|
||||
# flag.
|
||||
else()
|
||||
# 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>")
|
||||
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()
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#.rst:
|
||||
# Find Node.js
|
||||
# ------------
|
||||
#
|
||||
# Finds the Node.js executable. This module defines:
|
||||
#
|
||||
# NodeJs_FOUND - True if Node.js executable is found
|
||||
# NodeJs::NodeJs - Node.js executable imported target
|
||||
# NodeJs_VERSION - Version string reported by ``node --version``
|
||||
#
|
||||
|
||||
#
|
||||
# This file is part of Corrade.
|
||||
#
|
||||
# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
|
||||
# 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026
|
||||
# Vladimír Vondruš <mosra@centrum.cz>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
find_program(NODEJS_EXECUTABLE node)
|
||||
mark_as_advanced(NODEJS_EXECUTABLE)
|
||||
|
||||
if(NODEJS_EXECUTABLE)
|
||||
execute_process(COMMAND ${NODEJS_EXECUTABLE} --version
|
||||
OUTPUT_VARIABLE NodeJs_VERSION
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NodeJs_VERSION MATCHES "^v[0-9]")
|
||||
string(SUBSTRING ${NodeJs_VERSION} 1 -1 NodeJs_VERSION)
|
||||
else()
|
||||
unset(NodeJs_VERSION)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(NodeJs
|
||||
REQUIRED_VARS NODEJS_EXECUTABLE
|
||||
VERSION_VAR NodeJs_VERSION)
|
||||
|
||||
if(NOT TARGET NodeJs::NodeJs)
|
||||
add_executable(NodeJs::NodeJs IMPORTED)
|
||||
set_property(TARGET NodeJs::NodeJs PROPERTY IMPORTED_LOCATION ${NODEJS_EXECUTABLE})
|
||||
endif()
|
||||
+874
@@ -0,0 +1,874 @@
|
||||
|
||||
# (the blank line is here so CMake doesn't generate documentation from it)
|
||||
|
||||
#
|
||||
# This file is part of Corrade.
|
||||
#
|
||||
# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
|
||||
# 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026
|
||||
# Vladimír Vondruš <mosra@centrum.cz>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
# Already included, nothing to do
|
||||
if(_CORRADE_USE_INCLUDED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Compiler identification. Unlike other CORRADE_TARGET_* variables it's not
|
||||
# saved/restored from configure.h as the compiler used to compile Corrade may
|
||||
# differ from the compiler used to link to it.
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CORRADE_TARGET_GCC 1)
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(CORRADE_TARGET_CLANG 1)
|
||||
if(CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
|
||||
set(CORRADE_TARGET_CLANG_CL 1)
|
||||
set(CORRADE_TARGET_MSVC 1)
|
||||
else()
|
||||
set(CORRADE_TARGET_GCC 1)
|
||||
endif()
|
||||
endif()
|
||||
# With older Emscripten (or CMake?) versions the compiler is detected as
|
||||
# "unknown" instead of Clang. Force the compiler resolution in that case.
|
||||
# TODO: figure out why
|
||||
if(CORRADE_TARGET_EMSCRIPTEN)
|
||||
set(CORRADE_TARGET_GCC 1)
|
||||
set(CORRADE_TARGET_CLANG 1)
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
set(CORRADE_TARGET_GCC 1)
|
||||
set(CORRADE_TARGET_CLANG 1)
|
||||
set(CORRADE_TARGET_APPLE_CLANG 1)
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
set(CORRADE_TARGET_MSVC 1)
|
||||
endif()
|
||||
if(MINGW)
|
||||
set(CORRADE_TARGET_MINGW 1)
|
||||
endif()
|
||||
|
||||
# Check compiler version
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
# Don't allow to use compilers older than what compatibility mode allows
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.1")
|
||||
message(FATAL_ERROR "Corrade cannot be used with GCC < 4.8.1. Sorry.")
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
# Don't allow to use compilers older than what compatibility mode allows
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0")
|
||||
message(FATAL_ERROR "Corrade cannot be used with MSVC < 2015. Sorry.")
|
||||
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.10")
|
||||
if(NOT CORRADE_MSVC2015_COMPATIBILITY)
|
||||
message(FATAL_ERROR "To use Corrade with MSVC 2015, build it with CORRADE_MSVC2015_COMPATIBILITY enabled")
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.20")
|
||||
if(NOT CORRADE_MSVC2017_COMPATIBILITY)
|
||||
message(FATAL_ERROR "To use Corrade with MSVC 2017, build it with CORRADE_MSVC2017_COMPATIBILITY enabled")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Don't allow to use compiler newer than what compatibility mode allows
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.10")
|
||||
if(CORRADE_MSVC2015_COMPATIBILITY)
|
||||
message(FATAL_ERROR "MSVC >= 2017 cannot be used if Corrade is built with CORRADE_MSVC2015_COMPATIBILITY")
|
||||
endif()
|
||||
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.20")
|
||||
if(CORRADE_MSVC2017_COMPATIBILITY)
|
||||
message(FATAL_ERROR "MSVC >= 2019 cannot be used if Corrade is built with CORRADE_MSVC2017_COMPATIBILITY")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# GCC/Clang-specific compiler flags
|
||||
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(CORRADE_PEDANTIC_COMPILER_OPTIONS
|
||||
"-Wall" "-Wextra"
|
||||
"$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:-Wold-style-cast>"
|
||||
"-Winit-self"
|
||||
# -Werror=return-type doesn't work on nvcc, use it just for C and C++
|
||||
"$<$<OR:$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>,$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>>:-Werror=return-type>"
|
||||
"-Wmissing-declarations"
|
||||
# -Wpedantic is since 4.8, until then only -pedantic (which doesn't
|
||||
# have any -Wno-pedantic or a way to disable it for a particular line)
|
||||
"-Wpedantic"
|
||||
# Needs to have both, otherwise Clang's linker on macOS complains that
|
||||
# "direct access in function [...] to global weak symbol [...] means the
|
||||
# weak symbol cannot be overridden at runtime. This was likely caused
|
||||
# by different translation units being compiled with different
|
||||
# visibility settings." See also various google results for the above
|
||||
# message.
|
||||
"-fvisibility=hidden" "-fvisibility-inlines-hidden"
|
||||
# A lot of functionality relies on aliased pointers, such as the whole
|
||||
# StridedArrayView. Given numerous other libraries including stb_image
|
||||
# *and the Linux kernel itself* disable this as well, I see no reason
|
||||
# for needless suffering either. I don't remember strict aliasing to
|
||||
# ever help with optimizing anything, plus it was disabled for the
|
||||
# whole of Magnum since December 2013 already:
|
||||
# https://github.com/mosra/magnum/commit/f373b6518e0b1fa3e4d0ffb19f77e80a8a56484c
|
||||
# So let's just make it official and disable it for everything,
|
||||
# everywhere, forever. Besides this place, which enables it for
|
||||
# everyone that enables CORRADE_USE_PEDANTIC_FLAGS, it's also enabled
|
||||
# for everyone who links to CorradeUtility in Utility/CMakeLists.txt
|
||||
# and to Corrade::Utility in FindCorrade.cmake, so even people who
|
||||
# don't enable pedantic flags (or can't due to too many warnings) get
|
||||
# it and I don't need to deal with insane bugs and random breakages. On
|
||||
# the other hand it's set here as well so even internal test code (that
|
||||
# doesn't necessarily link to CorradeUtility) gets it implicitly too.
|
||||
"-fno-strict-aliasing")
|
||||
|
||||
# Some flags are not yet supported everywhere
|
||||
# TODO: do this with check_c_compiler_flags()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
list(APPEND CORRADE_PEDANTIC_COMPILER_OPTIONS
|
||||
"$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:-Wzero-as-null-pointer-constant>"
|
||||
|
||||
# TODO: enable when this gets to Clang (not in 3.9, but in master
|
||||
# since https://github.com/llvm-mirror/clang/commit/0a022661c797356e9c28e4999b6ec3881361371e)
|
||||
"-Wdouble-promotion")
|
||||
|
||||
# GCC 4.8 doesn't like when structs are initialized using just {} and
|
||||
# because we use that a lot, the output gets extremely noisy. Disable
|
||||
# the warning altogether there.
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0")
|
||||
list(APPEND CORRADE_PEDANTIC_COMPILER_OPTIONS "-Wno-missing-field-initializers")
|
||||
endif()
|
||||
|
||||
# Prints a warning in all cases of
|
||||
# functionReturningATemporaryView()[i]
|
||||
# i.e., basically all use cases of Utility::Json. Hopefully gets fixed
|
||||
# better than what https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532
|
||||
# did so far.
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "13.0")
|
||||
list(APPEND CORRADE_PEDANTIC_COMPILER_OPTIONS "-Wno-dangling-reference")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang" OR CORRADE_TARGET_EMSCRIPTEN)
|
||||
list(APPEND CORRADE_PEDANTIC_COMPILER_OPTIONS
|
||||
# Clang's -Wmissing-declarations does something else and the
|
||||
# behavior we want is under -Wmissing-prototypes. See
|
||||
# https://llvm.org/bugs/show_bug.cgi?id=16286.
|
||||
"-Wmissing-prototypes"
|
||||
|
||||
# Fixing it in all places would add too much noise to the code.
|
||||
"-Wno-shorten-64-to-32")
|
||||
|
||||
list(APPEND CORRADE_PEDANTIC_TEST_COMPILER_OPTIONS
|
||||
# Unlike GCC, -Wunused-function (which is enabled through -Wall)
|
||||
# doesn't fire for member functions, it's controlled separately
|
||||
"-Wunused-member-function"
|
||||
# This is implicitly enabled by the above and causes lots of
|
||||
# warnings for e.g. move constructors, so disabling
|
||||
"-Wno-unneeded-member-function")
|
||||
endif()
|
||||
|
||||
# MSVC-specific compiler flags
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
|
||||
set(CORRADE_PEDANTIC_COMPILER_OPTIONS
|
||||
# Enable extra warnings (similar to -Wall)
|
||||
"/W4"
|
||||
|
||||
# "conditional expression is constant", especially when a template
|
||||
# argument is passed to an if, which happens mainly in tests but
|
||||
# sometimes also in recursive constexpr functions. As I can't use if
|
||||
# constexpr in C++11 code, there's not really much I can do.
|
||||
"/wd4127"
|
||||
|
||||
# "needs to have dll-interface to be used by clients", as the fix for
|
||||
# that would effectively prevent using STL completely.
|
||||
"/wd4251"
|
||||
|
||||
# "conversion from '<bigger int type>' to '<smaller int type>'",
|
||||
# "conversion from 'size_t' to '<smaller int type>', possible loss of
|
||||
# data", fixing this would add too much noise. Equivalent to
|
||||
# -Wshorten-64-to-32 on Clang.
|
||||
"/wd4244"
|
||||
"/wd4267"
|
||||
|
||||
# "structure was padded due to alignment specifier". YES. THAT'S
|
||||
# EXACTLY AS INTENDED.
|
||||
"/wd4324"
|
||||
|
||||
# "new behavior: elements of array will be default initialized".
|
||||
# YES. YES I KNOW WHAT I'M DOING.
|
||||
"/wd4351"
|
||||
|
||||
# "previous versions of the compiler did not override when parameters
|
||||
# only differed by const/volatile qualifiers". Okay. So you had bugs.
|
||||
# And?
|
||||
"/wd4373"
|
||||
|
||||
# "declaration of 'foo' hides class member". I use this a lot in
|
||||
# constructor arguments, `Class(int foo): foo{foo} {}` and adding some
|
||||
# underscores to mitigate this would not be pretty. OTOH, "C4456:
|
||||
# declaration of 'foo' hides previous local declaration" points to a
|
||||
# valid issue that I should get rid of.
|
||||
"/wd4458"
|
||||
|
||||
# "default constructor could not be generated/can never be
|
||||
# instantiated". Apparently it can.
|
||||
"/wd4510"
|
||||
"/wd4610"
|
||||
|
||||
# "assignment operator could not be generated". Do I want one? NO I
|
||||
# DON'T.
|
||||
"/wd4512"
|
||||
|
||||
# "no suitable definition for explicit template instantiation". No. The
|
||||
# problem is apparently that I'm having the definitions in *.cpp file
|
||||
# and instantiating them explicitly. Common practice here.
|
||||
"/wd4661"
|
||||
|
||||
# "unreachable code". *Every* assertion has return after std::abort().
|
||||
# So?
|
||||
"/wd4702"
|
||||
|
||||
# "assignment within conditional expression". It's not my problem that
|
||||
# it doesn't get the hint with extra parentheses (`if((a = b))`).
|
||||
"/wd4706"
|
||||
|
||||
# "forcing value to bool 'true' or 'false' (performance warning)". So
|
||||
# what. I won't wrap everything in bool(). This is a _language feature_,
|
||||
# dammit.
|
||||
"/wd4800"
|
||||
|
||||
# "dllexport and extern are incompatible on an explicit instantiation".
|
||||
# Why the error is emitted only on classes? Functions are okay with
|
||||
# dllexport extern?!
|
||||
"/wd4910")
|
||||
set(CORRADE_PEDANTIC_COMPILER_DEFINITIONS
|
||||
# Disabling warning for not using "secure-but-not-standard" STL algos
|
||||
"_CRT_SECURE_NO_WARNINGS" "_SCL_SECURE_NO_WARNINGS")
|
||||
endif()
|
||||
|
||||
if(CORRADE_TARGET_CLANG_CL)
|
||||
list(APPEND CORRADE_PEDANTIC_COMPILER_OPTIONS
|
||||
# See Utility::Path::libraryLocation() for details
|
||||
"-Wno-microsoft-cast")
|
||||
endif()
|
||||
|
||||
# Compiler flags to undo horrible crimes done by windows.h, common for both
|
||||
# MSVC and MinGW
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC" OR MINGW)
|
||||
list(APPEND CORRADE_PEDANTIC_COMPILER_DEFINITIONS
|
||||
# Disabling all minmax nonsense macros coming from windows.h
|
||||
"NOMINMAX"
|
||||
|
||||
# Disabling GDI and other mud in windows.h (which in turn fixes the
|
||||
# dreaded #define interface struct UNLESS something includes the cursed
|
||||
# headers such as shlwapi.h directly -- libjpeg does that, for
|
||||
# instance).
|
||||
"WIN32_LEAN_AND_MEAN")
|
||||
endif()
|
||||
|
||||
define_property(TARGET PROPERTY CORRADE_CXX_STANDARD INHERITED
|
||||
BRIEF_DOCS "C++ standard to require for given target"
|
||||
FULL_DOCS "Sets compiler-specific flags to enable C++11 or later standard
|
||||
when building given target or targets in given directory. Set in
|
||||
combination with INTERFACE_CORRADE_CXX_STANDARD to force the standard
|
||||
also on users of given target.")
|
||||
define_property(TARGET PROPERTY INTERFACE_CORRADE_CXX_STANDARD INHERITED
|
||||
BRIEF_DOCS "C++ standard to require for users of given target"
|
||||
FULL_DOCS "Sets compiler-specific flags to enable C++11 or later standard
|
||||
when using given target or targets in given directory.")
|
||||
define_property(TARGET PROPERTY CORRADE_USE_PEDANTIC_FLAGS INHERITED
|
||||
BRIEF_DOCS "Use pedantic compiler/linker flags"
|
||||
FULL_DOCS "Enables additional pedantic C, C++ and linker flags on given
|
||||
targets or directories.")
|
||||
|
||||
# Enable C++11/14/17/2a on GCC/Clang if CORRADE_CXX_STANDARD is set. Does
|
||||
# nothing in case the user put "-std=" in CMAKE_CXX_FLAGS.
|
||||
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) AND NOT CMAKE_CXX_FLAGS MATCHES "-std=")
|
||||
set(CORRADE_CXX11_STANDARD_FLAG "-std=c++11")
|
||||
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) OR ((CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang" OR CORRADE_TARGET_EMSCRIPTEN) AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5))
|
||||
set(CORRADE_CXX14_STANDARD_FLAG "-std=c++14")
|
||||
else()
|
||||
set(CORRADE_CXX14_STANDARD_FLAG "-std=c++1y")
|
||||
endif()
|
||||
# TODO: change to C++17 when compiler support is widespread enough
|
||||
set(CORRADE_CXX17_STANDARD_FLAG "-std=c++1z")
|
||||
set(CORRADE_CXX20_STANDARD_FLAG "-std=c++2a")
|
||||
endif()
|
||||
|
||||
# Enable C++14/17/2a on MSVC if CORRADE_CXX_STANDARD is set. C++11 is present
|
||||
# implicitly, 14, 17 and 20 has to be enabled through a flag. Does nothing in
|
||||
# case the user put "/std:" or "-std:" in CMAKE_CXX_FLAGS.
|
||||
if((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") AND NOT CMAKE_CXX_FLAGS MATCHES "[-/]std:")
|
||||
set(CORRADE_CXX14_STANDARD_FLAG "/std:c++14")
|
||||
set(CORRADE_CXX17_STANDARD_FLAG "/std:c++17")
|
||||
# TODO: change to c++20? when such flag appears
|
||||
# https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=vs-2019
|
||||
set(CORRADE_CXX20_STANDARD_FLAG "/std:c++latest")
|
||||
endif()
|
||||
|
||||
# Finally, in order to avoid clashes with builtin CMake features, we won't add
|
||||
# the standard flag in case the CXX_STANDARD property is present. Additionally,
|
||||
# since CMake 3.15, the cxx_std_14 compile feature doesn't result in any flag
|
||||
# being added to compiler command-line if C++14 is a default on given compiler
|
||||
# (such as GCC 6 and up). That unfortunately means ours default flag (-std=c++11)
|
||||
# gets set, making it look like the COMPILE_FEATURES didn't work at all. To
|
||||
# circumvent that, the CORRADE_CXX_STANDARD isn't set if anything from
|
||||
# COMPILE_FEATURES is present either. It doesn't cover adding flags using
|
||||
# target_compile_options(), though.
|
||||
set(_CORRADE_CXX_STANDARD_ONLY_IF_NOT_ALREADY_SET
|
||||
"$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>,$<NOT:$<BOOL:$<TARGET_PROPERTY:CXX_STANDARD>>>,$<NOT:$<BOOL:$<TARGET_PROPERTY:COMPILE_FEATURES>>>")
|
||||
foreach(_standard 11 14 17 20)
|
||||
if(CORRADE_CXX${_standard}_STANDARD_FLAG)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS
|
||||
"$<$<AND:${_CORRADE_CXX_STANDARD_ONLY_IF_NOT_ALREADY_SET},$<STREQUAL:$<TARGET_PROPERTY:CORRADE_CXX_STANDARD>,${_standard}>>:${CORRADE_CXX${_standard}_STANDARD_FLAG}>")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# On-demand pedantic compiler flags
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "$<$<BOOL:$<TARGET_PROPERTY:CORRADE_USE_PEDANTIC_FLAGS>>:${CORRADE_PEDANTIC_COMPILER_OPTIONS}>")
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "$<$<BOOL:$<TARGET_PROPERTY:CORRADE_USE_PEDANTIC_FLAGS>>:${CORRADE_PEDANTIC_COMPILER_DEFINITIONS}>")
|
||||
|
||||
# Provide a way to distinguish between debug and release builds via
|
||||
# preprocessor define
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "$<$<CONFIG:Debug>:CORRADE_IS_DEBUG_BUILD>")
|
||||
|
||||
if(CORRADE_TESTSUITE_TARGET_XCTEST)
|
||||
find_package(XCTest)
|
||||
|
||||
# Workaround for CMake iOS generator expression bug, see below
|
||||
if(CORRADE_TARGET_IOS)
|
||||
if(CMAKE_OSX_SYSROOT MATCHES "iPhoneOS")
|
||||
set(_CORRADE_EFFECTIVE_PLATFORM_NAME "-iphoneos")
|
||||
elseif(CMAKE_OSX_SYSROOT MATCHES "iPhoneSimulator")
|
||||
set(_CORRADE_EFFECTIVE_PLATFORM_NAME "-iphonesimulator")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CORRADE_TARGET_IOS AND NOT CORRADE_TESTSUITE_TARGET_XCTEST)
|
||||
set(CORRADE_TESTSUITE_BUNDLE_IDENTIFIER_PREFIX ${PROJECT_NAME} CACHE STRING
|
||||
"Bundle identifier prefix for tests ran on iOS device")
|
||||
endif()
|
||||
|
||||
function(corrade_add_test test_name)
|
||||
# See _CORRADE_USE_NO_TARGET_CHECKS in Corrade's root CMakeLists
|
||||
if(NOT _CORRADE_USE_NO_TARGET_CHECKS AND (NOT TARGET Corrade::TestSuite OR NOT TARGET Corrade::Main))
|
||||
message(FATAL_ERROR "The Corrade::TestSuite target, needed by corrade_add_test(), doesn't exist. Add the TestSuite component to your find_package() or enable CORRADE_WITH_TESTSUITE if you have Corrade as a CMake subproject.")
|
||||
endif()
|
||||
|
||||
# If CORRADE_TESTSUITE_TEST_TARGET is set, tests aren't built by default
|
||||
# (in the ALL target) but instead set as dependencies of a target named
|
||||
# after the value of CORRADE_TESTSUITE_TEST_TARGET.
|
||||
if(CORRADE_TESTSUITE_TEST_TARGET)
|
||||
if(NOT TARGET ${CORRADE_TESTSUITE_TEST_TARGET})
|
||||
add_custom_target(${CORRADE_TESTSUITE_TEST_TARGET})
|
||||
endif()
|
||||
set(EXCLUDE_FROM_ALL_IF_TEST_TARGET EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
set(_corrade_file_pair_match "^(.+)@([^@]+)$")
|
||||
set(_corrade_file_pair_replace "\\1;\\2")
|
||||
|
||||
# TestSuite library to link to. Gets reset below if the tests already link
|
||||
# to their own variant.
|
||||
set(testsuite_library Corrade::TestSuite)
|
||||
|
||||
# Get DLL and path lists
|
||||
foreach(arg ${ARGN})
|
||||
if(arg STREQUAL LIBRARIES)
|
||||
set(_DOING_LIBRARIES ON)
|
||||
elseif(arg STREQUAL FILES)
|
||||
set(_DOING_LIBRARIES OFF)
|
||||
set(_DOING_FILES ON)
|
||||
elseif(arg STREQUAL ARGUMENTS)
|
||||
set(_DOING_LIBRARIES OFF)
|
||||
set(_DOING_FILES OFF)
|
||||
set(_DOING_ARGUMENTS ON)
|
||||
else()
|
||||
if(_DOING_LIBRARIES)
|
||||
# If Corrade's own tests link their own variant of TestSuite,
|
||||
# don't link the implicit one as well, as otherwise we'd end
|
||||
# up with duplicated symbols.
|
||||
if(arg STREQUAL CorradeTestSuiteTestLib)
|
||||
set(testsuite_library )
|
||||
endif()
|
||||
list(APPEND libraries ${arg})
|
||||
elseif(_DOING_FILES)
|
||||
# If the file is already a pair of file and destination, just
|
||||
# extract them
|
||||
if(arg MATCHES ${_corrade_file_pair_match})
|
||||
set(input_filename ${CMAKE_MATCH_1})
|
||||
set(output_filename ${CMAKE_MATCH_2})
|
||||
|
||||
# Otherwise create the output filename from the input
|
||||
else()
|
||||
set(input_filename ${arg})
|
||||
|
||||
# Extract only the leaf component from absolute filename
|
||||
# (applies also to paths with ..)
|
||||
if(IS_ABSOLUTE ${arg} OR arg MATCHES "\\.\\.[\\\\/]")
|
||||
get_filename_component(output_filename ${arg} NAME)
|
||||
|
||||
# Otherwise use the full relative path as output filename
|
||||
else()
|
||||
set(output_filename ${arg})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Sanity checks
|
||||
if(output_filename MATCHES "(\\.\\.[\\\\/]|@)" OR IS_ABSOLUTE ${output_filename})
|
||||
message(SEND_ERROR "Names of files added to corrade_add_test() can't contain .., @ or be absolute")
|
||||
endif()
|
||||
|
||||
# Convert input to absolute, concatenate the files back and
|
||||
# add to the list
|
||||
get_filename_component(input_filename ${input_filename} ABSOLUTE)
|
||||
list(APPEND files ${input_filename}@${output_filename})
|
||||
list(APPEND absolute_files ${input_filename})
|
||||
elseif(_DOING_ARGUMENTS)
|
||||
list(APPEND arguments ${arg})
|
||||
else()
|
||||
list(APPEND sources ${arg})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(CORRADE_TESTSUITE_TARGET_XCTEST)
|
||||
add_library(${test_name} SHARED ${EXCLUDE_FROM_ALL_IF_TEST_TARGET} ${sources})
|
||||
set_target_properties(${test_name} PROPERTIES FRAMEWORK TRUE)
|
||||
# This is never Windows, so no need to bother with Corrade::Main
|
||||
target_link_libraries(${test_name} PRIVATE ${libraries} ${testsuite_library})
|
||||
|
||||
set(test_runner_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}.mm)
|
||||
configure_file(${CORRADE_TESTSUITE_XCTEST_RUNNER}
|
||||
${test_runner_file})
|
||||
xctest_add_bundle(${test_name}Runner ${test_name} ${test_runner_file})
|
||||
if(CORRADE_TARGET_IOS)
|
||||
# The EFFECTIVE_PLATFORM_NAME variable is not expanded when using
|
||||
# TARGET_* generator expressions on iOS, we need to hardcode it
|
||||
# manually. See https://cmake.org/pipermail/cmake/2016-March/063049.html
|
||||
# In case we redirect the runtime output directory, use that (and
|
||||
# assume there's no TARGET_* generator expression). This will of
|
||||
# course break when someone sets the LIBRARY_OUTPUT_DIRECTORY
|
||||
# property of the target, but that didn't work before either.
|
||||
if(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
add_test(NAME ${test_name} COMMAND ${XCTest_EXECUTABLE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${test_name}Runner.xctest)
|
||||
else()
|
||||
add_test(NAME ${test_name} COMMAND ${XCTest_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>${_CORRADE_EFFECTIVE_PLATFORM_NAME}/${test_name}Runner.xctest)
|
||||
endif()
|
||||
else()
|
||||
xctest_add_test(${test_name} ${test_name}Runner)
|
||||
endif()
|
||||
if(arguments)
|
||||
message(WARNING "corrade_add_test() ARGUMENTS are not supported when CORRADE_TESTSUITE_TARGET_XCTEST is enabled")
|
||||
endif()
|
||||
else()
|
||||
add_executable(${test_name} ${EXCLUDE_FROM_ALL_IF_TEST_TARGET} ${sources})
|
||||
target_link_libraries(${test_name} PRIVATE ${libraries} ${testsuite_library} Corrade::Main)
|
||||
|
||||
# Run tests using Node.js on Emscripten
|
||||
if(CORRADE_TARGET_EMSCRIPTEN)
|
||||
# Emscripten needs to have exceptions enabled for TestSuite to work
|
||||
# properly. See TestSuite CMakeLists for further information.
|
||||
# TODO do directly on the TestSuite target and in FindCorrade via
|
||||
# INTERFACE_COMPILE_OPTIONS and INTERFACE_LINK_OPTIONS and SHELL:
|
||||
# once we require CMake 3.13 unconditionally
|
||||
set_property(TARGET ${test_name} APPEND_STRING PROPERTY COMPILE_FLAGS " -s DISABLE_EXCEPTION_CATCHING=0")
|
||||
set_property(TARGET ${test_name} APPEND_STRING PROPERTY LINK_FLAGS " -s DISABLE_EXCEPTION_CATCHING=0")
|
||||
# FindNodeJs is installed to a subdirectory next to UseCorrade, to
|
||||
# prevent it from being in CMAKE_MODULE_PATH always and clashing
|
||||
# with modules of the same name from elsewhere. Add it to the
|
||||
# CMAKE_MODULE_PATH just locally for this function. If the variable
|
||||
# is not defined, we're running from within Corrade's own sources
|
||||
# (and FindNodeJs is thus in CMAKE_MODULE_PATH already) or an old
|
||||
# FindCorrade may be used, in which case we assume the user
|
||||
# supplies it in a different way.
|
||||
if(CORRADE_DEPENDENCY_MODULE_DIR)
|
||||
set(CMAKE_MODULE_PATH "${CORRADE_DEPENDENCY_MODULE_DIR}" ${CMAKE_MODULE_PATH})
|
||||
endif()
|
||||
find_package(NodeJs REQUIRED)
|
||||
# Node.js before version 17 needs --experimental-wasm-simd. Version
|
||||
# 17 upgraded to V8 9.1, which has the option enabled by default:
|
||||
# https://github.com/nodejs/node/commit/a7cbf19a82c75e9a65e90fb8ba4947e2fc52ef39
|
||||
# Since the code defining these flags explicitly says "remove once
|
||||
# they hit stable":
|
||||
# https://github.com/v8/v8/blob/ba8ad5dd17ea85c856c09c2ff603641487d1f0ca/src/wasm/wasm-feature-flags.h#L101-L109
|
||||
# even though it causes numerous issues such as:
|
||||
# https://github.com/nodejs/node/issues/43592
|
||||
# Not setting it for version 17+, the flag is removed in version
|
||||
# 20. From the other side, the flag goes back to ancient version 6
|
||||
# (2017), so it should be no problem to just pass it there always:
|
||||
# https://github.com/v8/v8/commit/45618a9ab5cc98a5de200b0116670e8c272f0c5f
|
||||
if(NodeJs_VERSION VERSION_LESS 17)
|
||||
set(extra_flags --experimental-wasm-simd)
|
||||
# Node.js 18 doesn't work with Emscripten before 3.1.13 unless the
|
||||
# fetch functionality is disabled.
|
||||
# https://github.com/emscripten-core/emscripten/pull/16917
|
||||
# https://github.com/emscripten-core/emscripten/issues/16915
|
||||
elseif(NodeJs_VERSION VERSION_GREATER_EQUAL 18.1.0 AND EMSCRIPTEN_VERSION VERSION_LESS 3.1.13)
|
||||
set(extra_flags --no-experimental-fetch)
|
||||
else()
|
||||
set(extra_flags )
|
||||
endif()
|
||||
# Using NodeJs::NodeJs works only if CMAKE_CROSSCOMPILING_EMULATOR
|
||||
# isn't set, as otherwise CMake mistakenly understands it as a
|
||||
# project-local target that needs to be emulated (even though it's
|
||||
# an IMPORTED target!), ultimately calling something like
|
||||
# /usr/bin/node /usr/bin/node <test>
|
||||
# This is likely a CMake bug, where it doesn't correctly check that
|
||||
# the target is imported before prepending the emulator. Using the
|
||||
# actual filename stops CMAKE_CROSSCOMPILING_EMULATOR from being
|
||||
# added second time.
|
||||
# TODO Use https://cmake.org/cmake/help/latest/prop_tgt/TEST_LAUNCHER.html
|
||||
# since 3.29 to deduplicate the add_test() invocations for
|
||||
# Emscripten/Android
|
||||
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:NodeJs::NodeJs> ${extra_flags} $<TARGET_FILE:${test_name}> ${arguments})
|
||||
|
||||
# Embed all files
|
||||
foreach(file ${files})
|
||||
string(REGEX REPLACE ${_corrade_file_pair_match} "${_corrade_file_pair_replace}" file_pair ${file})
|
||||
list(GET file_pair 0 input_filename)
|
||||
list(GET file_pair 1 output_filename)
|
||||
|
||||
# This is a verbatim copy of emscripten_embed_file() from
|
||||
# UseEmscripten inside the toolchains submodule. It's not
|
||||
# included in order to avoid a dependency on the toolchains and
|
||||
# thus allow 3rd party toolchains to be used instead.
|
||||
get_filename_component(absolute_file ${input_filename} ABSOLUTE)
|
||||
get_target_property(${test_name}_LINK_FLAGS ${test_name} LINK_FLAGS)
|
||||
if(NOT ${test_name}_LINK_FLAGS)
|
||||
set(${test_name}_LINK_FLAGS )
|
||||
endif()
|
||||
set_target_properties(${test_name} PROPERTIES LINK_FLAGS "${${test_name}_LINK_FLAGS} --embed-file ${absolute_file}@/${output_filename}")
|
||||
# TODO according to CMake docs, this only works with Makefile
|
||||
# and Ninja generators, not for example VS or Xcode. Which
|
||||
# should be mostly fine I guess?
|
||||
set_property(TARGET ${test_name} APPEND PROPERTY LINK_DEPENDS ${input_filename})
|
||||
endforeach()
|
||||
|
||||
# Generate the runner file, first replacing ${test_name} with
|
||||
# configure_file() and then copying that into the final location.
|
||||
# Two steps because file(GENERATE) can't replace variables while
|
||||
# configure_file() can't have generator expressions in the path.
|
||||
configure_file(${CORRADE_TESTSUITE_EMSCRIPTEN_RUNNER}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${test_name}.html)
|
||||
file(GENERATE OUTPUT $<TARGET_FILE_DIR:${test_name}>/${test_name}.html
|
||||
INPUT ${CMAKE_CURRENT_BINARY_DIR}/${test_name}.html)
|
||||
|
||||
# Run tests using ADB on Android
|
||||
elseif(CORRADE_TARGET_ANDROID)
|
||||
# The executables need to be PIE
|
||||
target_compile_options(${test_name} PRIVATE "-fPIE")
|
||||
set_property(TARGET ${test_name} APPEND_STRING PROPERTY LINK_FLAGS "-fPIE -pie")
|
||||
# All files will be copied to the target when the test is run. The
|
||||
# arguments are passed together with the filename, at the moment it
|
||||
# will fail for arguments with spaces
|
||||
string(REPLACE ";" " " arguments_str "${arguments}")
|
||||
# TODO Use https://cmake.org/cmake/help/latest/prop_tgt/TEST_LAUNCHER.html
|
||||
# since 3.29 to deduplicate the add_test() invocations for
|
||||
# Emscripten/Android
|
||||
add_test(NAME ${test_name} COMMAND ${CORRADE_TESTSUITE_ADB_RUNNER} $<TARGET_FILE_DIR:${test_name}> "$<TARGET_FILE_NAME:${test_name}> ${arguments_str}" ${files})
|
||||
|
||||
# Run tests natively elsewhere
|
||||
else()
|
||||
add_test(NAME ${test_name} COMMAND ${test_name} ${arguments})
|
||||
endif()
|
||||
|
||||
# iOS-specific
|
||||
if(CORRADE_TARGET_IOS)
|
||||
set_target_properties(${test_name} PROPERTIES
|
||||
MACOSX_BUNDLE ON
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER ${CORRADE_TESTSUITE_BUNDLE_IDENTIFIER_PREFIX}.${test_name}
|
||||
XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "YES")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# If a custom test target is used instead of ALL, add the test as a
|
||||
# dependency of it so they can still be all built with a single command.
|
||||
if(CORRADE_TESTSUITE_TEST_TARGET)
|
||||
if(CORRADE_TESTSUITE_TARGET_XCTEST)
|
||||
add_dependencies(${CORRADE_TESTSUITE_TEST_TARGET} ${test_name}Runner)
|
||||
else()
|
||||
add_dependencies(${CORRADE_TESTSUITE_TEST_TARGET} ${test_name})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${test_name} APPEND PROPERTY COMPILE_OPTIONS "$<$<BOOL:$<TARGET_PROPERTY:CORRADE_USE_PEDANTIC_FLAGS>>:${CORRADE_PEDANTIC_TEST_COMPILER_OPTIONS}>")
|
||||
|
||||
# Add the file to list of required files for given test case
|
||||
set_tests_properties(${test_name} PROPERTIES REQUIRED_FILES "${absolute_files}")
|
||||
endfunction()
|
||||
|
||||
function(corrade_add_resource name input)
|
||||
foreach(arg ${ARGN})
|
||||
if(arg STREQUAL SINGLE)
|
||||
set(single_file --single)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# See _CORRADE_USE_NO_TARGET_CHECKS in Corrade's root CMakeLists
|
||||
if(NOT _CORRADE_USE_NO_TARGET_CHECKS AND NOT TARGET Corrade::rc)
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
message(FATAL_ERROR "The Corrade::rc target, needed by corrade_add_resource() and corrade_add_static_plugin(), doesn't exist. Either build a native version, make it available through PATH or pass its location to CMake using the CORRADE_RC_EXECUTABLE option, or specify CMAKE_CROSSCOMPILING_EMULATOR to have Corrade run a cross-compiled executable instead, and add the Utility / rc component to your find_package(Corrade).")
|
||||
else()
|
||||
message(FATAL_ERROR "The Corrade::rc target, needed by corrade_add_resource() and corrade_add_static_plugin(), doesn't exist. Add the Utility / rc component to your find_package(Corrade) or enable CORRADE_WITH_UTILITY / CORRADE_WITH_RC if you have Corrade as a CMake subproject.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Parse dependencies from the file, unless it's a single file
|
||||
if(NOT single_file)
|
||||
set(dependencies )
|
||||
set(filenameRegex "^[ \t]*filename[ \t]*=(.+)$")
|
||||
get_filename_component(configurationFilePath ${input} PATH)
|
||||
|
||||
file(STRINGS "${input}" filenames REGEX ${filenameRegex} ENCODING UTF-8)
|
||||
foreach(filename ${filenames})
|
||||
# Get the filename together with leading/trailing whitespace and quotes
|
||||
# from the file line
|
||||
string(REGEX REPLACE ${filenameRegex} "\\1" filename "${filename}")
|
||||
# Strip leading/trailing whitespace
|
||||
string(STRIP "${filename}" filename)
|
||||
# If it's quoted (for example because the filename itself has spaces),
|
||||
# remove the quotes
|
||||
string(REGEX REPLACE "^\"([^\"]+)\"$" "\\1" filename "${filename}")
|
||||
if(NOT IS_ABSOLUTE "${filename}" AND configurationFilePath)
|
||||
set(filename "${configurationFilePath}/${filename}")
|
||||
endif()
|
||||
list(APPEND dependencies "${filename}")
|
||||
endforeach()
|
||||
|
||||
# Force IDEs display also the resource files in project view
|
||||
add_custom_target(${name}-dependencies SOURCES ${dependencies})
|
||||
list(APPEND dependencies ${name}-dependencies)
|
||||
endif()
|
||||
|
||||
# Output file name
|
||||
set(out "${CMAKE_CURRENT_BINARY_DIR}/resource_${name}.cpp")
|
||||
|
||||
# Tell CMake to re-run and update the dependency list when the resource
|
||||
# list file changes (otherwise it parses the file only during the explicit
|
||||
# configure step and never again, thus additions/deletions are not
|
||||
# recognized automatically)
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${input})
|
||||
|
||||
# Run command. If a non-native Corrade::rc was found and needs to be run
|
||||
# through an emulator, we need to pass the actual executable path to it,
|
||||
# not just the target.
|
||||
if(CORRADE_RC_EXECUTABLE_EMULATOR)
|
||||
set(command ${CORRADE_RC_EXECUTABLE_EMULATOR} $<TARGET_FILE:Corrade::rc>)
|
||||
else()
|
||||
set(command Corrade::rc)
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT "${out}"
|
||||
COMMAND ${command} ${single_file} ${name} "${input}" "${out}"
|
||||
DEPENDS Corrade::rc ${input} ${dependencies}
|
||||
COMMENT "Compiling data resource file ${out}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
# Save output filename
|
||||
set(${name} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(corrade_add_plugin plugin_name debug_install_dirs release_install_dirs metadata_file)
|
||||
# See _CORRADE_USE_NO_TARGET_CHECKS in Corrade's root CMakeLists
|
||||
if(NOT _CORRADE_USE_NO_TARGET_CHECKS AND NOT TARGET Corrade::PluginManager)
|
||||
message(FATAL_ERROR "The Corrade::PluginManager target, needed by corrade_add_plugin(), doesn't exist. Add the PluginManager component to your find_package() or enable CORRADE_WITH_PLUGINMANAGER if you have Corrade as a CMake subproject.")
|
||||
endif()
|
||||
|
||||
if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_WINDOWS_RT OR CORRADE_TARGET_IOS)
|
||||
message(SEND_ERROR "corrade_add_plugin(): dynamic plugins are not available on this platform, use corrade_add_static_plugin() instead")
|
||||
endif()
|
||||
|
||||
# Populate {debug,release}_{binary,library,conf}_install_dir variables
|
||||
if(NOT debug_install_dirs STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
list(LENGTH debug_install_dirs debug_install_dir_count)
|
||||
list(LENGTH release_install_dirs release_install_dir_count)
|
||||
if(NOT debug_install_dir_count EQUAL release_install_dir_count)
|
||||
message(FATAL_ERROR "corrade_add_plugin(): either none or both install dirs must contain binary location")
|
||||
elseif(debug_install_dir_count EQUAL 1)
|
||||
set(debug_binary_install_dir ${debug_install_dirs})
|
||||
set(debug_library_install_dir ${debug_install_dirs})
|
||||
set(release_binary_install_dir ${release_install_dirs})
|
||||
set(release_library_install_dir ${release_install_dirs})
|
||||
elseif(debug_install_dir_count EQUAL 2)
|
||||
list(GET debug_install_dirs 0 debug_binary_install_dir)
|
||||
list(GET debug_install_dirs 1 debug_library_install_dir)
|
||||
list(GET release_install_dirs 0 release_binary_install_dir)
|
||||
list(GET release_install_dirs 1 release_library_install_dir)
|
||||
else()
|
||||
message(FATAL_ERROR "corrade_add_plugin(): install dirs must contain either just library location or both binary and library location")
|
||||
endif()
|
||||
|
||||
if(CORRADE_TARGET_WINDOWS)
|
||||
set(debug_conf_install_dir ${debug_binary_install_dir})
|
||||
set(release_conf_install_dir ${release_binary_install_dir})
|
||||
else()
|
||||
set(debug_conf_install_dir ${debug_library_install_dir})
|
||||
set(release_conf_install_dir ${release_library_install_dir})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Create dynamic library and bring all needed options along. On Windows a
|
||||
# DLL cannot have undefined references, so we need to link against all its
|
||||
# dependencies *at compile time*, as opposed to runtime like in all sane
|
||||
# systems. But when using add_library(MODULE), CMake disallows linking
|
||||
# MODULEs to MODULEs (when dealing with inter-plugin dependencies, for
|
||||
# example) -- probably because, on Windows, creating a MODULE doesn't
|
||||
# create the corresponding import lib for it. So we work around that by
|
||||
# using SHARED on Windows.
|
||||
if(CORRADE_TARGET_WINDOWS)
|
||||
add_library(${plugin_name} SHARED ${ARGN})
|
||||
else()
|
||||
add_library(${plugin_name} MODULE ${ARGN})
|
||||
endif()
|
||||
set_target_properties(${plugin_name} PROPERTIES CORRADE_CXX_STANDARD 11)
|
||||
target_compile_definitions(${plugin_name} PRIVATE "CORRADE_DYNAMIC_PLUGIN")
|
||||
target_include_directories(${plugin_name} PUBLIC $<TARGET_PROPERTY:Corrade::PluginManager,INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
|
||||
# Plugins don't have any prefix (e.g. 'lib' on Linux)
|
||||
set_target_properties(${plugin_name} PROPERTIES PREFIX "")
|
||||
|
||||
# On Apple platforms, it's by default not allowed to have plugins with
|
||||
# undefined (i.e., runtime-resolved) symbols. This flag enables them,
|
||||
# however when targeting macOS 12+ / iOS 15+, it produces
|
||||
# ld: warning: -undefined dynamic_lookup may not work with chained fixups
|
||||
# One solution would be to use the Windows-specific codepath on Apple as
|
||||
# well, i.e. explicitly linking all dependencies, but that's just horrible.
|
||||
# TODO Python has the same issue, so far (2024-11-11) with no solution yet,
|
||||
# retry when they do: https://github.com/python/cpython/issues/97524
|
||||
if(CORRADE_TARGET_APPLE)
|
||||
set_target_properties(${plugin_name} PROPERTIES
|
||||
LINK_FLAGS "-undefined dynamic_lookup")
|
||||
endif()
|
||||
|
||||
if(metadata_file)
|
||||
get_filename_component(metadata_file_suffix ${metadata_file} EXT)
|
||||
# Force IDEs display also the resource files in project view
|
||||
add_custom_target(${plugin_name}-metadata SOURCES ${metadata_file})
|
||||
|
||||
# Copy metadata next to the binary so tests and CMake subprojects can
|
||||
# use it as well.
|
||||
# TODO Ideally this would be done not just when the plugin is rebuilt,
|
||||
# but also when the metadata file changes. Not sure how to do that,
|
||||
# add_custom_command(TARGET) doesn't support the DEPENDS option.
|
||||
add_custom_command(TARGET ${plugin_name} POST_BUILD
|
||||
# This would be nice to Ninja, but BYPRODUCTS don't support generator
|
||||
# expressions right now (last checked: CMake 3.16)
|
||||
#BYPRODUCTS $<TARGET_FILE_DIR:${plugin_name}>/${plugin_name}${metadata_file_suffix}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${metadata_file} $<TARGET_FILE_DIR:${plugin_name}>/${plugin_name}${metadata_file_suffix}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
# Install it somewhere, unless that's explicitly not wanted
|
||||
if(NOT debug_install_dirs STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
# CONFIGURATIONS must be first in order to not be ignored when having
|
||||
# multiple destinations.
|
||||
# https://gitlab.kitware.com/cmake/cmake/issues/16361
|
||||
install(TARGETS ${plugin_name}
|
||||
CONFIGURATIONS Debug
|
||||
RUNTIME DESTINATION ${debug_binary_install_dir}
|
||||
LIBRARY DESTINATION ${debug_library_install_dir}
|
||||
ARCHIVE DESTINATION ${debug_library_install_dir})
|
||||
install(TARGETS ${plugin_name}
|
||||
CONFIGURATIONS "" None Release RelWithDebInfo MinSizeRel
|
||||
RUNTIME DESTINATION ${release_binary_install_dir}
|
||||
LIBRARY DESTINATION ${release_library_install_dir}
|
||||
ARCHIVE DESTINATION ${release_library_install_dir})
|
||||
if(metadata_file)
|
||||
install(FILES ${metadata_file} DESTINATION ${debug_conf_install_dir}
|
||||
RENAME "${plugin_name}${metadata_file_suffix}"
|
||||
CONFIGURATIONS Debug)
|
||||
install(FILES ${metadata_file} DESTINATION ${release_conf_install_dir}
|
||||
RENAME "${plugin_name}${metadata_file_suffix}"
|
||||
CONFIGURATIONS "" None Release RelWithDebInfo MinSizeRel)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(corrade_add_static_plugin plugin_name install_dirs metadata_file)
|
||||
# See _CORRADE_USE_NO_TARGET_CHECKS in Corrade's root CMakeLists
|
||||
if(NOT _CORRADE_USE_NO_TARGET_CHECKS AND NOT TARGET Corrade::PluginManager)
|
||||
message(FATAL_ERROR "The Corrade::PluginManager target, needed by corrade_add_static_plugin(), doesn't exist. Add the PluginManager component to your find_package() or enable CORRADE_WITH_PLUGINMANAGER if you have Corrade as a CMake subproject.")
|
||||
endif()
|
||||
|
||||
# Populate library_install_dir variable
|
||||
list(LENGTH install_dirs install_dir_count)
|
||||
if(install_dir_count EQUAL 1)
|
||||
set(library_install_dir ${install_dirs})
|
||||
elseif(install_dir_count EQUAL 2)
|
||||
list(GET install_dirs 1 library_install_dir)
|
||||
else()
|
||||
message(FATAL_ERROR "corrade_add_static_plugin(): install dir must contain either just library location or both library and binary location")
|
||||
endif()
|
||||
|
||||
# Compile resources. If the metadata file is disabled, the resource is
|
||||
# empty. If a non-native Corrade::rc was found and needs to be run through
|
||||
# an emulator, we need to pass the actual executable path to it, not just
|
||||
# the target.
|
||||
if(CORRADE_RC_EXECUTABLE_EMULATOR)
|
||||
set(command ${CORRADE_RC_EXECUTABLE_EMULATOR} $<TARGET_FILE:Corrade::rc>)
|
||||
else()
|
||||
set(command Corrade::rc)
|
||||
endif()
|
||||
set(resource_out ${CMAKE_CURRENT_BINARY_DIR}/resource_${plugin_name}.cpp)
|
||||
if(metadata_file)
|
||||
add_custom_command(
|
||||
OUTPUT ${resource_out}
|
||||
COMMAND ${command} ${plugin_name} --single ${metadata_file} ${resource_out}
|
||||
DEPENDS Corrade::rc ${metadata_file}
|
||||
COMMENT "Compiling static plugin metadata file ${resource_out}"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
else()
|
||||
set(metadata_file ${CMAKE_CURRENT_BINARY_DIR}/${plugin_name}-empty.conf)
|
||||
add_custom_command(
|
||||
OUTPUT ${resource_out}
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${metadata_file}
|
||||
COMMAND ${command} ${plugin_name} --single ${metadata_file} ${resource_out}
|
||||
DEPENDS Corrade::rc
|
||||
COMMENT "Compiling static plugin metadata file ${resource_out}"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
# Create static library and bring all needed options along
|
||||
add_library(${plugin_name} STATIC ${ARGN} ${resource_out})
|
||||
set_target_properties(${plugin_name} PROPERTIES CORRADE_CXX_STANDARD 11)
|
||||
target_compile_definitions(${plugin_name} PRIVATE "CORRADE_STATIC_PLUGIN")
|
||||
target_include_directories(${plugin_name} PUBLIC $<TARGET_PROPERTY:Corrade::PluginManager,INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
|
||||
set_target_properties(${plugin_name} PROPERTIES DEBUG_POSTFIX "-d")
|
||||
|
||||
# Install, if not into the same place
|
||||
if(NOT install_dirs STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
install(TARGETS ${plugin_name} DESTINATION ${library_install_dir})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(CORRADE_TARGET_WINDOWS)
|
||||
function(corrade_find_dlls_for_libs result)
|
||||
set(dlls )
|
||||
foreach(lib ${ARGN})
|
||||
get_filename_component(lib_dir ${lib} DIRECTORY)
|
||||
get_filename_component(lib_name ${lib} NAME_WE)
|
||||
find_file(CORRADE_DLL_FOR_${lib_name} ${lib_name}.dll HINTS ${lib_dir}/../bin)
|
||||
list(APPEND dlls ${CORRADE_DLL_FOR_${lib_name}})
|
||||
endforeach()
|
||||
set(${result} ${dlls} PARENT_SCOPE)
|
||||
endfunction()
|
||||
endif()
|
||||
|
||||
set(_CORRADE_USE_INCLUDED TRUE)
|
||||
Reference in New Issue
Block a user