Skip to content

Commit

Permalink
CMake: Cleanup and finding LibOVR, OpenAL, SDL2
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 18, 2015
1 parent 34cff9e commit 9184a70
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 41 deletions.
14 changes: 7 additions & 7 deletions doomsday/apps/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ add_subdirectory (hexen)
add_subdirectory (doom64)

add_subdirectory (fmod)
add_subdirectory (openal)
if (NOT WIN32)
add_subdirectory (fluidsynth)
endif ()
# add_subdirectory (openal)
#
# # Platform-specific plugins.
# if (WIN32)
# add_subdirectory (directsound)
# add_subdirectory (winmm)
# endif ()

# Platform-specific plugins.
if (WIN32)
add_subdirectory (directsound)
add_subdirectory (winmm)
endif ()
6 changes: 1 addition & 5 deletions doomsday/apps/plugins/PluginConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ project (DENG_PLUGINS)
include (${CMAKE_CURRENT_LIST_DIR}/../../cmake/Config.cmake)

find_package (DengDoomsday QUIET)
find_package (LZSS)

macro (deng_add_plugin target)
sublist (_src 1 -1 ${ARGV})
add_library (${target} MODULE ${_src} ${DENG_RESOURCES})
target_include_directories (${target} PUBLIC ${DENG_API_DIR})
target_link_libraries (${target}
PUBLIC Deng::libdoomsday
PRIVATE lzss
)
target_link_libraries (${target} PUBLIC Deng::libdoomsday)
enable_cxx11 (${target})
set_target_properties (${target} PROPERTIES FOLDER Plugins)
if (APPLE)
Expand Down
27 changes: 27 additions & 0 deletions doomsday/apps/plugins/openal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# The Doomsday Engine Project
# Copyright (c) 2015 Jaakko Keränen <jaakko.keranen@iki.fi>

cmake_minimum_required (VERSION 3.0)
project (DENG_OPENAL)
include (CheckIncludeFile)
include (../PluginConfig.cmake)

find_package (OpenAL QUIET)

if (OPENAL_FOUND)
# Check if the headers are in a plain folder.
set (CMAKE_REQUIRED_INCLUDES ${OPENAL_INCLUDE_DIR})
check_include_file (al.h HAVE_AL_H)
if (HAVE_AL_H)
add_definitions (-DHAVE_AL_H)
endif ()

append (CMAKE_CXX_FLAGS_DEBUG "-DDENG_DSOPENAL_DEBUG")

include_directories (include)
include_directories (SYSTEM ${OPENAL_INCLUDE_DIR})

file (GLOB SOURCES src/*.cpp include/*.h)
deng_add_plugin (audio_openal ${SOURCES})
target_link_libraries (audio_openal PRIVATE ${OPENAL_LIBRARY})
endif ()
10 changes: 5 additions & 5 deletions doomsday/apps/plugins/openal/src/driver_openal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
# pragma warning (disable: 4244)
#endif

#ifndef FINK
#include <AL/al.h>
#include <AL/alc.h>
#ifdef HAVE_AL_H
# include <al.h>
# include <alc.h>
#else
#include <openal/al.h>
#include <openal/alc.h>
# include <AL/al.h>
# include <AL/alc.h>
#endif
#include <stdio.h>
#include <cassert>
Expand Down
5 changes: 3 additions & 2 deletions doomsday/apps/server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Doomsday Engine -- Server
# The Doomsday Engine Project -- Server
# Copyright (c) 2012-2015 Jaakko Keränen <jaakko.keranen@iki.fi>
# Copyright (c) 2012-2014 Daniel Swanson <danij@dengine.net>

cmake_minimum_required (VERSION 3.0)
project (DENG_SERVER)
include (../../cmake/Config.cmake)

# Dependencies.
find_package (Qt5Core)
find_package (DengCore QUIET)
find_package (DengLegacy QUIET)
find_package (DengShell QUIET)
Expand Down
8 changes: 4 additions & 4 deletions doomsday/cmake/FindAssimp.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
find_package (PkgConfig)

pkg_check_modules (ASSIMP REQUIRED assimp)
find_library (LIBASSIMP ${ASSIMP_LIBRARIES} HINTS ${ASSIMP_LIBRARY_DIRS})
mark_as_advanced (LIBASSIMP)

if (NOT TARGET assimp)
pkg_check_modules (ASSIMP REQUIRED assimp)
find_library (LIBASSIMP ${ASSIMP_LIBRARIES} HINTS ${ASSIMP_LIBRARY_DIRS})
mark_as_advanced (LIBASSIMP)

add_library (assimp INTERFACE)
target_include_directories (assimp INTERFACE ${ASSIMP_INCLUDE_DIRS})
target_link_libraries (assimp INTERFACE ${LIBASSIMP})
Expand Down
13 changes: 5 additions & 8 deletions doomsday/cmake/FindLZSS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ if (TARGET lzss)
endif ()

if (WIN32)
add_library (lzss SHARED IMPORTED)
set_target_properties (lzss PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${DENG_LZSS_DIR}/portable/include"
)
add_library (lzss INTERFACE)
target_include_directories (lzss INTERFACE "${DENG_LZSS_DIR}/portable/include")
target_link_libraries (lzss INTERFACE "${DENG_LZSS_DIR}/win32/lzss.lib")
else ()
add_library (lzss STATIC ${DENG_LZSS_DIR}/unix/src/lzss.c)
target_include_directories (lzss
PUBLIC "${DENG_LZSS_DIR}/portable/include"
)
add_library (lzss STATIC EXCLUDE_FROM_ALL ${DENG_LZSS_DIR}/unix/src/lzss.c)
target_include_directories (lzss PUBLIC "${DENG_LZSS_DIR}/portable/include")
target_link_libraries (lzss PRIVATE Deng::liblegacy)
set_property (TARGET lzss PROPERTY AUTOMOC OFF)
endif ()
Expand Down
24 changes: 24 additions & 0 deletions doomsday/cmake/FindOculusVR.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set (LIBOVR_DIR "LibOVR" CACHE PATH "Location of the LibOVR library (from Oculus SDK)")

if (NOT LIBOVR_FOUND)
get_filename_component (fullPath "${LIBOVR_DIR}" ABSOLUTE)
if (EXISTS "${fullPath}/Include")
set (LIBOVR_FOUND YES CACHE BOOL "LibOVR found")
mark_as_advanced (LIBOVR_FOUND)
message (STATUS "Found LibOVR: ${LIBOVR_DIR}")
endif ()
endif ()

if (LIBOVR_FOUND AND NOT TARGET LibOVR)
add_library (LibOVR INTERFACE)
target_include_directories (LibOVR INTERFACE "${LIBOVR_DIR}/Include" "${LIBOVR_DIR}/Src")
target_compile_definitions (LibOVR INTERFACE -DDENG_HAVE_OCULUS_API)
if (APPLE)
target_link_libraries (LibOVR INTERFACE
debug "${LIBOVR_DIR}/Lib/Mac/Debug/libovr.a"
optimized "${LIBOVR_DIR}/Lib/Mac/Release/libovr.a"
)
link_framework (LibOVR INTERFACE Cocoa)
link_framework (LibOVR INTERFACE IOKit)
endif ()
endif ()
11 changes: 11 additions & 0 deletions doomsday/cmake/FindSDL2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
find_package (PkgConfig)

add_pkgconfig_interface_library (SDL2 OPTIONAL sdl2)
add_pkgconfig_interface_library (SDL2_mixer OPTIONAL SDL2_mixer)

if (NOT TARGET SDL2)
add_definitions (-DDENG_NO_SDL)
endif ()
if (NOT TARGET SDL2_mixer)
add_definitions (-DDENG_DISABLE_SDLMIXER)
endif ()
22 changes: 16 additions & 6 deletions doomsday/cmake/Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,17 @@ function (deng_filter_platform_sources outName)
list (REMOVE_AT ARGV 0) # outName
foreach (fn ${ARGV})
set (filtered NO)
if ("${fn}" MATCHES ".*_windows\\..*") # Windows-specific
if ("${fn}" MATCHES ".*_windows\\..*" OR
"${fn}" MATCHES ".*/windows/.*") # Windows-specific
if (NOT WIN32)
set (filtered YES)
endif ()
elseif ("${fn}" MATCHES ".*_macx\\..*") # OS X specific
if (NOT APPLE)
set (filtered YES)
endif ()
elseif ("${fn}" MATCHES ".*_unix\\..*") # Unix specific files (Linux / OS X / etc.)
elseif ("${fn}" MATCHES ".*_unix\\..*" OR
"${fn}" MATCHES ".*/unix/.*") # Unix specific files (Linux / OS X / etc.)
if (NOT UNIX)
set (filtered YES)
endif ()
Expand Down Expand Up @@ -280,9 +282,18 @@ endmacro (deng_add_application)

function (add_pkgconfig_interface_library target)
sublist (pkgNames 1 -1 ${ARGV})
list (GET pkgNames 0 first)
if (NOT first STREQUAL "OPTIONAL")
set (checkMode REQUIRED)
else ()
list (REMOVE_AT pkgNames 0)
endif ()
foreach (pkg ${pkgNames})
set (prefix "PKG_${pkg}")
pkg_check_modules (${prefix} REQUIRED ${pkg})
pkg_check_modules (${prefix} ${checkMode} ${pkg})
if (NOT checkMode STREQUAL "REQUIRED" AND NOT ${prefix}_FOUND)
return ()
endif ()
# Locate full paths of the required shared libraries.
foreach (lib ${${prefix}_LIBRARIES})
find_library (path ${lib} HINTS ${${prefix}_LIBRARY_DIRS})
Expand Down Expand Up @@ -319,7 +330,7 @@ function (fix_bundled_install_names binaryFile)
execute_process (COMMAND ${CMAKE_INSTALL_NAME_TOOL}
-change ${depPath} @loader_path/../Frameworks/${base}
${binaryFile}
)
)
endforeach (fn)
endfunction (fix_bundled_install_names)

Expand All @@ -329,8 +340,7 @@ macro (deng_bundle_install_names target)
sublist (libs 1 -1 ${ARGV})
set (scriptName ${target}-postbuild.cmake)
# Correct the install names of the dependent libraries.
file (GENERATE OUTPUT ${scriptName}
CONTENT "\
file (GENERATE OUTPUT ${scriptName} CONTENT "\
set (CMAKE_MODULE_PATH ${DENG_SOURCE_DIR}/cmake)\n\
set (CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL})\n\
include (Macros)\n\
Expand Down
7 changes: 5 additions & 2 deletions doomsday/cmake/PlatformMacx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ add_definitions (

set (DENG_FIXED_ASM_DEFAULT OFF)

macro (link_framework target fw)
macro (link_framework target linkType fw)
find_library (${fw}_LIBRARY ${fw})
if (${fw}_LIBRARY STREQUAL "${fw}_LIBRARY-NOTFOUND")
message (FATAL_ERROR "link_framework: ${fw} framework not found")
endif ()
mark_as_advanced (${fw}_LIBRARY)
target_link_libraries (${target} PRIVATE ${${fw}_LIBRARY})
target_link_libraries (${target} ${linkType} ${${fw}_LIBRARY})
endmacro (link_framework)
4 changes: 4 additions & 0 deletions doomsday/sdk/libappfw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ find_package (Qt5OpenGL)
find_package (DengCore QUIET)
find_package (DengGui QUIET)
find_package (DengShell QUIET)
find_package (OculusVR QUIET)
include (OpenGL)

# Definitions.
Expand All @@ -25,5 +26,8 @@ target_link_libraries (libappfw
PUBLIC Deng::libcore Deng::libgui Deng::libshell Qt5::Widgets Qt5::OpenGL
PRIVATE opengl
)
if (LIBOVR_FOUND)
target_link_libraries (libappfw PRIVATE LibOVR)
endif ()

deng_deploy_library (libappfw DengAppfw)
2 changes: 1 addition & 1 deletion doomsday/sdk/libgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ target_link_libraries (libgui
PRIVATE opengl assimp
)
if (APPLE)
link_framework (libgui Cocoa)
link_framework (libgui PRIVATE Cocoa)
endif ()

deng_deploy_library (libgui DengGui)
1 change: 0 additions & 1 deletion doomsday/sdk/libgui/DengGuiConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
find_package (DengCore REQUIRED)
find_package (Qt5Gui REQUIRED)
find_package (Qt5OpenGL REQUIRED)
find_package (Assimp REQUIRED)

include ("${CMAKE_CURRENT_LIST_DIR}/DengGui.cmake")

Expand Down

0 comments on commit 9184a70

Please sign in to comment.