From 7ce29ce8ae8778bd29bb711a5ed5b83c35fdf4d7 Mon Sep 17 00:00:00 2001 From: James Grogan Date: Thu, 10 Nov 2022 09:06:02 +0000 Subject: [PATCH] Support minimal dependency linux build. --- README.md | 38 ++++- apps/CMakeLists.txt | 22 +-- apps/sample-gui/CMakeLists.txt | 27 +++ apps/{ => sample-gui}/gui-main-win.cpp | 0 apps/{ => sample-gui}/gui-main.cpp | 0 apps/website-generator/WebsiteGenerator.cpp | 3 +- apps/website-generator/WebsiteGenerator.h | 3 +- src/audio/CMakeLists.txt | 31 ++-- .../audio_interfaces/NullAudioInterface.cpp | 141 ++++++++++++++++ .../audio_interfaces/NullAudioInterface.h | 40 +++++ src/core/serializers/TomlReader.cpp | 155 +++++++++--------- src/graphics/CMakeLists.txt | 25 ++- src/windows/CMakeLists.txt | 83 +++++----- test/CMakeLists.txt | 29 +++- 14 files changed, 421 insertions(+), 176 deletions(-) create mode 100644 apps/sample-gui/CMakeLists.txt rename apps/{ => sample-gui}/gui-main-win.cpp (100%) rename apps/{ => sample-gui}/gui-main.cpp (100%) create mode 100644 src/audio/audio_interfaces/NullAudioInterface.cpp create mode 100644 src/audio/audio_interfaces/NullAudioInterface.h diff --git a/README.md b/README.md index d4d6486..638d23d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,39 @@ -# limmto -limmto (Light Multi-Media Tool) is a free, low-dependency C++ library for working with digital media. +# MediaTool + +This is a collection of tools and apps for working with various media (Web, Desktop Publishing, Video/Audio) on different platforms (Linux, Windows). + +It tries to have low dependencies and lots of things are built from scratch. + +This is a personal/hobby project - things will break/change a lot. + +# Build Dependencies + +## Linux + +### Minimal + +```bash +sudo apt-get install build-essential cmake +``` + +### Optional + +#### Audio + +```bash +sudo apt-get install libasound2-dev +``` + +#### Image Formats + +```bash +sudo apt-get install libpng-dev +``` + + +# Build from Source + +## Linux ```bash mkdir build diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 47b9f8f..b2945bb 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -1,24 +1,9 @@ # Sample GUI -add_executable(sample_gui gui-main.cpp) -target_include_directories(sample_gui PUBLIC - "${PROJECT_SOURCE_DIR}/src/console" - "${PROJECT_SOURCE_DIR}/src/client" - ) -target_link_libraries(sample_gui PUBLIC client windows console core - network database geometry audio web) + +add_subdirectory(sample-gui) if(WIN32) -add_executable(sample_gui_win WIN32 gui-main-win.cpp) -target_include_directories(sample_gui PUBLIC - "${PROJECT_SOURCE_DIR}/src/console" - "${PROJECT_SOURCE_DIR}/src/client" - ) -target_link_libraries(sample_gui_win PUBLIC client windows console core - network database geometry audio web) -set_property(TARGET sample_gui_win PROPERTY FOLDER apps) - -add_subdirectory(directx-practice) - + add_subdirectory(directx-practice) endif() # Sample Console @@ -30,7 +15,6 @@ target_link_libraries(sample_console PUBLIC console core network database geometry audio web) set_property(TARGET sample_console PROPERTY FOLDER apps) -set_property(TARGET sample_gui PROPERTY FOLDER apps) add_subdirectory(website-generator) diff --git a/apps/sample-gui/CMakeLists.txt b/apps/sample-gui/CMakeLists.txt new file mode 100644 index 0000000..f774b34 --- /dev/null +++ b/apps/sample-gui/CMakeLists.txt @@ -0,0 +1,27 @@ + +if(WIN32) + add_executable(sample_gui_win WIN32 gui-main-win.cpp) + target_include_directories(sample_gui PUBLIC + "${PROJECT_SOURCE_DIR}/src/console" + "${PROJECT_SOURCE_DIR}/src/client" + ) + target_link_libraries(sample_gui_win PUBLIC client windows console core + network database geometry audio web) + set_property(TARGET sample_gui_win PROPERTY FOLDER apps) +else() + find_package(X11 QUIET) + if(X11_FOUND) + add_executable(sample_gui gui-main.cpp) + target_include_directories(sample_gui PUBLIC + "${PROJECT_SOURCE_DIR}/src/console" + "${PROJECT_SOURCE_DIR}/src/client" + ) + target_link_libraries(sample_gui PUBLIC client windows console core + network database geometry audio web) + set_property(TARGET sample_gui PROPERTY FOLDER apps) + else() + message(STATUS "Skipping sample GUI as no X11 dev support") + endif() +endif() + + diff --git a/apps/gui-main-win.cpp b/apps/sample-gui/gui-main-win.cpp similarity index 100% rename from apps/gui-main-win.cpp rename to apps/sample-gui/gui-main-win.cpp diff --git a/apps/gui-main.cpp b/apps/sample-gui/gui-main.cpp similarity index 100% rename from apps/gui-main.cpp rename to apps/sample-gui/gui-main.cpp diff --git a/apps/website-generator/WebsiteGenerator.cpp b/apps/website-generator/WebsiteGenerator.cpp index 6a8f4f6..8809d05 100644 --- a/apps/website-generator/WebsiteGenerator.cpp +++ b/apps/website-generator/WebsiteGenerator.cpp @@ -50,8 +50,7 @@ void WebsiteGenerator::parseTemplateFiles() const auto template_files = Directory::getFilesWithExtension(template_path, ".html"); for (const auto& path : template_files) { - auto file = TemplateFile(path); - mTemplateFiles[path.stem().string()] = file; + mTemplateFiles[path.stem().string()] = std::make_unique(path); } } diff --git a/apps/website-generator/WebsiteGenerator.h b/apps/website-generator/WebsiteGenerator.h index 5affd4f..fb9a53c 100644 --- a/apps/website-generator/WebsiteGenerator.h +++ b/apps/website-generator/WebsiteGenerator.h @@ -44,6 +44,7 @@ public: { } + private: Path mPath; }; @@ -80,5 +81,5 @@ private: GeneratorConfig mConfig; std::vector mPages; std::vector mArticles; - std::unordered_map mTemplateFiles; + std::unordered_map > mTemplateFiles; }; diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index 7ce05f2..f38c4aa 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -3,17 +3,26 @@ set(platform_HEADERS "") set(platform_INCLUDES "") if (UNIX) - find_package(ALSA REQUIRED) - list(APPEND platform_HEADERS - audio_interfaces/AlsaInterface.h - ${ALSA_INCLUDE_DIRS} - ) - list(APPEND platform_INCLUDES - audio_interfaces/AlsaInterface.cpp - ) - list(APPEND platform_LIBS - ${ALSA_LIBRARIES} - ) + find_package(ALSA QUIET) + if(ALSA_FOUND) + list(APPEND platform_HEADERS + audio_interfaces/AlsaInterface.h + ${ALSA_INCLUDE_DIRS}) + list(APPEND platform_INCLUDES + audio_interfaces/AlsaInterface.cpp + ) + list(APPEND platform_LIBS + ${ALSA_LIBRARIES} + ) + else() + message(STATUS "ALSA package not found - not building audio interface.") + list(APPEND platform_HEADERS + audio_interfaces/NullAudioInterface.h + ) + list(APPEND platform_INCLUDES + audio_interfaces/NullAudioInterface.cpp + ) + endif() else() list(APPEND platform_HEADERS audio_interfaces/WasapiInterface.h diff --git a/src/audio/audio_interfaces/NullAudioInterface.cpp b/src/audio/audio_interfaces/NullAudioInterface.cpp new file mode 100644 index 0000000..de413a5 --- /dev/null +++ b/src/audio/audio_interfaces/NullAudioInterface.cpp @@ -0,0 +1,141 @@ +#include "AlsaInterface.h" +#include "FileLogger.h" + +#include "AudioSynth.h" + +#include + +AlsaInterface::AlsaInterface() + :mHandle(), + mHardwareParams(), + mPeriodSize(8192) +{ + +} + +AlsaInterface::~AlsaInterface() +{ + +} + +std::unique_ptr AlsaInterface::Create() +{ + return std::make_unique(); +} + +void AlsaInterface::OpenDevice(const AudioDevicePtr& device) +{ + MLOG_INFO("Opening Device"); + snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK; + if (snd_pcm_open(&mHandle, device->GetName().c_str(), stream, 0) < 0) + { + MLOG_ERROR("Error opening PCM device: " + device->GetName()); + return; + } + + snd_pcm_hw_params_alloca(&mHardwareParams); + if (snd_pcm_hw_params_any(mHandle, mHardwareParams) < 0) + { + MLOG_ERROR("Can not configure this PCM device."); + return; + } + + SetAccessType(device); + SetSampleFormat(device); + SetSampleRate(device); + SetPeriod(device); + SetBufferSize(device); + SetChannelNumber(device); + + /* Apply HW parameter settings to */ + /* PCM device and prepare device */ + if (snd_pcm_hw_params(mHandle, mHardwareParams) < 0) { + MLOG_ERROR("Error setting HW params."); + return; + } +} + +void AlsaInterface::SetAccessType(const AudioDevicePtr& device) +{ + if (snd_pcm_hw_params_set_access(mHandle, mHardwareParams, SND_PCM_ACCESS_RW_INTERLEAVED) < 0) { + MLOG_ERROR("Error setting device access."); + return; + } +} + +void AlsaInterface::SetSampleFormat(const AudioDevicePtr& device) +{ + /* Set sample format */ + if (snd_pcm_hw_params_set_format(mHandle, mHardwareParams, SND_PCM_FORMAT_S16_LE) < 0) { + MLOG_ERROR("Error setting format. "); + return; + } +} + +void AlsaInterface::SetSampleRate(const AudioDevicePtr& device) +{ + unsigned rate = device->GetSampleRate(); + unsigned exact_rate = rate; + if (snd_pcm_hw_params_set_rate_near(mHandle, mHardwareParams, &exact_rate, 0) < 0) + { + MLOG_ERROR("Error setting rate. "); + return; + } + if (rate != exact_rate) { + MLOG_ERROR("The rate is not supported by your hardware."); + } +} + +void AlsaInterface::SetPeriod(const AudioDevicePtr& device) +{ + /* Set number of periods. Periods used to be called fragments. */ + if (snd_pcm_hw_params_set_periods(mHandle, mHardwareParams, device->GetPeriod(), 0) < 0) + { + MLOG_ERROR("Error setting periods. "); + return; + } +} + +void AlsaInterface::SetBufferSize(const AudioDevicePtr& device) +{ + int periods = static_cast(device->GetPeriod()); + + /* Set buffer size (in frames). The resulting latency is given by */ + /* latency = periodsize * periods / (rate * bytes_per_frame) */ + if (snd_pcm_hw_params_set_buffer_size(mHandle, mHardwareParams, (mPeriodSize * periods)>>2) < 0) + { + MLOG_ERROR("Error setting buffersize. "); + return; + } +} + +void AlsaInterface::SetChannelNumber(const AudioDevicePtr& device) +{ + /* Set number of channels */ + if (snd_pcm_hw_params_set_channels(mHandle, mHardwareParams, device->GetNumChannels()) < 0) + { + MLOG_ERROR("Error setting channels"); + return; + } +} + +void AlsaInterface::Play(const AudioDevicePtr& device) +{ + MLOG_INFO("Playing audio"); + AudioSynth synth; + const unsigned duration = 100; + double freq = 440; + auto data = synth.GetSineWave(freq, duration)->GetChannelData(0); + + int numFrames = mPeriodSize >> 2; + for(int count = 0; count < duration; count++) + { + const auto offset= count*4*numFrames; + unsigned char frame[4] = {data[offset], data[offset+1], data[offset+2], data[offset+3]}; + while ((snd_pcm_writei(mHandle, frame, numFrames)) < 0) + { + snd_pcm_prepare(mHandle); + MLOG_ERROR("<<<<<<<<<<<<<<< Buffer Underrun >>>>>>>>>>>>>>>"); + } + } +} diff --git a/src/audio/audio_interfaces/NullAudioInterface.h b/src/audio/audio_interfaces/NullAudioInterface.h new file mode 100644 index 0000000..fe0eb2c --- /dev/null +++ b/src/audio/audio_interfaces/NullAudioInterface.h @@ -0,0 +1,40 @@ +#pragma once + +#include "IAudioInterface.h" +#include "AudioDevice.h" + +#include +#include + +class AlsaInterface : public IAudioInterface +{ + snd_pcm_t* mHandle; + snd_pcm_hw_params_t* mHardwareParams; + snd_pcm_uframes_t mPeriodSize; + +public: + + AlsaInterface(); + + ~AlsaInterface(); + + static std::unique_ptr Create(); + + void OpenDevice(const AudioDevicePtr& device) override; + + void SetAccessType(const AudioDevicePtr& device); + + void SetSampleFormat(const AudioDevicePtr& device); + + void SetSampleRate(const AudioDevicePtr& device); + + void SetPeriod(const AudioDevicePtr& device); + + void SetBufferSize(const AudioDevicePtr& device); + + void SetChannelNumber(const AudioDevicePtr& device); + + void Play(const AudioDevicePtr& device) override; +}; + +using AlsaInterfacePtr = std::shared_ptr; diff --git a/src/core/serializers/TomlReader.cpp b/src/core/serializers/TomlReader.cpp index 0ef0cd0..ff40272 100644 --- a/src/core/serializers/TomlReader.cpp +++ b/src/core/serializers/TomlReader.cpp @@ -2,151 +2,152 @@ #include #include +#include TomlTable::TomlTable(const std::string& header) - : mHeader(header) + : mHeader(header) { } void TomlTable::addComment(const Comment& comment) { - mComments.push_back(comment); + mComments.push_back(comment); } void TomlTable::addTable(std::unique_ptr table) { - mTables[table->getHeader()] = std::move(table); + mTables[table->getHeader()] = std::move(table); } void TomlTable::addKeyValuePair(const std::string& key, const std::string& value) { - mMap[key] = value; + mMap[key] = value; } std::string TomlTable::getHeader() const { - return mHeader; + return mHeader; } TomlTable* TomlTable::getTable(const std::string& path) { - return mTables[path].get(); + return mTables[path].get(); } TomlTable::KeyValuePairs TomlTable::getKeyValuePairs() const { - return mMap; + return mMap; } TomlContent::TomlContent() - : mRootTable(std::make_unique("root")) + : mRootTable(std::make_unique("root")) { } TomlTable* TomlContent::getRootTable() const { - return mRootTable.get(); + return mRootTable.get(); } TomlTable* TomlContent::getTable(const std::string& path) const { - return mRootTable->getTable(path); + return mRootTable->getTable(path); } TomlReader::TomlReader() - : mContent(std::make_unique()) + : mContent(std::make_unique()) { } TomlContent* TomlReader::getContent() const { - return mContent.get(); + return mContent.get(); } void TomlReader::read(const Path& input_path) { - const auto lines = File(input_path).readLines(); - mLastSectionOffset = 0; - mWorkingTable = mContent->getRootTable(); + const auto lines = File(input_path).readLines(); + mLastSectionOffset = 0; + mWorkingTable = mContent->getRootTable(); - for (const auto& line : lines) - { - processLine(line); - mLastSectionOffset++; - } + for (const auto& line : lines) + { + processLine(line); + mLastSectionOffset++; + } - mWorkingTable = nullptr; + mWorkingTable = nullptr; } void TomlReader::processLine(const std::string& line) { - bool in_comment{ false }; - bool in_header{ false }; - bool found_key{ false }; - std::string working_string; - std::string key_string; - for (auto c : line) - { - if (c == '#' && !in_comment) - { - in_comment = true; - } - else if (c == '[' && !in_comment && !in_header) - { - in_header = true; - } - else if (c == '=' && !in_comment && !in_header) - { - found_key = true; - key_string = working_string; - working_string = ""; - } - else if (c == ']' && in_header) - { - break; - } - else - { - working_string += c; - } - } + bool in_comment{ false }; + bool in_header{ false }; + bool found_key{ false }; + std::string working_string; + std::string key_string; + for (auto c : line) + { + if (c == '#' && !in_comment) + { + in_comment = true; + } + else if (c == '[' && !in_comment && !in_header) + { + in_header = true; + } + else if (c == '=' && !in_comment && !in_header) + { + found_key = true; + key_string = working_string; + working_string = ""; + } + else if (c == ']' && in_header) + { + break; + } + else + { + working_string += c; + } + } - if (in_comment) - { - mWorkingTable->addComment({ mLastSectionOffset, working_string }); - } - else if (in_header) - { - onHeader(working_string); - } - else if (found_key) - { - std::locale locale; - key_string.erase(std::remove_if(key_string.begin(), key_string.end(), [locale](unsigned char c) {return std::isspace(c, locale); }), key_string.end()); - working_string.erase(std::remove_if(working_string.begin(), working_string.end(), [locale](unsigned char c) {return std::isspace(c, locale); }), working_string.end()); - - if (working_string.size()>2 && working_string[0] == '"' && working_string[working_string.size() - 1] == '"') - { - working_string = working_string.substr(1, working_string.size() - 2); - } - - onKeyValuePair(key_string, working_string); - } + if (in_comment) + { + mWorkingTable->addComment({ mLastSectionOffset, working_string }); + } + else if (in_header) + { + onHeader(working_string); + } + else if (found_key) + { + std::locale locale; + key_string.erase(std::remove_if(key_string.begin(), key_string.end(), [locale](unsigned char c) {return std::isspace(c, locale); }), key_string.end()); + working_string.erase(std::remove_if(working_string.begin(), working_string.end(), [locale](unsigned char c) {return std::isspace(c, locale); }), working_string.end()); + + if (working_string.size()>2 && working_string[0] == '"' && working_string[working_string.size() - 1] == '"') + { + working_string = working_string.substr(1, working_string.size() - 2); + } + + onKeyValuePair(key_string, working_string); + } } void TomlReader::onHeader(const std::string& header) { - auto new_table = std::make_unique(header); - auto table_temp = new_table.get(); - mWorkingTable->addTable(std::move(new_table)); - mWorkingTable = table_temp; + auto new_table = std::make_unique(header); + auto table_temp = new_table.get(); + mWorkingTable->addTable(std::move(new_table)); + mWorkingTable = table_temp; } void TomlReader::onKeyValuePair(const std::string key, const std::string value) { - mWorkingTable->addKeyValuePair(key, value); + mWorkingTable->addKeyValuePair(key, value); } diff --git a/src/graphics/CMakeLists.txt b/src/graphics/CMakeLists.txt index 1fa1858..1ba5fe5 100644 --- a/src/graphics/CMakeLists.txt +++ b/src/graphics/CMakeLists.txt @@ -3,32 +3,29 @@ set(platform_INCLUDE_DIRS "") set(platform_HEADERS "") set(platform_LIBS "") -if (UNIX) -list(APPEND platform_LIBSs - GL -) -else() -list(APPEND platform_LIBS - OpenGL32.lib -) -endif() - list(APPEND graphics_LIB_INCLUDES DrawingContext.cpp DrawingManager.cpp DrawingSurface.cpp Rasterizer.cpp - opengl/OpenGlInterface.cpp - ${platform_LIB_INCLUDES} + ${platform_LIB_INCLUDES} ) list(APPEND graphics_HEADERS - opengl/OpenGlInterface.h ${platform_HEADERS} Rasterizer.h INativeDrawingSurface.h - INativeDrawingContext.h) + INativeDrawingContext.h + ) +find_package(OpenGL QUIET) +if (OpenGL_FOUND) + list(APPEND platform_LIBS OpenGL::GL) + list(APPEND graphics_LIB_INCLUDES opengl/OpenGlInterface.cpp) + list(APPEND graphics_HEADERS opengl/OpenGlInterface.h) +else() + message(STATUS "OpenGL headers not found - skipping OpenGL support") +endif() add_library(graphics SHARED ${graphics_LIB_INCLUDES} diff --git a/src/windows/CMakeLists.txt b/src/windows/CMakeLists.txt index 94d6fe9..4b6aa80 100644 --- a/src/windows/CMakeLists.txt +++ b/src/windows/CMakeLists.txt @@ -4,50 +4,51 @@ set (platform_LIBS "") set(_HAS_WAYLAND Off) if(UNIX) - list(APPEND platform_INCLUDES - ui_interfaces/x11/XcbInterface.cpp - ui_interfaces/x11/XcbEventInterface.cpp - ui_interfaces/x11/XcbWindow.cpp - ui_interfaces/x11/XcbScreen.cpp - ui_interfaces/x11/XcbWindowInterface.cpp - ui_interfaces/x11/XcbLayerInterface.cpp - ui_interfaces/x11/XcbTextInterface.cpp - ui_interfaces/x11/XcbKeyboard.cpp - ui_interfaces/x11/GlxInterface.cpp - ) + find_package(X11 QUIET) + if(X11_FOUND) + list(APPEND platform_INCLUDES + ui_interfaces/x11/XcbInterface.cpp + ui_interfaces/x11/XcbEventInterface.cpp + ui_interfaces/x11/XcbWindow.cpp + ui_interfaces/x11/XcbScreen.cpp + ui_interfaces/x11/XcbWindowInterface.cpp + ui_interfaces/x11/XcbLayerInterface.cpp + ui_interfaces/x11/XcbTextInterface.cpp + ui_interfaces/x11/XcbKeyboard.cpp + ui_interfaces/x11/GlxInterface.cpp + ) + list(APPEND platform_LIBS ${X11_LIBRARIES} ${X11_xcb_LIB} ${X11_X11_xcb_LIB}) + else() + message(STATUS "x11 development headers not found - skipping support") + endif() - list(APPEND platform_LIBS - X11 X11-xcb xcb ) - - - find_path( - WAYLAND_CLIENT_INCLUDE_DIR - NAMES wayland-client.h - ) - list(APPEND WAYLAND_INCLUDE_DIRS ${WAYLAND_CLIENT_INCLUDE_DIR}) - - find_path( - WAYLAND_EXTENSIONS_INCLUDE_DIR - NAMES xdg-shell-client-protocol.h - HINTS ENV WAYLAND_EXTENSION_DIR - ) - if(NOT ${WAYLAND_EXTENSIONS_INCLUDE_DIR-NOTFOUND}) - find_library( - WAYLAND_CLIENT_LIBRARY - NAMES wayland-client libwayland-client - ) + find_path(WAYLAND_CLIENT_INCLUDE_DIR NAMES wayland-client.h) + if (NOT ${WAYLAND_CLIENT_INCLUDE_DIR-NOTFOUND}) + list(APPEND WAYLAND_INCLUDE_DIRS ${WAYLAND_CLIENT_INCLUDE_DIR}) - list(APPEND WAYLAND_INCLUDE_DIRS ${WAYLAND_EXTENSIONS_INCLUDE_DIR}) - - list(APPEND platform_INCLUDES - ui_interfaces/wayland/WaylandWindowInterface.cpp - ui_interfaces/wayland/WaylandSurface.cpp - ui_interfaces/wayland/WaylandBuffer.cpp - ${WAYLAND_EXTENSIONS_INCLUDE_DIR}/xdg-shell-protocol.cpp - ) - set(_HAS_WAYLAND ON) + find_path(WAYLAND_EXTENSIONS_INCLUDE_DIR NAMES xdg-shell-client-protocol.h + HINTS ENV WAYLAND_EXTENSION_DIR + ) + if(NOT ${WAYLAND_EXTENSIONS_INCLUDE_DIR-NOTFOUND}) + find_library( + WAYLAND_CLIENT_LIBRARY + NAMES wayland-client libwayland-client + ) + + list(APPEND WAYLAND_INCLUDE_DIRS ${WAYLAND_EXTENSIONS_INCLUDE_DIR}) + + list(APPEND platform_INCLUDES + ui_interfaces/wayland/WaylandWindowInterface.cpp + ui_interfaces/wayland/WaylandSurface.cpp + ui_interfaces/wayland/WaylandBuffer.cpp + ${WAYLAND_EXTENSIONS_INCLUDE_DIR}/xdg-shell-protocol.cpp + ) + set(_HAS_WAYLAND ON) + else() + message(STATUS "Wayland Extensions Header not found - not building Wayland support") + endif() else() - message(STATUS "Wayland Extensions Header not found - not building Wayland support") + message(STATUS "Wayland Client Header not found - not building Wayland support") endif() else() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9159a01..f440cfa 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -11,15 +11,13 @@ list(APPEND TestFiles audio/TestAudioWriter.cpp audio/TestMidiReader.cpp core/TestBinaryStream.cpp - core/TestTomlReader.cpp + core/TestTomlReader.cpp compiler/TestLexer.cpp - compiler/TestTemplatingEngine.cpp + compiler/TestTemplatingEngine.cpp compression/TestStreamCompressor.cpp database/TestDatabase.cpp fonts/TestFontReader.cpp - graphics/TestOpenGlRendering.cpp graphics/TestRasterizer.cpp - ipc/TestDbus.cpp image/TestPngReader.cpp image/TestPngWriter.cpp network/TestNetworkManagerClient.cpp @@ -30,20 +28,33 @@ list(APPEND TestFiles if (${HAS_FFMPEG}) list(APPEND TestFiles - video/TestVideoDecoder.cpp + video/TestVideoDecoder.cpp ) endif() if (${HAS_WAYLAND}) list(APPEND TestFiles - windows/TestWaylandWindow.cpp - ) + windows/TestWaylandWindow.cpp + ) endif() +find_package(OpenGL QUIET) +if (OpenGL_FOUND) +list(APPEND TestFiles + graphics/TestOpenGlRendering.cpp + ) +endif() + + find_package(PkgConfig) pkg_check_modules(DBUS dbus-1) -include_directories(${DBUS_INCLUDE_DIRS}) -link_directories(${DBUS_LIBRARY_DIRS}) +if (DBUS_FOUND) + include_directories(${DBUS_INCLUDE_DIRS}) + link_directories(${DBUS_LIBRARY_DIRS}) + list(APPEND TestFiles + ipc/TestDbus.cpp + ) +endif() foreach(TestFile ${TestFiles}) cmake_path(GET TestFile FILENAME TestFileName)