mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 22:16:04 +00:00
[CMAKE] Get rid of add_compile_flags_language macro
in favor of add_compile_options and the like with generator expressions Also take this as an opportunity to remove the C++11 standard hack, GCC 8 now defaults to C++14
This commit is contained in:
parent
7e116f0ef3
commit
ed61512236
19 changed files with 20 additions and 103 deletions
|
@ -71,13 +71,11 @@ macro(replace_compiler_option _var _old _new)
|
|||
endmacro(replace_compiler_option)
|
||||
|
||||
# add_compile_flags
|
||||
# add_compile_flags_language
|
||||
# Add or replace compiler flags in the global scope for either all source
|
||||
# files or only those of the specified language.
|
||||
#
|
||||
# Examples:
|
||||
# add_compile_flags("-pedantic -O5")
|
||||
# add_compile_flags_language("-std=gnu99" "C")
|
||||
function(add_compile_flags _flags)
|
||||
if(${ARGC} GREATER 1)
|
||||
message(FATAL_ERROR "Excess arguments to add_compile_flags! Args ${ARGN}")
|
||||
|
@ -87,12 +85,3 @@ function(add_compile_flags _flags)
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flags}" PARENT_SCOPE)
|
||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${_flags}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(add_compile_flags_language _flags _lang)
|
||||
if(NOT ${ARGC} EQUAL 2)
|
||||
message(FATAL_ERROR "Wrong arguments to add_compile_flags_language! Args ${ARGN}")
|
||||
endif()
|
||||
# Adds the compiler flag for the specified language only, e.g. CMAKE_C_FLAGS
|
||||
set(CMAKE_${_lang}_FLAGS "${CMAKE_${_lang}_FLAGS} ${_flags}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ add_compile_flags("-mstackrealign")
|
|||
add_compile_flags("-fno-aggressive-loop-optimizations")
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_flags_language("-std=gnu99 -Wno-microsoft" "C")
|
||||
add_compile_options("$<$<COMPILE_LANGUAGE:C>:-std=gnu99;-Wno-microsoft>")
|
||||
set(CMAKE_LINK_DEF_FILE_FLAG "")
|
||||
set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
|
||||
set(CMAKE_LINK_LIBRARY_SUFFIX "")
|
||||
|
@ -65,7 +65,7 @@ endif()
|
|||
|
||||
if(DBG)
|
||||
if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_flags_language("-Wold-style-declaration" "C")
|
||||
add_compile_options("$<$<COMPILE_LANGUAGE:C>:-Wold-style-declaration>")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -125,8 +125,7 @@ endif()
|
|||
add_compile_flags("/w14115")
|
||||
|
||||
if(USE_CLANG_CL)
|
||||
add_compile_flags_language("-nostdinc -Wno-multichar -Wno-char-subscripts -Wno-microsoft-enum-forward-reference -Wno-pragma-pack -Wno-microsoft-anon-tag -Wno-parentheses-equality -Wno-unknown-pragmas" "C")
|
||||
add_compile_flags_language("-nostdinc -Wno-multichar -Wno-char-subscripts -Wno-microsoft-enum-forward-reference -Wno-pragma-pack -Wno-microsoft-anon-tag -Wno-parentheses-equality -Wno-unknown-pragmas" "CXX")
|
||||
add_compile_options("$<$<COMPILE_LANGUAGE:C,CXX>:-nostdinc;-Wno-multichar;-Wno-char-subscripts;-Wno-microsoft-enum-forward-reference;-Wno-pragma-pack;-Wno-microsoft-anon-tag;-Wno-parentheses-equality;-Wno-unknown-pragmas>")
|
||||
endif()
|
||||
|
||||
# Debugging
|
||||
|
|
|
@ -6,10 +6,10 @@ endfunction()
|
|||
|
||||
if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -DHAVE_IO_H=1)
|
||||
add_compile_flags_language("/EHsc" "CXX")
|
||||
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/EHsc>")
|
||||
|
||||
# Disable warning "conversion from 'size_t' to 'int', possible loss of data"
|
||||
add_compile_flags("/wd4267")
|
||||
add_compile_options("/wd4267")
|
||||
endif()
|
||||
|
||||
add_host_tool(bin2c bin2c.c)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue