https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ed615122367bae54186637a3a3e34bb6418c9496

commit ed615122367bae54186637a3a3e34bb6418c9496
Author:     Jérôme Gardou <jerome.gar...@reactos.org>
AuthorDate: Fri Sep 18 16:18:24 2020 +0200
Commit:     Jérôme Gardou <zefk...@users.noreply.github.com>
CommitDate: Tue Oct 20 21:44:54 2020 +0200

    [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
---
 base/applications/charmap_new/CMakeLists.txt      |  5 -----
 base/applications/network/telnet/CMakeLists.txt   | 14 ++++----------
 dll/shellext/acppage/CMakeLists.txt               |  5 -----
 dll/shellext/mydocs/CMakeLists.txt                |  5 -----
 dll/shellext/netshell/CMakeLists.txt              |  6 ------
 dll/shellext/ntobjshex/CMakeLists.txt             |  5 -----
 dll/shellext/sendmail/CMakeLists.txt              |  5 -----
 dll/shellext/shellbtrfs/CMakeLists.txt            |  4 ----
 dll/shellext/stobject/CMakeLists.txt              |  5 -----
 dll/shellext/zipfldr/CMakeLists.txt               |  7 -------
 dll/win32/devmgr/CMakeLists.txt                   |  5 -----
 dll/win32/shell32/CMakeLists.txt                  |  5 -----
 drivers/network/dd/netkvm/CMakeLists.txt          | 17 +++++++++--------
 modules/rostests/apitests/browseui/CMakeLists.txt |  6 +-----
 sdk/cmake/compilerflags.cmake                     | 11 -----------
 sdk/cmake/gcc.cmake                               |  4 ++--
 sdk/cmake/msvc.cmake                              |  3 +--
 sdk/tools/CMakeLists.txt                          |  4 ++--
 win32ss/CMakeLists.txt                            |  7 +------
 19 files changed, 20 insertions(+), 103 deletions(-)

diff --git a/base/applications/charmap_new/CMakeLists.txt 
b/base/applications/charmap_new/CMakeLists.txt
index 06616bf0bca..c9198f5f9b1 100644
--- a/base/applications/charmap_new/CMakeLists.txt
+++ b/base/applications/charmap_new/CMakeLists.txt
@@ -1,10 +1,5 @@
 PROJECT(CHARMAP)
 
-if(NOT MSVC)
-    # HACK: this should be enabled globally!
-    add_compile_flags_language("-std=c++11" "CXX")
-endif()
-
 include_directories(
     includes)
 
diff --git a/base/applications/network/telnet/CMakeLists.txt 
b/base/applications/network/telnet/CMakeLists.txt
index acd2aa06cba..d77a95cc8bd 100644
--- a/base/applications/network/telnet/CMakeLists.txt
+++ b/base/applications/network/telnet/CMakeLists.txt
@@ -1,10 +1,4 @@
 
-add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
-
-if(NOT MSVC)
-    add_compile_flags("-Wno-restrict")
-endif()
-
 list(APPEND SOURCE
     src/ansiprsr.cpp
     src/keytrans.cpp
@@ -27,13 +21,13 @@ list(APPEND SOURCE
     src/ttelhndl.cpp
     precomp.h)
 
-if(NOT MSVC)
-    add_compile_flags_language("-Wno-narrowing" "CXX")
-endif()
-
 add_executable(telnet ${SOURCE} telnet.rc)
 target_link_libraries(telnet cppstl)
 set_target_cpp_properties(telnet WITH_EXCEPTIONS)
+if (NOT MSVC)
+    target_compile_options(telnet PRIVATE -Wno-restrict 
$<$<COMPILE_LANGUAGE:CXX>:-Wno-narrowing>)
+    target_compile_definitions(telnet PRIVATE _CRT_NONSTDC_NO_DEPRECATE)
+endif()
 set_module_type(telnet win32cui)
 add_importlibs(telnet ws2_32 user32 msvcrt kernel32 ntdll)
 add_pch(telnet precomp.h SOURCE)
diff --git a/dll/shellext/acppage/CMakeLists.txt 
b/dll/shellext/acppage/CMakeLists.txt
index fe694f869f2..f38c77c50ce 100644
--- a/dll/shellext/acppage/CMakeLists.txt
+++ b/dll/shellext/acppage/CMakeLists.txt
@@ -1,11 +1,6 @@
 
 project(appcompat)
 
-if(NOT MSVC)
-    # HACK: this should be enabled globally!
-    add_compile_flags_language("-std=c++11" "CXX")
-endif()
-
 include_directories(
     ${REACTOS_SOURCE_DIR}/dll/appcompat/apphelp
     ${REACTOS_SOURCE_DIR})
diff --git a/dll/shellext/mydocs/CMakeLists.txt 
b/dll/shellext/mydocs/CMakeLists.txt
index b74998e6603..5c1b170faa5 100644
--- a/dll/shellext/mydocs/CMakeLists.txt
+++ b/dll/shellext/mydocs/CMakeLists.txt
@@ -3,11 +3,6 @@ spec2def(mydocs.dll mydocs.spec)
 add_definitions(
     -D_WINE)
 
-if(NOT MSVC)
-    # HACK: this should be enabled globally!
-    add_compile_flags_language("-std=c++11" "CXX")
-endif()
-
 file(GLOB_RECURSE mydocs_rc_deps res/*.*)
 add_rc_deps(mydocs.rc ${mydocs_rc_deps})
 
diff --git a/dll/shellext/netshell/CMakeLists.txt 
b/dll/shellext/netshell/CMakeLists.txt
index 48ce800d927..30efec78ffa 100644
--- a/dll/shellext/netshell/CMakeLists.txt
+++ b/dll/shellext/netshell/CMakeLists.txt
@@ -1,12 +1,6 @@
 
 project(SHELL)
 
-
-if(NOT MSVC)
-    # HACK: this should be enabled globally!
-    add_compile_flags_language("-std=c++11 -Wshadow" "CXX")
-endif()
-
 remove_definitions(-D_WIN32_WINNT=0x502)
 add_definitions(-D_WIN32_WINNT=0x600)
 
diff --git a/dll/shellext/ntobjshex/CMakeLists.txt 
b/dll/shellext/ntobjshex/CMakeLists.txt
index 3ecdae1a263..f5ce057c572 100644
--- a/dll/shellext/ntobjshex/CMakeLists.txt
+++ b/dll/shellext/ntobjshex/CMakeLists.txt
@@ -1,11 +1,6 @@
 
 project(SHELL)
 
-if(NOT MSVC)
-    # HACK: this should be enabled globally!
-    add_compile_flags_language("-std=c++11" "CXX")
-endif()
-
 spec2def(ntobjshex.dll ntobjshex.spec)
 
 file(GLOB_RECURSE ntobjshex_rc_deps resources/*.*)
diff --git a/dll/shellext/sendmail/CMakeLists.txt 
b/dll/shellext/sendmail/CMakeLists.txt
index 5adbf3a847f..5271729ae82 100644
--- a/dll/shellext/sendmail/CMakeLists.txt
+++ b/dll/shellext/sendmail/CMakeLists.txt
@@ -3,11 +3,6 @@ spec2def(sendmail.dll sendmail.spec)
 add_definitions(
     -D_WINE)
 
-if(NOT MSVC)
-    # HACK: this should be enabled globally!
-    add_compile_flags_language("-std=c++11" "CXX")
-endif()
-
 file(GLOB_RECURSE sendmail_rc_deps res/*.*)
 add_rc_deps(sendmail.rc ${sendmail_rc_deps})
 
diff --git a/dll/shellext/shellbtrfs/CMakeLists.txt 
b/dll/shellext/shellbtrfs/CMakeLists.txt
index 7a21c8aa6de..6cbd3b04271 100644
--- a/dll/shellext/shellbtrfs/CMakeLists.txt
+++ b/dll/shellext/shellbtrfs/CMakeLists.txt
@@ -2,10 +2,6 @@
 remove_definitions(-D_WIN32_WINNT=0x502)
 add_definitions(-D_WIN32_WINNT=0x603)
 
-if(NOT MSVC)
-    add_compile_flags_language("-std=c++11" "CXX")
-endif()
-
 include_directories(${REACTOS_SOURCE_DIR}/drivers/filesystems/btrfs)
 
 spec2def(shellbtrfs.dll shellbtrfs.spec)
diff --git a/dll/shellext/stobject/CMakeLists.txt 
b/dll/shellext/stobject/CMakeLists.txt
index f5c67cc58f6..b8b18915cab 100644
--- a/dll/shellext/stobject/CMakeLists.txt
+++ b/dll/shellext/stobject/CMakeLists.txt
@@ -1,11 +1,6 @@
 
 project(SHELL)
 
-if(NOT MSVC)
-    # HACK: this should be enabled globally!
-    add_compile_flags_language("-std=c++11" "CXX")
-endif()
-
 spec2def(stobject.dll stobject.spec)
 
 file(GLOB_RECURSE stobject_rc_deps resources/*.*)
diff --git a/dll/shellext/zipfldr/CMakeLists.txt 
b/dll/shellext/zipfldr/CMakeLists.txt
index 106a8860f74..1706cddb105 100644
--- a/dll/shellext/zipfldr/CMakeLists.txt
+++ b/dll/shellext/zipfldr/CMakeLists.txt
@@ -1,9 +1,4 @@
 
-if(NOT MSVC)
-    # HACK: this should be enabled globally!
-    add_compile_flags_language("-std=c++11" "CXX")
-endif()
-
 remove_definitions(-D_WIN32_WINNT=0x502)
 add_definitions(-D_WIN32_WINNT=0x600)
 
@@ -13,7 +8,6 @@ include_directories(
 
 spec2def(zipfldr.dll zipfldr.spec ADD_IMPORTLIB)
 
-
 list(APPEND SOURCE
     zipfldr.cpp
     zippidl.cpp
@@ -40,7 +34,6 @@ add_library(zipfldr MODULE
     zipfldr.rc
     ${CMAKE_CURRENT_BINARY_DIR}/zipfldr.def)
 
-
 set_module_type(zipfldr win32dll UNICODE)
 target_link_libraries(zipfldr minizip zlib uuid cpprt atl_classes)
 set_target_cpp_properties(zipfldr WITH_EXCEPTIONS)
diff --git a/dll/win32/devmgr/CMakeLists.txt b/dll/win32/devmgr/CMakeLists.txt
index e86615f6e25..c4833caf662 100644
--- a/dll/win32/devmgr/CMakeLists.txt
+++ b/dll/win32/devmgr/CMakeLists.txt
@@ -2,11 +2,6 @@ PROJECT(DEVMGR)
 
 spec2def(devmgr.dll devmgr.spec ADD_IMPORTLIB)
 
-if(NOT MSVC)
-    # HACK: this should be enabled globally!
-    add_compile_flags_language("-std=c++11" "CXX")
-endif()
-
 include_directories(
     ${REACTOS_SOURCE_DIR}/sdk/include/reactos/dll
     includes)
diff --git a/dll/win32/shell32/CMakeLists.txt b/dll/win32/shell32/CMakeLists.txt
index 464ef62774b..4525db49984 100644
--- a/dll/win32/shell32/CMakeLists.txt
+++ b/dll/win32/shell32/CMakeLists.txt
@@ -6,11 +6,6 @@ add_subdirectory(shellrecyclebin)
 
 spec2def(shell32.dll shell32.spec ADD_IMPORTLIB)
 
-if(NOT MSVC)
-    # HACK: this should be enabled globally!
-    add_compile_flags_language("-std=c++11" "CXX")
-endif()
-
 remove_definitions(-D_WIN32_WINNT=0x502)
 add_definitions(-D_WIN32_WINNT=0x600)
 
diff --git a/drivers/network/dd/netkvm/CMakeLists.txt 
b/drivers/network/dd/netkvm/CMakeLists.txt
index 73a4a2fe323..ac916e92cab 100644
--- a/drivers/network/dd/netkvm/CMakeLists.txt
+++ b/drivers/network/dd/netkvm/CMakeLists.txt
@@ -27,12 +27,13 @@ add_cd_file(TARGET netkvm DESTINATION 
reactos/system32/drivers FOR all)
 add_driver_inf(netkvm netkvm.inf)
 
 if(NOT MSVC)
-    add_compile_flags("-Wno-unused-function")
-    add_compile_flags("-Wno-old-style-declaration")
-    add_compile_flags("-Wno-unknown-pragmas")
-    add_compile_flags("-Wno-unused-but-set-variable")
-    add_compile_flags("-Wno-pointer-sign")
-    add_compile_flags("-Wno-pointer-to-int-cast")
-    add_compile_flags("-Wno-int-to-pointer-cast")
-    add_compile_flags("-Wno-attributes")
+    target_compile_options(netkvm PRIVATE
+        -Wno-unused-function
+        -Wno-old-style-declaration
+        -Wno-unknown-pragmas
+        -Wno-unused-but-set-variable
+        -Wno-pointer-sign
+        -Wno-pointer-to-int-cast
+        -Wno-int-to-pointer-cast
+        -Wno-attributes)
 endif()
diff --git a/modules/rostests/apitests/browseui/CMakeLists.txt 
b/modules/rostests/apitests/browseui/CMakeLists.txt
index f1875d3a03f..efae63cf8d9 100644
--- a/modules/rostests/apitests/browseui/CMakeLists.txt
+++ b/modules/rostests/apitests/browseui/CMakeLists.txt
@@ -1,9 +1,4 @@
 
-if(NOT MSVC)
-    # HACK: this should be enabled globally!
-    add_compile_flags_language("-std=c++11" "CXX")
-endif()
-
 include_directories(
     includes)
 
@@ -15,6 +10,7 @@ list(APPEND SOURCE
     testlist.c)
 
 add_executable(browseui_apitest ${SOURCE})
+
 target_link_libraries(browseui_apitest uuid wine cpprt atl_classes)
 set_target_cpp_properties(browseui_apitest WITH_EXCEPTIONS WITH_RTTI)
 set_module_type(browseui_apitest win32cui)
diff --git a/sdk/cmake/compilerflags.cmake b/sdk/cmake/compilerflags.cmake
index c644ee21fc4..5da48e6cb53 100644
--- a/sdk/cmake/compilerflags.cmake
+++ b/sdk/cmake/compilerflags.cmake
@@ -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()
-
diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake
index cf72baeeea4..3ef5f58598a 100644
--- a/sdk/cmake/gcc.cmake
+++ b/sdk/cmake/gcc.cmake
@@ -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()
 
diff --git a/sdk/cmake/msvc.cmake b/sdk/cmake/msvc.cmake
index 92d5bf41053..f44af850478 100644
--- a/sdk/cmake/msvc.cmake
+++ b/sdk/cmake/msvc.cmake
@@ -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
diff --git a/sdk/tools/CMakeLists.txt b/sdk/tools/CMakeLists.txt
index f9e0e19f5f4..3b6bf1368f0 100644
--- a/sdk/tools/CMakeLists.txt
+++ b/sdk/tools/CMakeLists.txt
@@ -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)
diff --git a/win32ss/CMakeLists.txt b/win32ss/CMakeLists.txt
index e3be784a27f..b74e41f0361 100644
--- a/win32ss/CMakeLists.txt
+++ b/win32ss/CMakeLists.txt
@@ -1,11 +1,6 @@
 
 set(USE_DIBLIB FALSE)
 
-if(NOT MSVC)
-    # HACK: this should be enabled globally!
-    add_compile_flags_language("-std=c++11" "CXX")
-endif()
-
 # Give WIN32 subsystem its own project.
 PROJECT(WIN32SS)
 
@@ -247,4 +242,4 @@ set_source_files_properties(sys-stubs.S PROPERTIES 
OBJECT_DEPENDS ${CMAKE_CURREN
 add_asm_files(win32ksys_asm sys-stubs.S)
 add_library(win32ksys ${win32ksys_asm})
 set_target_properties(win32ksys PROPERTIES LINKER_LANGUAGE "C")
-add_dependencies(win32ksys asm)
\ No newline at end of file
+add_dependencies(win32ksys asm)

Reply via email to