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_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
find_package(SQLite3)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(apps) add_subdirectory(apps)
add_subdirectory(test) add_subdirectory(test)

View file

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

View file

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

View file

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

View file

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

View file

@ -2,6 +2,7 @@
#include "Widget.h" #include "Widget.h"
#include "StackWidget.h" #include "StackWidget.h"
#include <string>
class TabbedPanelWidget : public Widget 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/audio/audio_interfaces"
"${PROJECT_SOURCE_DIR}/src/graphics" "${PROJECT_SOURCE_DIR}/src/graphics"
"${PROJECT_SOURCE_DIR}/src/web" "${PROJECT_SOURCE_DIR}/src/web"
"${SQLite3_INCLUDE_DIR}"
) )
set_property(TARGET console PROPERTY FOLDER src) set_property(TARGET console PROPERTY FOLDER src)
target_link_libraries(console PUBLIC core audio network database web graphics) target_link_libraries(console PUBLIC core audio network database web graphics)

View file

@ -1,6 +1,7 @@
#include "File.h" #include "File.h"
#include "FileLogger.h" #include "FileLogger.h"
#include <streambuf> #include <streambuf>
#include <fstream>
File::File(std::filesystem::path path) File::File(std::filesystem::path path)
: mFullPath(path), : mFullPath(path),
@ -38,7 +39,7 @@ void File::Open(bool asBinary)
auto flags = std::ifstream::in; auto flags = std::ifstream::in;
if (asBinary) if (asBinary)
{ {
flags |= std::ifstream::binary; //flags |= std::ifstream::binary;
} }
mInHandle = std::make_unique<std::ifstream>(); mInHandle = std::make_unique<std::ifstream>();
mInHandle->open(mFullPath, flags); mInHandle->open(mFullPath, flags);
@ -48,7 +49,7 @@ void File::Open(bool asBinary)
auto flags = std::ofstream::out; auto flags = std::ofstream::out;
if (asBinary) if (asBinary)
{ {
flags |= std::ofstream::binary; //flags |= std::ofstream::binary;
} }
mOutHandle = std::make_unique<std::ofstream>(); mOutHandle = std::make_unique<std::ofstream>();
mOutHandle->open(mFullPath, flags); 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 list(APPEND database_LIB_INCLUDES
Database.cpp Database.cpp
DatabaseManager.cpp DatabaseManager.cpp
database_interfaces/SqliteInterface.cpp) database_interfaces/SqliteInterface.cpp
${SQLite3_SOURCE_FILE})
add_library(database SHARED ${database_LIB_INCLUDES}) add_library(database SHARED ${database_LIB_INCLUDES})
@ -11,6 +15,4 @@ target_include_directories(database PUBLIC
"${SQLite3_INCLUDE_DIR}" "${SQLite3_INCLUDE_DIR}"
) )
set_property(TARGET database PROPERTY FOLDER src) set_property(TARGET database PROPERTY FOLDER src)
set_target_properties( database PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON ) set_target_properties( database PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
target_link_libraries(database PUBLIC ${SQLite3_LIBRARIES})

View file

@ -1,18 +1,9 @@
list(APPEND graphics_LIB_INCLUDES set(platform_LIB_INCLUDES "")
DrawingContext.cpp set(platform_INCLUDE_DIRS "")
DrawingManager.cpp set(platform_HEADERS "")
DrawingSurface.cpp set(platform_LIBS "")
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)
if (UNIX)
find_package(PkgConfig) find_package(PkgConfig)
PKG_CHECK_MODULES(PC_CAIRO cairo) PKG_CHECK_MODULES(PC_CAIRO cairo)
FIND_PATH(CAIRO_INCLUDE_DIRS FIND_PATH(CAIRO_INCLUDE_DIRS
@ -27,13 +18,48 @@ FIND_LIBRARY(CAIRO_LIBRARIES
HINTS ${PC_CAIRO_LIBDIR} HINTS ${PC_CAIRO_LIBDIR}
${PC_CAIRO_LIBRARY_DIRS} ${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 add_library(graphics SHARED
${graphics_LIB_INCLUDES} ${graphics_LIB_INCLUDES}
${graphics_HEADERS}) ${graphics_HEADERS})
target_include_directories(graphics PUBLIC target_include_directories(graphics PUBLIC
${CAIRO_INCLUDE_DIRS} ${platform_INCLUDE_DIRS}
"${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/cairo" "${CMAKE_CURRENT_SOURCE_DIR}/cairo"
"${CMAKE_CURRENT_SOURCE_DIR}/opengl" "${CMAKE_CURRENT_SOURCE_DIR}/opengl"
@ -41,6 +67,7 @@ target_include_directories(graphics PUBLIC
"${PROJECT_SOURCE_DIR}/src/visual_elements/" "${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 "INativeDrawingContext.h"
#include "DrawingSurface.h" #include "DrawingSurface.h"
#include "DrawingContext.h" #include "DrawingContext.h"
#ifdef __linux__
#include "CairoInterface.h" #include "CairoInterface.h"
#endif
DrawingManager::DrawingManager() DrawingManager::DrawingManager()
{ {
#ifdef __linux__
mCairoInterface = CairoInterface::Create(); mCairoInterface = CairoInterface::Create();
#endif
} }
std::unique_ptr<DrawingManager> DrawingManager::Create() std::unique_ptr<DrawingManager> DrawingManager::Create()
@ -19,21 +23,23 @@ void DrawingManager::InitalizeSurface(unsigned width, unsigned height)
{ {
mDrawingSurface = DrawingSurface::Create(); mDrawingSurface = DrawingSurface::Create();
mDrawingSurface->SetSize(width, height); mDrawingSurface->SetSize(width, height);
#ifdef __linux__
if (mCairoInterface) if (mCairoInterface)
{ {
mCairoInterface->InitializeSurface(mDrawingSurface.get()); mCairoInterface->InitializeSurface(mDrawingSurface.get());
} }
#endif
} }
void DrawingManager::InitializeContext() void DrawingManager::InitializeContext()
{ {
mDrawingContext = DrawingContext::Create(); mDrawingContext = DrawingContext::Create();
#ifdef __linux__
if (mCairoInterface && mDrawingSurface) if (mCairoInterface && mDrawingSurface)
{ {
mCairoInterface->InitializeContext(mDrawingContext.get(), mDrawingSurface.get()); mCairoInterface->InitializeContext(mDrawingContext.get(), mDrawingSurface.get());
} }
#endif
} }
void DrawingManager::AddText(TextElement* text) void DrawingManager::AddText(TextElement* text)
@ -47,17 +53,20 @@ void DrawingManager::AddText(TextElement* text)
{ {
return; return;
} }
#ifdef __linux__
if (mCairoInterface) if (mCairoInterface)
{ {
mCairoInterface->AddText(text, mDrawingContext.get()); mCairoInterface->AddText(text, mDrawingContext.get());
} }
#endif
} }
void DrawingManager::RenderToFile(const std::string& path) void DrawingManager::RenderToFile(const std::string& path)
{ {
#ifdef __linux__
if (mDrawingSurface && mCairoInterface) if (mDrawingSurface && mCairoInterface)
{ {
mCairoInterface->RenderToFile(mDrawingSurface.get(), path); mCairoInterface->RenderToFile(mDrawingSurface.get(), path);
} }
#endif
} }

View file

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

View file

@ -1,4 +1,7 @@
#include "OpenGlInterface.h" #include "OpenGlInterface.h"
#ifdef _WIN32
#include <windows.h>
#endif
#include <GL/gl.h> #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) sockets/UnixSocketInterface.cpp)
endif()
list(APPEND network_HEADERS list(APPEND network_HEADERS
NetworkManager.h NetworkManager.h
@ -12,7 +15,7 @@ list(APPEND network_LIB_INCLUDES
sockets/Socket.cpp 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 target_include_directories(network PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}"

View file

@ -22,7 +22,9 @@ std::unique_ptr<NetworkManager> NetworkManager::Create()
void NetworkManager::Initialize() void NetworkManager::Initialize()
{ {
#ifdef __linux__
mSocketInterface = UnixSocketInterface::Create(); mSocketInterface = UnixSocketInterface::Create();
#endif
} }
void NetworkManager::RunHttpServer() 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 "Color.h"
#include <algorithm> #include <algorithm>
#include <iterator>
Widget::Widget() Widget::Widget()
: mLocation(DiscretePoint(0, 0)), : mLocation(DiscretePoint(0, 0)),

View file

@ -17,7 +17,7 @@ XmlParser::XmlParser()
void XmlParser::ProcessLine(const std::string& input) 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]) switch (input[idx])
{ {

View file

@ -28,7 +28,7 @@ void XmlProlog::SetEncoding(const std::string& encoding)
{ {
if(encoding == "UTF-8") 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") 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/XcbInterface.cpp
ui_interfaces/x11/XcbEventInterface.cpp ui_interfaces/x11/XcbEventInterface.cpp
ui_interfaces/x11/XcbWindow.cpp ui_interfaces/x11/XcbWindow.cpp
@ -8,6 +12,10 @@ list(APPEND linux_INCLUDES
ui_interfaces/x11/XcbTextInterface.cpp ui_interfaces/x11/XcbTextInterface.cpp
ui_interfaces/x11/XcbKeyboard.cpp ui_interfaces/x11/XcbKeyboard.cpp
ui_interfaces/x11/GlxInterface.cpp) ui_interfaces/x11/GlxInterface.cpp)
list(APPEND platform_LIBS
X11 X11-xcb xcb )
endif()
list(APPEND windows_LIB_INCLUDES list(APPEND windows_LIB_INCLUDES
managers/WindowManager.cpp managers/WindowManager.cpp
@ -15,7 +23,7 @@ list(APPEND windows_LIB_INCLUDES
managers/EventManager.cpp) managers/EventManager.cpp)
# add the library # 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 target_include_directories(windows PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}"
@ -27,7 +35,7 @@ target_include_directories(windows PUBLIC
"${PROJECT_SOURCE_DIR}/src/ui_elements/widgets" "${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_property(TARGET windows PROPERTY FOLDER src)
set_target_properties( windows PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON ) set_target_properties( windows PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )

View file

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