From e925d6d54c39ff62a588d281ecc27d1974809420 Mon Sep 17 00:00:00 2001 From: nadavi Date: Wed, 8 Apr 2020 14:29:40 -0600 Subject: [PATCH] turn lodepng into a library --- vtkm/rendering/CMakeLists.txt | 3 +- vtkm/rendering/Canvas.cxx | 3 +- vtkm/rendering/DecodePNG.cxx | 4 +-- vtkm/rendering/WorldAnnotatorGL.cxx | 5 ++- vtkm/rendering/testing/CMakeLists.txt | 2 +- vtkm/thirdparty/lodepng/CMakeLists.txt | 46 +++++++++++++++++++------- 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/vtkm/rendering/CMakeLists.txt b/vtkm/rendering/CMakeLists.txt index 2c80d8cda..e115ebaf1 100644 --- a/vtkm/rendering/CMakeLists.txt +++ b/vtkm/rendering/CMakeLists.txt @@ -88,7 +88,7 @@ set(sources DecodePNG.cxx EncodePNG.cxx raytracing/Logger.cxx - ) +) # This list of sources has code that uses devices and so might need to be # compiled with a device-specific compiler (like CUDA). @@ -103,6 +103,7 @@ set(device_sources ColorBarAnnotation.cxx ColorLegendAnnotation.cxx ConnectivityProxy.cxx + DecodePNG.cxx LineRenderer.cxx Mapper.cxx MapperConnectivity.cxx diff --git a/vtkm/rendering/Canvas.cxx b/vtkm/rendering/Canvas.cxx index 431c9e64d..32045c31c 100644 --- a/vtkm/rendering/Canvas.cxx +++ b/vtkm/rendering/Canvas.cxx @@ -523,7 +523,8 @@ bool Canvas::LoadFont() const const std::vector& rawPNG = Internals->Font.GetRawImageData(); std::vector rgba; unsigned long textureWidth, textureHeight; - auto error = DecodePNG(rgba, textureWidth, textureHeight, &rawPNG[0], rawPNG.size()); + auto error = + vtkm::rendering::DecodePNG(rgba, textureWidth, textureHeight, &rawPNG[0], rawPNG.size()); if (error != 0) { return false; diff --git a/vtkm/rendering/DecodePNG.cxx b/vtkm/rendering/DecodePNG.cxx index 359d7b4fc..ab2a656e4 100644 --- a/vtkm/rendering/DecodePNG.cxx +++ b/vtkm/rendering/DecodePNG.cxx @@ -14,8 +14,8 @@ #include VTKM_THIRDPARTY_PRE_INCLUDE -#include -VTKM_THIRDPARTY_PRE_INCLUDE +#include +VTKM_THIRDPARTY_POST_INCLUDE namespace vtkm { diff --git a/vtkm/rendering/WorldAnnotatorGL.cxx b/vtkm/rendering/WorldAnnotatorGL.cxx index 0993743cc..e7ef4259e 100644 --- a/vtkm/rendering/WorldAnnotatorGL.cxx +++ b/vtkm/rendering/WorldAnnotatorGL.cxx @@ -8,14 +8,13 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ -#include - #include #include #include #include #include #include +#include #include @@ -103,7 +102,7 @@ void WorldAnnotatorGL::RenderText(vtkm::Float32 scale, const std::vector& rawpngdata = this->Font.GetRawImageData(); std::vector rgba; - unsigned long width, height; + unsigned width, height; int error = vtkm::rendering::DecodePNG(rgba, width, height, &rawpngdata[0], rawpngdata.size()); if (error != 0) { diff --git a/vtkm/rendering/testing/CMakeLists.txt b/vtkm/rendering/testing/CMakeLists.txt index 2ab5d75bd..5a2bd7e8c 100644 --- a/vtkm/rendering/testing/CMakeLists.txt +++ b/vtkm/rendering/testing/CMakeLists.txt @@ -27,7 +27,7 @@ set(unit_tests UnitTestScalarRenderer.cxx ) -vtkm_unit_tests(SOURCES ${unit_tests} ALL_BACKENDS LIBRARIES vtkm_rendering) +vtkm_unit_tests(SOURCES ${unit_tests} ALL_BACKENDS LIBRARIES vtkm_rendering vtkm_lodepng) if(VTKm_ENABLE_GL_CONTEXT) # message(STATUS "rendering testing/glfw needs a FindGLFW") diff --git a/vtkm/thirdparty/lodepng/CMakeLists.txt b/vtkm/thirdparty/lodepng/CMakeLists.txt index 957d5c7e6..b19b6be8a 100644 --- a/vtkm/thirdparty/lodepng/CMakeLists.txt +++ b/vtkm/thirdparty/lodepng/CMakeLists.txt @@ -7,19 +7,41 @@ ## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ## PURPOSE. See the above copyright notice for more information. ##============================================================================ -add_library(vtkm_lodepng INTERFACE) - -vtkm_get_kit_name(kit_name kit_dir) - +set(headers + vtkmlodepng/lodepng.h +) +set(sources + vtkmlodepng/lodepng.cpp +) +# vtkm_library(NAME vtkm_lodepng HEADERS ${headers} SOURCES ${sources}) +add_library(vtkm_lodepng STATIC ${headers} ${sources}) +if(DEFINED VTKm_CUSTOM_LIBRARY_SUFFIX) + set(_lib_suffix "${VTKm_CUSTOM_LIBRARY_SUFFIX}") +else() + set(_lib_suffix "-${VTKm_VERSION_MAJOR}.${VTKm_VERSION_MINOR}") +endif() +set_target_properties(vtkm_lodepng + PROPERTIES + OUTPUT_NAME "vtkm_lodepng${_lib_suffix}" + LIBRARY_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH} + ARCHIVE_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH} + RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH} + VERSION 1 + SOVERSION 1 +) +vtkm_generate_export_header(vtkm_lodepng) target_include_directories(vtkm_lodepng INTERFACE $ - $) + $ +) +install(DIRECTORY vtkmlodepng + DESTINATION "${VTKm_INSTALL_INCLUDE_DIR}/vtkm/thirdparty/lodepng" +) install(TARGETS vtkm_lodepng - EXPORT ${VTKm_EXPORT_NAME}) - -## Install headers -if(NOT VTKm_INSTALL_ONLY_LIBRARIES) - install(DIRECTORY vtkmlodepng - DESTINATION ${VTKm_INSTALL_INCLUDE_DIR}/${kit_dir}/) -endif() + EXPORT ${VTKm_EXPORT_NAME} + LIBRARY DESTINATION ${VTKm_INSTALL_LIB_DIR} + ARCHIVE DESTINATION ${VTKm_INSTALL_LIB_DIR} + RUNTIME DESTINATION ${VTKm_INSTALL_BIN_DIR} + COMPONENT libraries +)