[libpng15] Revised CMakeLists.txt to work with mingw and removed some material

from CMakeLists.txt that is no longer useful in libpng-1.5.
diff --git a/ANNOUNCE b/ANNOUNCE
index 5cff8c1..4099f85 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -48,7 +48,9 @@
 Version 1.5.6beta03 [September 27, 2011]
   Revised test-pngtest.sh to report FAIL when pngtest fails.
   Added "--strict" option to pngtest, to report FAIL when the failure is
-     only because the resulting valid files are different.
+    only because the resulting valid files are different.
+  Revised CMakeLists.txt to work with mingw and removed some material from
+    CMakeLists.txt that is no longer useful in libpng-1.5.
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
 (subscription required; visit
diff --git a/CHANGES b/CHANGES
index dec424f..baa67eb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3609,7 +3609,9 @@
 Version 1.5.6beta03 [September 27, 2011]
   Revised test-pngtest.sh to report FAIL when pngtest fails.
   Added "--strict" option to pngtest, to report FAIL when the failure is
-     only because the resulting valid files are different.
+    only because the resulting valid files are different.
+  Revised CMakeLists.txt to work with mingw and removed some material from
+    CMakeLists.txt that is no longer useful in libpng-1.5.
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eee6a2b..d57f7a6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,39 +69,11 @@
   option(PNG_STATIC "Build static lib" ON)
 endif()
 
-if(MINGW)
-  option(PNG_TESTS  "Build pngtest" NO)
-else()
-  option(PNG_TESTS  "Build pngtest" YES)
-endif()
+option(PNG_TESTS  "Build libpng tests" YES)
 
-option(PNG_NO_CONSOLE_IO "FIXME" YES)
-option(PNG_NO_STDIO      "FIXME" YES)
+# Many more configuration options could be added here
 option(PNG_DEBUG         "Build with debug output" NO)
-option(PNGARG            "FIXME" YES)
-#TODO:
-# PNG_CONSOLE_IO_SUPPORTED
-
-# maybe needs improving, but currently I don't know when we can enable what :)
-set(png_asm_tmp "OFF")
-if(NOT WIN32)
-  find_program(uname_executable NAMES uname PATHS /bin /usr/bin /usr/local/bin)
-  if(uname_executable)
-    exec_program(${uname_executable}
-                 ARGS --machine OUTPUT_VARIABLE uname_output)
-    if("uname_output" MATCHES "^.*i[1-9]86.*$")
-      set(png_asm_tmp "ON")
-    else("uname_output" MATCHES "^.*i[1-9]86.*$")
-      set(png_asm_tmp "OFF")
-    endif("uname_output" MATCHES "^.*i[1-9]86.*$")
-  endif(uname_executable)
-else()
-  # this env var is normally only set on win64
-  set(TEXT "ProgramFiles(x86)")
-  if("$ENV{${TEXT}}" STREQUAL "")
-    set(png_asm_tmp "ON")
-  endif("$ENV{${TEXT}}" STREQUAL "")
-endif()
+option(PNGARG            "Disable ANSI-C prototypes" NO)
 
 # SET LIBNAME
 set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
@@ -110,6 +82,9 @@
 set(CMAKE_DEBUG_POSTFIX "d")
 
 # Use the prebuilt pnglibconf.h file from the scripts folder
+# TODO: fix this by building with awk; without this no cmake build can be
+# configured directly (to do so indirectly use your local awk to build a
+# pnglibconf.h in the build directory.)
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
                ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
@@ -145,39 +120,21 @@
 set(pngtest_sources
   pngtest.c
 )
+set(pngvalid_sources
+  pngvalid.c
+)
 # SOME NEEDED DEFINITIONS
 
 add_definitions(-DPNG_CONFIGURE_LIBPNG)
 
 if(MSVC)
-  add_definitions(-DPNG_NO_MODULEDEF -D_CRT_SECURE_NO_DEPRECATE)
+  add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
 endif(MSVC)
 
-if(PNG_SHARED OR  NOT MSVC)
-  #if building msvc static this has NOT to be defined
-  add_definitions(-DZLIB_DLL)
-endif()
-
-if(PNG_CONSOLE_IO_SUPPORTED)
-  add_definitions(-DPNG_CONSOLE_IO_SUPPORTED)
-endif()
-
-if(PNG_NO_CONSOLE_IO)
-  add_definitions(-DPNG_NO_CONSOLE_IO)
-endif()
-
-if(PNG_NO_STDIO)
-  add_definitions(-DPNG_NO_STDIO)
-endif()
-
 if(PNG_DEBUG)
   add_definitions(-DPNG_DEBUG)
 endif()
 
-if(NOT M_LIBRARY AND NOT WIN32)
-  add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED)
-endif()
-
 # NOW BUILD OUR TARGET
 include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
 
@@ -211,6 +168,10 @@
   add_executable(pngtest ${pngtest_sources})
   target_link_libraries(pngtest ${PNG_LIB_NAME})
   add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
+  #
+  add_executable(pngvalid ${pngvalid_sources})
+  target_link_libraries(pngvalid ${PNG_LIB_NAME})
+  add_test(pngvalid ./pngvalid)
 endif()
 
 # Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set
@@ -241,11 +202,16 @@
   endif(WIN32 AND NOT CYGWIN)
 endmacro()
 
-# CREATE PKGCONFIG FILES
-# we use the same files like ./configure, so we have to set its vars
+# libpng is a library so default to 'lib'
 if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
   set(CMAKE_INSTALL_LIBDIR lib)
 endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
+
+# CREATE PKGCONFIG FILES
+# we use the same files like ./configure, so we have to set its vars
+# Only do this on Windows for Cygwin - the files don't make much sense outside
+# a UNIX look alike
+if(NOT WIN32 OR CYGWIN)
 set(prefix      ${CMAKE_INSTALL_PREFIX})
 set(exec_prefix ${CMAKE_INSTALL_PREFIX})
 set(libdir      ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
@@ -258,6 +224,7 @@
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
   ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
 CREATE_SYMLINK(${PNGLIB_NAME}-config libpng-config)
+endif(NOT WIN32 OR CYGWIN)
 
 # SET UP LINKS
 if(PNG_SHARED)