mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[master] Revised CMakeLists.txt (Philip Lowman).
This commit is contained in:
parent
afb77541b4
commit
185cd6c058
6
ANNOUNCE
6
ANNOUNCE
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Libpng 1.4.4rc02 - September 10, 2010
|
Libpng 1.4.4rc02 - September 13, 2010
|
||||||
|
|
||||||
This is not intended to be a public release. It will be replaced
|
This is not intended to be a public release. It will be replaced
|
||||||
within a few weeks by a public version or by another test version.
|
within a few weeks by a public version or by another test version.
|
||||||
@ -77,8 +77,8 @@ version 1.4.4beta08 [September 2, 2010]
|
|||||||
version 1.4.4rc01 [September 10, 2010]
|
version 1.4.4rc01 [September 10, 2010]
|
||||||
No changes.
|
No changes.
|
||||||
|
|
||||||
version 1.4.4rc02 [September 10, 2010]
|
version 1.4.4rc02 [September 13, 2010]
|
||||||
|
Revised CMakeLists.txt (Philip Lowman).
|
||||||
|
|
||||||
Send comments/corrections/commendations to glennrp at users.sourceforge.net
|
Send comments/corrections/commendations to glennrp at users.sourceforge.net
|
||||||
or to png-mng-implement at lists.sf.net (subscription required; visit
|
or to png-mng-implement at lists.sf.net (subscription required; visit
|
||||||
|
135
CMakeLists.txt
135
CMakeLists.txt
@ -1,14 +1,19 @@
|
|||||||
cmake_minimum_required(VERSION 2.4.3)
|
cmake_minimum_required(VERSION 2.4.4)
|
||||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||||
|
|
||||||
if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE)
|
if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
if(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4)
|
||||||
"Choose the type of build, options are:
|
# workaround CMake 2.4.x bug
|
||||||
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used)
|
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.")
|
||||||
Debug
|
else()
|
||||||
Release
|
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
||||||
RelWithDebInfo
|
"Choose the type of build, options are:
|
||||||
MinSizeRel.")
|
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used)
|
||||||
|
Debug
|
||||||
|
Release
|
||||||
|
RelWithDebInfo
|
||||||
|
MinSizeRel.")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(libpng C)
|
project(libpng C)
|
||||||
@ -91,7 +96,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# SET LIBNAME
|
# SET LIBNAME
|
||||||
set(PNG_LIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||||
|
|
||||||
# to distinguish between debug and release lib
|
# to distinguish between debug and release lib
|
||||||
set(CMAKE_DEBUG_POSTFIX "d")
|
set(CMAKE_DEBUG_POSTFIX "d")
|
||||||
@ -101,7 +106,7 @@ set(CMAKE_DEBUG_POSTFIX "d")
|
|||||||
set(libpng_sources
|
set(libpng_sources
|
||||||
png.h
|
png.h
|
||||||
pngconf.h
|
pngconf.h
|
||||||
pngpriv.h
|
pngpriv.h
|
||||||
png.c
|
png.c
|
||||||
pngerror.c
|
pngerror.c
|
||||||
pngget.c
|
pngget.c
|
||||||
@ -167,6 +172,7 @@ if(PNG_SHARED)
|
|||||||
if(MSVC)
|
if(MSVC)
|
||||||
# msvc does not append 'lib' - do it here to have consistent name
|
# msvc does not append 'lib' - do it here to have consistent name
|
||||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
|
set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
|
||||||
|
set_target_properties(${PNG_LIB_NAME} PROPERTIES IMPORT_PREFIX "lib")
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY})
|
target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
@ -179,6 +185,7 @@ if(PNG_STATIC)
|
|||||||
# msvc does not append 'lib' - do it here to have consistent name
|
# msvc does not append 'lib' - do it here to have consistent name
|
||||||
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
|
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
|
||||||
endif()
|
endif()
|
||||||
|
target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
@ -193,6 +200,26 @@ if(PNG_TESTS AND PNG_SHARED)
|
|||||||
add_test(pngtest pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
|
add_test(pngtest pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Set a variable with CMake code which:
|
||||||
|
# Creates a symlink from src to dest (if possible) or alternatively
|
||||||
|
# copies if different.
|
||||||
|
macro(_png_generate_symlink_code CODE SRC DEST)
|
||||||
|
if(WIN32 AND NOT CYGWIN)
|
||||||
|
set(_png_gsc_message "Copying ${SRC} to ${DEST} if needed")
|
||||||
|
set(_png_gsc_operation "copy_if_different")
|
||||||
|
else()
|
||||||
|
set(_png_gsc_message "Symlinking ${SRC} to ${DEST}")
|
||||||
|
set(_png_gsc_operation "create_symlink")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${CODE} "
|
||||||
|
message(STATUS \"${_png_gsc_message}\")
|
||||||
|
execute_process(COMMAND \${CMAKE_COMMAND} -E ${_png_gsc_operation}
|
||||||
|
\"${SRC}\"
|
||||||
|
\"${DEST}\")
|
||||||
|
")
|
||||||
|
endmacro()
|
||||||
|
|
||||||
# CREATE PKGCONFIG FILES
|
# CREATE PKGCONFIG FILES
|
||||||
# we use the same files like ./configure, so we have to set its vars
|
# we use the same files like ./configure, so we have to set its vars
|
||||||
@ -204,18 +231,15 @@ set(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
|||||||
set(libdir ${CMAKE_INSTALL_LIBDIR})
|
set(libdir ${CMAKE_INSTALL_LIBDIR})
|
||||||
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
|
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
|
||||||
set(LIBS "-lz -lm")
|
set(LIBS "-lz -lm")
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
|
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
|
||||||
install(CODE "
|
_png_generate_symlink_code(PNG_PC_INSTALL_CODE ${PNGLIB_NAME}.pc libpng.pc)
|
||||||
MESSAGE(STATUS \"Symlinking ${PNGLIB_NAME}.pc to libpng.pc\")
|
install(CODE ${PNG_PC_INSTALL_CODE})
|
||||||
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
|
|
||||||
\"${PNGLIB_NAME}.pc\"
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
||||||
\"libpng.pc\")
|
|
||||||
")
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
|
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
|
||||||
install(CODE "
|
_png_generate_symlink_code(PNG_CONFIG_INSTALL_CODE ${PNGLIB_NAME}-config libpng-config)
|
||||||
|
install(CODE ${PNG_CONFIG_INSTALL_CODE})
|
||||||
MESSAGE(STATUS \"Symlinking ${PNGLIB_NAME}-config to libpng-config\")
|
MESSAGE(STATUS \"Symlinking ${PNGLIB_NAME}-config to libpng-config\")
|
||||||
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
|
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
|
||||||
\"${PNGLIB_NAME}-config\"
|
\"${PNGLIB_NAME}-config\"
|
||||||
@ -231,40 +255,64 @@ if(PNG_SHARED)
|
|||||||
CLEAN_DIRECT_OUTPUT 1)
|
CLEAN_DIRECT_OUTPUT 1)
|
||||||
endif()
|
endif()
|
||||||
if(PNG_STATIC)
|
if(PNG_STATIC)
|
||||||
if(NOT WIN32)
|
# MSVC doesn't use a different file extension for shared vs. static
|
||||||
# that's uncool on win32 - it overwrites our static import lib...
|
# libs. We are able to change OUTPUT_NAME to remove the _static
|
||||||
|
# for all other platforms.
|
||||||
|
if(NOT MSVC)
|
||||||
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES
|
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES
|
||||||
OUTPUT_NAME ${PNG_LIB_NAME}
|
OUTPUT_NAME ${PNG_LIB_NAME}
|
||||||
CLEAN_DIRECT_OUTPUT 1)
|
CLEAN_DIRECT_OUTPUT 1)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# If CMake > 2.4.x, we set a variable used below to export
|
||||||
|
# targets to an export file.
|
||||||
|
# TODO: Use VERSION_GREATER after our cmake_minimum_required >= 2.6.2
|
||||||
|
if(CMAKE_MAJOR_VERSION GREATER 1 AND CMAKE_MINOR_VERSION GREATER 4)
|
||||||
|
set(PNG_EXPORT_RULE EXPORT libpng)
|
||||||
|
elseif(CMAKE_MAJOR_VERSION GREATER 2) # future proof
|
||||||
|
set(PNG_EXPORT_RULE EXPORT libpng)
|
||||||
|
endif()
|
||||||
|
|
||||||
# INSTALL
|
# INSTALL
|
||||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||||
if(PNG_SHARED)
|
if(PNG_SHARED)
|
||||||
install(TARGETS ${PNG_LIB_NAME}
|
install(TARGETS ${PNG_LIB_NAME}
|
||||||
RUNTIME DESTINATION bin
|
${PNG_EXPORT_RULE}
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
install(CODE "
|
|
||||||
MESSAGE(STATUS \"Symlinking ${PNGLIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} to libpng${CMAKE_SHARED_LIBRARY_SUFFIX}\")
|
# Create a symlink for libpng.dll.a => libpng14.dll.a on Cygwin
|
||||||
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
|
if(CYGWIN)
|
||||||
\"${PNGLIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}\"
|
_png_generate_symlink_code(PNG_SHARED_IMPLIB_INSTALL_CODE
|
||||||
\"libpng${CMAKE_SHARED_LIBRARY_SUFFIX}\")
|
${PNGLIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
||||||
")
|
libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
install(CODE ${PNG_SHARED_IMPLIB_INSTALL_CODE})
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT WIN32)
|
||||||
|
_png_generate_symlink_code(PNG_SHARED_INSTALL_CODE
|
||||||
|
${PNGLIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||||
|
libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||||
|
install(CODE ${PNG_SHARED_INSTALL_CODE})
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PNG_STATIC)
|
if(PNG_STATIC)
|
||||||
install(TARGETS ${PNG_LIB_NAME_STATIC}
|
install(TARGETS ${PNG_LIB_NAME_STATIC}
|
||||||
|
${PNG_EXPORT_RULE}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
install(CODE "
|
if(NOT WIN32 OR CYGWIN)
|
||||||
MESSAGE(STATUS \"Symlinking ${PNGLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX} to libpng${CMAKE_STATIC_LIBRARY_SUFFIX}\")
|
_png_generate_symlink_code(PNG_STATIC_INSTALL_CODE
|
||||||
execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
|
${PNGLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||||
\"${PNGLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}\"
|
libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||||
\"libpng${CMAKE_STATIC_LIBRARY_SUFFIX}\")
|
install(CODE ${PNG_STATIC_INSTALL_CODE})
|
||||||
")
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -279,8 +327,11 @@ if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
|
|||||||
endif()
|
endif()
|
||||||
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||||
# Install man pages
|
# Install man pages
|
||||||
install(FILES libpng.3 libpngpf.3 DESTINATION share/man/man3)
|
if(NOT PNG_MAN_DIR)
|
||||||
install(FILES png.5 DESTINATION share/man/man5)
|
set(PNG_MAN_DIR "share/man")
|
||||||
|
endif()
|
||||||
|
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
|
||||||
|
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
|
||||||
# Install pkg-config files
|
# Install pkg-config files
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
@ -292,6 +343,12 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
|||||||
DESTINATION bin)
|
DESTINATION bin)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# On versions of CMake that support it, create an export file CMake
|
||||||
|
# users can include() to import our targets
|
||||||
|
if(PNG_EXPORT_RULE AND NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL )
|
||||||
|
install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake)
|
||||||
|
endif()
|
||||||
|
|
||||||
# what's with libpng.txt and all the extra files?
|
# what's with libpng.txt and all the extra files?
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user