create new project
This commit is contained in:
parent
520b57fe78
commit
fd5958887c
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build/
|
13
CMakeLists.txt
Normal file
13
CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project(nf7 C CXX)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
include(cmake/git_hash.cmake)
|
||||
|
||||
add_subdirectory(iface)
|
||||
add_subdirectory(core)
|
||||
|
||||
add_executable(nf7)
|
||||
target_sources(nf7 PRIVATE main.cc)
|
||||
target_link_libraries(nf7 PRIVATE nf7_iface nf7_core)
|
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@ -0,0 +1,10 @@
|
||||
FROM alpine:3.14
|
||||
|
||||
RUN apk add --no-cache \
|
||||
cmake \
|
||||
gdb \
|
||||
git \
|
||||
g++ \
|
||||
make
|
||||
|
||||
WORKDIR /repo
|
19
cmake/git_hash.cmake
Normal file
19
cmake/git_hash.cmake
Normal file
@ -0,0 +1,19 @@
|
||||
set(dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
set(out "${dir}/git_hash.hh")
|
||||
|
||||
find_program(SH sh REQUIRED)
|
||||
|
||||
make_directory("${dir}")
|
||||
add_custom_command(
|
||||
COMMAND ${SH} -c "echo constexpr const char\* GIT_HASH = \\\"`git rev-parse --short HEAD``git diff --quiet && echo \\\*`\\\"\\; > ${out}"
|
||||
OUTPUT "${out}"
|
||||
DEPENDS "${PROJECT_SOURCE_DIR}/.git/HEAD"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_library(git_hash INTERFACE)
|
||||
target_sources(git_hash PUBLIC "${out}")
|
||||
target_include_directories(git_hash INTERFACE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
unset(out)
|
||||
unset(dir)
|
9
core/CMakeLists.txt
Normal file
9
core/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
add_library(nf7_core)
|
||||
target_link_libraries(nf7_core PRIVATE git_hash nf7_iface)
|
||||
|
||||
target_sources(nf7_core
|
||||
PRIVATE
|
||||
version.cc
|
||||
PUBLIC
|
||||
version.hh
|
||||
)
|
10
core/version.cc
Normal file
10
core/version.cc
Normal file
@ -0,0 +1,10 @@
|
||||
// No copyright
|
||||
#include "core/version.hh"
|
||||
|
||||
#include "generated/git_hash.hh"
|
||||
|
||||
namespace nf7::core {
|
||||
|
||||
const char* version() noexcept { return GIT_HASH; }
|
||||
|
||||
} // namespace nf7::core
|
8
core/version.hh
Normal file
8
core/version.hh
Normal file
@ -0,0 +1,8 @@
|
||||
// No copyright
|
||||
#pragma once
|
||||
|
||||
namespace nf7::core {
|
||||
|
||||
const char* version() noexcept;
|
||||
|
||||
} // namespace nf7::core
|
7
docker-compose.yml
Normal file
7
docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
dev:
|
||||
build: .
|
||||
volumes:
|
||||
- ./:/repo/
|
10
iface/CMakeLists.txt
Normal file
10
iface/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
add_library(nf7_iface)
|
||||
target_include_directories(nf7_iface PUBLIC ${PROJECT_SOURCE_DIR})
|
||||
target_link_libraries(nf7_iface PRIVATE git_hash)
|
||||
|
||||
target_sources(nf7_iface
|
||||
PRIVATE
|
||||
version.cc
|
||||
PUBLIC
|
||||
version.hh
|
||||
)
|
13
iface/version.cc
Normal file
13
iface/version.cc
Normal file
@ -0,0 +1,13 @@
|
||||
// No copyright
|
||||
#include "iface/version.hh"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "generated/git_hash.hh"
|
||||
|
||||
|
||||
namespace nf7::iface {
|
||||
|
||||
const char* version() noexcept { return GIT_HASH; }
|
||||
|
||||
} // namespace nf7::iface
|
8
iface/version.hh
Normal file
8
iface/version.hh
Normal file
@ -0,0 +1,8 @@
|
||||
// No copyright
|
||||
#pragma once
|
||||
|
||||
namespace nf7::iface {
|
||||
|
||||
const char* version() noexcept;
|
||||
|
||||
} // namespace nf7::iface
|
Loading…
x
Reference in New Issue
Block a user