From b9f277df66cb99c59cf6aa48a9dd76045876b63b Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 10 Dec 2022 01:53:23 -0600 Subject: [PATCH] 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. (cherry picked from commit fcf69001ada08077f82d3fc8510dcd24b4433e64) --- thirdparty/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 0f8ddd2aa..8e9793ee7 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -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)