Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent initialize git submodules #8

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
IncludeBlocks: Regroup
IndentPPDirectives: AfterHash
IndentWidth: '2'
IndentWidth: '4'
NamespaceIndentation: All
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: 'true'
Expand Down
19 changes: 18 additions & 1 deletion .cmake-format
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ parse:
GITHUB_REPOSITORY: 1
GITLAB_REPOSITORY: 1
GIT_REPOSITORY: 1
GIT_SUBMODULES: 1
SVN_REPOSITORY: 1
SVN_REVISION: 1
SOURCE_DIR: 1
Expand Down Expand Up @@ -56,11 +57,15 @@ parse:
spelling: packageProject
kwargs:
NAME: 1
VERSION: 1
INCLUDE_DIR: 1
INCLUDE_DESTINATION: 1
INCLUDE_HEADER_PATTERN: 1
BINARY_DIR: 1
COMPATIBILITY: 1
DISABLE_VERSION_SUFFIX: 1
EXPORT_HEADER: 1
NAMESPACE: 1
VERSION: 1
VERSION_HEADER: 1
DEPENDENCIES: +
cpmusepackagelock:
Expand All @@ -72,3 +77,15 @@ parse:
cpmgetpackageversion:
pargs: 2
spelling: CPMGetPackageVersion
project_options:
pargs:
nargs: '*'
flags: [ENABLE_CACHE]
kwargs:
PREFIX: 1
dynamic_project_options:
pargs:
nargs: '*'
flags: [ENABLE_CACHE]
kwargs:
PREFIX: 1
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export CMAKE_EXPORT_COMPILE_COMMANDS=YES
export CTEST_OUTPUT_ON_FAILURE=YES

export CPM_USE_LOCAL_PACKAGES=YES
export CPM_SOURCE_CACHE=${PWD}/.cache/CPM
export CPM_SOURCE_CACHE=${HOME}/.cache/CPM

export LD_LIBRARY_PATH=${CMAKE_PREFIX_PATH}/lib
export BUILD_DIR=${PWD}/build
Expand Down
7 changes: 5 additions & 2 deletions CMakeDefaultPresets.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": 6,
"version": 7,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"minor": 27,
"patch": 0
},
"configurePresets": [
Expand Down Expand Up @@ -30,6 +30,9 @@
"warnings": {
"deprecated": true,
"uninitialized": false
},
"trace": {
"mode": "off"
}
}
],
Expand Down
25 changes: 15 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ include(GNUInstallDirs)

# ---- local Options ----

if(NOT PROJECT_IS_TOP_LEVEL)
message(WARNING "set(CMAKE_SKIP_INSTALL_RULES YES)")
option(CMAKE_SKIP_INSTALL_RULES "Whether to disable generation of installation rules" YES)
endif()
option(CMAKE_SKIP_INSTALL_RULES "Whether to disable generation of installation rules" NO)

# --- Import project options ----

Expand Down Expand Up @@ -68,12 +65,14 @@ include(DynamicProjectOptions)
# sets `project_warnings` uncomment the options to enable them:
# cmake-format: off
dynamic_project_options(
PREFIX ${PROJECT_NAME}
ENABLE_CACHE
# MSVC_WARNINGS "/permissive-" # Override the defaults for the MSVC warnings
# CLANG_WARNINGS "-Wall;-Wextra" # Override the defaults for the CLANG warnings
# GCC_WARNINGS "-Wextra" # Override the defaults for the GCC warnings
)
# cmake-format: on
target_compile_features(project_options INTERFACE cxx_std_${CMAKE_CXX_STANDARD})
target_compile_features(${PROJECT_NAME}_project_options INTERFACE cxx_std_${CMAKE_CXX_STANDARD})

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

Expand Down Expand Up @@ -106,12 +105,15 @@ target_link_libraries(${PROJECT_NAME} PRIVATE $<BUILD_INTERFACE:fmt::fmt-header-
# target_include_directories with the SYSTEM modifier will request the compiler to omit warnings
# from the provided paths, if the compiler supports that
target_include_directories(
${PROJECT_NAME} SYSTEM PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

if(CMAKE_SKIP_INSTALL_RULES OR CMAKE_BUILD_TYPE STREQUAL "Debug")
target_link_libraries(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:project_warnings project_options>)
target_link_libraries(
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_NAME}_project_warnings>
$<BUILD_INTERFACE:${PROJECT_NAME}_project_options>
)
return()
endif()

Expand All @@ -126,11 +128,14 @@ install(FILES test.cfg DESTINATION ${CMAKE_INSTALL_SYSCONFDIR})

packageProject(
NAME ${PROJECT_NAME}
VERSION ${PROJECT_VERSION} NAMESPACE ${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
NAMESPACE ${PROJECT_NAME}
BINARY_DIR ${PROJECT_BINARY_DIR}
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
INCLUDE_DESTINATION include/${PROJECT_NAME}
VERSION_HEADER ${VERSION_HEADER_LOCATION} DISABLE_VERSION_SUFFIX YES
VERSION_HEADER ${VERSION_HEADER_LOCATION}
EXPORT_HEADER ${PROJECT_NAME}/export.h
DISABLE_VERSION_SUFFIX YES
COMPATIBILITY SameMajorVersion
# TODO: DEPENDENCIES "fmt 10.0.0"
)
Expand Down
92 changes: 46 additions & 46 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
"include": [
"CMakeDefaultPresets.json"
],
"configurePresets": [
{
"name": "ninja-multi",
"inherits": "default",
"displayName": "Ninja Multi-Config",
"description": "Default build using Ninja Multi-Config generator",
"generator": "Ninja Multi-Config"
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
{
"name": "windows-only",
"inherits": "default",
"displayName": "Windows-only configuration",
"description": "This build is only available on Windows",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
}
],
"workflowPresets": [
{
"name": "default",
"steps": [
"include": [
"CMakeDefaultPresets.json"
],
"configurePresets": [
{
"type": "configure",
"name": "default"
"name": "ninja-multi",
"inherits": "default",
"displayName": "Ninja Multi-Config",
"description": "Default build using Ninja Multi-Config generator",
"generator": "Ninja Multi-Config"
},
{
"type": "build",
"name": "default"
},
{
"type": "build",
"name": "install"
},
"name": "windows-only",
"inherits": "default",
"displayName": "Windows-only configuration",
"description": "This build is only available on Windows",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
}
],
"workflowPresets": [
{
"type": "package",
"name": "default"
"name": "default",
"steps": [
{
"type": "configure",
"name": "default"
},
{
"type": "build",
"name": "default"
},
{
"type": "build",
"name": "install"
},
{
"type": "package",
"name": "default"
}
]
}
]
}
]
]
}
6 changes: 4 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ BUILD_DIR:=$(shell realpath $(CURDIR)/build)

.PHONY: setup all test gcov install lib_install test_install standalone documentation clean distclean check format
all: install
cd all && cmake --preset default --debug-find-pkg=greeter
#XXX cd all && cmake --preset default --debug-find-pkg=greeter
cd all && cmake --workflow --preset default

test: setup
Expand All @@ -29,7 +29,7 @@ check: setup
run-clang-tidy -extra-arg=-Wno-unknown-warning-option -p $(BUILD_DIR)/all source */source

setup:
cd all && cmake --preset default --log-level=TRACE --trace-expand --trace-source=CPM.cmake
cd all && cmake --preset default #XXX --log-level=TRACE --trace-expand --trace-source=CPM_0.38.2.cmake
#XXX perl -i.bak -p -e 's#-W[-\w]+(=\d)?\b##g;' \
#XXX -e 's#-I(${CPM_SOURCE_CACHE})#-isystem $$1#g;' $(BUILD_DIR)/all/compile_commands.json

Expand Down Expand Up @@ -64,5 +64,7 @@ distclean: #XXX clean

format: setup
cmake --build $(BUILD_DIR)/all --target $@
clang-format -i *.json */*.json
git-clang-format .

################################
5 changes: 5 additions & 0 deletions all/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ project(BuildAll LANGUAGES CXX)

# ---- local Options ----

option(CMAKE_SKIP_INSTALL_RULES "Whether to disable generation of installation rules" YES)
if(CMAKE_SKIP_INSTALL_RULES)
message(WARNING "CMAKE_SKIP_INSTALL_RULES=YES")
endif()

# Note: by default ENABLE_DEVELOPER_MODE is True. This means that all analysis (sanitizers, static
# analysis) is enabled and all warnings are treated as errors. if you want to switch this behavior,
# change TRUE to FALSE
Expand Down
Loading
Loading