Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set C standard through cmake variables #1221

Merged
merged 1 commit into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(CMAKE_C_STANDARD 11)
Nightwalker-87 marked this conversation as resolved.
Show resolved Hide resolved
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)


###
# General project settings
Expand Down
4 changes: 0 additions & 4 deletions cmake/modules/c_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ function(add_cflag_if_supported flag)
endif ()
endfunction()

add_cflag_if_supported("-std=gnu11")
add_cflag_if_supported("-std=gnu18")
add_cflag_if_supported("-Wall")
add_cflag_if_supported("-Wextra")
add_cflag_if_supported("-Wshadow")
Expand Down Expand Up @@ -47,8 +45,6 @@ endif ()

if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
add_cflag_if_supported("-ggdb")
add_cflag_if_supported("-O0")
else ()
add_cflag_if_supported("-O2")
add_cflag_if_supported("-Werror")
endif ()