From 22f6b4acfe7bc77e5322550caccc9e37238fc063 Mon Sep 17 00:00:00 2001 From: illyum Date: Tue, 11 Mar 2025 12:29:20 -0600 Subject: [PATCH] Initial Commit --- .gitignore | 61 ++++++++++++++++++++++++++ CMakeLists.txt | 48 ++++++++++++++++++++ README.md | 38 ++++++++++++++++ src/interface/launchpad/CMakeLists.txt | 11 +++++ src/interface/launchpad/launchpad.cpp | 5 +++ src/interface/launchpad/launchpad.h | 7 +++ src/interface/net/CMakeLists.txt | 8 ++++ src/interface/net/interface.cpp | 5 +++ src/interface/net/interface.h | 7 +++ src/main/CMakeLists.txt | 12 +++++ src/main/main.cpp | 15 +++++++ 11 files changed, 217 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 src/interface/launchpad/CMakeLists.txt create mode 100644 src/interface/launchpad/launchpad.cpp create mode 100644 src/interface/launchpad/launchpad.h create mode 100644 src/interface/net/CMakeLists.txt create mode 100644 src/interface/net/interface.cpp create mode 100644 src/interface/net/interface.h create mode 100644 src/main/CMakeLists.txt create mode 100644 src/main/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..12619cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,61 @@ +# ========================= +# General Editor/IDE Files +# ========================= + +# Vim/Neovim +Session.vim + +# Visual Studio Code +.vscode/ +*.code-workspace + +# IntelliJ IDEA / JetBrains IDEs +.idea/ +out/ + +# Sublime Text +*.sublime-workspace +*.sublime-project +.sublime/ + +# Xcode +*.xcworkspace/ +*.xcuserstate +*.xcuserdatad/ +xcuserdata/ + +*.bak +*.old +*.tmp +*.temp +.DS_Store +Thumbs.db + +# ========== +# Toolchain +# ========== + +compile_commands.json +CMakeCache.txt +cmake/ +.cache/ + +# Remove this if you want to add third party dlls +*.so +*.dylib +*.dll +*.lai +*.la +*.a +*.lib + +**.exe +**.db +**.o +**.obj +**.d + +# ========= +# Binaries +# ========= +build/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1992d29 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 3.30.0 FATAL_ERROR) +project(LightShow VERSION 0.1.0 LANGUAGES CXX C) + +set(CMAKE_C_STANDARD 23) +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Change this to ON if you are using something like Fleet or Neovim +option(USE_COMPILE_COMMANDS "Enable compile_commands.json for LSPs" OFF) +set(CMAKE_EXPORT_COMPILE_COMMANDS ${USE_COMPILE_COMMANDS}) + +# Set different output directories for MSVC and MinGW +if (MSVC) + set(OUTPUT_BIN "${CMAKE_BINARY_DIR}/msvc/bin") + set(OUTPUT_LIB "${CMAKE_BINARY_DIR}/msvc/lib") +elseif (MINGW) + set(OUTPUT_BIN "${CMAKE_BINARY_DIR}/mingw/bin") + set(OUTPUT_LIB "${CMAKE_BINARY_DIR}/mingw/lib") +else() + set(OUTPUT_BIN "${CMAKE_BINARY_DIR}/bin") + set(OUTPUT_LIB "${CMAKE_BINARY_DIR}/lib") +endif() + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BIN}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_BIN}) # Shared libraries +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_LIB}) # Static libraries + +add_subdirectory(src/interface/launchpad) +add_subdirectory(src/interface/net) +add_subdirectory(src/main) + +# cmake --install +if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + message(FATAL_ERROR "You must specify an installation path using -DCMAKE_INSTALL_PREFIX=") +endif() + +install(TARGETS LightShow launchpad net-interface + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +install(FILES + src/interface/launchpad/launchpad.h + src/interface/net/interface.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/LightShow +) diff --git a/README.md b/README.md new file mode 100644 index 0000000..99a3eb8 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +## Building and Running from Source + +### **Prerequisites** +- Ensure you have **CMake (>=3.30)** +- Use a supported toolchain: **MinGW or MSVC** + +### **Steps to Build and Install** +#### **1. Generate Build Files** +Run CMake to configure the build system. **You must specify an install location**: +```sh +cmake -B build -DCMAKE_INSTALL_PREFIX=./cmake-install +``` + +- This creates a `build/` directory with the necessary build files. +- `./cmake-install/` will be the location where the files are installed, feel free to change this. + +#### **2. Build the Project** +```sh +cmake --build build +``` + +#### **2. Run the Install Command** +```sh +cmake --install build +``` + +### Running the program +After installation, you can run the executable from the `./cmake-install` directory: +```sh +./cmake-install/bin/LightShow +``` + + +NOTE: +If you want to use export compile commands you need to use +```sh +-DUSE_COMPILE_COMMANDS=ON +``` \ No newline at end of file diff --git a/src/interface/launchpad/CMakeLists.txt b/src/interface/launchpad/CMakeLists.txt new file mode 100644 index 0000000..60d8684 --- /dev/null +++ b/src/interface/launchpad/CMakeLists.txt @@ -0,0 +1,11 @@ +add_library(launchpad SHARED launchpad.cpp) + +target_include_directories(launchpad PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +set_target_properties(launchpad PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BIN} + ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_LIB} +) + +# Link against https://github.com/PortMidi/portmidi +# target_link_libraries(launchpad PRIVATE PortMidi::PortMidi) \ No newline at end of file diff --git a/src/interface/launchpad/launchpad.cpp b/src/interface/launchpad/launchpad.cpp new file mode 100644 index 0000000..43b07c0 --- /dev/null +++ b/src/interface/launchpad/launchpad.cpp @@ -0,0 +1,5 @@ +#include "launchpad.h" + +LPAPI void TestLaunchpad() { + return; +} \ No newline at end of file diff --git a/src/interface/launchpad/launchpad.h b/src/interface/launchpad/launchpad.h new file mode 100644 index 0000000..3dccf51 --- /dev/null +++ b/src/interface/launchpad/launchpad.h @@ -0,0 +1,7 @@ +#ifdef _WIN32 +#define LPAPI __declspec(dllexport) +#else +#define LPAPI +#endif + +LPAPI void TestLaunchpad(); \ No newline at end of file diff --git a/src/interface/net/CMakeLists.txt b/src/interface/net/CMakeLists.txt new file mode 100644 index 0000000..762d12b --- /dev/null +++ b/src/interface/net/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(net-interface SHARED interface.cpp) + +target_include_directories(net-interface PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +set_target_properties(net-interface PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BIN} + ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_LIB} +) diff --git a/src/interface/net/interface.cpp b/src/interface/net/interface.cpp new file mode 100644 index 0000000..a46923a --- /dev/null +++ b/src/interface/net/interface.cpp @@ -0,0 +1,5 @@ +#include "interface.h" + +NETAPI void TestInterface() { + return; +} \ No newline at end of file diff --git a/src/interface/net/interface.h b/src/interface/net/interface.h new file mode 100644 index 0000000..1cb5ec7 --- /dev/null +++ b/src/interface/net/interface.h @@ -0,0 +1,7 @@ +#ifdef _WIN32 +#define NETAPI __declspec(dllexport) +#else +#define NETAPI +#endif + +void TestInterface(); \ No newline at end of file diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt new file mode 100644 index 0000000..b0f82b2 --- /dev/null +++ b/src/main/CMakeLists.txt @@ -0,0 +1,12 @@ +add_executable(LightShow main.cpp) + +target_link_libraries(LightShow PRIVATE launchpad net-interface) + +target_include_directories(LightShow PRIVATE + ${CMAKE_SOURCE_DIR}/src/interface/launchpad + ${CMAKE_SOURCE_DIR}/src/interface/net +) + +set_target_properties(LightShow PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BIN} +) diff --git a/src/main/main.cpp b/src/main/main.cpp new file mode 100644 index 0000000..b12366a --- /dev/null +++ b/src/main/main.cpp @@ -0,0 +1,15 @@ +#include "launchpad.h" +#include "interface.h" +#include + +int main() { + std::cout << "Calling TestLaunchpad()..." << std::endl; + TestLaunchpad(); + std::cout << "TestLaunchpad() executed successfully." << std::endl; + + std::cout << "Calling TestInterface()..." << std::endl; + TestInterface(); + std::cout << "TestInterface() executed successfully." << std::endl; + + return 0; +}