shithub: choc

Download patch

ref: b9422484fbfbc467645a75d17f30227fb2c4a260
parent: b69478df6dfeedd1a9ee1fae5676397a80b1ac96
author: Alex Mayfield <alexmax2742@gmail.com>
date: Tue May 1 19:10:46 EDT 2018

Initial stab at SDL2 and textscreen

diff: cannot open b/cmake//null: file does not exist: 'b/cmake//null'
--- /dev/null
+++ b/CMakeLists.txt
@@ -1,0 +1,10 @@
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+cmake_minimum_required(VERSION 3.9.3)
+project("Chocolate Doom" VERSION 3.0.0 LANGUAGES C)
+
+find_package(SDL2 2.0.1)
+find_package(SDL2_mixer 2.0.0)
+find_package(SDL2_net 2.0.0)
+
+add_subdirectory(textscreen)
--- /dev/null
+++ b/cmake/FindSDL2.cmake
@@ -1,0 +1,53 @@
+# Currently works with the following generators:
+# - Visual Studio
+
+set(SDL2_DIR "${SDL2_DIR}" CACHE PATH "Location of SDL2 library directory")
+
+find_path(SDL2_INCLUDE_DIR "SDL_version.h"
+          PATHS "${SDL2_DIR}/include")
+
+if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h")
+    file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$")
+    file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$")
+    file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$")
+    string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MAJOR "${SDL2_VERSION_MAJOR_LINE}")
+    string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MINOR "${SDL2_VERSION_MINOR_LINE}")
+    string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_PATCH "${SDL2_VERSION_PATCH_LINE}")
+    set(SDL2_VERSION "${SDL2_VERSION_MAJOR}.${SDL2_VERSION_MINOR}.${SDL2_VERSION_PATCH}")
+    unset(SDL2_VERSION_MAJOR_LINE)
+    unset(SDL2_VERSION_MINOR_LINE)
+    unset(SDL2_VERSION_PATCH_LINE)
+    unset(SDL2_VERSION_MAJOR)
+    unset(SDL2_VERSION_MINOR)
+    unset(SDL2_VERSION_PATCH)
+endif()
+
+if(CMAKE_SIZEOF_VOID_P STREQUAL 8)
+    find_library(SDL2_LIBRARY "SDL2"
+                 PATHS "${SDL2_DIR}/lib/x64")
+    find_library(SDL2_MAIN_LIBRARY "SDL2main"
+                 PATHS "${SDL2_DIR}/lib/x64")
+else()
+    find_library(SDL2_LIBRARY "SDL2"
+                 PATHS "${SDL2_DIR}/lib/x86")
+    find_library(SDL2_MAIN_LIBRARY "SDL2main"
+                 PATHS "${SDL2_DIR}/lib/x86")
+endif()
+set(SDL2_LIBRARIES "${SDL2_MAIN_LIBRARY}" "${SDL2_LIBRARY}")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(SDL2
+    FOUND_VAR SDL2_FOUND
+    REQUIRED_VARS SDL2_INCLUDE_DIR SDL2_LIBRARIES
+    VERSION_VAR SDL2_VERSION
+)
+
+if(SDL2_FOUND)
+    add_library(SDL2::SDL2 UNKNOWN IMPORTED)
+    set_target_properties(SDL2::SDL2 PROPERTIES
+                          INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
+                          IMPORTED_LOCATION "${SDL2_LIBRARY}")
+    add_library(SDL2::SDL2main UNKNOWN IMPORTED)
+    set_target_properties(SDL2::SDL2main PROPERTIES
+                          IMPORTED_LOCATION "${SDL2_MAIN_LIBRARY}")
+endif()
--- /dev/null
+++ b/textscreen/CMakeLists.txt
@@ -1,0 +1,26 @@
+add_library(textscreen
+            textscreen.h
+            txt_conditional.c   txt_conditional.h
+            txt_checkbox.c      txt_checkbox.h
+            txt_desktop.c       txt_desktop.h
+            txt_dropdown.c      txt_dropdown.h
+            txt_fileselect.c    txt_fileselect.h
+            txt_gui.c           txt_gui.h
+            txt_inputbox.c      txt_inputbox.h
+            txt_io.c            txt_io.h
+                                txt_main.h
+            txt_button.c        txt_button.h
+            txt_label.c         txt_label.h
+            txt_radiobutton.c   txt_radiobutton.h
+            txt_scrollpane.c    txt_scrollpane.h
+            txt_separator.c     txt_separator.h
+            txt_spinctrl.c      txt_spinctrl.h
+            txt_sdl.c           txt_sdl.h
+            txt_strut.c         txt_strut.h
+            txt_table.c         txt_table.h
+            txt_utf8.c          txt_utf8.h
+            txt_widget.c        txt_widget.h
+            txt_window.c        txt_window.h
+            txt_window_action.c txt_window_action.h)
+target_include_directories(textscreen PRIVATE "../src/")
+target_link_libraries(textscreen SDL2::SDL2)