Skip to content

Commit

Permalink
Merge pull request #71089 from alef/link_exe_things
Browse files Browse the repository at this point in the history
Align and fix some Windows MSVC build setting
  • Loading branch information
Maleclypse authored Jan 24, 2024
2 parents e918859 + b76120b commit c374e1a
Show file tree
Hide file tree
Showing 20 changed files with 230 additions and 284 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ endif()
message(STATUS "${PROJECT_NAME} build environment --")
message(STATUS "Build realm is: ${CMAKE_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}")

if (NOT CMAKE_BUILD_TYPE)
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL
PROPERTY GENERATOR_IS_MULTI_CONFIG
)
if (NOT CMAKE_BUILD_TYPE AND NOT GENERATOR_IS_MULTI_CONFIG)
set(CMAKE_BUILD_TYPE Debug)
endif ()

Expand Down Expand Up @@ -94,6 +97,10 @@ endif ()

include(CheckCXXCompilerFlag)

if(DEFINED ENV{MSYSTEM})
set(MSYS2 True)
add_definitions(-DMSYS2)
endif()
#FIXME: Add dest build choice: m32 for 32 bit or m64 for 64 bit version
#add_definitions("-m32")
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
Expand Down
55 changes: 53 additions & 2 deletions CMakeModules/Find/FindSDL2_image.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ if(NOT DYNAMIC_LINKING AND PKG_CONFIG_FOUND)
find_package(JPEG REQUIRED)
find_package(PNG REQUIRED)
find_package(TIFF REQUIRED)
pkg_check_modules(WEBP REQUIRED IMPORTED_TARGET libwebp)
target_link_libraries(TIFF::TIFF INTERFACE
PkgConfig::WEBP
)
find_library(JBIG jbig REQUIRED)
find_package(LibLZMA REQUIRED)
target_link_libraries(SDL2_image::SDL2_image-static INTERFACE
Expand All @@ -117,16 +121,63 @@ if(NOT DYNAMIC_LINKING AND PKG_CONFIG_FOUND)
LibLZMA::LibLZMA
${ZSTD}
)
pkg_check_modules(WEBP REQUIRED IMPORTED_TARGET libwebp)
pkg_check_modules(ZIP REQUIRED IMPORTED_TARGET libzip)
pkg_check_modules(ZSTD REQUIRED IMPORTED_TARGET libzstd)
pkg_check_modules(DEFLATE REQUIRED IMPORTED_TARGET libdeflate)
target_link_libraries(SDL2_image::SDL2_image-static INTERFACE
PkgConfig::WEBP
PkgConfig::ZIP
PkgConfig::ZSTD
PkgConfig::DEFLATE
)
if(MSYS2)
# only SHARED: find_package(libavif REQUIRED)
find_library(AVIF avif)
add_library(libavif STATIC IMPORTED)
set_target_properties(libavif PROPERTIES
IMPORTED_LOCATION ${AVIF}
)
pkg_check_modules(libyuv REQUIRED IMPORTED_TARGET libyuv)
pkg_check_modules(dav1d REQUIRED IMPORTED_TARGET dav1d)
pkg_check_modules(rav1e REQUIRED IMPORTED_TARGET rav1e)
pkg_check_modules(SvtAv1Enc REQUIRED IMPORTED_TARGET SvtAv1Enc)
target_link_libraries(PkgConfig::rav1e INTERFACE
ntdll
)
pkg_check_modules(aom REQUIRED IMPORTED_TARGET aom)
target_link_libraries(libavif INTERFACE
PkgConfig::libyuv
PkgConfig::dav1d
PkgConfig::rav1e
PkgConfig::SvtAv1Enc
PkgConfig::aom
)
pkg_check_modules(JXL REQUIRED IMPORTED_TARGET libjxl libjxl_threads)
# only SHARED: find_package(hwy REQUIRED)
pkg_check_modules(hwy REQUIRED IMPORTED_TARGET libhwy)
target_link_libraries(PkgConfig::JXL INTERFACE
PkgConfig::hwy
PkgConfig::BROTLI
)
find_package(libjpeg-turbo REQUIRED)
pkg_check_modules(Lerc REQUIRED IMPORTED_TARGET Lerc)
target_link_libraries(SDL2_image::SDL2_image-static INTERFACE
libavif
PkgConfig::JXL
PkgConfig::Lerc
libjpeg-turbo::turbojpeg
)
pkg_check_modules(WEBPDEMUX REQUIRED IMPORTED_TARGET libwebpdemux)
pkg_check_modules(WEBPDECODER REQUIRED IMPORTED_TARGET libwebpdecoder)
target_link_libraries(TIFF::TIFF INTERFACE
WEBPDEMUX
WEBPDECODER
JPEG::JPEG
)
pkg_check_modules(sharpyuv REQUIRED IMPORTED_TARGET libsharpyuv)
target_link_libraries(PkgConfig::WEBP INTERFACE
PkgConfig::sharpyuv
)
endif()
elseif(NOT TARGET SDL2_image::SDL2_image)
add_library(SDL2_image::SDL2_image UNKNOWN IMPORTED)
set_target_properties(SDL2_image::SDL2_image PROPERTIES
Expand Down
15 changes: 15 additions & 0 deletions CMakeModules/Find/FindSDL2_mixer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,21 @@ if(PKG_CONFIG_FOUND)
target_link_libraries(SDL2_mixer::SDL2_mixer-static INTERFACE
PkgConfig::FLAC
)
if(MSYS2)
pkg_check_modules(libmpg123 REQUIRED IMPORTED_TARGET libmpg123)
pkg_check_modules(opus REQUIRED IMPORTED_TARGET opus)
pkg_check_modules(opusfile REQUIRED IMPORTED_TARGET opusfile)
# SHARED only: find_package(Ogg REQUIRED)
pkg_check_modules(ogg REQUIRED IMPORTED_TARGET ogg)
target_link_libraries(PkgConfig::opusfile INTERFACE
PkgConfig::ogg
PkgConfig::opus
)
target_link_libraries(SDL2_mixer::SDL2_mixer-static INTERFACE
PkgConfig::libmpg123
PkgConfig::opusfile
)
endif()
elseif(TARGET SDL2_mixer::SDL2_mixer)
pkg_check_modules(FLAC REQUIRED IMPORTED_TARGET flac)
target_link_libraries(SDL2_mixer::SDL2_mixer INTERFACE
Expand Down
45 changes: 36 additions & 9 deletions CMakeModules/Find/FindSDL2_ttf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,43 @@ if (NOT DYNAMIC_LINKING AND PKG_CONFIG_FOUND)
)
endif()
message(STATUS "Searching for SDL_ttf deps libraries --")
find_package(Freetype REQUIRED)
find_package(Harfbuzz REQUIRED)
target_link_libraries(SDL2_ttf::SDL2_ttf-static INTERFACE
Freetype::Freetype
harfbuzz::harfbuzz
)
if(MSYS2)
pkg_check_modules(Freetype REQUIRED IMPORTED_TARGET freetype2)
pkg_check_modules(harfbuzz REQUIRED IMPORTED_TARGET harfbuzz)
pkg_check_modules(graphite REQUIRED IMPORTED_TARGET graphite2)
target_link_libraries(PkgConfig::harfbuzz INTERFACE
PkgConfig::graphite
rpcrt4
)
target_link_libraries(SDL2_ttf::SDL2_ttf-static INTERFACE
PkgConfig::Freetype
PkgConfig::harfbuzz
)
else()
find_package(Freetype REQUIRED)
find_package(Harfbuzz REQUIRED)
get_target_property(_loc harfbuzz::harfbuzz IMPORTED_LOCATION)
set_target_properties(harfbuzz::harfbuzz PROPERTIES
IMPORTED_IMPLIB_RELEASE ${_loc}
IMPORTED_IMPLIB_DEBUG ${_loc}
IMPORTED_IMPLIB_RELWITHDEBINFO ${_loc}
)
target_link_libraries(SDL2_ttf::SDL2_ttf-static INTERFACE
Freetype::Freetype
harfbuzz::harfbuzz
)
endif()
pkg_check_modules(BROTLI REQUIRED IMPORTED_TARGET libbrotlidec libbrotlicommon)
target_link_libraries(Freetype::Freetype INTERFACE
PkgConfig::BROTLI
)
if(MSYS2)
pkg_check_modules(bzip2 REQUIRED IMPORTED_TARGET bzip2)
target_link_libraries(PkgConfig::Freetype INTERFACE
PkgConfig::bzip2
)
else()
target_link_libraries(Freetype::Freetype INTERFACE
PkgConfig::BROTLI
)
endif()
elseif(NOT TARGET SDL2_ttf::SDL2_ttf)
add_library(SDL2_ttf::SDL2_ttf UNKNOWN IMPORTED)
set_target_properties(SDL2_ttf::SDL2_ttf PROPERTIES
Expand Down
24 changes: 22 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
"patch": 0
},
"configurePresets": [
{
"name": "windows-tiles-sounds-x64",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"displayName": "Windows Tiles Sounds x64 MSYS2 (MinGW)",
"description": "Target Windows (64-bit) with the MingGW Win64 development environment.",
"generator": "Ninja Multi-Config",
"cacheVariables": {
"DYNAMIC_LINKING": "False",
"CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "TESTS": "True",
"CMAKE_INSTALL_MESSAGE": "NEVER"
}
},
{
"name": "windows-tiles-sounds-x64-msvc",
"binaryDir": "${sourceDir}/out/build/${presetName}",
Expand All @@ -19,7 +31,7 @@
"CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/${presetName}.cmake",
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake",
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
"DYNAMIC_LINKING": "False", "CMAKE_BUILD_TYPE": "RelWithDebInfo",
"DYNAMIC_LINKING": "False",
"CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "TESTS": "True",
"CMAKE_INSTALL_MESSAGE": "NEVER"
}
Expand All @@ -31,7 +43,7 @@
"description": "Target Linux (64-bit) with the GCC development environment.",
"generator": "Ninja Multi-Config",
"cacheVariables": {
"DYNAMIC_LINKING": "True", "CMAKE_BUILD_TYPE": "RelWithDebInfo",
"DYNAMIC_LINKING": "True",
"CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "TESTS": "True",
"CMAKE_INSTALL_MESSAGE": "NEVER"
}
Expand All @@ -53,13 +65,21 @@
}
],
"buildPresets": [
{
"name": "windows-tiles-sounds-x64",
"configurePreset": "windows-tiles-sounds-x64"
},
{
"name": "linux-tiles-sounds-x64",
"configurePreset": "linux-tiles-sounds-x64"
},
{
"name": "linux-tiles-sounds-x64-vcpkg",
"configurePreset": "linux-tiles-sounds-x64-vcpkg"
},
{
"name": "windows-tiles-sounds-x64-msvc",
"configurePreset": "windows-tiles-sounds-x64-msvc"
}
],
"testPresets": [
Expand Down
2 changes: 2 additions & 0 deletions build-scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sym-db
sym-locatedb
4 changes: 2 additions & 2 deletions build-scripts/MSVC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ C++ flags used by all builds:
/GF Eliminate Duplicate Strings
/wd4068 unknown pragma
/wd4146 negate unsigned
/wd4661 explicit template undefined
/wd4819 codepage?
/wd6237 short-circuit eval
/wd6319 a, b: unused a
Expand Down Expand Up @@ -54,7 +55,7 @@ set(CMAKE_C_COMPILER cl.exe)
set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_FLAGS_INIT "\
/MP /utf-8 /bigobj /permissive- /sdl- /FC /Gd /GS- /Gy /GF \
/wd4068 /wd4146 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \
/wd4068 /wd4146 /wd4661 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \
/TP /Zc:forScope /Zc:inline /Zc:wchar_t"
)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT
Expand All @@ -71,7 +72,6 @@ add_link_options(
/OPT:REF
/OPT:ICF
/LTCG:OFF
/MANIFEST:NO
/INCREMENTAL:NO
/DYNAMICBASE
/NXCOMPAT
Expand Down
115 changes: 0 additions & 115 deletions build-scripts/VsDevCmd.cmake

This file was deleted.

Loading

0 comments on commit c374e1a

Please sign in to comment.