Fixing up Windows build.

This commit is contained in:
jamgroga 2021-09-26 21:42:35 +01:00
parent 32ace0fcac
commit 5d32592126
22 changed files with 247994 additions and 53 deletions

View file

@ -11,8 +11,6 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
find_package(SQLite3)
add_subdirectory(src)
add_subdirectory(apps)
add_subdirectory(test)

View file

@ -1,11 +1,16 @@
#include "AudioManager.h"
#ifdef __linux__
#include "AlsaInterface.h"
#endif
AudioManager::AudioManager()
: mAudioDevices(),
mAudioInterface()
{
#ifdef __linux__
mAudioInterface = AlsaInterface::Create();
#endif
}
AudioManager::~AudioManager()
@ -28,7 +33,7 @@ IAudioInterface* AudioManager::GetAudioInterface()
return mAudioInterface.get();
}
unsigned AudioManager::GetNumAudioDevices() const
std::size_t AudioManager::GetNumAudioDevices() const
{
return mAudioDevices.size();
}

View file

@ -19,7 +19,7 @@ public:
void AddAudioDevice(AudioDevicePtr device);
unsigned GetNumAudioDevices() const;
std::size_t GetNumAudioDevices() const;
AudioDevice* GetAudioDevice(unsigned idx) const;

View file

@ -1,4 +1,6 @@
#include "AudioSynth.h"
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <limits>
#include <iostream>

View file

@ -1,10 +1,20 @@
set(platform_HEADERS "")
set(platform_INCLUDES "")
if (UNIX)
find_package(ALSA REQUIRED)
list(APPEND linux_HEADERS
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}
)
endif (UNIX)
list(APPEND audio_HEADERS
AudioDevice.h
@ -20,11 +30,8 @@ list(APPEND audio_HEADERS
midi/MidiElements.h
midi/MidiEvent.h
midi/MetaMidiEvent.h
midi/MidiChannelEvent.h)
list(APPEND linux_INCLUDES
audio_interfaces/AlsaInterface.cpp
)
midi/MidiChannelEvent.h
${platform_HEADERS})
list(APPEND audio_LIB_INCLUDES
AudioDevice.cpp
@ -41,9 +48,10 @@ list(APPEND audio_LIB_INCLUDES
midi/MidiDocument.cpp
midi/MidiEvent.cpp
midi/MetaMidiEvent.cpp
midi/MidiChannelEvent.cpp)
midi/MidiChannelEvent.cpp
${platform_INCLUDES})
add_library(audio SHARED ${audio_LIB_INCLUDES} ${linux_INCLUDES} ${audio_HEADERS} ${linux_HEADERS})
add_library(audio SHARED ${audio_LIB_INCLUDES} ${platform_INCLUDES} ${audio_HEADERS} ${platform_HEADERS})
target_include_directories(audio PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/src/core/file_utilities"
@ -52,11 +60,7 @@ target_include_directories(audio PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/midi"
"${CMAKE_CURRENT_SOURCE_DIR}/midi/reader"
)
list(APPEND linux_LIBS
${ALSA_LIBRARIES}
)
target_link_libraries(audio PUBLIC core ${linux_LIBS})
target_link_libraries(audio PUBLIC core ${platform_LIBS})
set_target_properties( audio PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
set_property(TARGET audio PROPERTY FOLDER src)

View file

@ -2,6 +2,7 @@
#include "Widget.h"
#include "StackWidget.h"
#include <string>
class TabbedPanelWidget : public Widget
{

View file

@ -17,7 +17,6 @@ target_include_directories(console PUBLIC
"${PROJECT_SOURCE_DIR}/src/audio/audio_interfaces"
"${PROJECT_SOURCE_DIR}/src/graphics"
"${PROJECT_SOURCE_DIR}/src/web"
"${SQLite3_INCLUDE_DIR}"
)
set_property(TARGET console PROPERTY FOLDER src)
target_link_libraries(console PUBLIC core audio network database web graphics)

View file

@ -1,6 +1,7 @@
#include "File.h"
#include "FileLogger.h"
#include <streambuf>
#include <fstream>
File::File(std::filesystem::path path)
: mFullPath(path),
@ -38,7 +39,7 @@ void File::Open(bool asBinary)
auto flags = std::ifstream::in;
if (asBinary)
{
flags |= std::ifstream::binary;
//flags |= std::ifstream::binary;
}
mInHandle = std::make_unique<std::ifstream>();
mInHandle->open(mFullPath, flags);
@ -48,7 +49,7 @@ void File::Open(bool asBinary)
auto flags = std::ofstream::out;
if (asBinary)
{
flags |= std::ofstream::binary;
//flags |= std::ofstream::binary;
}
mOutHandle = std::make_unique<std::ofstream>();
mOutHandle->open(mFullPath, flags);

View file

@ -1,7 +1,11 @@
set(SQLite3_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/src/third_party/sqlite3")
set(SQLite3_SOURCE_FILE "${CMAKE_SOURCE_DIR}/src/third_party/sqlite3/sqlite3.c")
list(APPEND database_LIB_INCLUDES
Database.cpp
DatabaseManager.cpp
database_interfaces/SqliteInterface.cpp)
database_interfaces/SqliteInterface.cpp
${SQLite3_SOURCE_FILE})
add_library(database SHARED ${database_LIB_INCLUDES})
@ -11,6 +15,4 @@ target_include_directories(database PUBLIC
"${SQLite3_INCLUDE_DIR}"
)
set_property(TARGET database PROPERTY FOLDER src)
set_target_properties( database PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
target_link_libraries(database PUBLIC ${SQLite3_LIBRARIES})
set_target_properties( database PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )

View file

@ -1,18 +1,9 @@
list(APPEND graphics_LIB_INCLUDES
DrawingContext.cpp
DrawingManager.cpp
DrawingSurface.cpp
opengl/OpenGlInterface.cpp
cairo/CairoInterface.cpp
cairo/CairoDrawingSurface.cpp
cairo/CairoDrawingContext.cpp)
list(APPEND graphics_HEADERS
opengl/OpenGlInterface.h
cairo/CairoInterface.h
INativeDrawingSurface.h
INativeDrawingContext.h)
set(platform_LIB_INCLUDES "")
set(platform_INCLUDE_DIRS "")
set(platform_HEADERS "")
set(platform_LIBS "")
if (UNIX)
find_package(PkgConfig)
PKG_CHECK_MODULES(PC_CAIRO cairo)
FIND_PATH(CAIRO_INCLUDE_DIRS
@ -27,13 +18,48 @@ FIND_LIBRARY(CAIRO_LIBRARIES
HINTS ${PC_CAIRO_LIBDIR}
${PC_CAIRO_LIBRARY_DIRS}
)
list(APPEND platform_LIB_INCLUDES
cairo/CairoInterface.cpp
cairo/CairoDrawingSurface.cpp
cairo/CairoDrawingContext.cpp
)
list(APPEND platform_INCLUDE_DIRS
${CAIRO_INCLUDE_DIRS}
)
list(APPEND platform_HEADERS
cairo/CairoInterface.h
)
list(APPEND platform_LIBS
${CAIRO_LIBRARIES}
GL
)
else()
list(APPEND platform_LIBS
OpenGL32.lib
)
endif()
list(APPEND graphics_LIB_INCLUDES
DrawingContext.cpp
DrawingManager.cpp
DrawingSurface.cpp
opengl/OpenGlInterface.cpp
${platform_LIB_INCLUDES}
)
list(APPEND graphics_HEADERS
opengl/OpenGlInterface.h
${platform_HEADERS}
INativeDrawingSurface.h
INativeDrawingContext.h)
add_library(graphics SHARED
${graphics_LIB_INCLUDES}
${graphics_HEADERS})
target_include_directories(graphics PUBLIC
${CAIRO_INCLUDE_DIRS}
${platform_INCLUDE_DIRS}
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/cairo"
"${CMAKE_CURRENT_SOURCE_DIR}/opengl"
@ -41,6 +67,7 @@ target_include_directories(graphics PUBLIC
"${PROJECT_SOURCE_DIR}/src/visual_elements/"
)
target_link_libraries(graphics PUBLIC visual_elements GL ${CAIRO_LIBRARIES})
target_link_libraries(graphics PUBLIC visual_elements ${platform_LIBS})
set_property(TARGET graphics PROPERTY FOLDER src)
set_property(TARGET graphics PROPERTY FOLDER src)
set_target_properties( graphics PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )

View file

@ -3,11 +3,15 @@
#include "INativeDrawingContext.h"
#include "DrawingSurface.h"
#include "DrawingContext.h"
#ifdef __linux__
#include "CairoInterface.h"
#endif
DrawingManager::DrawingManager()
{
#ifdef __linux__
mCairoInterface = CairoInterface::Create();
#endif
}
std::unique_ptr<DrawingManager> DrawingManager::Create()
@ -19,21 +23,23 @@ void DrawingManager::InitalizeSurface(unsigned width, unsigned height)
{
mDrawingSurface = DrawingSurface::Create();
mDrawingSurface->SetSize(width, height);
#ifdef __linux__
if (mCairoInterface)
{
mCairoInterface->InitializeSurface(mDrawingSurface.get());
}
#endif
}
void DrawingManager::InitializeContext()
{
mDrawingContext = DrawingContext::Create();
#ifdef __linux__
if (mCairoInterface && mDrawingSurface)
{
mCairoInterface->InitializeContext(mDrawingContext.get(), mDrawingSurface.get());
}
#endif
}
void DrawingManager::AddText(TextElement* text)
@ -47,17 +53,20 @@ void DrawingManager::AddText(TextElement* text)
{
return;
}
#ifdef __linux__
if (mCairoInterface)
{
mCairoInterface->AddText(text, mDrawingContext.get());
}
#endif
}
void DrawingManager::RenderToFile(const std::string& path)
{
#ifdef __linux__
if (mDrawingSurface && mCairoInterface)
{
mCairoInterface->RenderToFile(mDrawingSurface.get(), path);
}
#endif
}

View file

@ -1,9 +1,12 @@
#pragma once
#include <memory>
#include <string>
#include "INativeDrawingContext.h"
#include "INativeDrawingSurface.h"
#ifdef __linux__
#include "CairoInterface.h"
#endif
class TextElement;
@ -25,7 +28,9 @@ public:
private:
DrawingSurfacePtr mDrawingSurface {nullptr};
DrawingContextPtr mDrawingContext {nullptr};
#ifdef __linux__
CairoInterfacePtr mCairoInterface {nullptr};
#endif
};
using DrawingManagerPtr = std::unique_ptr<DrawingManager>;

View file

@ -1,4 +1,7 @@
#include "OpenGlInterface.h"
#ifdef _WIN32
#include <windows.h>
#endif
#include <GL/gl.h>

View file

@ -1,5 +1,8 @@
list(APPEND linux_INCLUDES
set(platform_INCLUDES)
if(UNIX)
list(APPEND platform_INCLUDES
sockets/UnixSocketInterface.cpp)
endif()
list(APPEND network_HEADERS
NetworkManager.h
@ -12,7 +15,7 @@ list(APPEND network_LIB_INCLUDES
sockets/Socket.cpp
)
add_library(network SHARED ${network_LIB_INCLUDES} ${linux_INCLUDES} ${network_HEADERS})
add_library(network SHARED ${network_LIB_INCLUDES} ${platform_INCLUDES} ${network_HEADERS})
target_include_directories(network PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"

View file

@ -22,7 +22,9 @@ std::unique_ptr<NetworkManager> NetworkManager::Create()
void NetworkManager::Initialize()
{
#ifdef __linux__
mSocketInterface = UnixSocketInterface::Create();
#endif
}
void NetworkManager::RunHttpServer()

235517
src/third_party/sqlite3/sqlite3.c vendored Normal file

File diff suppressed because it is too large Load diff

12353
src/third_party/sqlite3/sqlite3.h vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -9,6 +9,7 @@
#include "Color.h"
#include <algorithm>
#include <iterator>
Widget::Widget()
: mLocation(DiscretePoint(0, 0)),

View file

@ -17,7 +17,7 @@ XmlParser::XmlParser()
void XmlParser::ProcessLine(const std::string& input)
{
for(std::size_t idx; idx<input.size(); idx++)
for(std::size_t idx=0; idx<input.size(); idx++)
{
switch (input[idx])
{

View file

@ -28,7 +28,7 @@ void XmlProlog::SetEncoding(const std::string& encoding)
{
if(encoding == "UTF-8")
{
mEncoding == XmlProlog::Encoding::UTF8;
mEncoding = XmlProlog::Encoding::UTF8;
}
}
@ -36,7 +36,7 @@ void XmlProlog::SetVersion(const std::string& version)
{
if(version == "1.0")
{
mVersion == XmlProlog::Version::V1_0;
mVersion = XmlProlog::Version::V1_0;
}
}

View file

@ -1,4 +1,8 @@
list(APPEND linux_INCLUDES
set (platform_INCLUDES "")
set (platform_LIBS "")
if(UNIX)
list(APPEND platform_INCLUDES
ui_interfaces/x11/XcbInterface.cpp
ui_interfaces/x11/XcbEventInterface.cpp
ui_interfaces/x11/XcbWindow.cpp
@ -8,6 +12,10 @@ list(APPEND linux_INCLUDES
ui_interfaces/x11/XcbTextInterface.cpp
ui_interfaces/x11/XcbKeyboard.cpp
ui_interfaces/x11/GlxInterface.cpp)
list(APPEND platform_LIBS
X11 X11-xcb xcb )
endif()
list(APPEND windows_LIB_INCLUDES
managers/WindowManager.cpp
@ -15,7 +23,7 @@ list(APPEND windows_LIB_INCLUDES
managers/EventManager.cpp)
# add the library
add_library(windows SHARED ${windows_LIB_INCLUDES} ${linux_INCLUDES})
add_library(windows SHARED ${windows_LIB_INCLUDES} ${platform_INCLUDES})
target_include_directories(windows PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"
@ -27,7 +35,7 @@ target_include_directories(windows PUBLIC
"${PROJECT_SOURCE_DIR}/src/ui_elements/widgets"
)
target_link_libraries(windows PUBLIC X11 X11-xcb xcb core geometry graphics ui_elements)
target_link_libraries(windows PUBLIC ${platform_LIBS} core geometry graphics ui_elements)
set_property(TARGET windows PROPERTY FOLDER src)
set_target_properties( windows PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )

View file

@ -3,6 +3,7 @@
#include "TestCase.h"
#include <vector>
#include <string>
class TestCaseRunner
{