Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
146 changes: 96 additions & 50 deletions .cmake-format
Original file line number Diff line number Diff line change
@@ -1,77 +1,123 @@
format:
tab_size: 2
line_width: 100
dangle_parens: true

markup:
enable_markup: false

parse:
additional_commands:
cpmaddpackage:
pargs:
nargs: '*'
flags: []
spelling: CPMAddPackage
kwargs: &cpmaddpackagekwargs
NAME: 1
FORCE: 1
VERSION: 1
GIT_TAG: 1
kwargs:
DOWNLOAD_COMMAND: 1
DOWNLOAD_NAME: 1
DOWNLOAD_NO_EXTRACT: 1
DOWNLOAD_ONLY: 1
FIND_PACKAGE_ARGUMENTS: 1
FORCE: 1
GITHUB_REPOSITORY: 1
GITLAB_REPOSITORY: 1
GIT_REPOSITORY: 1
GIT_SHALLOW: 1
GIT_TAG: 1
HTTP_PASSWORD: 1
HTTP_USERNAME: 1
NAME: 1
NO_CACHE: 1
OPTIONS: +
SOURCE_DIR: 1
SVN_REPOSITORY: 1
SVN_REVISION: 1
SOURCE_DIR: 1
URL: 1
URL_HASH: 1
URL_MD5: 1
VERSION: 1
pargs:
flags: []
nargs: '*'
spelling: CPMAddPackage
cpmdeclarepackage:
kwargs:
DOWNLOAD_COMMAND: 1
DOWNLOAD_NAME: 1
DOWNLOAD_NO_EXTRACT: 1
DOWNLOAD_ONLY: 1
FIND_PACKAGE_ARGUMENTS: 1
NO_CACHE: 1
FORCE: 1
GITHUB_REPOSITORY: 1
GITLAB_REPOSITORY: 1
GIT_REPOSITORY: 1
GIT_SHALLOW: 1
GIT_TAG: 1
HTTP_PASSWORD: 1
HTTP_USERNAME: 1
NAME: 1
NO_CACHE: 1
OPTIONS: +
SOURCE_DIR: 1
SVN_REPOSITORY: 1
SVN_REVISION: 1
URL: 1
URL_HASH: 1
URL_MD5: 1
VERSION: 1
pargs:
flags: []
nargs: '*'
spelling: CPMDeclarePackage
cpmfindpackage:
kwargs:
DOWNLOAD_COMMAND: 1
DOWNLOAD_NAME: 1
DOWNLOAD_NO_EXTRACT: 1
HTTP_USERNAME: 1
DOWNLOAD_ONLY: 1
FIND_PACKAGE_ARGUMENTS: 1
FORCE: 1
GITHUB_REPOSITORY: 1
GITLAB_REPOSITORY: 1
GIT_REPOSITORY: 1
GIT_SHALLOW: 1
GIT_TAG: 1
HTTP_PASSWORD: 1
HTTP_USERNAME: 1
NAME: 1
NO_CACHE: 1
OPTIONS: +
cpmfindpackage:
SOURCE_DIR: 1
SVN_REPOSITORY: 1
SVN_REVISION: 1
URL: 1
URL_HASH: 1
URL_MD5: 1
VERSION: 1
pargs:
nargs: '*'
flags: []
spelling: CPMFindPackage
kwargs: *cpmaddpackagekwargs
cpmdeclarepackage:
pargs:
nargs: '*'
flags: []
spelling: CPMDeclarePackage
kwargs: *cpmaddpackagekwargs
spelling: CPMFindPackage
cpmgetpackageversion:
pargs: 2
spelling: CPMGetPackageVersion
cpmregisterpackage:
pargs: 1
spelling: CPMRegisterPackage
cpmusepackagelock:
pargs: 1
spelling: CPMUsePackageLock
packageproject:
pargs:
nargs: '*'
flags: []
spelling: packageProject
kwargs:
NAME: 1
VERSION: 1
NAMESPACE: 1
INCLUDE_DIR: 1
INCLUDE_DESTINATION: 1
BINARY_DIR: 1
COMPATIBILITY: 1
VERSION_HEADER: 1
EXPORT_HEADER: 1
DISABLE_VERSION_SUFFIX: 1
DEPENDENCIES: +
cpmusepackagelock:
pargs: 1
spelling: CPMUsePackageLock
cpmregisterpackage:
pargs: 1
spelling: CPMRegisterPackage
cpmgetpackageversion:
pargs: 2
spelling: CPMGetPackageVersion
DISABLE_VERSION_SUFFIX: 1
DISABLE_CHECK_REQUIRED_COMPONENTS: 1
EXPORT_HEADER: 1
INCLUDE_DESTINATION: 1
INCLUDE_DIR: 1
NAME: 1
NAMESPACE: 1
VERSION: 1
VERSION_HEADER: 1
pargs:
flags: []
nargs: '*'
spelling: packageProject
format:
line_width: 100
tab_size: 2
dangle_parens: true

markup:
enable_markup: false
42 changes: 20 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.14...3.20)
cmake_minimum_required(VERSION 3.21...3.25)

# ---- Project ----

# Note: update this to your new project's name and version
project(
MathFunctions
VERSION 1.0.0
VERSION 1.0.1
LANGUAGES CXX
)

Expand All @@ -14,8 +14,7 @@ project(
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(
FATAL_ERROR
"In-source builds not allowed. Please make a new directory (called a build directory) \
and run CMake from there."
"In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
)
endif()

Expand All @@ -29,22 +28,17 @@ include(cmake/options.cmake)
include(cmake/CPM.cmake)

# PackageProject.cmake will be used to make our target installable
CPMAddPackage(
NAME PackageProject.cmake
GITHUB_REPOSITORY ClausKlein/PackageProject.cmake
# VERSION CK1.6.0
GIT_TAG 4ac95860ba72bb0eb324c4d63e35fb59be3bd50d
)
CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.10.0")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed


set(COMPONENT_TARGETS_ENABLED NO) # Note: DO not set! CK
# NO! set(COMPONENT_TARGETS_ENABLED NO) # Note: DO not set! CK
set(PROJECT_NAMESPACE ${PROJECT_NAME})
set(PROJECT_VERSION_INCLUDE_DIR ${PROJECT_BINARY_DIR}/PackageProjectInclude)
include_directories(${PROJECT_VERSION_INCLUDE_DIR})

set(NAMESPACE_HEADER_LOCATION ${CMAKE_CURRENT_LIST_DIR}/include)
set(INCLUDE_INSTALL_DIR include/${PROJECT_NAMESPACE}-${PROJECT_VERSION}) # XXX VERSION_SUFFIX
string(TOLOWER ${PROJECT_NAMESPACE} PROJECT_HEADER_LOCATION)
# TODO: needed to be lower case? CK
# TODO: why needed to be lower case? CK

# ---- Add components libraries here ----

Expand Down Expand Up @@ -74,7 +68,7 @@ set_target_properties(
# header paths
string(TOLOWER ${PROJECT_NAMESPACE}/version.h PROJECT_VERSION_HEADER)
string(TOLOWER ${PROJECT_NAMESPACE}/${PROJECT_NAMESPACE}_export.h PROJECT_EXPORT_HEADER)
# TODO: needed to be lower case? CK
# TODO: why needed to be lower case? CK

# Note: This needs to be done after all install(TARGETS ...) commands!
# generate and install export targets file
Expand All @@ -95,14 +89,18 @@ packageProject(
INCLUDE_DESTINATION ${INCLUDE_INSTALL_DIR}
VERSION_HEADER ${PROJECT_VERSION_HEADER}
EXPORT_HEADER ${PROJECT_EXPORT_HEADER}
COMPATIBILITY SameMajorVersion # XXX DISABLE_VERSION_SUFFIX NOT YET! CK
DISABLE_CHECK_REQUIRED_COMPONENTS YES
COMPATIBILITY SameMajorVersion
# XXX DISABLE_VERSION_SUFFIX NOT YET! CK
DISABLE_CHECK_REQUIRED_COMPONENTS YES
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed too!

)

# generate the export targets for the build tree. Note: The file created by this command is specific
# to the build tree and should never be installed!
export(
EXPORT ${PROJECT_NAMESPACE}Targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAMESPACE}Targets.cmake
NAMESPACE ${PROJECT_NAMESPACE}::
)
# generate the export targets for the build tree.
# if(COMPONENT_TARGETS_ENABLED)
# # Note: The file created by this command is specific to the build tree
# # and and must be created after packageProject()! CK
# export(
# EXPORT ${PROJECT_NAMESPACE}Targets
# FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAMESPACE}Targets.cmake
# NAMESPACE ${PROJECT_NAMESPACE}::
# )
# endif()
3 changes: 2 additions & 1 deletion GNUmakefile
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ tidy: all
run-clang-tidy.py -p $(BUILD_DIR)/all -quiet -header-filter='$(CURDIR)/.*' $(CURDIR) # Note: only local sources! CK

gcov: all
gcovr -r . --html-title $(PROJECT_NAME) --html-detail $(CURDIR)/reports/gcov/index.html
mkdir -p reports
gcovr -r . --html-title $(PROJECT_NAME) --html-details $(CURDIR)/reports/gcov/index.html
perl -i.bak -pe 's#class="headerValue">./<#class="headerValue">$(PROJECT_NAME)<#g;' $(CURDIR)/reports/gcov/*.html

# GenerateDocs
Expand Down
2 changes: 1 addition & 1 deletion all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# this script adds all subprojects to a single build to allow IDEs understand the full project
# structure.

cmake_minimum_required(VERSION 3.14...3.20)
cmake_minimum_required(VERSION 3.21...3.25)

project(BuildAll LANGUAGES CXX)

Expand Down
6 changes: 3 additions & 3 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
set(CPM_DOWNLOAD_VERSION 0.31.1)
set(CPM_DOWNLOAD_VERSION 0.36.0)

if(CPM_SOURCE_CACHE)
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
Expand Down
12 changes: 12 additions & 0 deletions cmake/ProjectWarningsAsErrors.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror -Wshadow)

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 10.0)
target_compile_options(${PROJECT_NAME} PRIVATE -Wdeprecated-copy-dtor -Wnewline-eof)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
endif()
1 change: 1 addition & 0 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ if(NOT MSVC)
)
endif()

option(ENABLE_TEST_COVERAGE "Enable test coverage" OFF)
if(ENABLE_TEST_COVERAGE AND "${CMAKE_BUILD_TYPE}" STREQUAL Debug)
add_compile_options(--coverage -O0 -g)
add_link_options(--coverage)
Expand Down
2 changes: 1 addition & 1 deletion documentation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14...3.20)
cmake_minimum_required(VERSION 3.21...3.25)

project(MathFunctionsDocs)

Expand Down
22 changes: 11 additions & 11 deletions source/Addition/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_library(
Addition Addition.cxx ${NAMESPACE_HEADER_LOCATION}/${PROJECT_HEADER_LOCATION}/Addition.h
)

add_library(${PROJECT_NAMESPACE}::Addition ALIAS Addition)
add_library(${PROJECT_NAMESPACE}::Addition ALIAS Addition) # NOTE: needed! CK
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed


# Note: for SameMajorVersion upgrade stategie
set_target_properties(
Expand All @@ -24,7 +24,7 @@ target_include_directories(
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
)

# install the target and create export-set
# NOTE: Need to install the target and create export-set manually! CK
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed

install(
TARGETS Addition
EXPORT ${PROJECT_NAMESPACE}Targets
Expand All @@ -41,12 +41,12 @@ install(
# DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAMESPACE}
# )

if(COMPONENT_TARGETS_ENABLED)
# generate and install export file
install(
EXPORT ${PROJECT_NAMESPACE}Targets
FILE ${PROJECT_NAMESPACE}AdditionTargets.cmake
NAMESPACE ${PROJECT_NAMESPACE}::
DESTINATION lib/cmake/${PROJECT_NAMESPACE}
)
endif()
# if(COMPONENT_TARGETS_ENABLED)
# # NOTE: generate and install export file for this target! CK
# install(
# EXPORT ${PROJECT_NAMESPACE}Targets
# FILE ${PROJECT_NAMESPACE}AdditionTargets.cmake
# NAMESPACE ${PROJECT_NAMESPACE}::
# DESTINATION lib/cmake/${PROJECT_NAMESPACE}
# )
# endif()
Loading