Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include(CheckCCompilerFlag)
- # Set C standard
- set(CMAKE_C_STANDARD 17)
- set(CMAKE_C_STANDARD_REQUIRED ON)
- # Set C++ standard
- set(CMAKE_CXX_STANDARD 17)
- set(CMAKE_CXX_STANDARD_REQUIRED ON)
- # Common flags
- set(COMMON_FLAGS
- -Wall
- -Wextra
- -Wpedantic
- -ffast-math
- -DPIC
- -freciprocal-math
- -fsingle-precision-constant
- -ftree-vectorize
- -funroll-loops
- )
- # Add flags conditionally
- if(EXTRA_OPTIMIZATIONS)
- list(APPEND COMMON_FLAGS -march=native -mtune=native)
- endif()
- if(EXTRA_DEBUG_INFO)
- list(APPEND COMMON_FLAGS -g3)
- endif()
- # Apply flags
- add_compile_options(${COMMON_FLAGS})
- # Strict flags (can be enabled with an option)
- if(STRICT_FLAGS)
- add_compile_options(-Werror)
- endif()
- # OS-specific flags
- if(WIN32)
- add_compile_options(-mms-bitfields -mwindows)
- add_link_options(-Wl,-Bdynamic -Wl,-as-needed)
- endif()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement