Skip to content

Commit 3fb8076

Browse files
authored
Merge branch 'dev' into dependabot/github_actions/dot-github/workflows/step-security/harden-runner-2.10.2
2 parents 08f049f + a584e96 commit 3fb8076

File tree

361 files changed

+10610
-4584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

361 files changed

+10610
-4584
lines changed

.github/workflows/codeql.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
21
name: "CodeQL"
32

43
on:
54
push:
6-
branches: ["main", "dev"]
5+
branches: [ "main", "dev" ]
76
pull_request:
87
# The branches below must be a subset of the branches above
9-
branches: ["main", "dev"]
8+
branches: [ "main", "dev" ]
109
schedule:
1110
- cron: "0 0 * * 1"
1211

@@ -25,7 +24,7 @@ jobs:
2524
strategy:
2625
fail-fast: false
2726
matrix:
28-
language: ["cpp", "python"]
27+
language: [ "cpp", "python" ]
2928
# CodeQL supports [ $supported-codeql-languages ]
3029
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
3130

CMakeLists.txt

Lines changed: 137 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ project(
1313
# Determine if this is the root project or a subproject.
1414
set(is_root_project OFF)
1515
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
16-
set(is_root_project ON)
16+
set(is_root_project ON)
1717
endif ()
1818
if (NOT CCMATH_SOURCE_DIR)
19-
set(CCMATH_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
19+
set(CCMATH_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
2020
endif ()
2121

2222
# TODO: Possibly change this to instead use cmakes more modern target_compile_features
@@ -38,56 +38,80 @@ add_library(${PROJECT_NAME}::${PROJECT_NAME}-compile-options ALIAS ${PROJECT_NAM
3838
#
3939
# Compiler Flags and Conditions
4040
#
41+
42+
# MSVC Compiler Options
4143
if (MSVC)
42-
# MSVC-specific options
43-
target_compile_options(${PROJECT_NAME}-compile-options INTERFACE
44-
/W4
45-
/permissive-
46-
/Zc:__cplusplus
47-
/D_ENABLE_EXTENDED_ALIGNED_STORAGE
48-
/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
49-
/EHsc
50-
)
51-
# Only define NOMINMAX on Windows platforms
52-
if (WIN32)
53-
target_compile_definitions(${PROJECT_NAME}-compile-options INTERFACE NOMINMAX)
54-
endif()
55-
56-
if (CCMATH_STRICT_WARNINGS)
57-
target_compile_options(${PROJECT_NAME}-compile-options INTERFACE /WX)
58-
endif()
59-
60-
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
61-
OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
62-
OR CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
63-
64-
# Generic clang/gcc/intel options
65-
# Consider making some of these suppressions configurable if requested by users.
66-
target_compile_options(${PROJECT_NAME}-compile-options INTERFACE
67-
-Wall
68-
-Wextra
69-
-Wconversion
70-
-Wpedantic
71-
# Define NOMINMAX only on Windows to avoid conflicts with min/max macros
72-
$<$<BOOL:${WIN32}>:-DNOMINMAX>
73-
#-Wno-unused-but-set-variable
74-
#-Wno-unused-value
75-
#-Wno-unused-parameter
76-
)
77-
78-
if (CCMATH_STRICT_WARNINGS)
79-
target_compile_options(${PROJECT_NAME}-compile-options INTERFACE -Werror=return-type)
80-
endif ()
81-
82-
# if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
83-
# target_compile_options(${PROJECT_NAME}-compile-options INTERFACE
84-
# -Wno-tautological-constant-compare
85-
# )
86-
# endif()
87-
88-
else()
89-
message(WARNING "CCMath: Unknown compiler. No specific flags applied.")
90-
endif()
44+
# Set MSVC-specific compilation flags
45+
target_compile_options(${PROJECT_NAME}-compile-options INTERFACE
46+
/W4 # Enable high warning level
47+
/permissive- # Enforce standard C++ conformance
48+
/Zc:__cplusplus # Properly define __cplusplus macro for the compiler version
49+
/EHsc # Enable standard exception handling
50+
)
51+
52+
# Define NOMINMAX on Windows platforms to avoid macro conflicts with std::min/std::max
53+
if (WIN32)
54+
target_compile_definitions(${PROJECT_NAME}-compile-options INTERFACE NOMINMAX)
55+
endif ()
56+
57+
# Treat warnings as errors if CCMATH_STRICT_WARNINGS is set
58+
if (CCMATH_STRICT_WARNINGS)
59+
target_compile_options(${PROJECT_NAME}-compile-options INTERFACE /WX) # Warnings as errors
60+
endif ()
61+
62+
# Clang, GCC, and IntelLLVM Compiler Options
63+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|IntelLLVM")
64+
65+
66+
# Generic options for Clang, GCC, and IntelLLVM
67+
target_compile_options(${PROJECT_NAME}-compile-options INTERFACE
68+
-Wall # Enable common warnings
69+
-Wextra # Enable additional warnings
70+
-Wconversion # Warn on implicit type conversions
71+
-Wpedantic # Enforce strict standard compliance
72+
# Define NOMINMAX on Windows to avoid macro conflicts with min/max
73+
$<$<BOOL:${WIN32}>:-DNOMINMAX>
74+
)
75+
76+
# Add Clang-specific options
77+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
78+
target_compile_options(${PROJECT_NAME}-compile-options INTERFACE
79+
-Wpedantic-macros # Warn about non-standard macro usage
80+
)
81+
endif ()
82+
83+
# Treat specific warnings as errors if CCMATH_STRICT_WARNINGS is set
84+
if (CCMATH_STRICT_WARNINGS)
85+
target_compile_options(${PROJECT_NAME}-compile-options INTERFACE
86+
-Werror=return-type # Treat missing return type warnings as errors
87+
)
88+
endif ()
89+
90+
# Add aggressive debug options for developers if CCMATH_DEV_AGGRESSIVE_DEBUG is set
91+
if (CCMATH_DEV_AGGRESIVE_DEBUG)
92+
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|IntelLLVM")
93+
94+
target_compile_options(${PROJECT_NAME}-compile-options INTERFACE
95+
-Wwrite-strings # Warn about writeable string literals
96+
-g3 # Maximum debug information
97+
)
98+
elseif (MSVC)
99+
target_compile_options(${PROJECT_NAME}-compile-options INTERFACE
100+
/Zi # Generate full debugging information
101+
)
102+
endif ()
103+
endif ()
104+
105+
# TODO: Decide if we plan to delete this or not
106+
# if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
107+
# target_compile_options(${PROJECT_NAME}-compile-options INTERFACE
108+
# -Wno-tautological-constant-compare
109+
# )
110+
# endif()
111+
112+
else ()
113+
message(WARNING "CCMath: Unknown compiler. No specific flags applied.")
114+
endif ()
91115

92116
add_library(${PROJECT_NAME} INTERFACE)
93117
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
@@ -113,91 +137,91 @@ target_link_libraries(${PROJECT_NAME} INTERFACE
113137
)
114138

115139
if (CCMATH_ENABLE_RUNTIME_SIMD)
116-
target_compile_definitions(${PROJECT_NAME} INTERFACE CCM_CONFIG_USE_RT_SIMD)
140+
target_compile_definitions(${PROJECT_NAME} INTERFACE CCM_CONFIG_USE_RT_SIMD)
117141
endif ()
118142

119143
if (NOT CCMATH_ENABLE_USER_DEFINED_OPTIMIZATION_MACROS)
120-
target_compile_definitions(${PROJECT_NAME} INTERFACE
121-
$<$<CONFIG:Debug>:CCM_CONFIG_DEBUG>
122-
$<$<CONFIG:RelWithDebInfo>:CCM_CONFIG_OPTIMIZE>
123-
$<$<CONFIG:Release>:CCM_CONFIG_AGGRESSIVELY_OPTIMIZE>
124-
$<$<CONFIG:MinSizeRel>:CCM_CONFIG_MINSIZE>
125-
)
144+
target_compile_definitions(${PROJECT_NAME} INTERFACE
145+
$<$<CONFIG:Debug>:CCM_CONFIG_DEBUG>
146+
$<$<CONFIG:RelWithDebInfo>:CCM_CONFIG_OPTIMIZE>
147+
$<$<CONFIG:Release>:CCM_CONFIG_AGGRESSIVELY_OPTIMIZE>
148+
$<$<CONFIG:MinSizeRel>:CCM_CONFIG_MINSIZE>
149+
)
126150
endif ()
127151

128152
if (CCMATH_DISABLE_ERRNO)
129-
target_compile_definitions(${PROJECT_NAME} INTERFACE CCM_CONFIG_DISABLE_ERRNO)
153+
target_compile_definitions(${PROJECT_NAME} INTERFACE CCM_CONFIG_DISABLE_ERRNO)
130154
endif ()
131155

132156
# Generate version header
133-
configure_file(cmake/version.hpp.in "${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}/version.hpp" @ONLY)
157+
configure_file(cmake/version.hpp.in "${CMAKE_CURRENT_BINARY_DIR}/include/ccmath/version.hpp" @ONLY)
134158

135159
# Add optional subdirectories only if requested
136160
if (CCMATH_BUILD_EXAMPLES OR CCMATH_BUILD_BENCHMARKS OR CCMATH_BUILD_TESTS)
137-
# Use SYSTEM to suppress warnings from thirdparty code if supported by the CMake version.
138-
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.25)
139-
add_subdirectory(thirdparty SYSTEM)
140-
else ()
141-
add_subdirectory(thirdparty)
142-
endif ()
161+
# Use SYSTEM to suppress warnings from thirdparty code if supported by the CMake version.
162+
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.25)
163+
add_subdirectory(thirdparty SYSTEM)
164+
else ()
165+
add_subdirectory(thirdparty)
166+
endif ()
143167
endif ()
144168

145169
if (CCMATH_BUILD_EXAMPLES)
146-
add_subdirectory(example)
170+
add_subdirectory(example)
147171
endif ()
148172

149173
if (CCMATH_BUILD_BENCHMARKS)
150-
add_subdirectory(benchmark)
174+
add_subdirectory(benchmark)
151175
endif ()
152176

153177
if (CCMATH_BUILD_TESTS)
154-
enable_testing()
155-
add_subdirectory(test)
178+
enable_testing()
179+
add_subdirectory(test)
156180
endif ()
157181

158182
# Installation and Packaging
159183
if (CCMATH_INSTALL)
160-
include(GNUInstallDirs)
161-
include(CMakePackageConfigHelpers)
162-
163-
install(TARGETS
164-
${PROJECT_NAME}
165-
${PROJECT_NAME}-compile-options
166-
EXPORT ${PROJECT_NAME}-targets
167-
)
168-
169-
install(DIRECTORY
170-
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
171-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
172-
FILES_MATCHING PATTERN "*.hpp"
173-
)
174-
175-
install(FILES
176-
"${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}/version.hpp"
177-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
178-
)
179-
180-
install(EXPORT ${PROJECT_NAME}-targets
181-
FILE ${PROJECT_NAME}-targets.cmake
182-
NAMESPACE ${PROJECT_NAME}::
183-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
184-
)
185-
186-
configure_package_config_file(
187-
cmake/${PROJECT_NAME}-config.cmake.in
188-
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
189-
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
190-
)
191-
192-
# Write a version file for strict version checking
193-
write_basic_package_version_file(
194-
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
195-
COMPATIBILITY SameMajorVersion
196-
)
197-
198-
install(FILES
199-
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
200-
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
201-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
202-
)
184+
include(GNUInstallDirs)
185+
include(CMakePackageConfigHelpers)
186+
187+
install(TARGETS
188+
${PROJECT_NAME}
189+
${PROJECT_NAME}-compile-options
190+
EXPORT ${PROJECT_NAME}-targets
191+
)
192+
193+
install(DIRECTORY
194+
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
195+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
196+
FILES_MATCHING PATTERN "*.hpp"
197+
)
198+
199+
install(FILES
200+
"${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}/version.hpp"
201+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
202+
)
203+
204+
install(EXPORT ${PROJECT_NAME}-targets
205+
FILE ${PROJECT_NAME}-targets.cmake
206+
NAMESPACE ${PROJECT_NAME}::
207+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
208+
)
209+
210+
configure_package_config_file(
211+
cmake/${PROJECT_NAME}-config.cmake.in
212+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
213+
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
214+
)
215+
216+
# Write a version file for strict version checking
217+
write_basic_package_version_file(
218+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
219+
COMPATIBILITY SameMajorVersion
220+
)
221+
222+
install(FILES
223+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
224+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
225+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
226+
)
203227
endif ()

0 commit comments

Comments
 (0)