Skip to content

Commit

Permalink
Common: Added new shared library “libgamefw” as a game-side foundation
Browse files Browse the repository at this point in the history
The Game Framework is the future home of all common code that is
shared by all the games and possibly other plugins as well. The
code in the “common” directory should be eventually relocated there.
  • Loading branch information
skyjake committed Nov 18, 2016
1 parent 6e8e80d commit e68955a
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 16 deletions.
5 changes: 2 additions & 3 deletions doomsday/apps/client/CMakeLists.txt
Expand Up @@ -169,9 +169,8 @@ endif ()

if (APPLE)
deng_install_bundle_deps (client
Deng::libcore Deng::libshell
Deng::libgui Deng::libappfw
Deng::liblegacy Deng::libdoomsday
Deng::libcore Deng::libshell Deng::libgui Deng::libappfw
Deng::liblegacy Deng::libdoomsday Deng::libgamefw
SDL2 SDL2_mixer
)

Expand Down
8 changes: 5 additions & 3 deletions doomsday/apps/plugins/CMakeLists.txt
Expand Up @@ -5,9 +5,7 @@ cmake_minimum_required (VERSION 3.1)
project (Plugins)
include (../../cmake/Config.cmake)

if (DENG_DEVELOPER)
add_subdirectory (example)
endif ()
add_subdirectory (libgamefw)

add_subdirectory (importdeh)
add_subdirectory (importidtech1)
Expand All @@ -30,3 +28,7 @@ if (WIN32)
add_subdirectory (directsound)
add_subdirectory (winmm)
endif ()

if (DENG_DEVELOPER)
add_subdirectory (example)
endif ()
21 changes: 11 additions & 10 deletions doomsday/apps/plugins/PluginConfig.cmake
@@ -1,11 +1,12 @@
# The Doomsday Engine Project -- Common build config for plugins
# Copyright (c) 2015 Jaakko Keränen <jaakko.keranen@iki.fi>
# Copyright (c) 2015-2016 Jaakko Keränen <jaakko.keranen@iki.fi>

cmake_minimum_required (VERSION 3.0)
project (DENG_PLUGINS)
include (${CMAKE_CURRENT_LIST_DIR}/../../cmake/Config.cmake)

find_package (DengDoomsday)
find_package (DengGamefw) # Game framework is available in all plugins.

macro (deng_add_plugin target)
sublist (_src 1 -1 ${ARGV})
Expand All @@ -23,20 +24,20 @@ macro (deng_add_plugin target)
list (APPEND _src ${_winres})
endif ()
add_library (${target} MODULE ${_src} ${DENG_RESOURCES})
target_include_directories (${target}
PUBLIC "${DENG_API_DIR}"
target_include_directories (${target}
PUBLIC "${DENG_API_DIR}"
PRIVATE "${DENG_SOURCE_DIR}/sdk/libgui/include"
)
target_link_libraries (${target} PUBLIC Deng::libdoomsday)
target_link_libraries (${target} PUBLIC Deng::libdoomsday Deng::libgamefw)
enable_cxx11 (${target})
set_target_properties (${target} PROPERTIES FOLDER Plugins)

if (APPLE)
# The plugins have some messy code.
set_property (TARGET ${target}
set_property (TARGET ${target}
APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-braces
)
set_target_properties (${target} PROPERTIES
set_target_properties (${target} PROPERTIES
BUNDLE ON
MACOSX_BUNDLE_INFO_PLIST ${DENG_SOURCE_DIR}/cmake/MacOSXPluginBundleInfo.plist.in
BUILD_WITH_INSTALL_RPATH ON # staging prevents CMake's own rpath fixing
Expand All @@ -49,14 +50,14 @@ macro (deng_add_plugin target)
# plugins are not installed yet -- the staging directory symlinks to the
# individual build directories.
set (stage "${DENG_BUILD_STAGING_DIR}/DengPlugins")
add_custom_command (TARGET ${target} POST_BUILD
add_custom_command (TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${stage}"
COMMAND ${CMAKE_COMMAND} -E create_symlink
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${target}.bundle"
COMMAND ${CMAKE_COMMAND} -E create_symlink
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${target}.bundle"
"${stage}/${target}.bundle"
)
# Fix the Qt framework install names manually.
deng_bundle_install_names (${target}
deng_bundle_install_names (${target}
SCRIPT_NAME "qtlibs"
LD_PATH "@executable_path/../Frameworks"
QtCore.framework/Versions/5/QtCore
Expand Down
35 changes: 35 additions & 0 deletions doomsday/apps/plugins/libgamefw/CMakeLists.txt
@@ -0,0 +1,35 @@
# Doomsday Engine -- libgamefw: Game base framework and common routines

cmake_minimum_required (VERSION 3.1)
project (DENG_LIBGAMEFW)
include (../../../cmake/Config.cmake)

# Dependencies.
find_package (DengCore)
find_package (DengLegacy)

# Definitions.
add_definitions (
-D__LIBGAMEFW__=1
)

# Set up the API.
include_directories (${DENG_API_DIR})

# Source and header files.
file (GLOB_RECURSE HEADERS include/gamefw/*)

deng_merge_sources (libgamefw src/*.cpp)

deng_add_library (libgamefw ${SOURCES} ${HEADERS})
target_link_libraries (libgamefw
PUBLIC Deng::libcore Deng::liblegacy
)

if (DENG_ENABLE_SDK)
install (DIRECTORY include/gamefw
DESTINATION include
COMPONENT sdk
)
endif ()
deng_deploy_library (libgamefw DengGamefw)
50 changes: 50 additions & 0 deletions doomsday/apps/plugins/libgamefw/include/gamefw/libgamefw.h
@@ -0,0 +1,50 @@
/** @file libgamefw.h Common framework for games.
*
* @authors Copyright (c) 2016 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBGAMEFW_H
#define LIBGAMEFW_H

/*
* The LIBGAMEFW_PUBLIC macro is used for declaring exported symbols. It must be
* applied in all exported classes and functions. DEF files are not used for
* exporting symbols on Windows.
*/
#if defined(_WIN32) && defined(_MSC_VER)
# ifdef __LIBGAMEFW__
// This is defined when compiling the library.
# define LIBGAMEFW_PUBLIC __declspec(dllexport)
# else
# define LIBGAMEFW_PUBLIC __declspec(dllimport)
# endif
#else
// No need to use any special declarators.
# define LIBGAMEFW_PUBLIC
#endif

#ifdef __cplusplus

/// libgamefw uses the @c gfw namespace for all its C++ symbols.
namespace gfw {



} // namespace gfw

#endif // __cplusplus

#endif // LIBGAMEFW_H
8 changes: 8 additions & 0 deletions doomsday/cmake/config/DengGamefwConfig.cmake
@@ -0,0 +1,8 @@
find_package (DengCore REQUIRED)
find_package (DengLegacy REQUIRED)

# Deng::libgamefw may exist in the current build, in which case using
# a previously installed version is inappropriate.
if (NOT TARGET Deng::libgamefw)
include ("${CMAKE_CURRENT_LIST_DIR}/DengGamefw.cmake")
endif ()

0 comments on commit e68955a

Please sign in to comment.