Better CMake

This commit is contained in:
TheBrokenRail 2022-08-05 22:07:19 -04:00
parent 4977898bcd
commit d761ad8614
3 changed files with 6 additions and 17 deletions

View File

@ -11,26 +11,15 @@ add_compile_options(-w)
# Options
set(PNG_TESTS FALSE CACHE BOOL "" FORCE)
set(PNG_NO_STDIO FALSE CACHE BOOL "" FORCE)
set(PNG_STATIC FALSE CACHE BOOL "" FORCE)
set(PNG_SHARED TRUE CACHE BOOL "" FORCE)
set(PNG_BUILD_ZLIB TRUE CACHE BOOL "" FORCE)
# Download
set(ZLIB_LIBRARY zlibstatic)
set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zlib/src")
set(CMAKE_POLICY_DEFAULT_CMP0054 OLD) # Silence Warning
set(CMAKE_POLICY_DEFAULT_CMP0003 NEW) # Silence Warning
set(CMAKE_POLICY_DEFAULT_CMP0022 NEW) # Fix Error
set(M_LIBRARY m) # No Full Paths!
set(ZLIB_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/zlib/src" "${CMAKE_CURRENT_BINARY_DIR}/zlib/src")
add_subdirectory(src EXCLUDE_FROM_ALL)
set(CMAKE_POLICY_DEFAULT_CMP0054 NEW) # Re-Enable New Behavior
# Setup Target
set_target_properties(png12 PROPERTIES LINK_OPTIONS "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libpng.vers") # Use Symbol Versioning
set_target_properties(png12 PROPERTIES DEBUG_POSTFIX "") # Fix LibPNG Suffix In Debug Mode
target_include_directories(png12 PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>")
foreach(zlib_include_dir IN ITEMS "${ZLIB_INCLUDE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/zlib/src")
target_include_directories(png12 PUBLIC "$<BUILD_INTERFACE:${zlib_include_dir}>")
endforeach()
# Use Symbol Versioning
set_target_properties(png12 PROPERTIES LINK_OPTIONS "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libpng.vers")
# Ensure Build
add_custom_target(png12-build ALL DEPENDS png12)

@ -1 +1 @@
Subproject commit 5bb5bf345aef1e62adcfe30791f4364730a2aede
Subproject commit 07d0b89cddb833770627b3e81d79cd8dfaf00b43

@ -1 +1 @@
Subproject commit 7dc886e7d217bb2ecaa2d771e08443b92c36fe28
Subproject commit 27cd9e88a72538b00d172dee67d94cb4ce6bc9b9