style: reformatted to make the CMake scripts more compact
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
8fd7d8328a
commit
4aa9978dcd
6 changed files with 48 additions and 91 deletions
|
@ -3,12 +3,12 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
---
|
---
|
||||||
format:
|
format:
|
||||||
line_width: 120
|
line_width: 140
|
||||||
tab_size: 4
|
tab_size: 4
|
||||||
use_tabchars: true
|
use_tabchars: true
|
||||||
fractional_tab_policy: round-up
|
fractional_tab_policy: round-up
|
||||||
max_subgroups_hwrap: 2
|
max_subgroups_hwrap: 3
|
||||||
max_pargs_hwrap: 3
|
max_pargs_hwrap: 6
|
||||||
dangle_parens: true
|
dangle_parens: true
|
||||||
dangle_align: prefix
|
dangle_align: prefix
|
||||||
min_prefix_chars: 0
|
min_prefix_chars: 0
|
||||||
|
|
|
@ -8,18 +8,11 @@ include(cmake/version-from-git.cmake)
|
||||||
|
|
||||||
# ---- Project ----
|
# ---- Project ----
|
||||||
|
|
||||||
project(
|
project(Glimpses VERSION ${VERSION_STRING} LANGUAGES CXX)
|
||||||
Glimpses
|
|
||||||
VERSION ${VERSION_STRING}
|
|
||||||
LANGUAGES CXX
|
|
||||||
)
|
|
||||||
|
|
||||||
# ---- Include guards ----
|
# ---- Include guards ----
|
||||||
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
|
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
|
||||||
message(
|
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.")
|
||||||
FATAL_ERROR
|
|
||||||
"In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ---- Add dependencies via CPM ----
|
# ---- Add dependencies via CPM ----
|
||||||
|
@ -30,22 +23,11 @@ include(cmake/CPM.cmake)
|
||||||
# PackageProject.cmake will be used to make our target installable
|
# PackageProject.cmake will be used to make our target installable
|
||||||
CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.8.0")
|
CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.8.0")
|
||||||
|
|
||||||
# CPMAddPackage( NAME fmt GIT_TAG 9.1.0 GITHUB_REPOSITORY fmtlib/fmt OPTIONS "FMT_INSTALL YES" # create an installable
|
# CPMAddPackage( NAME fmt GIT_TAG 9.1.0 GITHUB_REPOSITORY fmtlib/fmt OPTIONS "FMT_INSTALL YES" # create an installable target )
|
||||||
# target )
|
|
||||||
|
|
||||||
# ---- Add source files ----
|
# ---- Add source files ----
|
||||||
file(
|
file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
|
||||||
GLOB_RECURSE
|
file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp")
|
||||||
headers
|
|
||||||
CONFIGURE_DEPENDS
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/*.h"
|
|
||||||
)
|
|
||||||
file(
|
|
||||||
GLOB_RECURSE
|
|
||||||
sources
|
|
||||||
CONFIGURE_DEPENDS
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp"
|
|
||||||
)
|
|
||||||
|
|
||||||
# ---- Create library ----
|
# ---- Create library ----
|
||||||
|
|
||||||
|
@ -60,8 +42,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE # fmt::fmt
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
|
||||||
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# the location where the project's version header will be placed should match the project's regular header paths
|
# the location where the project's version header will be placed should match the project's regular header paths
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
# this script adds all subprojects to a single build to allow IDEs understand the full project
|
# this script adds all subprojects to a single build to allow IDEs understand the full project structure.
|
||||||
# structure.
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.14...3.22)
|
cmake_minimum_required(VERSION 3.14...3.22)
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,8 @@ endif()
|
||||||
# Expand relative path. This is important if the provided path contains a tilde (~)
|
# Expand relative path. This is important if the provided path contains a tilde (~)
|
||||||
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
|
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
|
||||||
|
|
||||||
file(DOWNLOAD
|
file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ${CPM_DOWNLOAD_LOCATION}
|
||||||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
|
EXPECTED_HASH SHA256=${CPM_HASH_SUM}
|
||||||
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
include(${CPM_DOWNLOAD_LOCATION})
|
include(${CPM_DOWNLOAD_LOCATION})
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
# this file contains a list of tools that can be activated and downloaded on-demand each tool is
|
# this file contains a list of tools that can be activated and downloaded on-demand each tool is enabled during configuration by passing an
|
||||||
# enabled during configuration by passing an additional `-DUSE_<TOOL>=<VALUE>` argument to CMake
|
# additional `-DUSE_<TOOL>=<VALUE>` argument to CMake
|
||||||
|
|
||||||
# only activate tools for top level project
|
# only activate tools for top level project
|
||||||
if(NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
if(NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||||
|
@ -12,8 +12,8 @@ endif()
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
|
||||||
|
|
||||||
# enables sanitizers support using the the `USE_SANITIZER` flag available values are: Address,
|
# enables sanitizers support using the the `USE_SANITIZER` flag available values are: Address, Memory, MemoryWithOrigins, Undefined, Thread,
|
||||||
# Memory, MemoryWithOrigins, Undefined, Thread, Leak, 'Address;Undefined'
|
# Leak, 'Address;Undefined'
|
||||||
if(USE_SANITIZER OR USE_STATIC_ANALYZER)
|
if(USE_SANITIZER OR USE_STATIC_ANALYZER)
|
||||||
CPMAddPackage("gh:StableCoder/cmake-scripts#1f822d1fc87c8d7720c074cde8a278b44963c354")
|
CPMAddPackage("gh:StableCoder/cmake-scripts#1f822d1fc87c8d7720c074cde8a278b44963c354")
|
||||||
|
|
||||||
|
@ -21,39 +21,22 @@ if(USE_SANITIZER OR USE_STATIC_ANALYZER)
|
||||||
include(${cmake-scripts_SOURCE_DIR}/sanitizers.cmake)
|
include(${cmake-scripts_SOURCE_DIR}/sanitizers.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# cmake-lint: disable=C0103
|
||||||
if(USE_STATIC_ANALYZER)
|
if(USE_STATIC_ANALYZER)
|
||||||
if("clang-tidy" IN_LIST USE_STATIC_ANALYZER)
|
if("clang-tidy" IN_LIST USE_STATIC_ANALYZER)
|
||||||
set(CLANG_TIDY
|
set(CLANG_TIDY ON CACHE INTERNAL "")
|
||||||
ON
|
|
||||||
CACHE INTERNAL ""
|
|
||||||
)
|
|
||||||
else()
|
else()
|
||||||
set(CLANG_TIDY
|
set(CLANG_TIDY OFF CACHE INTERNAL "")
|
||||||
OFF
|
|
||||||
CACHE INTERNAL ""
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
if("iwyu" IN_LIST USE_STATIC_ANALYZER)
|
if("iwyu" IN_LIST USE_STATIC_ANALYZER)
|
||||||
set(IWYU
|
set(IWYU ON CACHE INTERNAL "")
|
||||||
ON
|
|
||||||
CACHE INTERNAL ""
|
|
||||||
)
|
|
||||||
else()
|
else()
|
||||||
set(IWYU
|
set(IWYU OFF CACHE INTERNAL "")
|
||||||
OFF
|
|
||||||
CACHE INTERNAL ""
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
if("cppcheck" IN_LIST USE_STATIC_ANALYZER)
|
if("cppcheck" IN_LIST USE_STATIC_ANALYZER)
|
||||||
set(CPPCHECK
|
set(CPPCHECK ON CACHE INTERNAL "")
|
||||||
ON
|
|
||||||
CACHE INTERNAL ""
|
|
||||||
)
|
|
||||||
else()
|
else()
|
||||||
set(CPPCHECK
|
set(CPPCHECK OFF CACHE INTERNAL "")
|
||||||
OFF
|
|
||||||
CACHE INTERNAL ""
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(${cmake-scripts_SOURCE_DIR}/tools.cmake)
|
include(${cmake-scripts_SOURCE_DIR}/tools.cmake)
|
||||||
|
|
|
@ -12,12 +12,7 @@ execute_process(
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
if(GIT_DESCRIBE_ERROR_CODE EQUAL 0)
|
if(GIT_DESCRIBE_ERROR_CODE EQUAL 0)
|
||||||
string(
|
string(REGEX MATCH "^v?([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?(\\.([0-9]+))?.*$" _ "${GIT_DESCRIBE_VERSION_STRING}")
|
||||||
REGEX MATCH
|
|
||||||
"^v?([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?(\\.([0-9]+))?.*$"
|
|
||||||
_
|
|
||||||
"${GIT_DESCRIBE_VERSION_STRING}"
|
|
||||||
)
|
|
||||||
if(DEFINED CMAKE_MATCH_1)
|
if(DEFINED CMAKE_MATCH_1)
|
||||||
set(VERSION_STRING "${CMAKE_MATCH_1}")
|
set(VERSION_STRING "${CMAKE_MATCH_1}")
|
||||||
if(DEFINED CMAKE_MATCH_3)
|
if(DEFINED CMAKE_MATCH_3)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue