blob: b4dcbb0d2d5c879d2906a53988c388c12c8b1c95 [file] [log] [blame]
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -05001cmake_minimum_required(VERSION 2.4.4)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06002set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
3
Glenn Randers-Pehrsonee35abb2009-10-30 15:42:54 -05004if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE)
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -05005 if(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4)
6 # workaround CMake 2.4.x bug
7 set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
8 else()
9 set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
10 "Choose the type of build, options are:
11 None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used)
12 Debug
13 Release
14 RelWithDebInfo
15 MinSizeRel.")
16 endif()
Glenn Randers-Pehrsonee35abb2009-10-30 15:42:54 -050017endif()
18
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -060019project(libpng C)
Glenn Randers-Pehrsonee35abb2009-10-30 15:42:54 -050020enable_testing()
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -060021
Glenn Randers-Pehrsonf81b50b2009-12-29 16:50:15 -060022# Copyright (C) 2007-2010 Glenn Randers-Pehrson
Glenn Randers-Pehrson3e61d792009-06-24 09:31:28 -050023
Glenn Randers-Pehrsonbfbf8652009-06-26 21:46:52 -050024# This code is released under the libpng license.
Glenn Randers-Pehrsonc332bbc2009-06-25 13:43:50 -050025# For conditions of distribution and use, see the disclaimer
Glenn Randers-Pehrson037023b2009-06-24 10:27:36 -050026# and license in png.h
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -060027
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -050028set(PNGLIB_MAJOR 1)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -060029set(PNGLIB_MINOR 5)
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -050030set(PNGLIB_RELEASE 0)
31set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
32set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -060033
34# needed packages
35find_package(ZLIB REQUIRED)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -050036include_directories(${ZLIB_INCLUDE_DIR})
37
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -050038if(NOT WIN32)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -060039 find_library(M_LIBRARY
40 NAMES m
41 PATHS /usr/lib /usr/local/lib
42 )
43 if(NOT M_LIBRARY)
44 message(STATUS
45 "math library 'libm' not found - floating point support disabled")
46 endif()
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -050047else()
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -060048 # not needed on windows
49 set(M_LIBRARY "")
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -050050endif()
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -060051
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -050052# COMMAND LINE OPTIONS
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -050053if(DEFINED PNG_SHARED)
54 option(PNG_SHARED "Build shared lib" ${PNG_SHARED})
55else()
56 option(PNG_SHARED "Build shared lib" ON)
57endif()
58if(DEFINED PNG_STATIC)
59 option(PNG_STATIC "Build static lib" ${PNG_STATIC})
60else()
61 option(PNG_STATIC "Build static lib" ON)
62endif()
63
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -050064if(MINGW)
65 option(PNG_TESTS "Build pngtest" NO)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -060066else()
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -050067 option(PNG_TESTS "Build pngtest" YES)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -060068endif()
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -050069
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -050070option(PNG_NO_CONSOLE_IO "FIXME" YES)
71option(PNG_NO_STDIO "FIXME" YES)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -050072option(PNG_DEBUG "Build with debug output" NO)
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -050073option(PNGARG "FIXME" YES)
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -060074#TODO:
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -060075# PNG_CONSOLE_IO_SUPPORTED
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -060076
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -050077# maybe needs improving, but currently I don't know when we can enable what :)
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -060078set(png_asm_tmp "OFF")
79if(NOT WIN32)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -060080 find_program(uname_executable NAMES uname PATHS /bin /usr/bin /usr/local/bin)
81 if(uname_executable)
82 exec_program(${uname_executable}
83 ARGS --machine OUTPUT_VARIABLE uname_output)
84 if("uname_output" MATCHES "^.*i[1-9]86.*$")
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -050085 set(png_asm_tmp "ON")
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -060086 else("uname_output" MATCHES "^.*i[1-9]86.*$")
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -050087 set(png_asm_tmp "OFF")
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -060088 endif("uname_output" MATCHES "^.*i[1-9]86.*$")
89 endif(uname_executable)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -050090else()
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -060091 # this env var is normally only set on win64
92 set(TEXT "ProgramFiles(x86)")
93 if("$ENV{${TEXT}}" STREQUAL "")
94 set(png_asm_tmp "ON")
95 endif("$ENV{${TEXT}}" STREQUAL "")
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -050096endif()
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -060097
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -050098# SET LIBNAME
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -050099set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600100
101# to distinguish between debug and release lib
102set(CMAKE_DEBUG_POSTFIX "d")
103
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500104# Use the prebuilt pnglibconf.h file from the scripts folder
105configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
106 ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
107include_directories(${CMAKE_CURRENT_BINARY_DIR})
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600108
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500109# OUR SOURCES
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500110set(libpng_public_hdrs
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600111 png.h
112 pngconf.h
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500113 ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h
114)
115set(libpng_sources
116 ${libpng_public_hdrs}
Glenn Randers-Pehrson07d9fc92010-08-26 17:11:55 -0500117 pngdebug.h
118 pnginfo.h
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500119 pngpriv.h
Glenn Randers-Pehrson07d9fc92010-08-26 17:11:55 -0500120 pngstruct.h
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600121 png.c
122 pngerror.c
123 pngget.c
124 pngmem.c
125 pngpread.c
126 pngread.c
127 pngrio.c
128 pngrtran.c
129 pngrutil.c
130 pngset.c
131 pngtrans.c
132 pngwio.c
133 pngwrite.c
134 pngwtran.c
135 pngwutil.c
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600136)
137set(pngtest_sources
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600138 pngtest.c
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600139)
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500140# SOME NEEDED DEFINITIONS
Glenn Randers-Pehrson69b0bc02009-11-07 12:02:48 -0600141
Glenn Randers-Pehrson8c037302010-08-23 17:07:32 -0500142add_definitions(-DPNG_CONFIGURE_LIBPNG)
143
144if(_AIX)
145 add_definitions(-D_ALL_SOURCE)
146endif(_AIX)
147
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600148if(MSVC)
Glenn Randers-Pehrson8c037302010-08-23 17:07:32 -0500149 add_definitions(-DPNG_NO_MODULEDEF -D_CRT_SECURE_NO_DEPRECATE)
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600150endif(MSVC)
151
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500152if(PNG_SHARED OR NOT MSVC)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600153 #if building msvc static this has NOT to be defined
154 add_definitions(-DZLIB_DLL)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500155endif()
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600156
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600157
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500158if(PNG_CONSOLE_IO_SUPPORTED)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600159 add_definitions(-DPNG_CONSOLE_IO_SUPPORTED)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500160endif()
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500161
162if(PNG_NO_CONSOLE_IO)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600163 add_definitions(-DPNG_NO_CONSOLE_IO)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500164endif()
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500165
166if(PNG_NO_STDIO)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600167 add_definitions(-DPNG_NO_STDIO)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500168endif()
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500169
170if(PNG_DEBUG)
Glenn Randers-Pehrson8c037302010-08-23 17:07:32 -0500171 add_definitions(-DPNG_DEBUG)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500172endif()
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500173
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -0500174if(NOT M_LIBRARY AND NOT WIN32)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600175 add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500176endif()
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500177
178# NOW BUILD OUR TARGET
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600179include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600180
181if(PNG_SHARED)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600182 add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
183 if(MSVC)
184 # msvc does not append 'lib' - do it here to have consistent name
185 set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500186 set_target_properties(${PNG_LIB_NAME} PROPERTIES IMPORT_PREFIX "lib")
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600187 endif()
188 target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY})
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500189endif()
190
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500191if(PNG_STATIC)
192# does not work without changing name
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600193 set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
194 add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
195 if(MSVC)
196 # msvc does not append 'lib' - do it here to have consistent name
197 set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
198 endif()
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500199 target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500200endif()
201
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600202
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600203if(PNG_SHARED AND WIN32)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600204 set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500205endif()
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600206
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500207if(PNG_TESTS AND PNG_SHARED)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600208 # does not work with msvc due to png_lib_ver issue
209 add_executable(pngtest ${pngtest_sources})
210 target_link_libraries(pngtest ${PNG_LIB_NAME})
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500211 add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500212endif()
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600213
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500214#
215# Set a variable with CMake code which:
216# Creates a symlink from src to dest (if possible) or alternatively
217# copies if different.
218macro(_png_generate_symlink_code CODE SRC DEST)
219 if(WIN32 AND NOT CYGWIN)
220 set(_png_gsc_message "Copying ${SRC} to ${DEST} if needed")
221 set(_png_gsc_operation "copy_if_different")
222 else()
223 set(_png_gsc_message "Symlinking ${SRC} to ${DEST}")
224 set(_png_gsc_operation "create_symlink")
225 endif()
226
227 set(${CODE} "
228 message(STATUS \"${_png_gsc_message}\")
229 execute_process(COMMAND \${CMAKE_COMMAND} -E ${_png_gsc_operation}
230 \"${SRC}\" \"${DEST}\")
231 ")
232endmacro()
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600233
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500234# CREATE PKGCONFIG FILES
235# we use the same files like ./configure, so we have to set its vars
Glenn Randers-Pehrson8c037302010-08-23 17:07:32 -0500236if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
237 set(CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib)
238endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500239set(prefix ${CMAKE_INSTALL_PREFIX})
240set(exec_prefix ${CMAKE_INSTALL_PREFIX})
Glenn Randers-Pehrson8c037302010-08-23 17:07:32 -0500241set(libdir ${CMAKE_INSTALL_LIBDIR})
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500242set(includedir ${CMAKE_INSTALL_PREFIX}/include)
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500243set(LIBS "-lz -lm")
244configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
Glenn Randers-Pehrson8c037302010-08-23 17:07:32 -0500245 ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500246_png_generate_symlink_code(PNG_PC_INSTALL_CODE ${PNGLIB_NAME}.pc libpng.pc)
247install(CODE ${PNG_PC_INSTALL_CODE})
248
249configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
Glenn Randers-Pehrson8c037302010-08-23 17:07:32 -0500250 ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500251_png_generate_symlink_code(PNG_CONFIG_INSTALL_CODE ${PNGLIB_NAME}-config libpng-config)
252install(CODE ${PNG_CONFIG_INSTALL_CODE})
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500253
254# SET UP LINKS
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500255if(PNG_SHARED)
256 set_target_properties(${PNG_LIB_NAME} PROPERTIES
Glenn Randers-Pehrson4f8e7e52010-09-10 22:07:45 -0500257# VERSION 15.${PNGLIB_RELEASE}.1.5.0beta48
Glenn Randers-Pehrsonf1eb9182010-02-08 15:36:41 -0600258 VERSION 15.${PNGLIB_RELEASE}.0
259 SOVERSION 15
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600260 CLEAN_DIRECT_OUTPUT 1)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500261endif()
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -0500262if(PNG_STATIC)
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500263 # MSVC doesn't use a different file extension for shared vs. static
264 # libs. We are able to change OUTPUT_NAME to remove the _static
265 # for all other platforms.
266 if(NOT MSVC)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500267 set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600268 OUTPUT_NAME ${PNG_LIB_NAME}
269 CLEAN_DIRECT_OUTPUT 1)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500270 endif()
271endif()
272
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500273# If CMake > 2.4.x, we set a variable used below to export
274# targets to an export file.
275# TODO: Use VERSION_GREATER after our cmake_minimum_required >= 2.6.2
276if(CMAKE_MAJOR_VERSION GREATER 1 AND CMAKE_MINOR_VERSION GREATER 4)
277 set(PNG_EXPORT_RULE EXPORT libpng)
278elseif(CMAKE_MAJOR_VERSION GREATER 2) # future proof
279 set(PNG_EXPORT_RULE EXPORT libpng)
280endif()
281
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500282# INSTALL
283if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600284 if(PNG_SHARED)
285 install(TARGETS ${PNG_LIB_NAME}
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500286 ${PNG_EXPORT_RULE}
287 RUNTIME DESTINATION bin
288 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
289 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
290
291 # Create a symlink for libpng.dll.a => libpng14.dll.a on Cygwin
292 if(CYGWIN)
293 _png_generate_symlink_code(PNG_SHARED_IMPLIB_INSTALL_CODE
294 ${PNGLIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX}
295 libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
296 install(CODE ${PNG_SHARED_IMPLIB_INSTALL_CODE})
297 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
298 endif()
299
300 if(NOT WIN32)
301 _png_generate_symlink_code(PNG_SHARED_INSTALL_CODE
302 ${PNGLIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
303 libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
304 install(CODE ${PNG_SHARED_INSTALL_CODE})
305 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
306 endif()
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600307 endif()
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500308
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600309 if(PNG_STATIC)
310 install(TARGETS ${PNG_LIB_NAME_STATIC}
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500311 ${PNG_EXPORT_RULE}
312 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
313 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
314 if(NOT WIN32 OR CYGWIN)
315 _png_generate_symlink_code(PNG_STATIC_INSTALL_CODE
316 ${PNGLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
317 libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
318 install(CODE ${PNG_STATIC_INSTALL_CODE})
319 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
320 endif()
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600321 endif()
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500322endif()
323
324if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500325 install(FILES ${libpng_public_hdrs} DESTINATION include)
326 install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME})
Glenn Randers-Pehrsonee35abb2009-10-30 15:42:54 -0500327endif()
328if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600329 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin)
330 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
331 DESTINATION bin)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500332endif()
333if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600334 # Install man pages
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500335 if(NOT PNG_MAN_DIR)
336 set(PNG_MAN_DIR "share/man")
337 endif()
338 install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
339 install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600340 # Install pkg-config files
341 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500342 DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
Glenn Randers-Pehrson8c037302010-08-23 17:07:32 -0500343 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600344 DESTINATION bin)
345 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500346 DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
Glenn Randers-Pehrson8c037302010-08-23 17:07:32 -0500347 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600348 DESTINATION bin)
Glenn Randers-Pehrson38e467e2009-08-27 15:59:40 -0500349endif()
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500350
Glenn Randers-Pehrson0c3fea32010-10-02 21:25:01 -0500351# On versions of CMake that support it, create an export file CMake
352# users can include() to import our targets
353if(PNG_EXPORT_RULE AND NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL )
354 install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake)
355endif()
356
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600357# what's with libpng.txt and all the extra files?
358
359
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500360# UNINSTALL
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600361# do we need this?
362
363
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -0500364# DIST
Glenn Randers-Pehrson7edd4582006-12-07 19:16:44 -0600365# do we need this?
366
367# to create msvc import lib for mingw compiled shared lib
368# pexports libpng.dll > libpng.def
369# lib /def:libpng.def /machine:x86
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -0500370