Skip to content

Commit

Permalink
Restore submodules for less widely available libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
exjam committed Jan 23, 2022
1 parent 75993f0 commit 2b55942
Show file tree
Hide file tree
Showing 26 changed files with 619 additions and 63 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,12 @@ jobs:
repository: 'microsoft/vcpkg'
path: 'build/vcpkg'

- name: 'Setup vcpkg (Ubuntu)'
if: startsWith(matrix.os, 'ubuntu')
run: ./build/vcpkg/bootstrap-vcpkg.sh

- name: 'Setup vcpkg (Windows)'
if: startsWith(matrix.os, 'windows')
run: ./build/vcpkg/bootstrap-vcpkg.bat

- name: 'Setup NuGet Credentials'
if: startsWith(matrix.os, 'windows')
shell: 'bash'
run: >
cd build &&
Expand All @@ -71,7 +68,7 @@ jobs:
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-bionic.list http://packages.lunarg.com/vulkan/lunarg-vulkan-bionic.list
sudo apt-add-repository ppa:cginternals/ppa
sudo apt-get update
sudo apt-get install -y cmake vulkan-sdk python3-setuptools nasm mesa-common-dev libglu1-mesa-dev ninja-build
sudo apt-get install -y cmake vulkan-sdk python3-setuptools mesa-common-dev libglu1-mesa-dev ninja-build libcurl4-openssl-dev libsdl2-dev libssl-dev zlib1g-dev libuv1-dev libc-ares-dev libavcodec-dev libavfilter-dev libavutil-dev libswscale-dev
if [ "${{ matrix.compiler }}" = "gcc" ]; then
sudo apt-get install -y g++-${{ matrix.version }}
else
Expand Down Expand Up @@ -152,7 +149,7 @@ jobs:
if: startsWith(matrix.os, 'ubuntu')
run: |
cd build
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux-release -DVCPKG_HOST_TRIPLET=x64-linux-release -DCMAKE_BUILD_TYPE=Release -DDECAF_BUILD_TOOLS=ON -DDECAF_VULKAN=ON -DDECAF_QT=ON -DCMAKE_PREFIX_PATH=$QTDIR -DCMAKE_INSTALL_PREFIX=install ..
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DDECAF_BUILD_TOOLS=ON -DDECAF_VULKAN=ON -DDECAF_QT=ON -DCMAKE_PREFIX_PATH=$QTDIR -DCMAKE_INSTALL_PREFIX=install ..
- name: Configure (Windows)
if: startsWith(matrix.os, 'windows')
Expand Down
27 changes: 27 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,21 +1,48 @@
[submodule "libraries/pugixml"]
path = libraries/pugixml
url = https://github.com/zeux/pugixml.git
[submodule "libraries/libbinrec"]
path = libraries/libbinrec
url = https://github.com/decaf-emu/libbinrec.git
[submodule "libraries/spdlog"]
path = libraries/spdlog
url = https://github.com/gabime/spdlog.git
[submodule "libraries/cereal"]
path = libraries/cereal
url = https://github.com/USCiLab/cereal.git
[submodule "libraries/ovsocket"]
path = libraries/ovsocket
url = https://github.com/exjam/ovsocket.git
[submodule "libraries/gsl-lite"]
path = libraries/gsl-lite
url = https://github.com/decaf-emu/gsl-lite.git
[submodule "libraries/addrlib"]
path = libraries/addrlib
url = https://github.com/decaf-emu/addrlib.git
[submodule "libraries/excmd"]
path = libraries/excmd
url = https://github.com/exjam/excmd
[submodule "libraries/imgui"]
path = libraries/imgui
url = https://github.com/ocornut/imgui.git
[submodule "libraries/cnl"]
path = libraries/cnl
url = https://github.com/decaf-emu/cnl.git
[submodule "libraries/catch"]
path = libraries/catch
url = https://github.com/philsquared/Catch.git
[submodule "libraries/cpptoml"]
path = libraries/cpptoml
url = https://github.com/decaf-emu/cpptoml.git
[submodule "libraries/cpp-peglib"]
path = libraries/cpp-peglib
url = https://github.com/yhirose/cpp-peglib.git
[submodule "libraries/fmt"]
path = libraries/fmt
url = https://github.com/fmtlib/fmt.git
[submodule "libraries/glslang"]
path = libraries/glslang
url = https://github.com/KhronosGroup/glslang.git
[submodule "libraries/qtads"]
path = libraries/qtads
url = https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
15 changes: 13 additions & 2 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,18 @@ Use cmake-gui to generate a VS project file:
Required:
- A modern C++17 friendly compiler such as g++9
- CMake
- [vcpkg](https://vcpkg.io/en/getting-started.html)

Required dependencies which can be acquired from system or vcpkg:
- c-ares
- curl
- ffmpeg
- libuv
- openssl
- sdl2
- zlib

For some systems, these can be installed with:
- `apt install cmake libcurl4-openssl-dev libsdl2-dev libssl-dev zlib1g-dev libuv1-dev libc-ares-dev libavcodec-dev libavfilter-dev libavutil-dev libswscale-dev`

Optional:
- [Vulkan SDK](https://vulkan.lunarg.com/sdk/home), disable by using `-DDECAF_VULKAN=OFF`
Expand All @@ -54,7 +65,7 @@ For some systems, Qt can be installed with:
- `cd decaf-emu`
- `mkdir build`
- `cd build`
- `cmake -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../`
- `cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../`
- `make`

You might want to use `cmake -G Ninja <...>` and build with Ninja instead of Make for faster builds.
Expand Down
66 changes: 43 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,6 @@ if(USING_CONAN)
conan_basic_setup(NO_OUTPUT_DIRS)
endif()

find_package(Threads REQUIRED)

find_package(c-ares CONFIG REQUIRED) # c-ares::cares c-ares::cares_shared c-ares::cares_static
find_package(Catch2 CONFIG REQUIRED) # Catch2::Catch2
find_package(cereal CONFIG REQUIRED) # cereal
find_package(CURL CONFIG REQUIRED) # CURL::libcurl
find_package(fmt CONFIG REQUIRED) # fmt::fmt
find_package(glslang CONFIG REQUIRED)
find_package(gsl-lite CONFIG REQUIRED) # gsl::gsl-lite
find_package(imgui CONFIG REQUIRED) # imgui::imgui
find_package(OpenSSL REQUIRED) # OpenSSL::SSL OpenSSL::Crypto
find_package(pugixml CONFIG REQUIRED) # pugixml pugixml::shared pugixml::pugixml
find_package(SDL2 CONFIG REQUIRED) # SDL2::SDL2 SDL2::SDL2main
find_package(spdlog CONFIG REQUIRED) # spdlog::spdlog spdlog::spdlog_header_only
find_package(unofficial-libuv CONFIG REQUIRED) # unofficial::libuv::libuv
find_package(ZLIB REQUIRED) # ZLIB::ZLIB

find_path(CPPTOML_INCLUDE_DIRS "cpptoml.h")

# Disable PCH by default on older versions of CMake
if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
set(DECAF_PCH_DEFAULT OFF)
Expand Down Expand Up @@ -69,10 +50,6 @@ if(DECAF_JIT_PROFILING)
add_definitions(-DDECAF_JIT_ALLOW_PROFILING)
endif()

find_package(FFMPEG REQUIRED)
add_definitions(-DDECAF_FFMPEG)
add_definitions(-DDECAF_SDL)

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
find_package(XCB QUIET)
find_package(X11 QUIET)
Expand All @@ -99,6 +76,49 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(DECAF_PLATFORM_COCOA TRUE)
endif()

find_package(Threads REQUIRED)


if(VCPKG_TARGET_TRIPLET)
find_package(c-ares CONFIG REQUIRED)
find_package(CURL CONFIG REQUIRED)
find_package(FFMPEG REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(SDL2 CONFIG REQUIRED)
find_package(unofficial-libuv CONFIG REQUIRED)
find_package(ZLIB REQUIRED)

set(CARES_LIBRARY c-ares::cares)
set(CURL_LIBRARY CURL::libcurl)
set(FFMPEG_LIBRARY FFMPEG::AVCODEC FFMPEG::AVFILTER FFMPEG::AVUTIL FFMPEG::SWSCALE)
set(LIBUV_LIBRARY unofficial::libuv::libuv)
set(OPENSSL_LIBRARY OpenSSL::SSL)
set(SDL2_LIBRARY SDL2::SDL2)
set(SDL2_MAIN_LIBRARY SDL2::SDL2main)
set(ZLIB_LIBRARY ZLIB::ZLIB)
else()
find_package(CARES REQUIRED)
find_package(CURL REQUIRED)
find_package(FFMPEG REQUIRED)
find_package(LibUV REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(SDL2 REQUIRED)
find_package(ZLIB REQUIRED)

set(CARES_LIBRARY CARES::CARES)
set(CURL_LIBRARY CURL::libcurl)
set(FFMPEG_LIBRARY FFMPEG::AVCODEC FFMPEG::AVFILTER FFMPEG::AVUTIL FFMPEG::SWSCALE)
set(LIBUV_LIBRARY LibUV::LibUV)
set(OPENSSL_LIBRARY OpenSSL::SSL)
set(SDL2_LIBRARY SDL2::SDL2)
set(SDL2_MAIN_LIBRARY SDL2::SDL2main)
set(ZLIB_LIBRARY ZLIB::ZLIB)
endif()

# TODO: Remove these definitions as they are no longer optional
add_definitions(-DDECAF_FFMPEG)
add_definitions(-DDECAF_SDL)

if(DECAF_VULKAN)
find_package(Vulkan 1.1.106.0 REQUIRED) # Vulkan_INCLUDE_DIRS and Vulkan_LIBRARIES
add_library(vulkan INTERFACE IMPORTED)
Expand Down
123 changes: 123 additions & 0 deletions CMakeModules/FindCARES.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#
# This is a slight edited version of FindLIBUV.cmake :)

#[=======================================================================[.rst:
FindCARES
---------

Find c-ares includes and library.

Imported Targets
^^^^^^^^^^^^^^^^

An :ref:`imported target <Imported targets>` named
``CARES::CARES`` is provided if c-ares has been found.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``CARES_FOUND``
True if c-ares was found, false otherwise.
``CARES_INCLUDE_DIRS``
Include directories needed to include c-ares headers.
``CARES_LIBRARIES``
Libraries needed to link to c-ares.
``CARES_VERSION``
The version of c-ares found.
``CARES_VERSION_MAJOR``
The major version of c-ares.
``CARES_VERSION_MINOR``
The minor version of c-ares.
``CARES_VERSION_PATCH``
The patch version of c-ares.

Cache Variables
^^^^^^^^^^^^^^^

This module uses the following cache variables:

``CARES_LIBRARY``
The location of the c-ares library file.
``CARES_INCLUDE_DIR``
The location of the c-ares include directory containing ``ares.h``.

The cache variables should not be used by project code.
They may be set by end users to point at c-ares components.
#]=======================================================================]

set(CARES_NAMES ${CARES_NAMES} cares)

#-----------------------------------------------------------------------------
find_library(CARES_LIBRARY
NAMES ${CARES_NAMES}
)
mark_as_advanced(CARES_LIBRARY)

find_path(CARES_INCLUDE_DIR
NAMES ares.h
)
mark_as_advanced(CARES_INCLUDE_DIR)

#-----------------------------------------------------------------------------
# Extract version number if possible.
set(_CARES_H_REGEX "#[ \t]*define[ \t]+ARES_VERSION_(MAJOR|MINOR|PATCH)[ \t]+[0-9]+")
if(CARES_INCLUDE_DIR AND EXISTS "${CARES_INCLUDE_DIR}/ares_version.h")
file(STRINGS "${CARES_INCLUDE_DIR}/ares_version.h" _CARES_H REGEX "${_CARES_H_REGEX}")
else()
set(_CARES_H "")
endif()
foreach(c MAJOR MINOR PATCH)
if(_CARES_H MATCHES "#[ \t]*define[ \t]+ARES_VERSION_${c}[ \t]+([0-9]+)")
set(_CARES_VERSION_${c} "${CMAKE_MATCH_1}")
else()
unset(_CARES_VERSION_${c})
endif()
endforeach()
if(DEFINED _CARES_VERSION_MAJOR AND DEFINED _CARES_VERSION_MINOR)
set(CARES_VERSION_MAJOR "${_CARES_VERSION_MAJOR}")
set(CARES_VERSION_MINOR "${_CARES_VERSION_MINOR}")
set(CARES_VERSION "${CARES_VERSION_MAJOR}.${CARES_VERSION_MINOR}")
if(DEFINED _CARES_VERSION_PATCH)
set(CARES_VERSION_PATCH "${_CARES_VERSION_PATCH}")
set(CARES_VERSION "${CARES_VERSION}.${CARES_VERSION_PATCH}")
else()
unset(CARES_VERSION_PATCH)
endif()
else()
set(CARES_VERSION_MAJOR "")
set(CARES_VERSION_MINOR "")
set(CARES_VERSION_PATCH "")
set(CARES_VERSION "")
endif()
unset(_CARES_VERSION_MAJOR)
unset(_CARES_VERSION_MINOR)
unset(_CARES_VERSION_PATCH)
unset(_CARES_H_REGEX)
unset(_CARES_H)

#-----------------------------------------------------------------------------
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CARES
FOUND_VAR CARES_FOUND
REQUIRED_VARS CARES_LIBRARY CARES_INCLUDE_DIR
VERSION_VAR CARES_VERSION
)
set(CARES_FOUND ${CARES_FOUND})

#-----------------------------------------------------------------------------
# Provide documented result variables and targets.
if(CARES_FOUND)
set(CARES_INCLUDE_DIRS ${CARES_INCLUDE_DIR})
set(CARES_LIBRARIES ${CARES_LIBRARY})
if(NOT TARGET CARES::CARES)
add_library(CARES::CARES UNKNOWN IMPORTED)
set_target_properties(CARES::CARES PROPERTIES
IMPORTED_LOCATION "${CARES_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${CARES_INCLUDE_DIRS}"
)
endif()
endif()
Loading

0 comments on commit 2b55942

Please sign in to comment.