Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mostly CMake stuff #106

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b8d4188
VFileIO: Check XDG_DATA_DIRS properly
bb010g Jul 29, 2020
ac7a60c
Nix: Wrap a proper XDG system data directory in
bb010g Jul 29, 2020
5803fc1
OpenGL: Build clean with USE_OPENGL off.
bb010g Jul 29, 2020
6f4739b
SDL: Introduce USE_SDL option (required)
bb010g Jul 29, 2020
a6a04c8
SDL_gfx: Builds return (more features stubbed-out)
bb010g Jul 29, 2020
3bc4b93
Nix: Add `/shell.nix`
bb010g Jul 29, 2020
36eb4ae
CMake: Switch to upstream FindSQLite3
bb010g Jul 29, 2020
1c191c8
Only add subdirectories if necessary
skitt Jul 8, 2020
36f79c3
CMake: Minor refactoring & reformatting.
bb010g Jul 29, 2020
9b9ad83
CMake: Use IMPORTED targets
bb010g Jul 29, 2020
901f86d
CMake: Invoke target_sources from subdirectories
bb010g Jul 29, 2020
d188a03
CMake: Consistently format CMakeSources
bb010g Jul 29, 2020
7c18a8e
CMake: Use IMPORTED targets
bb010g Jul 29, 2020
2916470
CMake: Use IMPORTED targets
bb010g Jul 29, 2020
4839148
CMake: EXCLUDE_FROM_ALL vendored subdirectories
bb010g Jul 29, 2020
1a61d78
CMake: Use IMPORTED targets
bb010g Jul 29, 2020
c5087f1
CMake: No IMPORTED_LOCATION for INTERFACE targets
bb010g Jul 30, 2020
d9158e9
CMake: Blanket PREFER_SYSTEM & USE_SYSTEM options
bb010g Jul 31, 2020
dab1e2e
CMake: Fix vendored Lua includes
bb010g Jul 31, 2020
fb3f928
CI: Switch to Travis apt addon
bb010g Jul 30, 2020
75b08dc
CI: Switch to Travis homebrew addon
bb010g Jul 30, 2020
c0764e2
CI: Switch CMake to pinned 3.13.4
bb010g Jul 30, 2020
71db3e5
CI: MXE `make download` instead of APT repository
bb010g Jul 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ CTestTestfile.cmake

/[Bb]uild*/

## Direnv

/.envrc

## Nix

/result*
10 changes: 10 additions & 0 deletions CMake/FindLuaTargets.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if(LUA_FOUND AND NOT TARGET Lua::Lua)
add_library(Lua::Lua UNKNOWN IMPORTED)
set_target_properties(Lua::Lua PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}"
IMPORTED_LOCATION "${LUA_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${LUA_LIBRARIES}"
VERSION "${LUA_VERSION_STRING}"
)
endif()

58 changes: 58 additions & 0 deletions CMake/FindSDLTargets.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
if(SDL_FOUND AND NOT TARGET SDL::SDL)
add_library(SDL::SDL INTERFACE IMPORTED)
set_target_properties(SDL::SDL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${SDL_LIBRARY}"
# VERSION "${SDL_VERSION_STRING}"
)
endif()

if(SDL_GFX_FOUND AND NOT TARGET SDL::SDL_gfx)
add_library(SDL::SDL_gfx UNKNOWN IMPORTED)
set_target_properties(SDL::SDL_gfx PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_GFX_INCLUDE_DIRS}"
IMPORTED_LOCATION "${SDL_GFX_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${SDL_GFX_LIBRARIES}"
VERSION "${SDL_GFX_VERSION_STRING}"
)
endif()

if(SDL_MIXER_FOUND AND NOT TARGET SDL::SDL_mixer)
add_library(SDL::SDL_mixer UNKNOWN IMPORTED)
set_target_properties(SDL::SDL_mixer PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_MIXER_INCLUDE_DIRS}"
IMPORTED_LOCATION "${SDL_MIXER_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${SDL_MIXER_LIBRARIES}"
VERSION "${SDL_MIXER_VERSION_STRING}"
)
endif()

if(SDL_NET_FOUND AND NOT TARGET SDL::SDL_net)
add_library(SDL::SDL_net UNKNOWN IMPORTED)
set_target_properties(SDL::SDL_net PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_NET_INCLUDE_DIRS}"
IMPORTED_LOCATION "${SDL_NET_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${SDL_NET_LIBRARIES}"
VERSION "${SDL_NET_VERSION_STRING}"
)
endif()

if(SDL_SOUND_FOUND AND NOT TARGET SDL::SDL_sound)
add_library(SDL::SDL_sound UNKNOWN IMPORTED)
set_target_properties(SDL::SDL_sound PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_SOUND_INCLUDE_DIRS}"
IMPORTED_LOCATION "${SDL_SOUND_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${SDL_SOUND_LIBRARIES}"
VERSION "${SDL_SOUND_VERSION_STRING}"
)
endif()

if(SDL_TTF_FOUND AND NOT TARGET SDL::SDL_ttf)
add_library(SDL::SDL_ttf UNKNOWN IMPORTED)
set_target_properties(SDL::SDL_ttf PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_TTF_INCLUDE_DIRS}"
IMPORTED_LOCATION "${SDL_TTF_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${SDL_TTF_LIBRARIES}"
VERSION "${SDL_TTF_VERSION_STRING}"
)
endif()
85 changes: 85 additions & 0 deletions CMake/FindSDL_gfx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Distributed under the OSI-approved BSD 3-Clause License. See
# https://cmake.org/licensing for details.

#[=======================================================================[.rst:
FindSDL_gfx
-----------

Locate SDL_gfx library

This module defines:

::

SDL_GFX_LIBRARIES, the name of the library to link against
SDL_GFX_INCLUDE_DIRS, where to find the headers
SDL_GFX_FOUND, if false, do not try to link against
SDL_GFX_VERSION_STRING - human-readable string containing the version of SDL_gfx



$SDLDIR is an environment variable that would correspond to the
./configure --prefix=$SDLDIR used in building SDL.

Created by Eric Wing. Modified by Dusk Banks. This was heavily based on
the FindSDL_net.cmake module, but with modifications for SDL_gfx instead.
#]=======================================================================]

find_path(SDL_GFX_INCLUDE_DIR SDL_gfxPrimitives.h
HINTS
ENV SDLGFXDIR
ENV SDLDIR
PATH_SUFFIXES SDL
# path suffixes to search inside ENV{SDLDIR}
include/SDL include/SDL12 include/SDL11 include
)

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(VC_LIB_PATH_SUFFIX lib/x64)
else()
set(VC_LIB_PATH_SUFFIX lib/x86)
endif()

find_library(SDL_GFX_LIBRARY
NAMES SDL_gfx
HINTS
ENV SDLGFXDIR
ENV SDLDIR
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
)

if(SDL_GFX_INCLUDE_DIR AND EXISTS "${SDL_GFX_INCLUDE_DIR}/SDL_gfxPrimitives.h")
file(STRINGS "${SDL_GFX_INCLUDE_DIR}/SDL_gfxPrimitives.h" SDL_GFX_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_GFXPRIMITIVES_MAJOR[ \t]+[0-9]+$")
file(STRINGS "${SDL_GFX_INCLUDE_DIR}/SDL_gfxPrimitives.h" SDL_GFX_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_GFXPRIMITIVES_MINOR[ \t]+[0-9]+$")
file(STRINGS "${SDL_GFX_INCLUDE_DIR}/SDL_gfxPrimitives.h" SDL_GFX_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_GFXPRIMITIVES_MICRO[ \t]+[0-9]+$")
string(REGEX REPLACE "^#define[ \t]+SDL_GFXPRIMITIVES_MAJOR[ \t]+([0-9]+)$" "\\1" SDL_GFX_VERSION_MAJOR "${SDL_GFX_VERSION_MAJOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_GFXPRIMITIVES_MINOR[ \t]+([0-9]+)$" "\\1" SDL_GFX_VERSION_MINOR "${SDL_GFX_VERSION_MINOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_GFXPRIMITIVES_MICRO[ \t]+([0-9]+)$" "\\1" SDL_GFX_VERSION_PATCH "${SDL_GFX_VERSION_PATCH_LINE}")
set(SDL_GFX_VERSION_STRING ${SDL_GFX_VERSION_MAJOR}.${SDL_GFX_VERSION_MINOR}.${SDL_GFX_VERSION_PATCH})
unset(SDL_GFX_VERSION_MAJOR_LINE)
unset(SDL_GFX_VERSION_MINOR_LINE)
unset(SDL_GFX_VERSION_PATCH_LINE)
unset(SDL_GFX_VERSION_MAJOR)
unset(SDL_GFX_VERSION_MINOR)
unset(SDL_GFX_VERSION_PATCH)
endif()

set(SDL_GFX_LIBRARIES ${SDL_GFX_LIBRARY})
set(SDL_GFX_INCLUDE_DIRS ${SDL_GFX_INCLUDE_DIR})

include(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_gfx
REQUIRED_VARS SDL_GFX_LIBRARIES SDL_GFX_INCLUDE_DIRS
VERSION_VAR SDL_GFX_VERSION_STRING)

mark_as_advanced(SDL_GFX_LIBRARY SDL_GFX_INCLUDE_DIR)

if(SDL_GFX_FOUND AND NOT TARGET SDL::SDL_gfx)
add_library(SDL::SDL_gfx UNKNOWN IMPORTED)
set_target_properties(SDL::SDL_gfx PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL_GFX_INCLUDE_DIR}"
IMPORTED_LOCATION "${SDL_GFX_LIBRARY}"
VERSION "${SDL_GFX_VERSION_STRING}"
)
endif()
86 changes: 0 additions & 86 deletions CMake/FindSQLITE3.cmake

This file was deleted.

66 changes: 66 additions & 0 deletions CMake/FindSQLite3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Distributed under the OSI-approved BSD 3-Clause License. See
# https://cmake.org/licensing for details.

#[=======================================================================[.rst:
FindSQLite3
-----------

Find the SQLite libraries, v3

IMPORTED targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` target:

``SQLite::SQLite3``

Result variables
^^^^^^^^^^^^^^^^

This module will set the following variables if found:

``SQLite3_INCLUDE_DIRS``
where to find sqlite3.h, etc.
``SQLite3_LIBRARIES``
the libraries to link against to use SQLite3.
``SQLite3_VERSION``
version of the SQLite3 library found
``SQLite3_FOUND``
TRUE if found

#]=======================================================================]

# Look for the necessary header
find_path(SQLite3_INCLUDE_DIR NAMES sqlite3.h)
mark_as_advanced(SQLite3_INCLUDE_DIR)

# Look for the necessary library
find_library(SQLite3_LIBRARY NAMES sqlite3 sqlite)
mark_as_advanced(SQLite3_LIBRARY)

# Extract version information from the header file
if(SQLite3_INCLUDE_DIR)
file(STRINGS ${SQLite3_INCLUDE_DIR}/sqlite3.h _ver_line
REGEX "^#define SQLITE_VERSION *\"[0-9]+\\.[0-9]+\\.[0-9]+\""
LIMIT_COUNT 1)
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+"
SQLite3_VERSION "${_ver_line}")
unset(_ver_line)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SQLite3
REQUIRED_VARS SQLite3_INCLUDE_DIR SQLite3_LIBRARY
VERSION_VAR SQLite3_VERSION)

# Create the imported target
if(SQLite3_FOUND)
set(SQLite3_INCLUDE_DIRS ${SQLite3_INCLUDE_DIR})
set(SQLite3_LIBRARIES ${SQLite3_LIBRARY})
if(NOT TARGET SQLite::SQLite3)
add_library(SQLite::SQLite3 UNKNOWN IMPORTED)
set_target_properties(SQLite::SQLite3 PROPERTIES
IMPORTED_LOCATION "${SQLite3_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}")
endif()
endif()