diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1a511c654e61aecd5dafdf802e4c7b9ce9d90644..427acc8679d7940a57254237a3729681c41bc9ce 100644 (file)
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
cmake_minimum_required(VERSION 3.6)
project(doom2d C)
cmake_minimum_required(VERSION 3.6)
project(doom2d C)
-option(WITH_OPENGL "Build with OpenGL render" ON)
-option(WITH_SOFTWARE "Build with Software render" ON)
+option(RENDER_DRIVER "Build with selected render driver" "OpenGL")
+option(SOUND_DRIVER "Build with selected sound driver" "OpenAL")
+
+string(TOUPPER "${RENDER_DRIVER}" RENDER_DRIVER)
+string(COMPARE EQUAL "${RENDER_DRIVER}" "OPENGL" WITH_OPENGL)
+string(COMPARE EQUAL "${RENDER_DRIVER}" "SOFTWARE" WITH_SOFTWARE)
+string(COMPARE EQUAL "${RENDER_DRIVER}" "STUB" WITH_STUBRENDER)
+
+string(TOUPPER "${SOUND_DRIVER}" SOUND_DRIVER)
+string(COMPARE EQUAL "${SOUND_DRIVER}" "OPENAL" WITH_OPENAL)
+string(COMPARE EQUAL "${SOUND_DRIVER}" "SDLMIXER" WITH_SDLMIXER)
+string(COMPARE EQUAL "${SOUND_DRIVER}" "STUB" WITH_STUBSOUND)
set(D2D_GAME_ROOT .)
set(D2D_OPENGL_ROOT ${D2D_GAME_ROOT}/gl)
set(D2D_SOFTWARE_ROOT ${D2D_GAME_ROOT}/soft)
set(D2D_GAME_ROOT .)
set(D2D_OPENGL_ROOT ${D2D_GAME_ROOT}/gl)
set(D2D_SOFTWARE_ROOT ${D2D_GAME_ROOT}/soft)
+set(D2D_STUBRENDER_ROOT ${D2D_GAME_ROOT}/stubren)
set(D2D_SDL_ROOT ${D2D_GAME_ROOT}/sdl)
set(D2D_SDL_ROOT ${D2D_GAME_ROOT}/sdl)
-
-find_package(SDL REQUIRED)
-find_package(SDL_mixer REQUIRED)
-if (WITH_OPENGL)
- find_package(OpenGL REQUIRED)
-endif (WITH_OPENGL)
+set(D2D_SDLMIXER_ROOT ${D2D_GAME_ROOT}/sdlmixer)
+set(D2D_OPENAL_ROOT ${D2D_GAME_ROOT}/openal)
+set(D2D_STUBSOUND_ROOT ${D2D_GAME_ROOT}/stubsnd)
aux_source_directory(${D2D_GAME_ROOT} D2D_GAME_SRC)
aux_source_directory(${D2D_OPENGL_ROOT} D2D_OPENGL_SRC)
aux_source_directory(${D2D_SOFTWARE_ROOT} D2D_SOFTWARE_SRC)
aux_source_directory(${D2D_GAME_ROOT} D2D_GAME_SRC)
aux_source_directory(${D2D_OPENGL_ROOT} D2D_OPENGL_SRC)
aux_source_directory(${D2D_SOFTWARE_ROOT} D2D_SOFTWARE_SRC)
+aux_source_directory(${D2D_STUBRENDER_ROOT} D2D_STUBRENDER_SRC)
aux_source_directory(${D2D_SDL_ROOT} D2D_SDL_SRC)
aux_source_directory(${D2D_SDL_ROOT} D2D_SDL_SRC)
+aux_source_directory(${D2D_SDLMIXER_ROOT} D2D_SDLMIXER_SRC)
+aux_source_directory(${D2D_OPENAL_ROOT} D2D_OPENAL_SRC)
+aux_source_directory(${D2D_STUBSOUND_ROOT} D2D_STUBSOUND_SRC)
+
+find_package(SDL REQUIRED)
+
+if (WITH_STUBRENDER)
+ set(D2D_RENDER_SRC "${D2D_STUBRENDER_SRC}")
+ set(D2D_RENDER_INCLUDE_DIR "")
+ set(D2D_RENDER_LIBRARY "")
+elseif(WITH_OPENGL)
+ find_package(OpenGL REQUIRED)
+ set(D2D_RENDER_SRC "${D2D_OPENGL_SRC}")
+ set(D2D_RENDER_INCLUDE_DIR "${OPENGL_INCLUDE_DIR}")
+ set(D2D_RENDER_LIBRARY "${OPENGL_LIBRARY}")
+elseif(WITH_SOFTWARE)
+ set(D2D_RENDER_SRC "${D2D_SOFTWARE_SRC}")
+ set(D2D_RENDER_INCLUDE_DIR "")
+ set(D2D_RENDER_LIBRARY "")
+else(WITH_STUBRENDER)
+ message(FATAL_ERROR "Select RENDER_DRIVER as 'OPENGL' or 'SOFTWARE' or 'STUB'")
+endif(WITH_STUBRENDER)
+
+if(WITH_STUBSOUND)
+ set(D2D_SOUND_SRC "${D2D_STUBSOUND_SRC}")
+ set(D2D_SOUND_INCLUDE_DIR "")
+ set(D2D_SOUND_LIBRARY "")
+elseif(WITH_OPENAL)
+ find_package(OpenAL REQUIRED)
+ set(D2D_SOUND_SRC "${D2D_OPENAL_SRC}")
+ set(D2D_SOUND_INCLUDE_DIR "${OPENAL_INCLUDE_DIR}")
+ set(D2D_SOUND_LIBRARY "${OPENAL_LIBRARY}")
+elseif(WITH_SDLMIXER)
+ find_package(SDL_mixer REQUIRED)
+ set(D2D_SOUND_SRC "${D2D_SDLMIXER_SRC}")
+ set(D2D_SOUND_INCLUDE_DIR "${SDLMIXER_INCLUDE_DIR}")
+ set(D2D_SOUND_LIBRARY "${SDLMIXER_LIBRARY}")
+else(WITH_STUBSOUND)
+ message(FATAL_ERROR "Select SOUND_DRIVER as 'OPENAL' or 'SDLMIXER' or 'STUB'")
+endif(WITH_STUBSOUND)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
message(STATUS "=== BUILD OPTIONS ===")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
message(STATUS "=== BUILD OPTIONS ===")
-message(STATUS "BUILD: " ${CMAKE_BUILD_TYPE})
-message(STATUS "CFLAGS: " ${CMAKE_C_FLAGS})
-
-message(STATUS "=== RENDERS ===")
-message(STATUS "SOFTWARE: " ${WITH_SOFTWARE})
-message(STATUS "OPENGL: " ${WITH_OPENGL})
-
-if (WITH_OPENGL)
- add_executable(doom2d-gl ${D2D_GAME_SRC} ${D2D_SDL_SRC} ${D2D_OPENGL_SRC})
- target_include_directories(doom2d-gl PRIVATE "${D2D_GAME_ROOT}" "${SDL_INCLUDE_DIR}" "${SDLMIXER_INCLUDE_DIR}" "${OPENGL_INCLUDE_DIR}")
- target_link_libraries(doom2d-gl "${SDL_LIBRARY}" "${SDLMIXER_LIBRARY}" "${OPENGL_LIBRARY}")
-endif (WITH_OPENGL)
-
-if (WITH_SOFTWARE)
- add_executable(doom2d-soft ${D2D_GAME_SRC} ${D2D_SDL_SRC} ${D2D_SOFTWARE_SRC})
- target_include_directories(doom2d-soft PRIVATE "${D2D_GAME_ROOT}" "${SDL_INCLUDE_DIR}" "${SDLMIXER_INCLUDE_DIR}")
- target_link_libraries(doom2d-soft "${SDL_LIBRARY}" "${SDLMIXER_LIBRARY}")
-endif (WITH_SOFTWARE)
+message(STATUS "BUILD: " "${CMAKE_BUILD_TYPE}")
+message(STATUS "CFLAGS: " "${CMAKE_C_FLAGS}")
+message(STATUS "RENDER: " "${RENDER_DRIVER}")
+message(STATUS "SOUND: " "${SOUND_DRIVER}")
+
+add_executable(doom2d ${D2D_GAME_SRC} ${D2D_RENDER_SRC} ${D2D_SOUND_SRC} ${D2D_SDL_SRC})
+target_include_directories(doom2d PRIVATE "${D2D_GAME_ROOT}" "${D2D_RENDER_INCLUDE_DIR}" "${D2D_SOUND_INCLUDE_DIR}" "${SDL_INCLUDE_DIR}")
+target_link_libraries(doom2d "${D2D_RENDER_LIBRARY}" "${D2D_SOUND_LIBRARY}" "${SDL_LIBRARY}")