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

Update and cleanup cmake files #5

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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
4 changes: 2 additions & 2 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: "**/cpm_modules"
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: "**/cpm_modules"
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: "**/cpm_modules"
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: "**/cpm_modules"
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: "**/cpm_modules"
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: "**/cpm_modules"
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}

- name: configure
run: cmake -S test -B build # XXX -G "Visual Studio 16 2019" -T ClangCL
run: cmake -S test -B build -G "Visual Studio 17 2022" -D BUILD_SHARED_LIBS=NO

- name: build
run: cmake --build build --config Debug -j4
Expand Down
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/[email protected]")
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()
11 changes: 6 additions & 5 deletions GNUmakefile
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ install:
cmake -S . -B $(BUILD_DIR)/$@ ${CMAKE_PRESET} -DCMAKE_INSTALL_PREFIX=$(STAGE_DIR)
cmake --build $(BUILD_DIR)/$@ --target $@
perl -i.bak -p -e 's#-W[-\w]+\b##g;' -e 's#-I($$CPM_SOURCE_CACHE)#-isystem $$1#g;' $(BUILD_DIR)/$@/compile_commands.json
run-clang-tidy.py -p $(BUILD_DIR)/$@ -quiet -header-filter='$(CURDIR)/.*' source # Note: only local sources! CK
run-clang-tidy -p $(BUILD_DIR)/$@ -quiet -header-filter='$(CURDIR)/.*' source # Note: only local sources! CK

# test the library
test: install
Expand All @@ -54,7 +54,7 @@ test: install
perl -i.bak -p -e 's#-W[-\w]+\b##g;' -e 's#-I($$CPM_SOURCE_CACHE)#-isystem $$1#g;' $(BUILD_DIR)/$@/compile_commands.json
cmake --build $(BUILD_DIR)/$@
cmake --build $(BUILD_DIR)/$@ --target $@
run-clang-tidy.py -p $(BUILD_DIR)/$@ -quiet -header-filter='$(CURDIR)/.*' test/source # Note: only local sources! CK
run-clang-tidy -p $(BUILD_DIR)/$@ -quiet -header-filter='$(CURDIR)/.*' test/source # Note: only local sources! CK

# all together
all:
Expand All @@ -65,10 +65,11 @@ all:
gcovr --root . #XXX --verbose

tidy: all
run-clang-tidy.py -p $(BUILD_DIR)/all -quiet -header-filter='$(CURDIR)/.*' $(CURDIR) # Note: only local sources! CK
run-clang-tidy -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 All @@ -89,5 +90,5 @@ standalone:

# modernize the library sources
modernize: standalone
run-clang-tidy.py -p $(BUILD_DIR)/standalone -quiet -header-filter='$(CURDIR)/.*' \
run-clang-tidy -p $(BUILD_DIR)/standalone -quiet -header-filter='$(CURDIR)/.*' \
-checks='-*,modernize-*' -j1 -fix $(CURDIR) # Note: only local sources! CK
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
Loading