diff options
author | Cosmin Truta <ctruta@gmail.com> | 2023-02-12 22:31:11 +0200 |
---|---|---|
committer | Cosmin Truta <ctruta@gmail.com> | 2023-02-12 22:31:11 +0200 |
commit | e519af8b49f52c4ac400f50f23b48ebe36a5f4df (patch) | |
tree | 46c000931803a0e7542ca7f2e048809a47e46e5d | |
parent | efc96c9d59a9052c4db9245ca0a204fc267fe396 (diff) | |
download | libpng-e519af8b49f52c4ac400f50f23b48ebe36a5f4df.tar.gz |
Users may opt to change the debug suffix, e.g., from "d" to "_debug".
Rather than making CMAKE_DEBUG_POSTFIX a cache variable (which is
an antipattern in CMake), we introduce a new cache variable, named
PNG_DEBUG_POSTFIX.
Suggested-by: Diego Barrios Romero <eldruin@gmail.com>
-rw-r--r-- | CMakeLists.txt | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e08f4c445..90b53f37c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,13 @@ set(PNGLIB_SHARED_VERSION ${PNGLIB_ABI_VERSION}.${PNGLIB_REVISION}.${PNGLIB_SUBR set(PNG_PREFIX "" CACHE STRING "Prefix to prepend to the API function names") +# Allow the users to override the postfix appended to debug library file names. +# Previously, we used to set CMAKE_DEBUG_POSTFIX globally. That variable should +# not be cached, however, because doing so would affect all projects processed +# after libpng, in unexpected and undesirable ways. +set(PNG_DEBUG_POSTFIX "d" + CACHE STRING "Postfix to append to library file names under the Debug configuration") + # Allow the users to import their own extra configuration settings. set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings") @@ -229,9 +236,6 @@ endif() endif(PNG_HARDWARE_OPTIMIZATIONS) -# Distinguish between debug and release builds. -set(CMAKE_DEBUG_POSTFIX "d") - option(ld-version-script "Enable linker version script" ON) if(ld-version-script AND NOT ANDROID AND NOT APPLE) # Check if LD supports linker scripts. @@ -639,6 +643,7 @@ if(PNG_SHARED) list(APPEND PNG_LIBRARY_TARGETS png_shared) set_target_properties(png_shared PROPERTIES OUTPUT_NAME "${PNG_SHARED_OUTPUT_NAME}" + DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}" VERSION "${PNGLIB_SHARED_VERSION}" SOVERSION "${PNGLIB_ABI_VERSION}") if(UNIX AND AWK) @@ -661,7 +666,8 @@ if(PNG_STATIC) add_dependencies(png_static png_genfiles) list(APPEND PNG_LIBRARY_TARGETS png_static) set_target_properties(png_static PROPERTIES - OUTPUT_NAME "${PNG_STATIC_OUTPUT_NAME}") + OUTPUT_NAME "${PNG_STATIC_OUTPUT_NAME}" + DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}") target_link_libraries(png_static ${ZLIB_LIBRARIES} ${M_LIBRARY}) endif() |