# Compiler flags for SmartBotic # Warning flags if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") add_compile_options( -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-missing-field-initializers ) # Debug flags if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_compile_options(-g -O0 -DDEBUG) # Note: _GLIBCXX_DEBUG is disabled because it causes ABI incompatibility # with pre-compiled system libraries (gRPC, etc.) # add_compile_definitions(_GLIBCXX_DEBUG) endif() # Release flags if(CMAKE_BUILD_TYPE STREQUAL "Release") add_compile_options(-O3 -DNDEBUG) add_compile_options(-flto) add_link_options(-flto) endif() # RelWithDebInfo flags if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") add_compile_options(-O2 -g -DNDEBUG) endif() endif() # MSVC flags (for potential Windows support) if(MSVC) add_compile_options(/W4 /permissive-) add_compile_definitions(_CRT_SECURE_NO_WARNINGS) if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_compile_options(/Od /Zi) else() add_compile_options(/O2) endif() endif() # Enable colored output if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") add_compile_options(-fdiagnostics-color=always) elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-fcolor-diagnostics) endif() # Position independent code set(CMAKE_POSITION_INDEPENDENT_CODE ON)