Skip to content

Commit f0dbcb6

Browse files
committed
Added a few tweaks to be able to build the app as an all-static executable, using /MT[d] on Windows.
Had to increase the minimum CMake requirement to 3.15, otherwise the CMAKE_MSVC_RUNTIME_LIBRARY won't work and devs can't easily use the static runtime.
1 parent 3fd9815 commit f0dbcb6

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
22

33
if(CMAKE_VERSION VERSION_LESS 3.19 AND CMAKE_GENERATOR STREQUAL "Xcode")
44
message(AUTHOR_WARNING "Using a CMake version before 3.19 with a recent Xcode SDK and the Xcode generator "

cmake/SDL2Target.cmake

+10-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,17 @@ endif()
5555

5656
# Temporary fix to deal with wrong include dir set by SDL2's CMake configuration.
5757
get_target_property(_SDL2_INCLUDE_DIR SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES)
58-
if(_SDL2_INCLUDE_DIR MATCHES "(.+)/SDL2\$")
58+
if(_SDL2_INCLUDE_DIR MATCHES "(.+)/SDL2\$" AND _SDL2_TARGET_TYPE STREQUAL STATIC_LIBRARY)
59+
# Check if SDL2::SDL2 is aliased to SDL2::SDL2-static (will be the case for static-only builds)
60+
get_target_property(_SDL2_ALIASED_TARGET SDL2::SDL2 ALIASED_TARGET)
61+
if(_SDL2_ALIASED_TARGET)
62+
set(_sdl2_target ${_SDL2_ALIASED_TARGET})
63+
else()
64+
set(_sdl2_target SDL2::SDL2)
65+
endif()
66+
5967
message(STATUS "SDL2 include dir contains \"SDL2\" subdir (SDL bug #4004) - fixing to \"${CMAKE_MATCH_1}\".")
60-
set_target_properties(SDL2::SDL2 PROPERTIES
68+
set_target_properties(${_sdl2_target} PROPERTIES
6169
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_MATCH_1}"
6270
)
6371
endif()

src/CMakeLists.txt

+15-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,20 @@ target_link_libraries(projectMSDL
4949
PRIVATE
5050
libprojectM::${PROJECTM_LINKAGE}
5151
Poco::Util
52-
SDL2::SDL2$<$<STREQUAL:"${SDL2_LINKAGE}","static">:"-static">
52+
SDL2::SDL2$<$<STREQUAL:${SDL2_LINKAGE},static>:-static>
5353
SDL2::SDL2main
54-
OpenGL::GL
5554
)
55+
56+
if(MSVC)
57+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.16")
58+
set_target_properties(projectMSDL
59+
PROPERTIES
60+
VS_DPI_AWARE "PerMonitor"
61+
)
62+
else()
63+
message(AUTHOR_WARNING
64+
"You're using a CMake version less than 3.16 with Visual Studio.\n"
65+
"The resulting projectMSDL executable will not be DPI-aware and possibly render at a "
66+
"lower-than-expected resolution on high-DPI displays.")
67+
endif()
68+
endif()

0 commit comments

Comments
 (0)