cmake: Fix png and openmpt builds in clean envs

In environments without zlib installed, png would fail to build since
it can't find zlib.h. The zlib build's generated public include dir
needs zlib.h to work.

openmpt fails to build because it can't find Rpcrt4, which is not a
necessary link under mingw, but exists in some mingw-w64 toolchains.
It is only needed for MSVC.
This commit is contained in:
Eidolon 2022-12-10 01:53:23 -06:00
parent fb0f0c5e6c
commit fcf69001ad

View file

@ -91,6 +91,7 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
configure_file("${ZLIB_SOURCE_DIR}/zlib.pc.cmakein" "${ZLIB_BINARY_DIR}/zlib.pc" @ONLY)
configure_file("${ZLIB_SOURCE_DIR}/zconf.h.cmakein" "${ZLIB_BINARY_DIR}/include/zconf.h" @ONLY)
configure_file("${ZLIB_SOURCE_DIR}/zlib.h" "${ZLIB_BINARY_DIR}/include/zlib.h" @ONLY)
add_library(ZLIB ${SRB2_INTERNAL_LIBRARY_TYPE} ${ZLIB_SRCS})
set_target_properties(ZLIB PROPERTIES
@ -173,8 +174,8 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
target_include_directories(png PUBLIC "${png_BINARY_DIR}/include")
# ... and these also need to be present only for png build
target_include_directories(png PRIVATE "${zlib_SOURCE_DIR}")
target_include_directories(png PRIVATE "${zlib_BINARY_DIR}")
target_include_directories(png PRIVATE "${ZLIB_SOURCE_DIR}")
target_include_directories(png PRIVATE "${ZLIB_BINARY_DIR}")
target_include_directories(png PRIVATE "${png_BINARY_DIR}")
target_link_libraries(png PRIVATE ZLIB::ZLIB)
@ -495,7 +496,7 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU OR "${CMAKE_C_COMPILER_ID}" STREQUAL Clang OR "${CMAKE_C_COMPILER_ID}" STREQUAL AppleClang)
target_compile_options(openmpt PRIVATE "-g0")
endif()
if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows)
if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND "${CMAKE_C_COMPILER_ID}" STREQUAL MSVC)
target_link_libraries(openmpt PRIVATE Rpcrt4)
endif()
target_compile_features(openmpt PRIVATE cxx_std_11)