@@ -38,49 +38,68 @@ add_library(${PROJECT_NAME}::${PROJECT_NAME}-compile-options ALIAS ${PROJECT_NAM
3838#
3939# Compiler Flags and Conditions
4040#
41+
42+ # MSVC Compiler Options
4143if (MSVC )
42- # MSVC-specific options
44+ # Set MSVC-specific compilation flags
4345 target_compile_options (${PROJECT_NAME} -compile-options INTERFACE
44- /W4
45- /permissive-
46- /Zc:__cplusplus
47- /EHsc
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
4850 )
49- # Only define NOMINMAX on Windows platforms
51+
52+ # Define NOMINMAX on Windows platforms to avoid macro conflicts with std::min/std::max
5053 if (WIN32 )
5154 target_compile_definitions (${PROJECT_NAME} -compile-options INTERFACE NOMINMAX)
5255 endif ()
5356
57+ # Treat warnings as errors if CCMATH_STRICT_WARNINGS is set
5458 if (CCMATH_STRICT_WARNINGS)
55- target_compile_options (${PROJECT_NAME} -compile-options INTERFACE /WX)
59+ target_compile_options (${PROJECT_NAME} -compile-options INTERFACE /WX) # Warnings as errors
5660 endif ()
5761
58- elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
59- OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
60- OR CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" )
62+ # Clang, GCC, and IntelLLVM Compiler Options
63+ elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|IntelLLVM" )
6164
62- # Generic clang/gcc/intel options
63- # Consider making some of these suppressions configurable if requested by users.
65+
66+ # Generic options for Clang, GCC, and IntelLLVM
6467 target_compile_options (${PROJECT_NAME} -compile-options INTERFACE
65- -Wall
66- -Wextra
67- -Wconversion
68- -Wpedantic
69- #-Wwrite-strings
70- -fpermissive # TODO: Figure out how to best remove this
71- -g3
72- # Define NOMINMAX only on Windows to avoid conflicts with min/max macros
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
7373 $<$<BOOL :${WIN32} >:-DNOMINMAX>
7474 )
7575
76- if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) # TODO: Check if intel llvm has this flag
76+ # Add Clang-specific options
77+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
7778 target_compile_options (${PROJECT_NAME} -compile-options INTERFACE
78- -Wpedantic-macros
79+ -Wpedantic-macros # Warn about non-standard macro usage
7980 )
8081 endif ()
8182
83+ # Treat specific warnings as errors if CCMATH_STRICT_WARNINGS is set
8284 if (CCMATH_STRICT_WARNINGS)
83- target_compile_options (${PROJECT_NAME} -compile-options INTERFACE -Werror=return-type )
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 ()
84103 endif ()
85104
86105 # TODO: Decide if we plan to delete this or not
0 commit comments