Glenn Randers-Pehrson | 0c03fc6 | 2011-08-17 09:46:29 -0500 | [diff] [blame] | 1 | # CMakeLists.txt |
| 2 | |
| 3 | # Copyright (C) 2007-2011 Glenn Randers-Pehrson |
| 4 | |
| 5 | # This code is released under the libpng license. |
| 6 | # For conditions of distribution and use, see the disclaimer |
| 7 | # and license in png.h |
| 8 | |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 9 | cmake_minimum_required(VERSION 2.4.4) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 10 | set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) |
| 11 | |
Glenn Randers-Pehrson | ee35abb | 2009-10-30 15:42:54 -0500 | [diff] [blame] | 12 | if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 13 | if(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4) |
| 14 | # workaround CMake 2.4.x bug |
Glenn Randers-Pehrson | e89d33a | 2010-10-02 21:36:02 -0500 | [diff] [blame] | 15 | set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING |
| 16 | "Choose the type of build, options are: |
| 17 | None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) |
| 18 | Debug |
| 19 | Release |
| 20 | RelWithDebInfo |
| 21 | MinSizeRel.") |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 22 | else() |
| 23 | set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING |
| 24 | "Choose the type of build, options are: |
| 25 | None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) |
| 26 | Debug |
| 27 | Release |
| 28 | RelWithDebInfo |
| 29 | MinSizeRel.") |
| 30 | endif() |
Glenn Randers-Pehrson | ee35abb | 2009-10-30 15:42:54 -0500 | [diff] [blame] | 31 | endif() |
| 32 | |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 33 | project(libpng C) |
Glenn Randers-Pehrson | ee35abb | 2009-10-30 15:42:54 -0500 | [diff] [blame] | 34 | enable_testing() |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 35 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 36 | set(PNGLIB_MAJOR 1) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 37 | set(PNGLIB_MINOR 5) |
Glenn Randers-Pehrson | 115020d | 2011-09-22 09:08:31 -0500 | [diff] [blame] | 38 | set(PNGLIB_RELEASE 6) |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 39 | set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) |
| 40 | set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 41 | |
| 42 | # needed packages |
| 43 | find_package(ZLIB REQUIRED) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 44 | include_directories(${ZLIB_INCLUDE_DIR}) |
| 45 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 46 | if(NOT WIN32) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 47 | find_library(M_LIBRARY |
| 48 | NAMES m |
| 49 | PATHS /usr/lib /usr/local/lib |
| 50 | ) |
| 51 | if(NOT M_LIBRARY) |
| 52 | message(STATUS |
| 53 | "math library 'libm' not found - floating point support disabled") |
| 54 | endif() |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 55 | else() |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 56 | # not needed on windows |
| 57 | set(M_LIBRARY "") |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 58 | endif() |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 59 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 60 | # COMMAND LINE OPTIONS |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 61 | if(DEFINED PNG_SHARED) |
| 62 | option(PNG_SHARED "Build shared lib" ${PNG_SHARED}) |
| 63 | else() |
| 64 | option(PNG_SHARED "Build shared lib" ON) |
| 65 | endif() |
| 66 | if(DEFINED PNG_STATIC) |
| 67 | option(PNG_STATIC "Build static lib" ${PNG_STATIC}) |
| 68 | else() |
| 69 | option(PNG_STATIC "Build static lib" ON) |
| 70 | endif() |
| 71 | |
Glenn Randers-Pehrson | e29c4b9 | 2011-09-27 19:01:58 -0500 | [diff] [blame^] | 72 | option(PNG_TESTS "Build libpng tests" YES) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 73 | |
Glenn Randers-Pehrson | e29c4b9 | 2011-09-27 19:01:58 -0500 | [diff] [blame^] | 74 | # Many more configuration options could be added here |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 75 | option(PNG_DEBUG "Build with debug output" NO) |
Glenn Randers-Pehrson | e29c4b9 | 2011-09-27 19:01:58 -0500 | [diff] [blame^] | 76 | option(PNGARG "Disable ANSI-C prototypes" NO) |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 77 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 78 | # SET LIBNAME |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 79 | set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 80 | |
| 81 | # to distinguish between debug and release lib |
| 82 | set(CMAKE_DEBUG_POSTFIX "d") |
| 83 | |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 84 | # Use the prebuilt pnglibconf.h file from the scripts folder |
Glenn Randers-Pehrson | e29c4b9 | 2011-09-27 19:01:58 -0500 | [diff] [blame^] | 85 | # TODO: fix this by building with awk; without this no cmake build can be |
| 86 | # configured directly (to do so indirectly use your local awk to build a |
| 87 | # pnglibconf.h in the build directory.) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 88 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt |
| 89 | ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h) |
| 90 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 91 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 92 | # OUR SOURCES |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 93 | set(libpng_public_hdrs |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 94 | png.h |
| 95 | pngconf.h |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 96 | ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h |
| 97 | ) |
| 98 | set(libpng_sources |
| 99 | ${libpng_public_hdrs} |
Glenn Randers-Pehrson | 07d9fc9 | 2010-08-26 17:11:55 -0500 | [diff] [blame] | 100 | pngdebug.h |
| 101 | pnginfo.h |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 102 | pngpriv.h |
Glenn Randers-Pehrson | 07d9fc9 | 2010-08-26 17:11:55 -0500 | [diff] [blame] | 103 | pngstruct.h |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 104 | png.c |
| 105 | pngerror.c |
| 106 | pngget.c |
| 107 | pngmem.c |
| 108 | pngpread.c |
| 109 | pngread.c |
| 110 | pngrio.c |
| 111 | pngrtran.c |
| 112 | pngrutil.c |
| 113 | pngset.c |
| 114 | pngtrans.c |
| 115 | pngwio.c |
| 116 | pngwrite.c |
| 117 | pngwtran.c |
| 118 | pngwutil.c |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 119 | ) |
| 120 | set(pngtest_sources |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 121 | pngtest.c |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 122 | ) |
Glenn Randers-Pehrson | e29c4b9 | 2011-09-27 19:01:58 -0500 | [diff] [blame^] | 123 | set(pngvalid_sources |
| 124 | pngvalid.c |
| 125 | ) |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 126 | # SOME NEEDED DEFINITIONS |
Glenn Randers-Pehrson | 69b0bc0 | 2009-11-07 12:02:48 -0600 | [diff] [blame] | 127 | |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 128 | add_definitions(-DPNG_CONFIGURE_LIBPNG) |
| 129 | |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 130 | if(MSVC) |
Glenn Randers-Pehrson | e29c4b9 | 2011-09-27 19:01:58 -0500 | [diff] [blame^] | 131 | add_definitions(-D_CRT_SECURE_NO_DEPRECATE) |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 132 | endif(MSVC) |
| 133 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 134 | if(PNG_DEBUG) |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 135 | add_definitions(-DPNG_DEBUG) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 136 | endif() |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 137 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 138 | # NOW BUILD OUR TARGET |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 139 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR}) |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 140 | |
| 141 | if(PNG_SHARED) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 142 | add_library(${PNG_LIB_NAME} SHARED ${libpng_sources}) |
| 143 | if(MSVC) |
| 144 | # msvc does not append 'lib' - do it here to have consistent name |
| 145 | set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib") |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 146 | set_target_properties(${PNG_LIB_NAME} PROPERTIES IMPORT_PREFIX "lib") |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 147 | endif() |
| 148 | target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY}) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 149 | endif() |
| 150 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 151 | if(PNG_STATIC) |
| 152 | # does not work without changing name |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 153 | set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static) |
| 154 | add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources}) |
| 155 | if(MSVC) |
| 156 | # msvc does not append 'lib' - do it here to have consistent name |
| 157 | set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib") |
| 158 | endif() |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 159 | target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY}) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 160 | endif() |
| 161 | |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 162 | if(PNG_SHARED AND WIN32) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 163 | set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 164 | endif() |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 165 | |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 166 | if(PNG_TESTS AND PNG_SHARED) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 167 | # does not work with msvc due to png_lib_ver issue |
| 168 | add_executable(pngtest ${pngtest_sources}) |
| 169 | target_link_libraries(pngtest ${PNG_LIB_NAME}) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 170 | add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png) |
Glenn Randers-Pehrson | e29c4b9 | 2011-09-27 19:01:58 -0500 | [diff] [blame^] | 171 | # |
| 172 | add_executable(pngvalid ${pngvalid_sources}) |
| 173 | target_link_libraries(pngvalid ${PNG_LIB_NAME}) |
| 174 | add_test(pngvalid ./pngvalid) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 175 | endif() |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 176 | |
Glenn Randers-Pehrson | e61e403 | 2011-08-17 09:02:07 -0500 | [diff] [blame] | 177 | # Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set |
| 178 | IF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) |
Glenn Randers-Pehrson | 0c03fc6 | 2011-08-17 09:46:29 -0500 | [diff] [blame] | 179 | IF(WIN32) |
| 180 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "bin") |
| 181 | ELSE(WIN32) |
| 182 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib") |
| 183 | ENDIF(WIN32) |
Glenn Randers-Pehrson | e61e403 | 2011-08-17 09:02:07 -0500 | [diff] [blame] | 184 | ENDIF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) |
| 185 | |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 186 | # Set a variable with CMake code which: |
| 187 | # Creates a symlink from src to dest (if possible) or alternatively |
| 188 | # copies if different. |
Glenn Randers-Pehrson | b17c75b | 2011-07-27 20:47:13 -0500 | [diff] [blame] | 189 | macro(CREATE_SYMLINK SRC_FILE DEST_FILE) |
Glenn Randers-Pehrson | 0c03fc6 | 2011-08-17 09:46:29 -0500 | [diff] [blame] | 190 | FILE(REMOVE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}) |
| 191 | if(WIN32 AND NOT CYGWIN) |
| 192 | ADD_CUSTOM_COMMAND( |
| 193 | OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE} |
| 194 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} |
| 195 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE} |
| 196 | DEPENDS ${PNG_LIB_NAME} ${PNG_LIB_NAME_STATIC} |
| 197 | ) |
| 198 | ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}) |
| 199 | else(WIN32 AND NOT CYGWIN) |
| 200 | execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 201 | execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 202 | endif(WIN32 AND NOT CYGWIN) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 203 | endmacro() |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 204 | |
Glenn Randers-Pehrson | e29c4b9 | 2011-09-27 19:01:58 -0500 | [diff] [blame^] | 205 | # libpng is a library so default to 'lib' |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 206 | if(NOT DEFINED CMAKE_INSTALL_LIBDIR) |
Glenn Randers-Pehrson | d3edb3f | 2011-01-14 17:08:28 -0600 | [diff] [blame] | 207 | set(CMAKE_INSTALL_LIBDIR lib) |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 208 | endif(NOT DEFINED CMAKE_INSTALL_LIBDIR) |
Glenn Randers-Pehrson | e29c4b9 | 2011-09-27 19:01:58 -0500 | [diff] [blame^] | 209 | |
| 210 | # CREATE PKGCONFIG FILES |
| 211 | # we use the same files like ./configure, so we have to set its vars |
| 212 | # Only do this on Windows for Cygwin - the files don't make much sense outside |
| 213 | # a UNIX look alike |
| 214 | if(NOT WIN32 OR CYGWIN) |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 215 | set(prefix ${CMAKE_INSTALL_PREFIX}) |
| 216 | set(exec_prefix ${CMAKE_INSTALL_PREFIX}) |
Glenn Randers-Pehrson | d3edb3f | 2011-01-14 17:08:28 -0600 | [diff] [blame] | 217 | set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 218 | set(includedir ${CMAKE_INSTALL_PREFIX}/include) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 219 | set(LIBS "-lz -lm") |
| 220 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 221 | ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY) |
Glenn Randers-Pehrson | b17c75b | 2011-07-27 20:47:13 -0500 | [diff] [blame] | 222 | CREATE_SYMLINK(${PNGLIB_NAME}.pc libpng.pc) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 223 | |
| 224 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 225 | ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY) |
Glenn Randers-Pehrson | b17c75b | 2011-07-27 20:47:13 -0500 | [diff] [blame] | 226 | CREATE_SYMLINK(${PNGLIB_NAME}-config libpng-config) |
Glenn Randers-Pehrson | e29c4b9 | 2011-09-27 19:01:58 -0500 | [diff] [blame^] | 227 | endif(NOT WIN32 OR CYGWIN) |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 228 | |
| 229 | # SET UP LINKS |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 230 | if(PNG_SHARED) |
| 231 | set_target_properties(${PNG_LIB_NAME} PROPERTIES |
Glenn Randers-Pehrson | f573ff7 | 2011-09-26 16:49:01 -0500 | [diff] [blame] | 232 | # VERSION 15.${PNGLIB_RELEASE}.1.5.6beta03 |
Glenn Randers-Pehrson | f1eb918 | 2010-02-08 15:36:41 -0600 | [diff] [blame] | 233 | VERSION 15.${PNGLIB_RELEASE}.0 |
| 234 | SOVERSION 15 |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 235 | CLEAN_DIRECT_OUTPUT 1) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 236 | endif() |
Glenn Randers-Pehrson glennrp@comcast.net | 7ecf7bd | 2009-05-02 15:36:08 -0500 | [diff] [blame] | 237 | if(PNG_STATIC) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 238 | # MSVC doesn't use a different file extension for shared vs. static |
| 239 | # libs. We are able to change OUTPUT_NAME to remove the _static |
| 240 | # for all other platforms. |
| 241 | if(NOT MSVC) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 242 | set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 243 | OUTPUT_NAME ${PNG_LIB_NAME} |
| 244 | CLEAN_DIRECT_OUTPUT 1) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 245 | endif() |
| 246 | endif() |
| 247 | |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 248 | # If CMake > 2.4.x, we set a variable used below to export |
| 249 | # targets to an export file. |
| 250 | # TODO: Use VERSION_GREATER after our cmake_minimum_required >= 2.6.2 |
| 251 | if(CMAKE_MAJOR_VERSION GREATER 1 AND CMAKE_MINOR_VERSION GREATER 4) |
| 252 | set(PNG_EXPORT_RULE EXPORT libpng) |
| 253 | elseif(CMAKE_MAJOR_VERSION GREATER 2) # future proof |
| 254 | set(PNG_EXPORT_RULE EXPORT libpng) |
| 255 | endif() |
| 256 | |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 257 | # INSTALL |
| 258 | if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 259 | if(PNG_SHARED) |
| 260 | install(TARGETS ${PNG_LIB_NAME} |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 261 | ${PNG_EXPORT_RULE} |
| 262 | RUNTIME DESTINATION bin |
| 263 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 264 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 265 | |
Glenn Randers-Pehrson | 8409b8f | 2010-12-31 09:14:01 -0600 | [diff] [blame] | 266 | # Create a symlink for libpng.dll.a => libpng15.dll.a on Cygwin |
Glenn Randers-Pehrson | 0c03fc6 | 2011-08-17 09:46:29 -0500 | [diff] [blame] | 267 | if(CYGWIN) |
| 268 | get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE}) |
| 269 | get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME) |
| 270 | CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}) |
| 271 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} |
| 272 | DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 273 | endif(CYGWIN) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 274 | |
| 275 | if(NOT WIN32) |
Glenn Randers-Pehrson | 0c03fc6 | 2011-08-17 09:46:29 -0500 | [diff] [blame] | 276 | get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE}) |
| 277 | get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME) |
| 278 | CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_SHARED_LIBRARY_SUFFIX}) |
| 279 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} |
| 280 | DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
Glenn Randers-Pehrson | b17c75b | 2011-07-27 20:47:13 -0500 | [diff] [blame] | 281 | endif(NOT WIN32) |
| 282 | endif(PNG_SHARED) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 283 | |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 284 | if(PNG_STATIC) |
| 285 | install(TARGETS ${PNG_LIB_NAME_STATIC} |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 286 | ${PNG_EXPORT_RULE} |
Glenn Randers-Pehrson | 0c03fc6 | 2011-08-17 09:46:29 -0500 | [diff] [blame] | 287 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 288 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 289 | if(NOT WIN32 OR CYGWIN) |
Glenn Randers-Pehrson | 0c03fc6 | 2011-08-17 09:46:29 -0500 | [diff] [blame] | 290 | get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME_STATIC} LOCATION_${CMAKE_BUILD_TYPE}) |
| 291 | get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME) |
| 292 | CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_STATIC_LIBRARY_SUFFIX}) |
| 293 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} |
| 294 | DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 295 | endif(NOT WIN32 OR CYGWIN) |
Glenn Randers-Pehrson | b17c75b | 2011-07-27 20:47:13 -0500 | [diff] [blame] | 296 | endif() |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 297 | endif() |
| 298 | |
| 299 | if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 300 | install(FILES ${libpng_public_hdrs} DESTINATION include) |
| 301 | install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME}) |
Glenn Randers-Pehrson | ee35abb | 2009-10-30 15:42:54 -0500 | [diff] [blame] | 302 | endif() |
| 303 | if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL ) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 304 | install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin) |
| 305 | install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config |
| 306 | DESTINATION bin) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 307 | endif() |
| 308 | if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 309 | # Install man pages |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 310 | if(NOT PNG_MAN_DIR) |
| 311 | set(PNG_MAN_DIR "share/man") |
| 312 | endif() |
| 313 | install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3) |
| 314 | install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 315 | # Install pkg-config files |
| 316 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 317 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 318 | install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 319 | DESTINATION bin) |
| 320 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 321 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 322 | install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 323 | DESTINATION bin) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 324 | endif() |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 325 | |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame] | 326 | # On versions of CMake that support it, create an export file CMake |
| 327 | # users can include() to import our targets |
| 328 | if(PNG_EXPORT_RULE AND NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL ) |
| 329 | install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake) |
| 330 | endif() |
| 331 | |
Glenn Randers-Pehrson | d3edb3f | 2011-01-14 17:08:28 -0600 | [diff] [blame] | 332 | # what's with libpng-$VER%.txt and all the extra files? |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 333 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 334 | # UNINSTALL |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 335 | # do we need this? |
| 336 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 337 | # DIST |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 338 | # do we need this? |
| 339 | |
| 340 | # to create msvc import lib for mingw compiled shared lib |
| 341 | # pexports libpng.dll > libpng.def |
| 342 | # lib /def:libpng.def /machine:x86 |
Glenn Randers-Pehrson glennrp@comcast.net | 7ecf7bd | 2009-05-02 15:36:08 -0500 | [diff] [blame] | 343 | |