summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2018-06-21 23:55:11 -0400
committerMike Frysinger <vapier@gentoo.org>2018-06-21 23:55:11 -0400
commit08b0dbaec64750b22d8aa195c9bca0455e0e34af (patch)
tree4c77fffdf98b9cd1e67a7e5500d88977d0a6b11d /examples
parentfd06f7f83c5e78bf5b7f5397746b4e5ee4366250 (diff)
downloadlibgd-08b0dbaec64750b22d8aa195c9bca0455e0e34af.tar.gz
move (redundant) ifdef checks from source to build files
We've been tracking program deps in the build files, so it ends up being redundant for a lot of our test/example programs. Clean them up, and update some of the cmake/automake files as needed.
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt25
-rw-r--r--examples/arc.c4
-rw-r--r--examples/crop.c9
-rw-r--r--examples/nnquant.c9
-rw-r--r--examples/tgaread.c6
5 files changed, 14 insertions, 39 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 869880f..ac3c612 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,15 +1,22 @@
include_directories (BEFORE "${GD_SOURCE_DIR}/src" "${CMAKE_BINARY_DIR}")
SET(TESTS_FILES
- arc
- crop
- gif
- nnquant
- tgaread
+ gif
)
+if (PNG_FOUND)
+ LIST(APPEND TEST_FILES arc crop tgaread)
+
+ if (JPEG_FOUND)
+ LIST(APPEND TESTS_FILES copyrotated flip nnquantnnquant)
+ if (UNIX)
+ target_link_libraries(copyrotated m)
+ endif (UNIX)
+ endif (JPEG_FOUND)
+endif (PNG_FOUND)
+
if (JPEG_FOUND)
- LIST(APPEND TESTS_FILES copyrotated flip)
+ LIST(APPEND TESTS_FILES resize)
endif (JPEG_FOUND)
if (TIFF_FOUND)
@@ -27,12 +34,6 @@ FOREACH(test_name ${TESTS_FILES})
target_link_libraries (${test_name} ${GD_LINK_LIB})
ENDFOREACH(test_name)
-if(JPEG_FOUND)
- if(UNIX)
- target_link_libraries(copyrotated m)
- endif(UNIX)
-endif(JPEG_FOUND)
-
if (WIN32 AND NOT MINGW AND NOT MSYS)
add_executable(windows WIN32 "windows.c")
target_link_libraries (windows ${GD_LINK_LIB})
diff --git a/examples/arc.c b/examples/arc.c
index 8e86283..ae3fcfd 100644
--- a/examples/arc.c
+++ b/examples/arc.c
@@ -19,11 +19,7 @@ int main()
gdImageDestroy(im);
return 1;
}
-#ifdef HAVE_LIBPNG
gdImagePng(im, fp);
-#else
- printf("No PNG support. Cannot save image.\n");
-#endif
fclose(fp);
gdImageDestroy(im);
diff --git a/examples/crop.c b/examples/crop.c
index bafb6df..3e30b7f 100644
--- a/examples/crop.c
+++ b/examples/crop.c
@@ -12,11 +12,7 @@ void save_png(gdImagePtr im, const char *filename)
fprintf(stderr, "Can't save png image %s\n", filename);
return;
}
-#ifdef HAVE_LIBPNG
gdImagePng(im, fp);
-#else
- printf("No PNG support. Cannot save image.\n");
-#endif
fclose(fp);
}
@@ -30,12 +26,7 @@ gdImagePtr read_png(const char *filename)
fprintf(stderr, "Can't read png image %s\n", filename);
return NULL;
}
-#ifdef HAVE_LIBPNG
im = gdImageCreateFromPng(fp);
-#else
- im = NULL;
- printf("No PNG support. Cannot read image.\n");
-#endif
fclose(fp);
return im;
}
diff --git a/examples/nnquant.c b/examples/nnquant.c
index 33ed523..91139b5 100644
--- a/examples/nnquant.c
+++ b/examples/nnquant.c
@@ -12,17 +12,12 @@ void save_png(gdImagePtr im, const char *filename)
fprintf(stderr, "Can't save png image %s\n", filename);
return;
}
-#ifdef HAVE_LIBPNG
gdImagePng(im, fp);
-#else
- printf("No PNG support. Cannot save image.\n");
-#endif
fclose(fp);
}
int main()
{
-#ifdef HAVE_JPEG
gdImagePtr im, im2;
FILE *fp;
char path[2048];
@@ -56,9 +51,5 @@ int main()
save_png(im, "a_jquant_dither.png");
gdImageDestroy(im);
-#else
- printf("JPEG support is required for this example. Please recompile GD with JPEG or change this example to use another format as input.");
- return 1;
-#endif
return 0;
}
diff --git a/examples/tgaread.c b/examples/tgaread.c
index a8e0807..1fa9daf 100644
--- a/examples/tgaread.c
+++ b/examples/tgaread.c
@@ -44,11 +44,7 @@ int main()
gdImageDestroy(im);
return 1;
}
-#ifdef HAVE_LIBPNG
- gdImagePng(im, fp);
-#else
- printf("No PNG support. Cannot save image.\n");
-#endif
+ gdImagePng(im, fp);
fclose(fp);
gdImageDestroy(im);
}