Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
GordonSmith committed Mar 19, 2024
1 parent 88a9fa7 commit 4d12b19
Show file tree
Hide file tree
Showing 18 changed files with 2,441 additions and 210 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/build*
/.vscode
/cpm_modules
.DS_Store
/vcpkg_installed
.DS_Store
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg.git
75 changes: 10 additions & 65 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
cmake_minimum_required(VERSION 3.14...3.22)

# ---- Project ----
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(VCPKG_FILES_DIR "${CMAKE_BINARY_DIR}" CACHE STRING "Folder for vcpkg download, build and installed files")
set(CMAKE_TOOLCHAIN_FILE ${ROOT_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake)
set(VCPKG_ROOT ${ROOT_DIR}/vcpkg)
set(VCPKG_INSTALLED_DIR "${VCPKG_FILES_DIR}/vcpkg_installed")
set(VCPKG_INSTALL_OPTIONS "--x-abi-tools-use-exact-versions;--downloads-root=${VCPKG_FILES_DIR}/vcpkg_downloads;--x-buildtrees-root=${VCPKG_FILES_DIR}/vcpkg_buildtrees;--x-packages-root=${VCPKG_FILES_DIR}/vcpkg_packages")
set(VCPKG_VERBOSE OFF)

# Note: update this to your new project's name and version
project(
Greeter
VERSION 1.0
LANGUAGES CXX
)
project(BuildAll LANGUAGES CXX)

# ---- Include guards ----

Expand All @@ -18,61 +19,5 @@ if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
)
endif()

# ---- Add dependencies via CPM ----
# see https://github.com/TheLartians/CPM.cmake for more info

include(cmake/CPM.cmake)

# PackageProject.cmake will be used to make our target installable
CPMAddPackage("gh:TheLartians/[email protected]")

CPMAddPackage(
NAME fmt
GIT_TAG 9.1.0
GITHUB_REPOSITORY fmtlib/fmt
OPTIONS "FMT_INSTALL YES" # create an installable target
)

# ---- Add source files ----

# Note: globbing sources is considered bad practice as CMake's generators may not detect new files
# automatically. Keep that in mind when changing files, or explicitly mention them here.
file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp")

# ---- Create library ----

# Note: for header-only libraries change all PUBLIC flags to INTERFACE and create an interface
# target: add_library(${PROJECT_NAME} INTERFACE)
add_library(${PROJECT_NAME} ${headers} ${sources})
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)

# being a cross-platform target, we enforce standards conformance on MSVC
target_compile_options(${PROJECT_NAME} PUBLIC "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->")

# Link dependencies
target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt)

target_include_directories(
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
)

# ---- Create an installable target ----
# this allows users to install and find the library via `find_package()`.

# the location where the project's version header will be placed should match the project's regular
# header paths
string(TOLOWER ${PROJECT_NAME}/version.h VERSION_HEADER_LOCATION)

packageProject(
NAME ${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
NAMESPACE ${PROJECT_NAME}
BINARY_DIR ${PROJECT_BINARY_DIR}
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
VERSION_HEADER "${VERSION_HEADER_LOCATION}"
COMPATIBILITY SameMajorVersion
DEPENDENCIES "fmt 9.1.0"
)
add_subdirectory(src)
add_subdirectory(test)
220 changes: 220 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 22,
"patch": 1
},
"configurePresets": [
{
"name": "default"
},
{
"name": "vcpkg",
"displayName": "vcpkg",
"toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
"binaryDir": "${sourceDir}/build",
"installDir": "${sourceDir}/build/stage",
"cacheVariables": {},
"hidden": true
},
{
"name": "ninja",
"generator": "Ninja",
"hidden": true
},
{
"name": "debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"hidden": true
},
{
"name": "release",
"binaryDir": "${sourceDir}/build/Release",
"installDir": "${sourceDir}/build/Release/stage",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
},
"hidden": true
},
{
"name": "relwithdebinfo",
"binaryDir": "${sourceDir}/build/RelWithDebInfo",
"installDir": "${sourceDir}/build/RelWithDebInfo/stage",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
},
"hidden": true
},
{
"name": "ubuntu",
"cacheVariables": {
"USE_OPTIONAL": "OFF",
"USE_CPPUNIT": "ON",
"INCLUDE_PLUGINS": "ON",
"SUPPRESS_V8EMBED": "ON",
"SUPPRESS_REMBED": "ON"
},
"hidden": true
},
{
"name": "windows",
"cacheVariables": {
"USE_OPTIONAL": "OFF",
"CLIENTTOOLS_ONLY": "ON",
"USE_AZURE": "OFF",
"USE_CASSANDRA": "OFF",
"USE_JAVA": "OFF",
"USE_OPENLDAP": "OFF"
},
"hidden": true
},
{
"name": "ubuntu-ninja",
"inherits": [
"vcpkg",
"ninja",
"ubuntu"
]
},
{
"name": "ubuntu-ninja-debug",
"inherits": [
"ubuntu-ninja",
"debug"
]
},
{
"name": "ubuntu-ninja-debug-minimal",
"inherits": [
"ubuntu-ninja",
"debug"
],
"cacheVariables": {
"USE_CPPUNIT": "OFF",
"INCLUDE_PLUGINS": "OFF"
}
},
{
"name": "ubuntu-ninja-release",
"inherits": [
"ubuntu-ninja",
"release"
]
},
{
"name": "ubuntu-ninja-relwithdebinfo",
"inherits": [
"ubuntu-ninja",
"relwithdebinfo"
]
},
{
"name": "VS-16",
"generator": "Visual Studio 16 2019",
"architecture": {
"strategy": "set",
"value": "x64"
},
"hidden": true
},
{
"name": "VS-17",
"generator": "Visual Studio 17 2022",
"architecture": {
"strategy": "set",
"value": "x64"
},
"toolset": {
"strategy": "set",
"value": "host=x64"
},
"hidden": true
},
{
"name": "vcpkg-VS-16",
"inherits": [
"vcpkg",
"windows",
"VS-16"
]
},
{
"name": "vcpkg-VS-17",
"inherits": [
"vcpkg",
"windows",
"VS-17"
]
}
],
"buildPresets": [
{
"name": "ninja-linux",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"hidden": true,
"nativeToolOptions": []
},
{
"name": "Ninja-Linux-Debug",
"inherits": "Ninja-Linux",
"configuration": "Debug"
},
{
"name": "Ninja-Linux-Release",
"inherits": "Ninja-Linux",
"configuration": "Release"
},
{
"name": "VS-16-Debug",
"configurePreset": "vcpkg-VS-16",
"configuration": "Debug",
"jobs": 0,
"nativeToolOptions": [
"-m"
]
},
{
"name": "VS-16-Release",
"configurePreset": "vcpkg-VS-16",
"configuration": "Release",
"jobs": 0,
"nativeToolOptions": [
"-m"
]
},
{
"name": "VS-17-Debug",
"configurePreset": "vcpkg-VS-17",
"configuration": "Debug",
"jobs": 0,
"nativeToolOptions": [
"-m"
]
},
{
"name": "VS-17-Release",
"configurePreset": "vcpkg-VS-17",
"configuration": "Release",
"jobs": 0,
"nativeToolOptions": [
"-m"
]
},
{
"name": "VS-17-RelWithDebInfo",
"configurePreset": "vcpkg-VS-17",
"configuration": "RelWithDebInfo",
"jobs": 0,
"nativeToolOptions": [
"-m"
]
}
]
}
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[![Actions Status](https://github.com/TheLartians/ModernCppStarter/workflows/MacOS/badge.svg)](https://github.com/TheLartians/ModernCppStarter/actions)
[![Actions Status](https://github.com/TheLartians/ModernCppStarter/workflows/Windows/badge.svg)](https://github.com/TheLartians/ModernCppStarter/actions)
[![Actions Status](https://github.com/TheLartians/ModernCppStarter/workflows/Ubuntu/badge.svg)](https://github.com/TheLartians/ModernCppStarter/actions)
[![Actions Status](https://github.com/TheLartians/ModernCppStarter/workflows/Style/badge.svg)](https://github.com/TheLartians/ModernCppStarter/actions)
[![Actions Status](https://github.com/TheLartians/ModernCppStarter/workflows/Install/badge.svg)](https://github.com/TheLartians/ModernCppStarter/actions)
[![codecov](https://codecov.io/gh/TheLartians/ModernCppStarter/branch/master/graph/badge.svg)](https://codecov.io/gh/TheLartians/ModernCppStarter)
[![Actions Status](https://github.com/GordonSmith/component-model-cpp/workflows/MacOS/badge.svg)](https://github.com/GordonSmith/component-model-cpp/actions)
[![Actions Status](https://github.com/GordonSmith/component-model-cpp/workflows/Windows/badge.svg)](https://github.com/GordonSmith/component-model-cpp/actions)
[![Actions Status](https://github.com/GordonSmith/component-model-cpp/workflows/Ubuntu/badge.svg)](https://github.com/GordonSmith/component-model-cpp/actions)
[![Actions Status](https://github.com/GordonSmith/component-model-cpp/workflows/Style/badge.svg)](https://github.com/GordonSmith/component-model-cpp/actions)
[![Actions Status](https://github.com/GordonSmith/component-model-cpp/workflows/Install/badge.svg)](https://github.com/GordonSmith/component-model-cpp/actions)
[![codecov](https://codecov.io/gh/GordonSmith/component-model-cpp/branch/master/graph/badge.svg)](https://codecov.io/gh/GordonSmith/component-model-cpp)

<p align="center">
<img src="https://repository-images.githubusercontent.com/254842585/4dfa7580-7ffb-11ea-99d0-46b8fe2f4170" height="175" width="auto" />
Expand Down Expand Up @@ -205,4 +205,4 @@ Perhaps the [MiniCppStarter](https://github.com/TheLartians/MiniCppStarter) is s

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=TheLartians/ModernCppStarter,cpp-best-practices/gui_starter_template,filipdutescu/modern-cpp-template&type=Date)](https://star-history.com/#TheLartians/ModernCppStarter&cpp-best-practices/gui_starter_template&filipdutescu/modern-cpp-template&Date)
[![Star History Chart](https://api.star-history.com/svg?repos=GordonSmith/component-model-cpp,cpp-best-practices/gui_starter_template,filipdutescu/modern-cpp-template&type=Date)](https://star-history.com/#GordonSmith/component-model-cpp&cpp-best-practices/gui_starter_template&filipdutescu/modern-cpp-template&Date)
24 changes: 0 additions & 24 deletions cmake/CPM.cmake

This file was deleted.

Loading

0 comments on commit 4d12b19

Please sign in to comment.