Change to CMake base
Signed-off-by: Tiago Garcia <tiago.rgarcia@ua.pt>
This commit is contained in:
parent
57c4109e19
commit
f6fcfdc03f
|
@ -1,2 +1,57 @@
|
|||
bin/
|
||||
# CMake build directories
|
||||
/build*/
|
||||
/CMakeFiles/
|
||||
/CMakeCache.txt
|
||||
/cmake_install.cmake
|
||||
/*.cmake
|
||||
/*.cbp
|
||||
/*.layout
|
||||
/*.stackdump
|
||||
/CPackConfig.cmake
|
||||
/Makefile
|
||||
/CTestTestfile.cmake
|
||||
|
||||
# Compiled binaries
|
||||
/bin/
|
||||
/lib/
|
||||
/*.so
|
||||
/*.dll
|
||||
/*.dylib
|
||||
|
||||
# Generated files
|
||||
/*.a
|
||||
/*.lib
|
||||
/*.exe
|
||||
/*.out
|
||||
/*.app
|
||||
|
||||
# Visual Studio Code specific
|
||||
/.vscode/
|
||||
|
||||
# Sublime Text specific
|
||||
/*.sublime-workspace
|
||||
|
||||
# macOS specific
|
||||
/.DS_Store
|
||||
|
||||
# JetBrains IDEs specific
|
||||
/.idea/
|
||||
/fleet/
|
||||
|
||||
# Emacs specific
|
||||
*~
|
||||
|
||||
# Vim specific
|
||||
*.swp
|
||||
|
||||
# Other editor and tool specific files
|
||||
*.bak
|
||||
*.orig
|
||||
*~
|
||||
|
||||
# Ignore all files in the root named test and tests
|
||||
/test
|
||||
/tests
|
||||
|
||||
# Configuration files
|
||||
config.json
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# Project name and version
|
||||
project(gh-wh-handler VERSION 0.1.0)
|
||||
|
||||
# Determine the architecture
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
|
||||
set(ARCH "x86_64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
|
||||
set(ARCH "aarch64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l")
|
||||
set(ARCH "armv7l")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686")
|
||||
set(ARCH "i686")
|
||||
else()
|
||||
set(ARCH "unknown")
|
||||
endif()
|
||||
|
||||
# Set the executable name
|
||||
set(EXECUTABLE_NAME "gh-wh-handler.${ARCH}")
|
||||
|
||||
# Set the C++ standard
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
# Set the output directory
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
||||
|
||||
# Add source files
|
||||
file(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||
|
||||
# Add the executable
|
||||
add_executable(${EXECUTABLE_NAME} ${SOURCES})
|
||||
|
||||
# Add compilation flags
|
||||
target_compile_options(${EXECUTABLE_NAME} PRIVATE -Wall -Werror)
|
||||
|
||||
# Set linker flags for static linking
|
||||
set_target_properties(${EXECUTABLE_NAME} PROPERTIES
|
||||
LINK_FLAGS "-static -static-libgcc -static-libstdc++"
|
||||
)
|
||||
|
7
Makefile
7
Makefile
|
@ -1,7 +0,0 @@
|
|||
.PHONY: static
|
||||
|
||||
static:
|
||||
@mkdir -p bin || exit
|
||||
@echo "Building static binary..."
|
||||
@g++ -Wall -Werror -static -static-libgcc -static-libstdc++ -std=c++23 src/*.cpp -o bin/gh_wh_handler || exit
|
||||
|
13
README.md
13
README.md
|
@ -12,7 +12,7 @@ Head over to the [Releases Page](https://github.com/TiagoRG/gh-wh-handler/releas
|
|||
|
||||
Run the application using your configuration file:
|
||||
```console
|
||||
/path/to/gh_wh_handler_<arch> /path/to/config.json
|
||||
/path/to/gh-wh-handler.<arch> /path/to/config.json
|
||||
```
|
||||
|
||||
You can see the config file format below.
|
||||
|
@ -24,17 +24,18 @@ Install the dependencies:
|
|||
- [CrowCpp](https://crowcpp.org/master/)
|
||||
- [nlohmann::json](https://github.com/nlohmann/json)
|
||||
|
||||
Compile the application:
|
||||
Build the application:
|
||||
```console
|
||||
make
|
||||
cmake -S . -B build
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
Run the application using your configuration file:
|
||||
```console
|
||||
bin/gh_wh_handler /path/to/config.json
|
||||
bin/gh-wh-handler.<arch> /path/to/config.json
|
||||
```
|
||||
|
||||
Note: default config file path is `/etc/gh_wh_handler/config.json`
|
||||
Note: default config file path is `/etc/gh-wh-handler/config.json`
|
||||
|
||||
## Config File
|
||||
|
||||
|
@ -65,4 +66,4 @@ The configuration file should be a JSON file with the following format:
|
|||
|
||||
## Endpoint
|
||||
|
||||
Currently, the only endpoint for the application is /update-files
|
||||
Currently, the only endpoint for the application is `/update-files`
|
||||
|
|
|
@ -18,7 +18,7 @@ int main(int argc, char **argv) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
std::string config_file_path = argc == 2 ? 1[argv] : "/etc/gh_wh_handler/config.json";
|
||||
std::string config_file_path = argc == 2 ? 1[argv] : "/etc/gh-wh-handler/config.json";
|
||||
|
||||
// Open config file, exit if it fails
|
||||
std::ifstream config_file(config_file_path);
|
||||
|
|
Loading…
Reference in New Issue