Skip to content

Commit

Permalink
iOS: Build configurable and platform-specific tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed May 4, 2017
1 parent 2228af3 commit 6794745
Show file tree
Hide file tree
Showing 19 changed files with 493 additions and 341 deletions.
117 changes: 72 additions & 45 deletions doomsday/apps/client/CMakeLists.txt
Expand Up @@ -7,7 +7,8 @@ project (DENG_CLIENT)
set (DENG_ENABLE_PK3S ON)
include (../../cmake/Config.cmake)

# Dependencies.
# Dependencies --------------------------------------------------------------------------

find_package (DengAppfw)
find_package (DengDoomsday)
find_package (Amethyst QUIET)
Expand All @@ -16,6 +17,8 @@ if (WIN32)
find_package (DirectX)
endif ()

# Sources and includes ------------------------------------------------------------------

include_directories (include ${DENG_API_DIR})

add_definitions (-D__DOOMSDAY__=1 -D__CLIENT__=1)
Expand Down Expand Up @@ -64,31 +67,6 @@ if (UNIX)
deng_merge_sources (unix src/unix/*.cpp)
endif ()

if (AMETHYST_FOUND)
if (APPLE)
set (readme "${CMAKE_CURRENT_BINARY_DIR}/Read Me.html")
deng_add_amedoc (HTML ${readme} ${DENG_SOURCE_DIR}/doc/readme readme.ame)
install (FILES ${readme} DESTINATION .)
list (APPEND SOURCES ${readme})
else ()
set (readme "${CMAKE_CURRENT_BINARY_DIR}/readme.html")
deng_add_amedoc (HTML ${readme} ${DENG_SOURCE_DIR}/doc/readme readme.ame)
list (APPEND SOURCES ${readme})
if (WIN32)
# WIX generator requires setting this manually.
set_property (INSTALL "${DENG_INSTALL_DOC_DIR}/readme.html"
PROPERTY CPACK_START_MENU_SHORTCUTS "Read Me"
)
endif ()
endif ()
# Manual page.
if (UNIX)
set (MAN_PAGE ${CMAKE_CURRENT_BINARY_DIR}/doomsday.6)
deng_add_amedoc (MAN ${MAN_PAGE} ${DENG_SOURCE_DIR}/doc/readme readme.ame)
list (APPEND SOURCES ${MAN_PAGE})
endif ()
endif ()

deng_filter_platform_sources (src ${SOURCES} ${HEADERS} ${API_HEADERS})

deng_add_package (net.dengine.client)
Expand Down Expand Up @@ -122,7 +100,8 @@ deng_add_application (client ${src} EXTRA_RESOURCES ${MACX_RESOURCES})
# There's some old code here so relax the warnings a bit.
relaxed_warnings (client)

# Libraries.
# Libraries -----------------------------------------------------------------------------

if (IOS)
link_framework (client PUBLIC CoreFoundation)
link_framework (client PUBLIC QuartzCore)
Expand All @@ -133,19 +112,34 @@ if (IOS)
link_framework (client PUBLIC MobileCoreServices)
link_framework (client PUBLIC Security)
link_framework (client PUBLIC UIKit)

# Static Qt libraries.
target_link_libraries (client PUBLIC
${QT_LIBS}/libqtlibpng.a
${QT_LIBS}/libqtharfbuzz.a
${QT_LIBS}/libqtfreetype.a
${QT_LIBS}/libqtpcre.a
${QT_LIBS}/libQt5FontDatabaseSupport_debug.a
${QT_LIBS}/libQt5GraphicsSupport_debug.a
${QT_LIBS}/libQt5ClipboardSupport_debug.a
${QT_PLUGINS}/platforms/libqios_debug.a
${QT_PLUGINS}/imageformats/libqgif.a
${QT_PLUGINS}/imageformats/libqicns.a
${QT_PLUGINS}/imageformats/libqtga.a
${QT_PLUGINS}/imageformats/libqjpeg.a
debug ${QT_LIBS}/libqtlibpng_debug.a
debug ${QT_LIBS}/libqtharfbuzz_debug.a
debug ${QT_LIBS}/libqtfreetype_debug.a
debug ${QT_LIBS}/libqtpcre_debug.a
debug ${QT_LIBS}/libQt5FontDatabaseSupport_debug.a
debug ${QT_LIBS}/libQt5GraphicsSupport_debug.a
debug ${QT_LIBS}/libQt5ClipboardSupport_debug.a
debug ${QT_PLUGINS}/platforms/libqios_debug.a
debug ${QT_PLUGINS}/imageformats/libqgif_debug.a
debug ${QT_PLUGINS}/imageformats/libqicns_debug.a
debug ${QT_PLUGINS}/imageformats/libqtga_debug.a
debug ${QT_PLUGINS}/imageformats/libqjpeg_debug.a

optimized ${QT_LIBS}/libqtlibpng.a
optimized ${QT_LIBS}/libqtharfbuzz.a
optimized ${QT_LIBS}/libqtfreetype.a
optimized ${QT_LIBS}/libqtpcre.a
optimized ${QT_LIBS}/libQt5FontDatabaseSupport.a
optimized ${QT_LIBS}/libQt5GraphicsSupport.a
optimized ${QT_LIBS}/libQt5ClipboardSupport.a
optimized ${QT_PLUGINS}/platforms/libqios.a
optimized ${QT_PLUGINS}/imageformats/libqgif.a
optimized ${QT_PLUGINS}/imageformats/libqicns.a
optimized ${QT_PLUGINS}/imageformats/libqtga.a
optimized ${QT_PLUGINS}/imageformats/libqjpeg.a
)
elseif (APPLE)
link_framework (client PUBLIC Cocoa)
Expand All @@ -162,19 +156,49 @@ endif ()
if (TARGET DirectX)
target_link_libraries (client PUBLIC DirectX)
endif ()

target_link_libraries (client PUBLIC Deng::libappfw Deng::libdoomsday)

# Deployment -----------------------------------------------------------------
# Deployment ----------------------------------------------------------------------------

if (AMETHYST_FOUND)
if (APPLE)
set (readme "${CMAKE_CURRENT_BINARY_DIR}/Read Me.html")
deng_add_amedoc (HTML ${readme} ${DENG_SOURCE_DIR}/doc/readme readme.ame)
install (FILES ${readme} DESTINATION .)
list (APPEND SOURCES ${readme})
else ()
set (readme "${CMAKE_CURRENT_BINARY_DIR}/readme.html")
deng_add_amedoc (HTML ${readme} ${DENG_SOURCE_DIR}/doc/readme readme.ame)
list (APPEND SOURCES ${readme})
if (WIN32)
# WIX generator requires setting this manually.
set_property (INSTALL "${DENG_INSTALL_DOC_DIR}/readme.html"
PROPERTY CPACK_START_MENU_SHORTCUTS "Read Me"
)
endif ()
endif ()
# Manual page.
if (UNIX)
set (MAN_PAGE ${CMAKE_CURRENT_BINARY_DIR}/doomsday.6)
deng_add_amedoc (MAN ${MAN_PAGE} ${DENG_SOURCE_DIR}/doc/readme readme.ame)
list (APPEND SOURCES ${MAN_PAGE})
endif ()
endif ()

if (WIN32 OR APPLE)
set_property (TARGET client PROPERTY OUTPUT_NAME "Doomsday")
set (MACOSX_BUNDLE_BUNDLE_EXECUTABLE "Doomsday")
set (MACOSX_BUNDLE_ICON_FILE "deng.icns")
if (IOS)
set (MACOSX_BUNDLE_ICON_FILE "deng.icns")
else ()
set (MACOSX_BUNDLE_ICON_FILE "deng.icns")
endif ()
else ()
set_property (TARGET client PROPERTY OUTPUT_NAME "doomsday")
endif ()

if (UNIX AND NOT APPLE)
if (UNIX_LINUX)
configure_file (doomsday-engine.desktop.in net.dengine.Doomsday.desktop)
install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/net.dengine.Doomsday.desktop
DESTINATION share/applications)
Expand All @@ -183,11 +207,10 @@ if (UNIX AND NOT APPLE)
endif ()

if (WIN32)
# WIX generator requires setting this manually.
# WIX generator requires setting Start Menu shortcut manually.
set_property (INSTALL "bin/$<TARGET_FILE_NAME:client>"
PROPERTY CPACK_START_MENU_SHORTCUTS "Doomsday Engine"
)

# Also include OpenSSL support.
if (OPENSSL_DIR)
find_file (OPENSSL_LIBEAY libeay32.dll
Expand Down Expand Up @@ -223,7 +246,11 @@ if (APPLE)
# work on them -- plugins are already self-contained.
get_property (outName TARGET client PROPERTY OUTPUT_NAME)
set (stageDir "${DENG_BUILD_STAGING_DIR}/DengPlugins")
set (destDir "${outName}.app/Contents/PlugIns/Doomsday")
if (IOS)
set (destDir "${outName}.app/PlugIns")
else ()
set (destDir "${outName}.app/Contents/PlugIns/Doomsday")
endif ()
install (CODE "execute_process (COMMAND ${CMAKE_COMMAND} -E remove_directory
\"\${CMAKE_INSTALL_PREFIX}/${destDir}\")")
deng_install_deployqt (client)
Expand Down
4 changes: 0 additions & 4 deletions doomsday/apps/client/include/updater/updatersettingsdialog.h
Expand Up @@ -23,8 +23,6 @@
#ifndef DENG_CLIENT_UPDATERSETTINGSDIALOG_H
#define DENG_CLIENT_UPDATERSETTINGSDIALOG_H

#if defined (DENG_HAVE_UPDATER)

#include <de/DialogWidget>

/**
Expand Down Expand Up @@ -58,6 +56,4 @@ public slots:
DENG2_PRIVATE(d)
};

#endif // DENG_HAVE_UPDATER

#endif // DENG_CLIENT_UPDATERSETTINGSDIALOG_H
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/gl/sys_opengl.cpp
Expand Up @@ -32,7 +32,7 @@

#ifdef WIN32
# define GETPROC(Type, x) x = de::function_cast<Type>(wglGetProcAddress(#x))
#elif defined (UNIX) && !defined (MACOSX) && !defined (DENG_IOS)
#elif defined (DENG_X11)
# include <GL/glx.h>
# undef None
# define GETPROC(Type, x) x = de::function_cast<Type>(glXGetProcAddress((GLubyte const *)#x))
Expand Down Expand Up @@ -276,7 +276,7 @@ void Sys_GLConfigureDefaultState(void)
LIBGUI_ASSERT_GL_OK();
LIBGUI_GL.glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
LIBGUI_ASSERT_GL_OK();

LIBGUI_GL.glPointSize(GL_state.currentPointSize);
LIBGUI_ASSERT_GL_OK();

Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/ui/widgets/taskbarwidget.cpp
Expand Up @@ -501,7 +501,7 @@ TaskBarWidget::TaskBarWidget() : GuiWidget("taskbar"), d(new Impl(this))
#endif
<< new ui::ActionItem(tr("About Doomsday"), new SignalAction(this, SLOT(showAbout())))
<< helpMenu
#if !defined (DENG_IOS)
#if !defined (DENG_MOBILE)
<< new ui::Item(ui::Item::Separator)
<< new ui::ActionItem(tr("Quit Doomsday"), new CommandAction("quit!"))
#endif
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/libdoomsday/src/uri.cpp
Expand Up @@ -514,7 +514,7 @@ void Uri::writeUri(writer_s *writer, int omitComponents) const
}

#ifdef _DEBUG
# if !defined (DENG_IOS)
# if !defined (DENG_MOBILE)

LIBDENG_DEFINE_UNITTEST(Uri)
{
Expand Down Expand Up @@ -616,7 +616,7 @@ LIBDENG_DEFINE_UNITTEST(Uri)

LIBDENG_RUN_UNITTEST(Uri)

# endif // DENG_IOS
# endif // DENG_MOBILE
#endif // _DEBUG

} // namespace de
12 changes: 10 additions & 2 deletions doomsday/apps/plugins/CMakeLists.txt
Expand Up @@ -5,32 +5,40 @@ cmake_minimum_required (VERSION 3.1)
project (Plugins)
include (../../cmake/Config.cmake)

# Libraries -----------------------------------------------------------------------------

add_subdirectory (libgamefw)

# Importers -----------------------------------------------------------------------------

add_subdirectory (importdeh)
add_subdirectory (importidtech1)
add_subdirectory (importudmf)
if (NOT IOS)
add_subdirectory (importsave)
endif ()

# Games ---------------------------------------------------------------------------------

add_subdirectory (doom)
add_subdirectory (heretic)
add_subdirectory (hexen)
add_subdirectory (doom64)

# Audio ---------------------------------------------------------------------------------

add_subdirectory (fmod)
add_subdirectory (openal)
if (NOT (WIN32 OR IOS))
add_subdirectory (fluidsynth)
endif ()

# Platform-specific plugins.
if (WIN32)
add_subdirectory (directsound)
add_subdirectory (winmm)
endif ()

# Other ---------------------------------------------------------------------------------

if (DENG_DEVELOPER)
add_subdirectory (example)
endif ()
11 changes: 11 additions & 0 deletions doomsday/apps/plugins/PluginConfig.cmake
Expand Up @@ -33,6 +33,17 @@ macro (deng_add_plugin target)
set_target_properties (${target} PROPERTIES FOLDER Plugins)

if (APPLE)
if (IOS)
link_framework (${target} PUBLIC Foundation)
link_framework (${target} PUBLIC CoreFoundation)
link_framework (${target} PUBLIC MobileCoreServices)
link_framework (${target} PUBLIC UIKit)
link_framework (${target} PUBLIC Security)
target_link_libraries (${target} PUBLIC
debug ${QT_LIBS}/libqtpcre_debug.a
optimized ${QT_LIBS}/libqtpcre.a
)
endif ()
# The plugins have some messy code.
set_property (TARGET ${target}
APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-braces
Expand Down
9 changes: 5 additions & 4 deletions doomsday/cmake/Config.cmake
Expand Up @@ -36,6 +36,11 @@ else ()
set (DENG_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE})
endif ()

if (UNIX AND NOT APPLE)
set (UNIX_LINUX YES)
include (GNUInstallDirs)
endif()

include (Macros)
include (Arch)
include (BuildTypes)
Expand All @@ -45,10 +50,6 @@ find_package (Ccache)
include (Options)
include (Packaging)

if (UNIX AND NOT APPLE)
include (GNUInstallDirs)
endif()

# Install directories.
set (DENG_INSTALL_DATA_DIR "share/doomsday")
set (DENG_INSTALL_DOC_DIR "share/doc")
Expand Down
7 changes: 7 additions & 0 deletions doomsday/cmake/InstallPrefix.cmake
@@ -1,3 +1,10 @@
if (IOS)
# On iOS, we'll install files into the app bundle instead of
# any user-specified location.
set (CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/apps/client/\${BUILD_TYPE}\${EFFECTIVE_PLATFORM_NAME})
return ()
endif ()

set (_oldPrefix ${CMAKE_INSTALL_PREFIX})

# Install destination. PREFIX can be used to set the location manually.
Expand Down
16 changes: 9 additions & 7 deletions doomsday/cmake/Macros.cmake
Expand Up @@ -359,10 +359,12 @@ function (deng_add_package packName)
# the packages need to be made available separately.
set (packComponent sdk)
endif ()
install (FILES ${outDir}/${outName}
DESTINATION ${DENG_INSTALL_DATA_DIR}
COMPONENT ${packComponent}
)
if (NOT IOS)
install (FILES ${outDir}/${outName}
DESTINATION ${DENG_INSTALL_DATA_DIR}
COMPONENT ${packComponent}
)
endif ()
if (MSVC)
# In addition to installing, copy the packages to the build products
# directories so that executables can be run in them.
Expand Down Expand Up @@ -645,7 +647,7 @@ endfunction (deng_bundle_install_names)

# macOS: Install the libraries of a dependency target into the application bundle.
function (deng_install_bundle_deps target)
if (APPLE)
if (APPLE AND NOT IOS)
sublist (_deps 1 -1 ${ARGV})
get_property (_outName TARGET ${target} PROPERTY OUTPUT_NAME)
set (_fwDir "${_outName}.app/Contents/Frameworks")
Expand Down Expand Up @@ -685,7 +687,7 @@ function (deng_install_deployqt target)
if (NOT DENG_ENABLE_DEPLOYQT)
return ()
endif ()
if (UNIX AND NOT APPLE)
if (UNIX_LINUX)
return () # No need to deploy Qt.
endif ()
get_property (_outName TARGET ${target} PROPERTY OUTPUT_NAME)
Expand Down Expand Up @@ -771,7 +773,7 @@ endfunction (deng_install_tool)
# Not applicable to macOS because libraries are not installed but instead
# bundled with the applicatino.
macro (deng_install_library library)
if (UNIX AND NOT APPLE)
if (UNIX_LINUX)
string (REGEX REPLACE "(.*)\\.so" "\\1-*.so" versioned ${library})
file (GLOB _links ${library}.* ${versioned})
install (FILES ${library} ${_links}
Expand Down
1 change: 1 addition & 0 deletions doomsday/cmake/PlatformMacx.cmake
Expand Up @@ -20,6 +20,7 @@ execute_process (COMMAND sw_vers -productVersion

add_definitions (
-DMACOSX=1
-DDENG_APPLE=1
-DDENG_PLATFORM_ID="mac10_10-${DENG_ARCH}"
# Fallback basedir for command line apps.
-DDENG_BASE_DIR="${CMAKE_INSTALL_PREFIX}/${DENG_INSTALL_DATA_DIR}"
Expand Down

0 comments on commit 6794745

Please sign in to comment.