| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- # Smartbotic-MicroBit Compiler Flags
- # Common warnings for all builds
- add_compile_options(
- -Wall
- -Wextra
- -Wpedantic
- -Werror=return-type
- -Werror=unused-result
- -Wno-unused-parameter
- )
- # Debug flags
- if(CMAKE_BUILD_TYPE STREQUAL "Debug")
- add_compile_options(
- -g3
- -O0
- -fno-omit-frame-pointer
- )
- option(ENABLE_SANITIZERS "Enable ASan and UBSan" OFF)
- if(ENABLE_SANITIZERS)
- add_compile_options(-fsanitize=address,undefined)
- add_link_options(-fsanitize=address,undefined)
- endif()
- endif()
- # Release flags
- if(CMAKE_BUILD_TYPE STREQUAL "Release")
- add_compile_options(
- -O3
- -DNDEBUG
- -march=native
- )
- endif()
- # RelWithDebInfo flags
- if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
- add_compile_options(
- -O2
- -g
- -DNDEBUG
- )
- endif()
- # LTO for release builds
- if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
- include(CheckIPOSupported)
- check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR)
- if(IPO_SUPPORTED)
- message(STATUS "IPO/LTO enabled")
- set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
- else()
- message(STATUS "IPO/LTO not supported: ${IPO_ERROR}")
- endif()
- endif()
- # Position independent code
- set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|