Initial Commit

This commit is contained in:
illyum 2025-03-11 12:29:20 -06:00
commit 22f6b4acfe
11 changed files with 217 additions and 0 deletions

61
.gitignore vendored Normal file
View File

@ -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/

48
CMakeLists.txt Normal file
View File

@ -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=<path>")
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
)

38
README.md Normal file
View File

@ -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
```

View File

@ -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)

View File

@ -0,0 +1,5 @@
#include "launchpad.h"
LPAPI void TestLaunchpad() {
return;
}

View File

@ -0,0 +1,7 @@
#ifdef _WIN32
#define LPAPI __declspec(dllexport)
#else
#define LPAPI
#endif
LPAPI void TestLaunchpad();

View File

@ -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}
)

View File

@ -0,0 +1,5 @@
#include "interface.h"
NETAPI void TestInterface() {
return;
}

View File

@ -0,0 +1,7 @@
#ifdef _WIN32
#define NETAPI __declspec(dllexport)
#else
#define NETAPI
#endif
void TestInterface();

12
src/main/CMakeLists.txt Normal file
View File

@ -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}
)

15
src/main/main.cpp Normal file
View File

@ -0,0 +1,15 @@
#include "launchpad.h"
#include "interface.h"
#include <iostream>
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;
}