Skip to content

Commit 3385167

Browse files
committed
Update build system with cmake-init-0.41.0
1 parent 4e81306 commit 3385167

File tree

6 files changed

+96
-61
lines changed

6 files changed

+96
-61
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
jobs:
1313
lint:
14-
runs-on: ubuntu-22.04
14+
runs-on: ubuntu-24.04
1515

1616
steps:
1717
- uses: actions/checkout@v4
@@ -23,7 +23,7 @@ jobs:
2323
run: pip3 install codespell
2424

2525
- name: Lint
26-
run: cmake -D FORMAT_COMMAND=clang-format-14 -P cmake/lint.cmake
26+
run: cmake -D FORMAT_COMMAND=clang-format-18 -P cmake/lint.cmake
2727

2828
- name: Spell check
2929
if: always()
@@ -32,7 +32,7 @@ jobs:
3232
coverage:
3333
needs: [lint]
3434

35-
runs-on: ubuntu-22.04
35+
runs-on: ubuntu-24.04
3636

3737
# To enable coverage, delete the last line from the conditional below and
3838
# edit the "<name>" placeholder to your GitHub name.
@@ -70,9 +70,9 @@ jobs:
7070
sanitize:
7171
needs: [lint]
7272

73-
runs-on: ubuntu-22.04
73+
runs-on: ubuntu-24.04
7474

75-
env: { CXX: clang++-14 }
75+
env: { CXX: clang++-18 }
7676

7777
steps:
7878
- uses: actions/checkout@v4
@@ -101,7 +101,7 @@ jobs:
101101

102102
strategy:
103103
matrix:
104-
os: [macos-14, ubuntu-22.04, windows-2022]
104+
os: [macos-14, ubuntu-24.04, windows-2022]
105105

106106
type: [shared, static]
107107

@@ -115,13 +115,13 @@ jobs:
115115
- uses: actions/checkout@v4
116116

117117
- name: Install static analyzers
118-
if: matrix.os == 'ubuntu-22.04'
118+
if: matrix.os == 'ubuntu-24.04'
119119
run: >-
120-
sudo apt-get install clang-tidy-14 cppcheck -y -q
120+
sudo apt-get install clang-tidy-18 cppcheck -y -q
121121
122122
sudo update-alternatives --install
123123
/usr/bin/clang-tidy clang-tidy
124-
/usr/bin/clang-tidy-14 140
124+
/usr/bin/clang-tidy-18 180
125125
126126
- name: Setup MultiToolTask
127127
if: matrix.os == 'windows-2022'
@@ -152,7 +152,7 @@ jobs:
152152
# Deploy docs only when builds succeed
153153
needs: [sanitize, test]
154154

155-
runs-on: ubuntu-22.04
155+
runs-on: ubuntu-24.04
156156

157157
# To enable, first you have to create an orphaned gh-pages branch:
158158
#

CMakeLists.txt

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include(cmake/prelude.cmake)
44

55
project(
66
HelloFitty
7-
VERSION 0.12.1
7+
VERSION 0.20.0
88
DESCRIPTION "Hello Fitty - a versatile histogram fitting tool for ROOT-based projects."
99
HOMEPAGE_URL "https://github.com/rlalik/HelloFitty"
1010
LANGUAGES CXX
@@ -15,12 +15,20 @@ include(cmake/variables.cmake)
1515
include(cmake/find_or_fetch_package.cmake)
1616

1717
# find ROOT
18-
#list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
1918
find_package(ROOT QUIET REQUIRED COMPONENTS Core Hist)
2019

21-
find_or_fetch_package(fmt https://github.com/fmtlib/fmt GIT_TAG 11.0.2 VERSION 11.0.2)
20+
# FMT
21+
find_or_fetch_package(fmt https://github.com/fmtlib/fmt GIT_TAG 11.1.2 VERSION 11.1.2)
22+
if (fmt_FETCHED)
23+
set(FMT_TARGET $<BUILD_INTERFACE:fmt::fmt-header-only>)
24+
else()
25+
set(FMT_TARGET fmt::fmt)
26+
endif()
2227

2328
# ---- Declare library ----
29+
30+
configure_file(config.h.in inc/hellofitty_config.h)
31+
2432
add_library(
2533
HelloFitty
2634
source/hellofitty.cpp
@@ -33,15 +41,10 @@ add_library(
3341
)
3442
add_library(HelloFitty::HelloFitty ALIAS HelloFitty)
3543

36-
target_link_libraries(HelloFitty PUBLIC ROOT::Core ROOT::Hist)
37-
if (fmt_FETCHED)
38-
set(FMT_TARGET $<BUILD_INTERFACE:fmt::fmt-header-only>)
39-
else()
40-
set(FMT_TARGET fmt::fmt)
41-
endif()
42-
target_link_libraries(HelloFitty PRIVATE ${FMT_TARGET})
43-
44-
configure_file(config.h.in hellofitty_config.h)
44+
target_link_libraries(HelloFitty
45+
PUBLIC ROOT::Core ROOT::Hist
46+
PRIVATE ${FMT_TARGET}
47+
)
4548

4649
include(GenerateExportHeader)
4750
generate_export_header(
@@ -68,24 +71,24 @@ set_target_properties(
6871
target_include_directories(
6972
HelloFitty ${warning_guard}
7073
PUBLIC
71-
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
72-
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/inc>"
74+
"\$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
75+
"\$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/inc>"
7376
)
7477

7578
target_include_directories(
7679
HelloFitty SYSTEM
7780
PUBLIC
78-
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/export>"
79-
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>"
81+
"\$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/export>"
82+
"\$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/inc>"
8083
)
8184

8285
option(BUILD_DICTIONARY "Build ROOT dictionary." OFF)
8386
if (BUILD_DICTIONARY)
84-
# cmake-format: off
85-
root_generate_dictionary(G__HelloFitty_cc hellofitty.hpp
86-
MODULE HelloFitty
87-
LINKDEF inc/LinkDef.h)
88-
# cmake-format: on
87+
# cmake-format: off
88+
root_generate_dictionary(G__HelloFitty_cc hellofitty.hpp
89+
MODULE HelloFitty
90+
LINKDEF inc/LinkDef.h)
91+
# cmake-format: on
8992
endif()
9093

9194
# target_compile_features(HelloFitty PUBLIC cxx_std_11)

CMakePresets.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": 3,
33
"cmakeMinimumRequired": {
44
"major": 3,
5-
"minor": 12,
5+
"minor": 14,
66
"patch": 0
77
},
88
"configurePresets": [
@@ -109,11 +109,13 @@
109109
},
110110
{
111111
"name": "ci-linux",
112+
"description": "Includes fortification with the CMake default release flags",
112113
"inherits": ["flags-gcc-clang", "ci-std"],
113114
"generator": "Unix Makefiles",
114115
"hidden": true,
115116
"cacheVariables": {
116-
"CMAKE_BUILD_TYPE": "Release"
117+
"CMAKE_BUILD_TYPE": "Release",
118+
"CMAKE_CXX_FLAGS_RELEASE": "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -O3 -DNDEBUG"
117119
}
118120
},
119121
{

CMakeUserPresets.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": 3,
33
"cmakeMinimumRequired": {
44
"major": 3,
5-
"minor": 12,
5+
"minor": 14,
66
"patch": 0
77
},
88
"configurePresets": [
@@ -72,7 +72,7 @@
7272
"name": "dev",
7373
"configurePreset": "dev",
7474
"configuration": "Debug",
75-
"jobs": 4
75+
"jobs": 32
7676
}
7777
],
7878
"testPresets": [
@@ -84,7 +84,7 @@
8484
"outputOnFailure": true
8585
},
8686
"execution": {
87-
"jobs": 4,
87+
"jobs": 32,
8888
"noTestsAction": "error"
8989
}
9090
}

example/CMakeLists.txt

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
1-
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_INSTALL_PREFIX}/lib/CMake)
2-
# set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${CMAKE_INSTALL_PREFIX}/lib/CMake)
1+
cmake_minimum_required(VERSION 3.14)
32

4-
# include(find_or_fetch_package)
5-
# find_or_fetch_package(RootTools https://github.com/rlalik/RootTools GIT_TAG
6-
# master)
3+
project(HelloFittyExamples CXX)
74

8-
# set(HAS_ROOTTOOLS ${RootTools_FOUND})
5+
include(../cmake/project-is-top-level.cmake)
6+
include(../cmake/folders.cmake)
97

10-
include_directories(${CMAKE_CURRENT_BINARY_DIR})
8+
if(PROJECT_IS_TOP_LEVEL)
9+
find_package(HelloFitty REQUIRED)
10+
endif()
1111

12-
add_executable(example1 example1.cpp)
13-
target_include_directories(example1 PRIVATE ${CMAKE_BINARY_DIR})
14-
target_link_libraries(example1 HelloFitty::HelloFitty ${FMT_TARGET})
12+
add_custom_target(run-examples)
1513

16-
add_executable(example2 example2.cpp)
17-
target_include_directories(example2 PRIVATE ${CMAKE_BINARY_DIR})
18-
target_link_libraries(example2 HelloFitty::HelloFitty ${FMT_TARGET})
14+
function(add_example NAME)
15+
add_executable("${NAME}" "${NAME}.cpp")
16+
target_link_libraries("${NAME}" PRIVATE HelloFitty::HelloFitty ${FMT_TARGET})
17+
target_compile_features("${NAME}" PRIVATE cxx_std_17)
18+
add_custom_target("run_${NAME}" COMMAND "${NAME}" VERBATIM)
19+
add_dependencies("run_${NAME}" "${NAME}")
20+
add_dependencies(run-examples "run_${NAME}")
21+
endfunction()
22+
23+
add_example(example1)
24+
add_example(example2)
1925

2026
if(RootTools_FOUND)
2127
# target_link_libraries(example2 RT::RootTools)
2228
endif(RootTools_FOUND)
29+
30+
add_folders(Example)

test/CMakeLists.txt

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
include(../cmake/find_or_fetch_package.cmake)
1+
cmake_minimum_required(VERSION 3.14)
22

3-
set(INSTALL_GTEST OFF)
4-
find_or_fetch_package(GTest https://github.com/google/googletest GIT_TAG release-1.11.0)
3+
project(HelloFittyTests LANGUAGES CXX)
54

6-
set(tests_SRCS tests_param.cpp
7-
tests_entry.cpp
8-
tests_parser_v1.cpp
9-
tests_parser_v2.cpp
10-
tests_fitter.cpp
11-
tests_hellofitty_tools.cpp)
5+
include(../cmake/project-is-top-level.cmake)
6+
include(../cmake/folders.cmake)
127

13-
add_executable(gtests ${tests_SRCS})
8+
# ---- Dependencies ----
9+
10+
if(PROJECT_IS_TOP_LEVEL)
11+
find_package(HelloFitty REQUIRED)
12+
enable_testing()
13+
endif()
1414

15-
target_include_directories(gtests PRIVATE ${CMAKE_BINARY_DIR})
15+
set(INSTALL_GTEST OFF)
16+
find_or_fetch_package(GTest https://github.com/google/googletest GIT_TAG release-1.11.0)
1617

1718
if(TARGET GTest::gtest_main)
1819
# new cmake provided
@@ -22,9 +23,30 @@ else()
2223
set(GTEST_TRG gtest gtest_main)
2324
endif()
2425

25-
target_link_libraries(gtests PRIVATE HelloFitty::HelloFitty ROOT::Core ${GTEST_TRG} ${FMT_TARGET})
26+
# ---- Tests ----
27+
28+
set(tests_SRCS tests_param.cpp
29+
tests_entry.cpp
30+
tests_parser_v1.cpp
31+
tests_parser_v2.cpp
32+
tests_fitter.cpp
33+
tests_hellofitty_tools.cpp)
34+
35+
add_executable(gtests ${tests_SRCS})
36+
target_link_libraries(gtests
37+
PRIVATE
38+
HelloFitty::HelloFitty
39+
ROOT::Core
40+
${GTEST_TRG}
41+
${FMT_TARGET}
42+
)
43+
2644
if(ENABLE_ADVANCE_TOOLS)
2745
target_code_coverage(gtests ALL)
2846
endif()
2947

3048
gtest_discover_tests(gtests)
49+
50+
# ---- End-of-file commands ----
51+
52+
add_folders(Test)

0 commit comments

Comments
 (0)