Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 1 | cmake_minimum_required(VERSION 2.4.4) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 2 | set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) |
| 3 | |
Glenn Randers-Pehrson | ee35abb | 2009-10-30 15:42:54 -0500 | [diff] [blame] | 4 | if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 5 | 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-Pehrson | ee35abb | 2009-10-30 15:42:54 -0500 | [diff] [blame] | 17 | endif() |
| 18 | |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 19 | project(libpng C) |
Glenn Randers-Pehrson | ee35abb | 2009-10-30 15:42:54 -0500 | [diff] [blame] | 20 | enable_testing() |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 21 | |
Glenn Randers-Pehrson | f81b50b | 2009-12-29 16:50:15 -0600 | [diff] [blame] | 22 | # Copyright (C) 2007-2010 Glenn Randers-Pehrson |
Glenn Randers-Pehrson | 3e61d79 | 2009-06-24 09:31:28 -0500 | [diff] [blame] | 23 | |
Glenn Randers-Pehrson | bfbf865 | 2009-06-26 21:46:52 -0500 | [diff] [blame] | 24 | # This code is released under the libpng license. |
Glenn Randers-Pehrson | c332bbc | 2009-06-25 13:43:50 -0500 | [diff] [blame] | 25 | # For conditions of distribution and use, see the disclaimer |
Glenn Randers-Pehrson | 037023b | 2009-06-24 10:27:36 -0500 | [diff] [blame] | 26 | # and license in png.h |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 27 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 28 | set(PNGLIB_MAJOR 1) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 29 | set(PNGLIB_MINOR 5) |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 30 | set(PNGLIB_RELEASE 0) |
| 31 | set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) |
| 32 | set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 33 | |
| 34 | # needed packages |
| 35 | find_package(ZLIB REQUIRED) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 36 | include_directories(${ZLIB_INCLUDE_DIR}) |
| 37 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 38 | if(NOT WIN32) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 39 | 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-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 47 | else() |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 48 | # not needed on windows |
| 49 | set(M_LIBRARY "") |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 50 | endif() |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 51 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 52 | # COMMAND LINE OPTIONS |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 53 | if(DEFINED PNG_SHARED) |
| 54 | option(PNG_SHARED "Build shared lib" ${PNG_SHARED}) |
| 55 | else() |
| 56 | option(PNG_SHARED "Build shared lib" ON) |
| 57 | endif() |
| 58 | if(DEFINED PNG_STATIC) |
| 59 | option(PNG_STATIC "Build static lib" ${PNG_STATIC}) |
| 60 | else() |
| 61 | option(PNG_STATIC "Build static lib" ON) |
| 62 | endif() |
| 63 | |
Glenn Randers-Pehrson glennrp@comcast.net | 7ecf7bd | 2009-05-02 15:36:08 -0500 | [diff] [blame] | 64 | if(MINGW) |
| 65 | option(PNG_TESTS "Build pngtest" NO) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 66 | else() |
Glenn Randers-Pehrson glennrp@comcast.net | 7ecf7bd | 2009-05-02 15:36:08 -0500 | [diff] [blame] | 67 | option(PNG_TESTS "Build pngtest" YES) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 68 | endif() |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 69 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 70 | option(PNG_NO_CONSOLE_IO "FIXME" YES) |
| 71 | option(PNG_NO_STDIO "FIXME" YES) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 72 | option(PNG_DEBUG "Build with debug output" NO) |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 73 | option(PNGARG "FIXME" YES) |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 74 | #TODO: |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 75 | # PNG_CONSOLE_IO_SUPPORTED |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 76 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 77 | # maybe needs improving, but currently I don't know when we can enable what :) |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 78 | set(png_asm_tmp "OFF") |
| 79 | if(NOT WIN32) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 80 | 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-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 85 | set(png_asm_tmp "ON") |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 86 | else("uname_output" MATCHES "^.*i[1-9]86.*$") |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 87 | set(png_asm_tmp "OFF") |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 88 | endif("uname_output" MATCHES "^.*i[1-9]86.*$") |
| 89 | endif(uname_executable) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 90 | else() |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 91 | # 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-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 96 | endif() |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 97 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 98 | # SET LIBNAME |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 99 | set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 100 | |
| 101 | # to distinguish between debug and release lib |
| 102 | set(CMAKE_DEBUG_POSTFIX "d") |
| 103 | |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 104 | # Use the prebuilt pnglibconf.h file from the scripts folder |
| 105 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt |
| 106 | ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h) |
| 107 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 108 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 109 | # OUR SOURCES |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 110 | set(libpng_public_hdrs |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 111 | png.h |
| 112 | pngconf.h |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 113 | ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h |
| 114 | ) |
| 115 | set(libpng_sources |
| 116 | ${libpng_public_hdrs} |
Glenn Randers-Pehrson | 07d9fc9 | 2010-08-26 17:11:55 -0500 | [diff] [blame] | 117 | pngdebug.h |
| 118 | pnginfo.h |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 119 | pngpriv.h |
Glenn Randers-Pehrson | 07d9fc9 | 2010-08-26 17:11:55 -0500 | [diff] [blame] | 120 | pngstruct.h |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 121 | 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-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 136 | ) |
| 137 | set(pngtest_sources |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 138 | pngtest.c |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 139 | ) |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 140 | # SOME NEEDED DEFINITIONS |
Glenn Randers-Pehrson | 69b0bc0 | 2009-11-07 12:02:48 -0600 | [diff] [blame] | 141 | |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 142 | add_definitions(-DPNG_CONFIGURE_LIBPNG) |
| 143 | |
| 144 | if(_AIX) |
| 145 | add_definitions(-D_ALL_SOURCE) |
| 146 | endif(_AIX) |
| 147 | |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 148 | if(MSVC) |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 149 | add_definitions(-DPNG_NO_MODULEDEF -D_CRT_SECURE_NO_DEPRECATE) |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 150 | endif(MSVC) |
| 151 | |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 152 | if(PNG_SHARED OR NOT MSVC) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 153 | #if building msvc static this has NOT to be defined |
| 154 | add_definitions(-DZLIB_DLL) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 155 | endif() |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 156 | |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 157 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 158 | if(PNG_CONSOLE_IO_SUPPORTED) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 159 | add_definitions(-DPNG_CONSOLE_IO_SUPPORTED) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 160 | endif() |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 161 | |
| 162 | if(PNG_NO_CONSOLE_IO) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 163 | add_definitions(-DPNG_NO_CONSOLE_IO) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 164 | endif() |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 165 | |
| 166 | if(PNG_NO_STDIO) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 167 | add_definitions(-DPNG_NO_STDIO) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 168 | endif() |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 169 | |
| 170 | if(PNG_DEBUG) |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 171 | add_definitions(-DPNG_DEBUG) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 172 | endif() |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 173 | |
Glenn Randers-Pehrson glennrp@comcast.net | 7ecf7bd | 2009-05-02 15:36:08 -0500 | [diff] [blame] | 174 | if(NOT M_LIBRARY AND NOT WIN32) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 175 | add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 176 | endif() |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 177 | |
| 178 | # NOW BUILD OUR TARGET |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 179 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR}) |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 180 | |
| 181 | if(PNG_SHARED) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 182 | 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-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 186 | set_target_properties(${PNG_LIB_NAME} PROPERTIES IMPORT_PREFIX "lib") |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 187 | endif() |
| 188 | target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY}) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 189 | endif() |
| 190 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 191 | if(PNG_STATIC) |
| 192 | # does not work without changing name |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 193 | 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-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 199 | target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY}) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 200 | endif() |
| 201 | |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 202 | |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 203 | if(PNG_SHARED AND WIN32) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 204 | 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] | 205 | endif() |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 206 | |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 207 | if(PNG_TESTS AND PNG_SHARED) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 208 | # 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-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 211 | add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 212 | endif() |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 213 | |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 214 | # |
| 215 | # Set a variable with CMake code which: |
| 216 | # Creates a symlink from src to dest (if possible) or alternatively |
| 217 | # copies if different. |
| 218 | macro(_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 | ") |
| 232 | endmacro() |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 233 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 234 | # CREATE PKGCONFIG FILES |
| 235 | # we use the same files like ./configure, so we have to set its vars |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 236 | if(NOT DEFINED CMAKE_INSTALL_LIBDIR) |
| 237 | set(CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib) |
| 238 | endif(NOT DEFINED CMAKE_INSTALL_LIBDIR) |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 239 | set(prefix ${CMAKE_INSTALL_PREFIX}) |
| 240 | set(exec_prefix ${CMAKE_INSTALL_PREFIX}) |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 241 | set(libdir ${CMAKE_INSTALL_LIBDIR}) |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 242 | set(includedir ${CMAKE_INSTALL_PREFIX}/include) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 243 | set(LIBS "-lz -lm") |
| 244 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 245 | ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 246 | _png_generate_symlink_code(PNG_PC_INSTALL_CODE ${PNGLIB_NAME}.pc libpng.pc) |
| 247 | install(CODE ${PNG_PC_INSTALL_CODE}) |
| 248 | |
| 249 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 250 | ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 251 | _png_generate_symlink_code(PNG_CONFIG_INSTALL_CODE ${PNGLIB_NAME}-config libpng-config) |
| 252 | install(CODE ${PNG_CONFIG_INSTALL_CODE}) |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 253 | |
| 254 | # SET UP LINKS |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 255 | if(PNG_SHARED) |
| 256 | set_target_properties(${PNG_LIB_NAME} PROPERTIES |
Glenn Randers-Pehrson | 4f8e7e5 | 2010-09-10 22:07:45 -0500 | [diff] [blame] | 257 | # VERSION 15.${PNGLIB_RELEASE}.1.5.0beta48 |
Glenn Randers-Pehrson | f1eb918 | 2010-02-08 15:36:41 -0600 | [diff] [blame] | 258 | VERSION 15.${PNGLIB_RELEASE}.0 |
| 259 | SOVERSION 15 |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 260 | CLEAN_DIRECT_OUTPUT 1) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 261 | endif() |
Glenn Randers-Pehrson glennrp@comcast.net | 7ecf7bd | 2009-05-02 15:36:08 -0500 | [diff] [blame] | 262 | if(PNG_STATIC) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 263 | # 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-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 267 | set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 268 | OUTPUT_NAME ${PNG_LIB_NAME} |
| 269 | CLEAN_DIRECT_OUTPUT 1) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 270 | endif() |
| 271 | endif() |
| 272 | |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 273 | # 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 |
| 276 | if(CMAKE_MAJOR_VERSION GREATER 1 AND CMAKE_MINOR_VERSION GREATER 4) |
| 277 | set(PNG_EXPORT_RULE EXPORT libpng) |
| 278 | elseif(CMAKE_MAJOR_VERSION GREATER 2) # future proof |
| 279 | set(PNG_EXPORT_RULE EXPORT libpng) |
| 280 | endif() |
| 281 | |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 282 | # INSTALL |
| 283 | if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 284 | if(PNG_SHARED) |
| 285 | install(TARGETS ${PNG_LIB_NAME} |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 286 | ${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-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 307 | endif() |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 308 | |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 309 | if(PNG_STATIC) |
| 310 | install(TARGETS ${PNG_LIB_NAME_STATIC} |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 311 | ${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-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 321 | endif() |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 322 | endif() |
| 323 | |
| 324 | if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 325 | install(FILES ${libpng_public_hdrs} DESTINATION include) |
| 326 | install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME}) |
Glenn Randers-Pehrson | ee35abb | 2009-10-30 15:42:54 -0500 | [diff] [blame] | 327 | endif() |
| 328 | if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL ) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 329 | 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-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 332 | endif() |
| 333 | if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 334 | # Install man pages |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 335 | 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-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 340 | # Install pkg-config files |
| 341 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 342 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 343 | install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 344 | DESTINATION bin) |
| 345 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 346 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) |
Glenn Randers-Pehrson | 8c03730 | 2010-08-23 17:07:32 -0500 | [diff] [blame] | 347 | install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 348 | DESTINATION bin) |
Glenn Randers-Pehrson | 38e467e | 2009-08-27 15:59:40 -0500 | [diff] [blame] | 349 | endif() |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 350 | |
Glenn Randers-Pehrson | 0c3fea3 | 2010-10-02 21:25:01 -0500 | [diff] [blame^] | 351 | # On versions of CMake that support it, create an export file CMake |
| 352 | # users can include() to import our targets |
| 353 | if(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) |
| 355 | endif() |
| 356 | |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 357 | # what's with libpng.txt and all the extra files? |
| 358 | |
| 359 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 360 | # UNINSTALL |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 361 | # do we need this? |
| 362 | |
| 363 | |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 364 | # DIST |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 365 | # 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.net | 7ecf7bd | 2009-05-02 15:36:08 -0500 | [diff] [blame] | 370 | |