mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
cmake: Fix the Clang support on Windows
Fix a build error that occurs with the Ninja code generator and the Clang compiler on Windows: ninja: error: build.ninja: multiple rules generate png16.lib Signed-off-by: Cosmin Truta <ctruta@gmail.com>
This commit is contained in:
parent
aeb26da4cb
commit
70fda1837d
@ -19,6 +19,7 @@
|
|||||||
# Revised by Owen Rudge, 2020
|
# Revised by Owen Rudge, 2020
|
||||||
# Revised by Gleb Mazovetskiy, 2021
|
# Revised by Gleb Mazovetskiy, 2021
|
||||||
# Revised by Christopher Sean Morrison, 2022
|
# Revised by Christopher Sean Morrison, 2022
|
||||||
|
# Revised by B. Scott Michel, 2022
|
||||||
# Revised by Martin Storsjo, 2022
|
# Revised by Martin Storsjo, 2022
|
||||||
# Revised by Jon Creighton, 2023
|
# Revised by Jon Creighton, 2023
|
||||||
# Revised by Gunther Nikl, 2023
|
# Revised by Gunther Nikl, 2023
|
||||||
@ -228,6 +229,18 @@ set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
|||||||
# Distinguish between debug and release builds.
|
# Distinguish between debug and release builds.
|
||||||
set(CMAKE_DEBUG_POSTFIX "d")
|
set(CMAKE_DEBUG_POSTFIX "d")
|
||||||
|
|
||||||
|
# Win32 and Clang (MinGW gcc is not affected by naming issues)
|
||||||
|
set(PNG_PREPEND_LIB_NAME "")
|
||||||
|
set(PNG_LIB_NAME_STATIC "${PNG_LIB_NAME}")
|
||||||
|
if(MSVC OR (WIN32 AND CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
|
||||||
|
# MSVC and Clang do not prepend 'lib'. Establish a consistent naming convention.
|
||||||
|
set(PNG_PREPEND_LIB_NAME "lib")
|
||||||
|
# Change the name of the static library.
|
||||||
|
set(PNG_LIB_NAME_STATIC png_static)
|
||||||
|
# Tamp down on the deprecated/potentially insecure warnings about fopen() and ilk.
|
||||||
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(CheckCSourceCompiles)
|
include(CheckCSourceCompiles)
|
||||||
option(ld-version-script "Enable linker version script" ON)
|
option(ld-version-script "Enable linker version script" ON)
|
||||||
if(ld-version-script AND NOT ANDROID AND NOT APPLE)
|
if(ld-version-script AND NOT ANDROID AND NOT APPLE)
|
||||||
@ -597,11 +610,8 @@ if(PNG_SHARED)
|
|||||||
set(PNG_LIB_TARGETS png)
|
set(PNG_LIB_TARGETS png)
|
||||||
set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME})
|
set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME})
|
||||||
add_dependencies(png genfiles)
|
add_dependencies(png genfiles)
|
||||||
if(MSVC)
|
set_target_properties(png PROPERTIES PREFIX "${PNG_PREPEND_LIB_NAME}")
|
||||||
# MVC does not append 'lib'. Do it here, to have consistent name.
|
set_target_properties(png PROPERTIES IMPORT_PREFIX "${PNG_PREPEND_LIB_NAME}")
|
||||||
set_target_properties(png PROPERTIES PREFIX "lib")
|
|
||||||
set_target_properties(png PROPERTIES IMPORT_PREFIX "lib")
|
|
||||||
endif()
|
|
||||||
target_link_libraries(png ${ZLIB_LIBRARIES} ${M_LIBRARY})
|
target_link_libraries(png ${ZLIB_LIBRARIES} ${M_LIBRARY})
|
||||||
|
|
||||||
if(UNIX AND AWK)
|
if(UNIX AND AWK)
|
||||||
@ -617,26 +627,16 @@ endif()
|
|||||||
|
|
||||||
if(PNG_STATIC)
|
if(PNG_STATIC)
|
||||||
# does not work without changing name
|
# does not work without changing name
|
||||||
set(PNG_LIB_NAME_STATIC png_static)
|
|
||||||
add_library(png_static STATIC ${libpng_sources})
|
add_library(png_static STATIC ${libpng_sources})
|
||||||
add_dependencies(png_static genfiles)
|
add_dependencies(png_static genfiles)
|
||||||
# MSVC doesn't use a different file extension for shared vs. static
|
# MSVC doesn't use a different file extension for shared vs. static
|
||||||
# libs. We are able to change OUTPUT_NAME to remove the _static
|
# libs. We are able to change OUTPUT_NAME to remove the _static
|
||||||
# for all other platforms.
|
# for all other platforms.
|
||||||
if(NOT MSVC)
|
|
||||||
set_target_properties(png_static PROPERTIES
|
set_target_properties(png_static PROPERTIES
|
||||||
OUTPUT_NAME "${PNG_LIB_NAME}"
|
OUTPUT_NAME "${PNG_LIB_NAME_STATIC}"
|
||||||
CLEAN_DIRECT_OUTPUT 1)
|
CLEAN_DIRECT_OUTPUT 1)
|
||||||
else()
|
|
||||||
set_target_properties(png_static PROPERTIES
|
|
||||||
OUTPUT_NAME "${PNG_LIB_NAME}_static"
|
|
||||||
CLEAN_DIRECT_OUTPUT 1)
|
|
||||||
endif()
|
|
||||||
list(APPEND PNG_LIB_TARGETS png_static)
|
list(APPEND PNG_LIB_TARGETS png_static)
|
||||||
if(MSVC)
|
set_target_properties(png_static PROPERTIES PREFIX "${PNG_PREPEND_LIB_NAME}")
|
||||||
# MSVC does not append 'lib'. Do it here, to have consistent name.
|
|
||||||
set_target_properties(png_static PROPERTIES PREFIX "lib")
|
|
||||||
endif()
|
|
||||||
target_link_libraries(png_static ${ZLIB_LIBRARIES} ${M_LIBRARY})
|
target_link_libraries(png_static ${ZLIB_LIBRARIES} ${M_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user