summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Irwin <antumdeluge@gmail.com>2022-07-14 16:43:11 -0700
committerjak1 <jak1@themanaworld.org>2022-12-18 17:24:32 +0000
commit0400eac96a69a322fd6d77868eb7edad81cc860f (patch)
tree92910694e8d975fb0a57f32093da32028b5b50fc
parente48e1826ec18d050db78b9c542501f5a92057006 (diff)
downloadplus-0400eac96a69a322fd6d77868eb7edad81cc860f.tar.gz
plus-0400eac96a69a322fd6d77868eb7edad81cc860f.tar.bz2
plus-0400eac96a69a322fd6d77868eb7edad81cc860f.tar.xz
plus-0400eac96a69a322fd6d77868eb7edad81cc860f.zip
Add CMake SDL2 build support
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/CMakeLists.txt82
2 files changed, 64 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6224f9d5f..2231aaaab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,6 +29,7 @@ SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
FIND_PACKAGE(Gettext)
OPTION(WITH_OPENGL "Enable OpenGL support" ON)
+OPTION(USE_SDL2 "Build with SDL 2.0 instead of 1.2" OFF)
OPTION(ENABLE_NLS "Enable building of tranlations" ON)
OPTION(ENABLE_TMWA "Enable tmwA support" ON)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 84526df9b..25d1e9be9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,9 +1,21 @@
-FIND_PACKAGE(SDL REQUIRED)
-FIND_PACKAGE(SDL_image REQUIRED)
-FIND_PACKAGE(SDL_mixer REQUIRED)
-FIND_PACKAGE(SDL_net REQUIRED)
-FIND_PACKAGE(SDL_ttf REQUIRED)
-FIND_PACKAGE(SDL_gfx REQUIRED)
+
+IF (USE_SDL2)
+ include(FindPkgConfig)
+ pkg_search_module(SDL2 REQUIRED sdl2)
+ pkg_search_module(SDL2IMAGE REQUIRED SDL2_image)
+ pkg_search_module(SDL2MIXER REQUIRED SDL2_mixer)
+ pkg_search_module(SDL2NET REQUIRED SDL2_net)
+ pkg_search_module(SDL2TTF REQUIRED SDL2_ttf)
+ pkg_search_module(SDL2GFX REQUIRED SDL2_gfx)
+else()
+ FIND_PACKAGE(SDL REQUIRED)
+ FIND_PACKAGE(SDL_image REQUIRED)
+ FIND_PACKAGE(SDL_mixer REQUIRED)
+ FIND_PACKAGE(SDL_net REQUIRED)
+ FIND_PACKAGE(SDL_ttf REQUIRED)
+ FIND_PACKAGE(SDL_gfx REQUIRED)
+endif()
+
FIND_PACKAGE(CURL REQUIRED)
FIND_PACKAGE(LibXml2 REQUIRED)
FIND_PACKAGE(PNG REQUIRED)
@@ -31,6 +43,10 @@ ENDIF()
SET(FLAGS "${FLAGS} -DENABLE_LIBXML -DENABLE_ASSERTS")
+IF (USE_SDL2)
+ SET(FLAGS "${FLAGS} -DUSE_SDL2")
+ENDIF()
+
IF (CMAKE_BUILD_TYPE)
STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug OR
@@ -67,14 +83,29 @@ IF (USE_X11)
SET(FLAGS "${FLAGS} -DUSE_X11")
ENDIF (USE_X11)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+IF (USE_SDL2)
+ INCLUDE_DIRECTORIES(
+ ${SDL2_INCLUDE_DIRS}
+ ${SDL2IMAGE_INCLUDE_DIRS}
+ ${SDL2MIXER_INCLUDE_DIRS}
+ ${SDL2NET_INCLUDE_DIRS}
+ ${SDL2TTF_INCLUDE_DIRS}
+ ${SDL2GFX_INCLUDE_DIRS}
+ )
+ELSE()
+ INCLUDE_DIRECTORIES(
+ ${SDL_INCLUDE_DIR}
+ ${SDLIMAGE_INCLUDE_DIR}
+ ${SDLMIXER_INCLUDE_DIR}
+ ${SDLNET_INCLUDE_DIR}
+ ${SDLTTF_INCLUDE_DIR}
+ ${SDLGFX_INCLUDE_DIR}
+ )
+ENDIF (USE_SDL2)
+
INCLUDE_DIRECTORIES(
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${SDL_INCLUDE_DIR}
- ${SDLIMAGE_INCLUDE_DIR}
- ${SDLMIXER_INCLUDE_DIR}
- ${SDLNET_INCLUDE_DIR}
- ${SDLTTF_INCLUDE_DIR}
- ${SDLGFX_INCLUDE_DIR}
${PNG_INCLUDE_DIR}
${CURL_INCLUDE_DIR}
${LIBXML2_INCLUDE_DIR}
@@ -2206,14 +2237,27 @@ ENDIF(ENABLE_TMWA)
ADD_EXECUTABLE(manaplus WIN32 ${SRCS} ${SRCS_EVOL})
#ADD_EXECUTABLE(dyecmd WIN32 ${DYE_CMD_SRCS})
+IF (USE_SDL2)
+ SET(SDL_LIBS
+ ${SDL2_LIBRARIES}
+ ${SDL2GFX_LIBRARIES}
+ ${SDL2IMAGE_LIBRARIES}
+ ${SDL2MIXER_LIBRARIES}
+ ${SDL2NET_LIBRARIES}
+ ${SDL2TTF_LIBRARIES})
+ELSE()
+ SET(SDL_LIBS
+ ${SDL_LIBRARY}
+ ${SDLGFX_LIBRARIES}
+ ${SDLIMAGE_LIBRARY}
+ ${SDLMIXER_LIBRARY}
+ ${SDLNET_LIBRARY}
+ ${SDLTTF_LIBRARY})
+ENDIF (USE_SDL2)
+
TARGET_LINK_LIBRARIES(manaplus
${X11_LIBRARIES}
- ${SDLGFX_LIBRARIES}
- ${SDL_LIBRARY}
- ${SDLIMAGE_LIBRARY}
- ${SDLMIXER_LIBRARY}
- ${SDLNET_LIBRARY}
- ${SDLTTF_LIBRARY}
+ ${SDL_LIBS}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${CURL_LIBRARIES}