Skip to content

Commit

Permalink
cmake, refactor: Rename try_add_compile_option to try_append_cflags
Browse files Browse the repository at this point in the history
Actually, `try_append_cflags()` can handle a list of flags, and the new
name is similar to the one used in `configure.ac`.
  • Loading branch information
hebasto committed Mar 12, 2023
1 parent 5562bc8 commit fbaf328
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,25 +182,25 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
endif()

include(TryAddCompileOption)
include(TryAppendCflags)
if(MSVC)
try_add_compile_option(/W2)
try_add_compile_option(/wd4146)
try_append_cflags(/W2)
try_append_cflags(/wd4146)
else()
try_add_compile_option(-pedantic)
try_add_compile_option(-Wall)
try_add_compile_option(-Wcast-align)
try_add_compile_option(-Wcast-align=strict)
try_add_compile_option(-Wconditional-uninitialized)
try_add_compile_option(-Wextra)
try_add_compile_option(-Wnested-externs)
try_add_compile_option(-Wno-long-long)
try_add_compile_option(-Wno-overlength-strings)
try_add_compile_option(-Wno-unused-function)
try_add_compile_option(-Wreserved-identifier)
try_add_compile_option(-Wshadow)
try_add_compile_option(-Wstrict-prototypes)
try_add_compile_option(-Wundef)
try_append_cflags(-pedantic)
try_append_cflags(-Wall)
try_append_cflags(-Wcast-align)
try_append_cflags(-Wcast-align=strict)
try_append_cflags(-Wconditional-uninitialized)
try_append_cflags(-Wextra)
try_append_cflags(-Wnested-externs)
try_append_cflags(-Wno-long-long)
try_append_cflags(-Wno-overlength-strings)
try_append_cflags(-Wno-unused-function)
try_append_cflags(-Wreserved-identifier)
try_append_cflags(-Wshadow)
try_append_cflags(-Wstrict-prototypes)
try_append_cflags(-Wundef)
endif()

if(CMAKE_VERSION VERSION_GREATER 3.2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include(CheckCCompilerFlag)

# Append flags to the COMPILE_OPTIONS directory property if CC accepts them.
macro(try_add_compile_option)
macro(try_append_cflags)
check_cflags_internal("${ARGV}" result)
if(result)
add_compile_options(${ARGV})
Expand Down

0 comments on commit fbaf328

Please sign in to comment.