initialized from cpp skeleton
This commit is contained in:
commit
8241aa3e04
7 changed files with 114 additions and 0 deletions
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles/
|
||||||
|
_deps/
|
||||||
|
*.a
|
||||||
|
*.o
|
||||||
|
Makefile
|
||||||
|
apps/cmake_install.cmake
|
||||||
|
cmake_install.cmake
|
||||||
|
src/cmake_install.cmake
|
||||||
|
.ninja_deps
|
||||||
|
.ninja_log
|
||||||
|
build.ninja
|
||||||
|
build
|
||||||
|
.cache
|
||||||
31
CMakeLists.txt
Normal file
31
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
# This is a template I intend to use to create C++ cmake projects going forwards
|
||||||
|
# the structure takes heavily after https://cliutils.gitlab.io/modern-cmake/chapters/basics/structure.html
|
||||||
|
# This file takes heavily from https://gitlab.com/CLIUtils/modern-cmake/-/blob/master/examples/extended-project/CMakeLists.txt
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 4.1.2)
|
||||||
|
|
||||||
|
project(project_name_here
|
||||||
|
VERSION 0.1
|
||||||
|
LANGUAGES CXX)
|
||||||
|
|
||||||
|
# setting this so compile_commands.json is generated for clangd
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
||||||
|
|
||||||
|
# allowances for debugging
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-Og")
|
||||||
|
|
||||||
|
# release optimizations
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||||
|
|
||||||
|
# generally useful
|
||||||
|
set(CMAKE_CXX_FLAGS "-Wall -pedantic -Wextra -Wfloat-equal -Wundef -Wpointer-arith -Wcast-align -Wstrict-overflow=2 -Wunreachable-code -fsanitize=address,undefined -g3")
|
||||||
|
# for convenience if they're needed
|
||||||
|
#find_package(Boost REQUIRED)
|
||||||
|
#find_package(fmt REQUIRED)
|
||||||
|
|
||||||
|
# lib src code
|
||||||
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
# app source code
|
||||||
|
add_subdirectory(apps)
|
||||||
|
|
||||||
37
CMakePresets.json
Normal file
37
CMakePresets.json
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"version":10,
|
||||||
|
"cmakeMinimumRequired":{
|
||||||
|
"major": 4,
|
||||||
|
"minor": 1,
|
||||||
|
"patch": 2
|
||||||
|
},
|
||||||
|
"configurePresets":[{
|
||||||
|
"name":"default",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"binaryDir": "./build",
|
||||||
|
"$comment":{"graphviz": "dependencies"}
|
||||||
|
}],
|
||||||
|
"buildPresets":[{
|
||||||
|
"name": "default",
|
||||||
|
"configurePreset":"default",
|
||||||
|
"jobs": 4
|
||||||
|
}],
|
||||||
|
"testPresets":[],
|
||||||
|
"workflowPresets":[
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"steps": [
|
||||||
|
{"type":"configure", "name":"default"},
|
||||||
|
{"type":"build", "name":"default"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default-test",
|
||||||
|
"$comment":"TODO: add test when we add a test setup here",
|
||||||
|
"steps": [
|
||||||
|
{"type":"configure", "name":"default"},
|
||||||
|
{"type":"build", "name":"default"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
8
apps/CMakeLists.txt
Normal file
8
apps/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# based heavily on https://gitlab.com/CLIUtils/modern-cmake/-/blob/master/examples/extended-project/apps/CMakeLists.txt
|
||||||
|
|
||||||
|
add_executable(exe_name exe_entry.cpp)
|
||||||
|
|
||||||
|
# example library link
|
||||||
|
#target_link_libraries(exe_name fmt::fmt)
|
||||||
|
|
||||||
|
target_compile_features(exe_name PRIVATE cxx_std_20)
|
||||||
4
apps/exe_entry.cpp
Normal file
4
apps/exe_entry.cpp
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
int main(void){
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
20
src/CMakeLists.txt
Normal file
20
src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# based heavily on https://gitlab.com/CLIUtils/modern-cmake/-/blob/master/examples/extended-project/src/CMakeLists.txt
|
||||||
|
|
||||||
|
# example from when I was doing raft cpp impl
|
||||||
|
#set(HEADER_LIST "${raft_cpp_impl_SOURCE_DIR}/include/raft/lib.hpp")
|
||||||
|
|
||||||
|
add_library(example_lib lib.cpp ${HEADER_LIST})
|
||||||
|
|
||||||
|
# We need this directory, and users of our library will need it too
|
||||||
|
target_include_directories(example_lib PUBLIC ../include)
|
||||||
|
|
||||||
|
|
||||||
|
#target_link_libraries(example_lib PRIVATE Boost::boost)
|
||||||
|
|
||||||
|
target_compile_features(example_lib PUBLIC cxx_std_17)
|
||||||
|
|
||||||
|
# IDEs should put the headers in a nice place
|
||||||
|
source_group(
|
||||||
|
TREE "${PROJECT_SOURCE_DIR}/include"
|
||||||
|
PREFIX "Header Files"
|
||||||
|
FILES ${HEADER_LIST})
|
||||||
0
src/lib.cpp
Normal file
0
src/lib.cpp
Normal file
Loading…
Reference in a new issue