mirror of https://github.com/mosra/magnum.git
52 changed files with 594 additions and 5 deletions
@ -0,0 +1,80 @@ |
|||||||
|
/*
|
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||||
|
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 "AnySceneConverter.h" |
||||||
|
|
||||||
|
#include <Corrade/PluginManager/Manager.h> |
||||||
|
#include <Corrade/Utility/Assert.h> |
||||||
|
#include <Corrade/Utility/DebugStl.h> |
||||||
|
#include <Corrade/Utility/String.h> |
||||||
|
|
||||||
|
#include "Magnum/Trade/ImageData.h" |
||||||
|
|
||||||
|
namespace Magnum { namespace Trade { |
||||||
|
|
||||||
|
AnySceneConverter::AnySceneConverter(PluginManager::Manager<AbstractSceneConverter>& manager): AbstractSceneConverter{manager} {} |
||||||
|
|
||||||
|
AnySceneConverter::AnySceneConverter(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractSceneConverter{manager, plugin} {} |
||||||
|
|
||||||
|
AnySceneConverter::~AnySceneConverter() = default; |
||||||
|
|
||||||
|
SceneConverterFeatures AnySceneConverter::doFeatures() const { |
||||||
|
return SceneConverterFeature::ConvertMeshToFile; |
||||||
|
} |
||||||
|
|
||||||
|
bool AnySceneConverter::doConvertToFile(const std::string& filename, const MeshData& mesh) { |
||||||
|
CORRADE_INTERNAL_ASSERT(manager()); |
||||||
|
|
||||||
|
/** @todo lowercase only the extension, once Directory::split() is done */ |
||||||
|
const std::string normalized = Utility::String::lowercase(filename); |
||||||
|
|
||||||
|
/* Detect the plugin from extension */ |
||||||
|
std::string plugin; |
||||||
|
if(Utility::String::endsWith(normalized, ".blob")) |
||||||
|
plugin = "MagnumSceneConverter"; |
||||||
|
else { |
||||||
|
Error{} << "Trade::AnySceneConverter::convertToFile(): cannot determine the format of" << filename; |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
/* Try to load the plugin */ |
||||||
|
if(!(manager()->load(plugin) & PluginManager::LoadState::Loaded)) { |
||||||
|
Error{} << "Trade::AnySceneConverter::convertToFile(): cannot load the" << plugin << "plugin"; |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
/* Instantiate the plugin, propagate flags */ |
||||||
|
Containers::Pointer<AbstractSceneConverter> converter = static_cast<PluginManager::Manager<AbstractSceneConverter>*>(manager())->instantiate(plugin); |
||||||
|
converter->setFlags(flags()); |
||||||
|
|
||||||
|
/* Try to convert the file (error output should be printed by the plugin
|
||||||
|
itself) */ |
||||||
|
return converter->convertToFile(filename, mesh); |
||||||
|
} |
||||||
|
|
||||||
|
}} |
||||||
|
|
||||||
|
CORRADE_PLUGIN_REGISTER(AnySceneConverter, Magnum::Trade::AnySceneConverter, |
||||||
|
"cz.mosra.magnum.Trade.AbstractSceneConverter/0.1") |
||||||
@ -0,0 +1,111 @@ |
|||||||
|
#ifndef Magnum_Trade_AnySceneConverter_h |
||||||
|
#define Magnum_Trade_AnySceneConverter_h |
||||||
|
/*
|
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||||
|
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. |
||||||
|
*/ |
||||||
|
|
||||||
|
/** @file
|
||||||
|
* @brief Class @ref Magnum::Trade::AnySceneConverter |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "Magnum/Trade/AbstractSceneConverter.h" |
||||||
|
#include "MagnumPlugins/AnySceneConverter/configure.h" |
||||||
|
|
||||||
|
#ifndef DOXYGEN_GENERATING_OUTPUT |
||||||
|
#ifndef MAGNUM_ANYSCENECONVERTER_BUILD_STATIC |
||||||
|
#ifdef AnySceneConverter_EXPORTS |
||||||
|
#define MAGNUM_ANYSCENECONVERTER_EXPORT CORRADE_VISIBILITY_EXPORT |
||||||
|
#else |
||||||
|
#define MAGNUM_ANYSCENECONVERTER_EXPORT CORRADE_VISIBILITY_IMPORT |
||||||
|
#endif |
||||||
|
#else |
||||||
|
#define MAGNUM_ANYSCENECONVERTER_EXPORT CORRADE_VISIBILITY_STATIC |
||||||
|
#endif |
||||||
|
#define MAGNUM_ANYSCENECONVERTER_LOCAL CORRADE_VISIBILITY_LOCAL |
||||||
|
#else |
||||||
|
#define MAGNUM_ANYSCENECONVERTER_EXPORT |
||||||
|
#define MAGNUM_ANYSCENECONVERTER_LOCAL |
||||||
|
#endif |
||||||
|
|
||||||
|
namespace Magnum { namespace Trade { |
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Any scene converter plugin |
||||||
|
|
||||||
|
Detects file type based on file extension, loads corresponding plugin and then |
||||||
|
tries to convert the file with it. Supported formats: |
||||||
|
|
||||||
|
- @ref blob "Magnum's memory-mappable serialization format" (`*.blob`), |
||||||
|
converted with @ref MagnumSceneConverter |
||||||
|
|
||||||
|
Only converting to files is supported. |
||||||
|
|
||||||
|
@section Trade-AnySceneConverter-usage Usage |
||||||
|
|
||||||
|
This plugin depends on the @ref Trade library and is built if |
||||||
|
`WITH_ANYSCENECONVERTER` is enabled when building Magnum. To use as a dynamic |
||||||
|
plugin, load @cpp "AnySceneConverter" @ce via |
||||||
|
@ref Corrade::PluginManager::Manager. |
||||||
|
|
||||||
|
Additionally, if you're using Magnum as a CMake subproject, do the following: |
||||||
|
|
||||||
|
@code{.cmake} |
||||||
|
set(WITH_ANYSCENECONVERTER ON CACHE BOOL "" FORCE) |
||||||
|
add_subdirectory(magnum EXCLUDE_FROM_ALL) |
||||||
|
|
||||||
|
# So the dynamically loaded plugin gets built implicitly |
||||||
|
add_dependencies(your-app Magnum::AnySceneConverter) |
||||||
|
@endcode |
||||||
|
|
||||||
|
To use as a static plugin or as a dependency of another plugin with CMake, you |
||||||
|
need to request the `AnySceneConverter` component of the `Magnum` package and |
||||||
|
link to the `Magnum::AnySceneConverter` target: |
||||||
|
|
||||||
|
@code{.cmake} |
||||||
|
find_package(Magnum REQUIRED AnySceneConverter) |
||||||
|
|
||||||
|
# ... |
||||||
|
target_link_libraries(your-app PRIVATE Magnum::AnySceneConverter) |
||||||
|
@endcode |
||||||
|
|
||||||
|
See @ref building, @ref cmake and @ref plugins for more information. |
||||||
|
*/ |
||||||
|
class MAGNUM_ANYSCENECONVERTER_EXPORT AnySceneConverter: public AbstractSceneConverter { |
||||||
|
public: |
||||||
|
/** @brief Constructor with access to plugin manager */ |
||||||
|
explicit AnySceneConverter(PluginManager::Manager<AbstractSceneConverter>& manager); |
||||||
|
|
||||||
|
/** @brief Plugin manager constructor */ |
||||||
|
explicit AnySceneConverter(PluginManager::AbstractManager& manager, const std::string& plugin); |
||||||
|
|
||||||
|
~AnySceneConverter(); |
||||||
|
|
||||||
|
private: |
||||||
|
MAGNUM_ANYSCENECONVERTER_LOCAL SceneConverterFeatures doFeatures() const override; |
||||||
|
MAGNUM_ANYSCENECONVERTER_LOCAL bool doConvertToFile(const std::string& filename, const MeshData& mesh) override; |
||||||
|
}; |
||||||
|
|
||||||
|
}} |
||||||
|
|
||||||
|
#endif |
||||||
@ -0,0 +1,68 @@ |
|||||||
|
# |
||||||
|
# This file is part of Magnum. |
||||||
|
# |
||||||
|
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||||
|
# 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_package(Corrade REQUIRED PluginManager) |
||||||
|
|
||||||
|
if(BUILD_PLUGINS_STATIC) |
||||||
|
set(MAGNUM_ANYSCENECONVERTER_BUILD_STATIC 1) |
||||||
|
endif() |
||||||
|
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake |
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/configure.h) |
||||||
|
|
||||||
|
# AnySceneConverter plugin |
||||||
|
add_plugin(AnySceneConverter |
||||||
|
"${MAGNUM_PLUGINS_SCENECONVERTER_DEBUG_BINARY_INSTALL_DIR};${MAGNUM_PLUGINS_SCENECONVERTER_DEBUG_LIBRARY_INSTALL_DIR}" |
||||||
|
"${MAGNUM_PLUGINS_SCENECONVERTER_RELEASE_BINARY_INSTALL_DIR};${MAGNUM_PLUGINS_SCENECONVERTER_RELEASE_LIBRARY_INSTALL_DIR}" |
||||||
|
AnySceneConverter.conf |
||||||
|
AnySceneConverter.cpp |
||||||
|
AnySceneConverter.h) |
||||||
|
if(BUILD_PLUGINS_STATIC AND BUILD_STATIC_PIC) |
||||||
|
set_target_properties(AnySceneConverter PROPERTIES POSITION_INDEPENDENT_CODE ON) |
||||||
|
endif() |
||||||
|
target_link_libraries(AnySceneConverter PUBLIC MagnumTrade) |
||||||
|
# Modify output location only if all are set, otherwise it makes no sense |
||||||
|
if(CMAKE_RUNTIME_OUTPUT_DIRECTORY AND CMAKE_LIBRARY_OUTPUT_DIRECTORY AND CMAKE_ARCHIVE_OUTPUT_DIRECTORY) |
||||||
|
set_target_properties(AnySceneConverter PROPERTIES |
||||||
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/magnum$<$<CONFIG:Debug>:-d>/imageconverters |
||||||
|
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/magnum$<$<CONFIG:Debug>:-d>/imageconverters |
||||||
|
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/magnum$<$<CONFIG:Debug>:-d>/imageconverters) |
||||||
|
endif() |
||||||
|
|
||||||
|
install(FILES AnySceneConverter.h ${CMAKE_CURRENT_BINARY_DIR}/configure.h |
||||||
|
DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/AnySceneConverter) |
||||||
|
|
||||||
|
# Automatic static plugin import |
||||||
|
if(BUILD_PLUGINS_STATIC) |
||||||
|
install(FILES importStaticPlugin.cpp DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/AnySceneConverter) |
||||||
|
target_sources(AnySceneConverter INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/importStaticPlugin.cpp) |
||||||
|
endif() |
||||||
|
|
||||||
|
if(BUILD_TESTS) |
||||||
|
add_subdirectory(Test) |
||||||
|
endif() |
||||||
|
|
||||||
|
# Magnum AnySceneConverter target alias for superprojects |
||||||
|
add_library(Magnum::AnySceneConverter ALIAS AnySceneConverter) |
||||||
@ -0,0 +1,121 @@ |
|||||||
|
/*
|
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||||
|
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 <sstream> |
||||||
|
#include <Corrade/PluginManager/Manager.h> |
||||||
|
#include <Corrade/TestSuite/Tester.h> |
||||||
|
#include <Corrade/Utility/Directory.h> |
||||||
|
#include <Corrade/Utility/DebugStl.h> |
||||||
|
#include <Corrade/Utility/FormatStl.h> |
||||||
|
|
||||||
|
#include "Magnum/Trade/AbstractSceneConverter.h" |
||||||
|
#include "Magnum/Trade/MeshData.h" |
||||||
|
|
||||||
|
#include "configure.h" |
||||||
|
|
||||||
|
namespace Magnum { namespace Trade { namespace Test { namespace { |
||||||
|
|
||||||
|
struct AnySceneConverterTest: TestSuite::Tester { |
||||||
|
explicit AnySceneConverterTest(); |
||||||
|
|
||||||
|
void load(); |
||||||
|
void detect(); |
||||||
|
|
||||||
|
void unknown(); |
||||||
|
|
||||||
|
void propagateFlags(); |
||||||
|
|
||||||
|
/* Explicitly forbid system-wide plugin dependencies */ |
||||||
|
PluginManager::Manager<AbstractSceneConverter> _manager{"nonexistent"}; |
||||||
|
}; |
||||||
|
|
||||||
|
constexpr struct { |
||||||
|
const char* name; |
||||||
|
const char* filename; |
||||||
|
const char* plugin; |
||||||
|
} DetectData[]{ |
||||||
|
{"BLOB", "huge.blob", "MagnumSceneConverter"} |
||||||
|
}; |
||||||
|
|
||||||
|
AnySceneConverterTest::AnySceneConverterTest() { |
||||||
|
addTests({&AnySceneConverterTest::load}); |
||||||
|
|
||||||
|
addInstancedTests({&AnySceneConverterTest::detect}, |
||||||
|
Containers::arraySize(DetectData)); |
||||||
|
|
||||||
|
addTests({&AnySceneConverterTest::unknown, |
||||||
|
|
||||||
|
&AnySceneConverterTest::propagateFlags}); |
||||||
|
|
||||||
|
/* Load the plugin directly from the build tree. Otherwise it's static and
|
||||||
|
already loaded. */ |
||||||
|
#ifdef ANYSCENECONVERTER_PLUGIN_FILENAME |
||||||
|
CORRADE_INTERNAL_ASSERT(_manager.load(ANYSCENECONVERTER_PLUGIN_FILENAME) & PluginManager::LoadState::Loaded); |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Create the output directory if it doesn't exist yet */ |
||||||
|
CORRADE_INTERNAL_ASSERT(Utility::Directory::mkpath(ANYSCENECONVERTER_TEST_DIR)); |
||||||
|
} |
||||||
|
|
||||||
|
void AnySceneConverterTest::load() { |
||||||
|
CORRADE_SKIP("No scene converter plugin available to test."); |
||||||
|
} |
||||||
|
|
||||||
|
void AnySceneConverterTest::detect() { |
||||||
|
auto&& data = DetectData[testCaseInstanceId()]; |
||||||
|
setTestCaseDescription(data.name); |
||||||
|
|
||||||
|
Containers::Pointer<AbstractSceneConverter> converter = _manager.instantiate("AnySceneConverter"); |
||||||
|
|
||||||
|
std::ostringstream out; |
||||||
|
Error redirectError{&out}; |
||||||
|
CORRADE_VERIFY(!converter->convertToFile(data.filename, MeshData{MeshPrimitive::Triangles, 0})); |
||||||
|
/* Can't use raw string literals in macros on GCC 4.8 */ |
||||||
|
#ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT |
||||||
|
CORRADE_COMPARE(out.str(), Utility::formatString( |
||||||
|
"PluginManager::Manager::load(): plugin {0} is not static and was not found in nonexistent\nTrade::AnySceneConverter::convertToFile(): cannot load the {0} plugin\n", data.plugin)); |
||||||
|
#else |
||||||
|
CORRADE_COMPARE(out.str(), Utility::formatString( |
||||||
|
"PluginManager::Manager::load(): plugin {0} was not found\nTrade::AnySceneConverter::convertToFile(): cannot load the {0} plugin\n", data.plugin)); |
||||||
|
#endif |
||||||
|
} |
||||||
|
|
||||||
|
void AnySceneConverterTest::unknown() { |
||||||
|
std::ostringstream output; |
||||||
|
Error redirectError{&output}; |
||||||
|
|
||||||
|
Containers::Pointer<AbstractSceneConverter> converter = _manager.instantiate("AnySceneConverter"); |
||||||
|
CORRADE_VERIFY(!converter->convertToFile("mesh.obj", MeshData{MeshPrimitive::Triangles, 0})); |
||||||
|
|
||||||
|
CORRADE_COMPARE(output.str(), "Trade::AnySceneConverter::convertToFile(): cannot determine the format of mesh.obj\n"); |
||||||
|
} |
||||||
|
|
||||||
|
void AnySceneConverterTest::propagateFlags() { |
||||||
|
CORRADE_SKIP("No plugin with verbose output available to test."); |
||||||
|
} |
||||||
|
|
||||||
|
}}}} |
||||||
|
|
||||||
|
CORRADE_TEST_MAIN(Magnum::Trade::Test::AnySceneConverterTest) |
||||||
@ -0,0 +1,71 @@ |
|||||||
|
# |
||||||
|
# This file is part of Magnum. |
||||||
|
# |
||||||
|
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||||
|
# 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(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID) |
||||||
|
set(ANYSCENECONVERTER_TEST_DIR "write") |
||||||
|
else() |
||||||
|
set(ANYSCENECONVERTER_TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
||||||
|
endif() |
||||||
|
|
||||||
|
# CMake before 3.8 has broken $<TARGET_FILE*> expressions for iOS (see |
||||||
|
# https://gitlab.kitware.com/cmake/cmake/merge_requests/404) and since Corrade |
||||||
|
# doesn't support dynamic plugins on iOS, this sorta works around that. Should |
||||||
|
# be revisited when updating Travis to newer Xcode (xcode7.3 has CMake 3.6). |
||||||
|
if(NOT BUILD_PLUGINS_STATIC) |
||||||
|
set(ANYSCENECONVERTER_PLUGIN_FILENAME $<TARGET_FILE:AnySceneConverter>) |
||||||
|
if(WITH_TGAIMAGECONVERTER) |
||||||
|
set(TGAIMAGECONVERTER_PLUGIN_FILENAME $<TARGET_FILE:TgaImageConverter>) |
||||||
|
endif() |
||||||
|
endif() |
||||||
|
|
||||||
|
# First replace ${} variables, then $<> generator expressions |
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake |
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/configure.h.in) |
||||||
|
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/configure.h |
||||||
|
INPUT ${CMAKE_CURRENT_BINARY_DIR}/configure.h.in) |
||||||
|
|
||||||
|
corrade_add_test(AnySceneConverterTest AnySceneConverterTest.cpp |
||||||
|
LIBRARIES MagnumTrade) |
||||||
|
target_include_directories(AnySceneConverterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>) |
||||||
|
if(BUILD_PLUGINS_STATIC) |
||||||
|
target_link_libraries(AnySceneConverterTest PRIVATE AnySceneConverter) |
||||||
|
if(WITH_TGAIMAGECONVERTER) |
||||||
|
target_link_libraries(AnySceneConverterTest PRIVATE TgaImageConverter) |
||||||
|
endif() |
||||||
|
else() |
||||||
|
# So the plugins get properly built when building the test |
||||||
|
add_dependencies(AnySceneConverterTest AnySceneConverter) |
||||||
|
if(WITH_TGAIMAGECONVERTER) |
||||||
|
add_dependencies(AnySceneConverterTest TgaImageConverter) |
||||||
|
endif() |
||||||
|
endif() |
||||||
|
set_target_properties(AnySceneConverterTest PROPERTIES FOLDER "MagnumPlugins/AnySceneConverter/Test") |
||||||
|
if(CORRADE_BUILD_STATIC AND NOT BUILD_PLUGINS_STATIC) |
||||||
|
# CMake < 3.4 does this implicitly, but 3.4+ not anymore (see CMP0065). |
||||||
|
# That's generally okay, *except if* the build is static, the executable |
||||||
|
# uses a plugin manager and needs to share globals with the plugins (such |
||||||
|
# as output redirection and so on). |
||||||
|
set_target_properties(AnySceneConverterTest PROPERTIES ENABLE_EXPORTS ON) |
||||||
|
endif() |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
/* |
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||||
|
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. |
||||||
|
*/ |
||||||
|
|
||||||
|
#cmakedefine ANYSCENECONVERTER_PLUGIN_FILENAME "${ANYSCENECONVERTER_PLUGIN_FILENAME}" |
||||||
|
#define ANYSCENECONVERTER_TEST_DIR "${ANYSCENECONVERTER_TEST_DIR}" |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
/* |
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||||
|
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. |
||||||
|
*/ |
||||||
|
|
||||||
|
#cmakedefine MAGNUM_ANYSCENECONVERTER_BUILD_STATIC |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
/*
|
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||||
|
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 "MagnumPlugins/AnySceneConverter/configure.h" |
||||||
|
|
||||||
|
#ifdef MAGNUM_ANYSCENECONVERTER_BUILD_STATIC |
||||||
|
#include <Corrade/PluginManager/AbstractManager.h> |
||||||
|
|
||||||
|
static int magnumAnySceneConverterStaticImporter() { |
||||||
|
CORRADE_PLUGIN_IMPORT(AnySceneConverter) |
||||||
|
return 1; |
||||||
|
} CORRADE_AUTOMATIC_INITIALIZER(magnumAnySceneConverterStaticImporter) |
||||||
|
#endif |
||||||
Loading…
Reference in new issue