aboutsummaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorJaebaek Seo <jaebaek@google.com>2019-07-24 16:12:59 -0400
committerGitHub <noreply@github.com>2019-07-24 16:12:59 -0400
commit6bdbb5fa50b1b82b0676cf9a91729c0f0f7f9e14 (patch)
treedfc35b0e7aeb05404f49543b3dd60ce9448771ef /samples
parent6e5c1c43ab8caf2ede9a75d8037c1715c2ce8a0f (diff)
downloadamber-6bdbb5fa50b1b82b0676cf9a91729c0f0f7f9e14.tar.gz
Optional PNG support (#596)
As discussed in #591, this CL sets lodepng as an optional library.
Diffstat (limited to 'samples')
-rw-r--r--samples/CMakeLists.txt9
-rw-r--r--samples/amber.cc9
2 files changed, 15 insertions, 3 deletions
diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt
index 3831b8b..d41ee21 100644
--- a/samples/CMakeLists.txt
+++ b/samples/CMakeLists.txt
@@ -19,12 +19,16 @@ set(AMBER_SOURCES
config_helper.cc
log.cc
ppm.cc
- png.cc
timestamp.cc
${CMAKE_BINARY_DIR}/src/build-versions.h.fake
)
-set(AMBER_EXTRA_LIBS "lodepng")
+set(AMBER_EXTRA_LIBS "")
+
+if (${AMBER_ENABLE_LODEPNG})
+ set(AMBER_SOURCES ${AMBER_SOURCES} png.cc)
+ list(APPEND AMBER_EXTRA_LIBS "lodepng")
+endif()
if (${Vulkan_FOUND})
set(AMBER_SOURCES ${AMBER_SOURCES} config_helper_vulkan.cc)
@@ -45,6 +49,7 @@ endif()
add_executable(amber ${AMBER_SOURCES})
target_include_directories(amber PRIVATE "${CMAKE_BINARY_DIR}")
+
set_target_properties(amber PROPERTIES OUTPUT_NAME "amber")
target_link_libraries(amber libamber ${AMBER_EXTRA_LIBS})
amber_default_compile_options(amber)
diff --git a/samples/amber.cc b/samples/amber.cc
index 0f68a9f..8c945b1 100644
--- a/samples/amber.cc
+++ b/samples/amber.cc
@@ -25,12 +25,15 @@
#include "amber/recipe.h"
#include "samples/config_helper.h"
-#include "samples/png.h"
#include "samples/ppm.h"
#include "samples/timestamp.h"
#include "src/build-versions.h"
#include "src/make_unique.h"
+#if AMBER_ENABLE_LODEPNG
+#include "samples/png.h"
+#endif // AMBER_ENABLE_LODEPNG
+
namespace {
const char* kGeneratedColorBuffer = "framebuffer";
@@ -431,8 +434,12 @@ int main(int argc, const char** argv) {
for (const amber::BufferInfo& buffer_info : amber_options.extractions) {
if (buffer_info.buffer_name == options.fb_name) {
if (usePNG) {
+#if AMBER_ENABLE_LODEPNG
result = png::ConvertToPNG(buffer_info.width, buffer_info.height,
buffer_info.values, &out_buf);
+#else // AMBER_ENABLE_LODEPNG
+ result = amber::Result("PNG support not enabled");
+#endif // AMBER_ENABLE_LODEPNG
} else {
ppm::ConvertToPPM(buffer_info.width, buffer_info.height,
buffer_info.values, &out_buf);