From 2e5eddc83b28aef6f2be160e08e9f27fc71d3387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 12 Jun 2015 20:52:35 +0200 Subject: [PATCH] MagnumFont, MagnumFontConverter: fix linker errors in tests on Windows. --- src/MagnumPlugins/MagnumFont/CMakeLists.txt | 14 +++++++++++++- .../MagnumFontConverter/CMakeLists.txt | 14 +++++++++++++- .../MagnumFontConverter/Test/CMakeLists.txt | 8 ++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/MagnumPlugins/MagnumFont/CMakeLists.txt b/src/MagnumPlugins/MagnumFont/CMakeLists.txt index e77f1674e..e521c9a3e 100644 --- a/src/MagnumPlugins/MagnumFont/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFont/CMakeLists.txt @@ -54,7 +54,19 @@ endif() install(FILES ${MagnumFont_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/MagnumFont) if(BUILD_GL_TESTS) - add_library(MagnumMagnumFontTestLib STATIC $) + # On Win32 we need to avoid dllimporting TgaImporter symbols, because it + # would search for the symbols in some DLL even when they were linked + # statically. However it apparently doesn't matter that they were + # dllexported when building the static library. EH. + if(WIN32) + add_library(MagnumMagnumFontTestLib STATIC + ${MagnumFont_SRCS} + ${MagnumFont_HEADERS}) + set_target_properties(MagnumMagnumFontTestLib PROPERTIES COMPILE_FLAGS "-DMAGNUM_TGAIMPORTER_BUILD_STATIC") + else() + add_library(MagnumMagnumFontTestLib STATIC $) + endif() target_link_libraries(MagnumMagnumFontTestLib Magnum MagnumText MagnumTgaImporterTestLib) + add_subdirectory(Test) endif() diff --git a/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt b/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt index 0fd471cd2..96d96b681 100644 --- a/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt @@ -54,7 +54,19 @@ endif() install(FILES ${MagnumFontConverter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/MagnumFontConverter) if(BUILD_GL_TESTS) - add_library(MagnumMagnumFontConverterTestLib STATIC $) + # On Win32 we need to avoid dllimporting TgaImageConverter symbols, because + # it would search for the symbols in some DLL even when they were linked + # statically. However it apparently doesn't matter that they were + # dllexported when building the static library. EH. + if(WIN32) + add_library(MagnumMagnumFontConverterTestLib STATIC + ${MagnumFontConverter_SRCS} + ${MagnumFontConverter_HEADERS}) + set_target_properties(MagnumMagnumFontConverterTestLib PROPERTIES COMPILE_FLAGS "-DMAGNUM_TGAIMAGECONVERTER_BUILD_STATIC") + else() + add_library(MagnumMagnumFontConverterTestLib STATIC $) + endif() target_link_libraries(MagnumMagnumFontConverterTestLib Magnum MagnumText MagnumTgaImageConverterTestLib) + add_subdirectory(Test) endif() diff --git a/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt b/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt index 5cebe78fa..6e97d3ad3 100644 --- a/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt @@ -32,3 +32,11 @@ corrade_add_test(MagnumFontConverterGLTest MagnumFontConverterGLTest.cpp LIBRARI MagnumMagnumFontConverterTestLib MagnumTgaImporterTestLib ${GL_TEST_LIBRARIES}) + +# On Win32 we need to avoid dllimporting TgaImporter symbols, because it would +# search for the symbols in some DLL even though they were linked statically. +# However it apparently doesn't matter that they were dllexported when building +# the static library. EH. +if(WIN32) + set_target_properties(MagnumFontConverterGLTest PROPERTIES COMPILE_FLAGS "-DMAGNUM_TGAIMPORTER_BUILD_STATIC") +endif()