aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-07-23 04:18:22 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-07-23 04:23:05 +0200
commite8dd951c6c2bc3f3496eec26192b9b81c062ca1a (patch)
treec209fdc85fb39499cd58925aace8e179b8998213 /CMakeLists.txt
parent94d98176ea79edc87f11456bbb295e82381fc947 (diff)
Use find_package for SDL libraries
CMake already distributes FindSDL*.cmake files for SDL and SDL_mixer, which support custom prefixes via environment variables, removing the need for ad-hoc logic in Win9x builds. Also, according to FindSDL.cmake, #include <SDL.h> is the preferred way for portability reasons, instead of #include <SDL/SDL.h>, which is the option that has been used so far.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt15
1 files changed, 15 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 37a6a94..f6f4fab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,11 +14,26 @@ if(CMAKE_TOOLCHAIN_FILE MATCHES "ps1")
set(PS1_BUILD 1)
elseif(CMAKE_TOOLCHAIN_FILE MATCHES "win9x")
set(WIN9X_BUILD 1)
+ set(SDL1_2_BUILD 1)
else()
set(HOST_BUILD 1)
+ set(SDL1_2_BUILD 1)
endif()
add_executable(${PROJECT_NAME} "src/main.c")
+
+if(SDL1_2_BUILD)
+ find_package(SDL 1.2 REQUIRED)
+ find_package(SDL_gfx 2.0 REQUIRED)
+ find_package(SDL_mixer 1.2 REQUIRED)
+ # FindSDL_mixer.cmake does not export any target, so do it here instead.
+ add_library(SDL::SDL_mixer STATIC IMPORTED)
+ set_property(TARGET SDL::SDL_mixer PROPERTY
+ IMPORTED_LOCATION ${SDL_MIXER_LIBRARIES})
+ target_include_directories(SDL::SDL_mixer INTERFACE ${SDL_MIXER_INCLUDE_DIRS})
+ target_link_libraries(SDL::SDL_mixer INTERFACE SDL::SDL)
+endif()
+
set(cdroot ${CMAKE_BINARY_DIR}/cdimg)
file(MAKE_DIRECTORY ${cdroot})
# Avoid C11 since it is not supported by the i386-mingw32 toolchain.