mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[CMAKE] Get rid of add_compile_flags
Use add_compile_options and the like instead
This commit is contained in:
parent
84621b3634
commit
00ed72d7e8
26 changed files with 158 additions and 198 deletions
|
@ -58,7 +58,7 @@ else()
|
|||
endif()
|
||||
|
||||
if(MSVC_IDE)
|
||||
add_compile_flags("/MP")
|
||||
add_compile_options("/MP")
|
||||
endif()
|
||||
|
||||
# Bison and Flex support
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
if(NOT MSVC)
|
||||
add_compile_flags("-Wno-format-overflow")
|
||||
endif()
|
||||
|
||||
add_executable(tftpd tftpd.cpp)
|
||||
set_module_type(tftpd win32cui)
|
||||
add_importlibs(tftpd advapi32 ws2_32 iphlpapi msvcrt kernel32)
|
||||
add_cd_file(TARGET tftpd DESTINATION reactos/system32 FOR all)
|
||||
|
||||
if ((NOT MSVC) OR USE_CLANG_CL)
|
||||
target_compile_options(tftpd PRIVATE -Wno-format-overflow)
|
||||
endif()
|
||||
|
|
|
@ -8,7 +8,7 @@ endif()
|
|||
|
||||
if(MSVC)
|
||||
# Explicitly use string pooling
|
||||
add_compile_flags("/GF")
|
||||
add_compile_options("/GF")
|
||||
endif()
|
||||
|
||||
spec2def(freeldr_pe.exe freeldr.spec)
|
||||
|
|
11
dll/3rdparty/libxslt/CMakeLists.txt
vendored
11
dll/3rdparty/libxslt/CMakeLists.txt
vendored
|
@ -1,8 +1,4 @@
|
|||
|
||||
if(NOT MSVC)
|
||||
add_compile_flags("-Wno-misleading-indentation")
|
||||
endif()
|
||||
|
||||
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/libxslt
|
||||
${REACTOS_SOURCE_DIR}/sdk/lib/3rdparty/libwin-iconv)
|
||||
|
||||
|
@ -47,9 +43,10 @@ if(MSVC)
|
|||
add_importlibs(libxslt ntdll)
|
||||
endif()
|
||||
|
||||
if ((NOT MSVC) OR USE_CLANG_CL)
|
||||
target_compile_options(libxslt PRIVATE -Wno-misleading-indentation -Wno-pointer-sign -Wno-unused-function)
|
||||
endif()
|
||||
|
||||
add_pch(libxslt precomp.h SOURCE)
|
||||
add_cd_file(TARGET libxslt DESTINATION reactos/system32 FOR all)
|
||||
|
||||
if(USE_CLANG_CL OR (NOT MSVC))
|
||||
target_compile_options(libxslt PRIVATE -Wno-pointer-sign -Wno-unused-function)
|
||||
endif()
|
||||
|
|
|
@ -64,8 +64,10 @@ add_library(comctl32 MODULE
|
|||
rsrc.rc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/comctl32.def)
|
||||
|
||||
if (MSVC)
|
||||
# Disable warning C4477 (printf format warnings)
|
||||
target_compile_options(comctl32 PRIVATE $<$<BOOL:${MSVC}>:/wd4477>)
|
||||
target_compile_options(comctl32 PRIVATE /wd4477)
|
||||
endif()
|
||||
|
||||
set_module_type(comctl32 win32dll UNICODE)
|
||||
target_link_libraries(comctl32 uuid wine ${PSEH_LIB})
|
||||
|
|
|
@ -7,10 +7,6 @@ list(APPEND SOURCE
|
|||
provider.cpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/framedyn.def)
|
||||
|
||||
if(MSVC)
|
||||
add_compile_flags("/Zc:wchar_t-")
|
||||
endif()
|
||||
|
||||
add_library(framedyn MODULE ${SOURCE})
|
||||
target_link_libraries(framedyn cpprt)
|
||||
set_target_cpp_properties(framedyn WITH_EXCEPTIONS)
|
||||
|
@ -22,4 +18,6 @@ if(NOT MSVC)
|
|||
add_asm_files(framedynex_asm alias_gcc.s)
|
||||
add_library(framedynex ${framedynex_asm})
|
||||
set_target_properties(framedynex PROPERTIES LINKER_LANGUAGE ASM)
|
||||
else()
|
||||
target_compile_options(framedyn PRIVATE /Zc:wchar_t-)
|
||||
endif()
|
||||
|
|
|
@ -6,10 +6,6 @@ add_definitions(
|
|||
-DLIBXML_STATIC
|
||||
-DCOM_NO_WINDOWS_H)
|
||||
|
||||
if(MSVC)
|
||||
add_compile_flags("/FIwine/typeof.h /FImsvc.h")
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine
|
||||
${REACTOS_SOURCE_DIR}/sdk/lib/3rdparty/libwin-iconv)
|
||||
|
@ -76,6 +72,11 @@ add_library(msxml3 MODULE
|
|||
add_idl_headers(xmlparser_idlheader xmlparser.idl)
|
||||
set_module_type(msxml3 win32dll)
|
||||
target_link_libraries(msxml3 libxml2 iconv-static uuid wine zlib)
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(msxml3 PRIVATE /FIwine/typeof.h /FImsvc.h)
|
||||
endif()
|
||||
|
||||
add_importlibs(msxml3 urlmon ws2_32 shlwapi oleaut32 ole32 user32 msvcrt kernel32 ntdll)
|
||||
add_dependencies(msxml3 xmlparser_idlheader stdole2) # msxml3_v1.tlb needs stdole2.tlb
|
||||
add_pch(msxml3 precomp.h "${PCH_SKIP_SOURCE}")
|
||||
|
|
|
@ -16,10 +16,6 @@ include_directories(
|
|||
${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/libpng
|
||||
${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/libtiff)
|
||||
|
||||
if(MSVC)
|
||||
add_compile_flags("/FItypeof.h")
|
||||
endif()
|
||||
|
||||
spec2def(windowscodecs.dll windowscodecs.spec ADD_IMPORTLIB)
|
||||
add_rpcproxy_files(windowscodecs_wincodec.idl)
|
||||
|
||||
|
@ -75,8 +71,9 @@ add_library(windowscodecs MODULE
|
|||
${CMAKE_CURRENT_BINARY_DIR}/windowscodecs.def)
|
||||
|
||||
if(MSVC)
|
||||
# error C4133: 'function': incompatible types - from 'WICPixelFormatNumericRepresentation *' to 'DWORD *'
|
||||
remove_target_compile_option(windowscodecs "/we4133")
|
||||
target_compile_options(windowscodecs PRIVATE
|
||||
/wd4133 # error C4133: 'function': incompatible types - from 'WICPixelFormatNumericRepresentation *' to 'DWORD *'
|
||||
/FItypeof.h)
|
||||
endif()
|
||||
|
||||
set_module_type(windowscodecs win32dll)
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
|
||||
if(GCC)
|
||||
add_compile_flags("-Wno-stringop-overflow")
|
||||
endif()
|
||||
|
||||
add_executable(createspec createspec.c)
|
||||
set_module_type(createspec win32cui)
|
||||
target_link_libraries(createspec wine)
|
||||
if (NOT MSVC)
|
||||
target_compile_options(createspec PRIVATE -Wno-stringop-overflow)
|
||||
endif()
|
||||
add_importlibs(createspec dbghelp msvcrt kernel32)
|
||||
add_cd_file(TARGET createspec DESTINATION reactos/system32 FOR all)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
include_directories(BEFORE include)
|
||||
add_compile_flags("-D__USE_W32_SOCKETS")
|
||||
|
||||
list(APPEND SOURCE
|
||||
config.cpp
|
||||
|
@ -15,6 +14,7 @@ list(APPEND SOURCE
|
|||
add_executable(roshttpd ${SOURCE} common/roshttpd.rc)
|
||||
target_link_libraries(roshttpd cppstl)
|
||||
set_target_cpp_properties(roshttpd WITH_EXCEPTIONS)
|
||||
target_compile_definitions(roshttpd PRIVATE __USE_W32_SOCKETS)
|
||||
set_module_type(roshttpd win32cui)
|
||||
add_importlibs(roshttpd user32 ws2_32 msvcrt kernel32)
|
||||
add_cd_file(TARGET roshttpd DESTINATION reactos/system32 FOR all)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
if (GCC)
|
||||
add_compile_flags("-fno-builtin")
|
||||
add_compile_options(-fno-builtin)
|
||||
endif()
|
||||
|
||||
include(ntdll_crt_apitest.cmake)
|
||||
|
|
|
@ -23,10 +23,6 @@ add_executable(dllexport_test dllexport_test.c)
|
|||
set_module_type(dllexport_test win32cui)
|
||||
add_importlibs(dllexport_test dllexport_test_dll1 msvcrt kernel32 ntdll)
|
||||
|
||||
if(MSVC)
|
||||
add_compile_flags("/Zc:wchar_t-")
|
||||
endif()
|
||||
|
||||
# framedyn is skipped in the clang-cl build
|
||||
if(NOT USE_CLANG_CL)
|
||||
|
||||
|
@ -34,7 +30,9 @@ add_library(dllimport_test MODULE dllimport_framedyn.cpp)
|
|||
set_module_type(dllimport_test module)
|
||||
add_importlibs(dllimport_test framedyn)
|
||||
|
||||
if(NOT MSVC)
|
||||
if (MSVC)
|
||||
target_compile_options(dllimport_test PRIVATE /Zc:wchar_t-)
|
||||
else()
|
||||
target_link_libraries(dllimport_test framedynex)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
|
||||
add_definitions(-DUSE_WINE_TODOS)
|
||||
|
||||
if(GCC)
|
||||
add_compile_flags("-Wno-format-overflow")
|
||||
endif()
|
||||
|
||||
list(APPEND SOURCE
|
||||
advpack.c
|
||||
files.c
|
||||
|
@ -12,7 +6,13 @@ list(APPEND SOURCE
|
|||
testlist.c)
|
||||
|
||||
add_executable(advpack_winetest ${SOURCE})
|
||||
target_link_libraries(advpack_winetest)
|
||||
|
||||
target_compile_definitions(advpack_winetest PRIVATE USE_WINE_TODOS)
|
||||
|
||||
if (NOT MSVC)
|
||||
target_compile_options(advpack_winetest PRIVATE -Wno-format-overflow)
|
||||
endif()
|
||||
|
||||
set_module_type(advpack_winetest win32cui)
|
||||
add_importlibs(advpack_winetest advpack cabinet advapi32 msvcrt kernel32)
|
||||
add_rostests_file(TARGET advpack_winetest)
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
|
||||
add_definitions(-DUSE_WINE_TODOS)
|
||||
|
||||
if(GCC)
|
||||
add_compile_flags("-Wno-format-overflow")
|
||||
endif()
|
||||
|
||||
list(APPEND SOURCE
|
||||
asmcache.c
|
||||
asmenum.c
|
||||
|
@ -13,6 +7,13 @@ list(APPEND SOURCE
|
|||
testlist.c)
|
||||
|
||||
add_executable(fusion_winetest ${SOURCE})
|
||||
|
||||
target_compile_definitions(fusion_winetest PRIVATE USE_WINE_TODOS)
|
||||
|
||||
if (NOT MSVC)
|
||||
target_compile_options(fusion_winetest PRIVATE -Wno-format-overflow)
|
||||
endif()
|
||||
|
||||
set_module_type(fusion_winetest win32cui)
|
||||
add_importlibs(fusion_winetest user32 msvcrt kernel32)
|
||||
add_rostests_file(TARGET fusion_winetest)
|
||||
|
|
|
@ -1,17 +1,4 @@
|
|||
|
||||
add_definitions(
|
||||
-DUSE_WINE_TODOS
|
||||
-D__WINESRC__)
|
||||
|
||||
if(MSVC_IDE)
|
||||
# msi_winetest.rc: let rc.exe find custom.dll in its subdirectory, i.e. Debug.
|
||||
include_directories($<TARGET_FILE_DIR:custom>)
|
||||
endif()
|
||||
|
||||
if(GCC)
|
||||
add_compile_flags("-Wno-format-overflow")
|
||||
endif()
|
||||
|
||||
spec2def(custom.dll custom.spec)
|
||||
add_library(custom MODULE custom.c ${CMAKE_CURRENT_BINARY_DIR}/custom.def)
|
||||
target_link_libraries(custom uuid)
|
||||
|
@ -43,6 +30,17 @@ add_executable(msi_winetest
|
|||
${PCH_SKIP_SOURCE}
|
||||
msi_winetest.rc)
|
||||
|
||||
target_compile_definitions(msi_winetest PRIVATE __WINESRC__ USE_WINE_TODOS)
|
||||
|
||||
if (NOT MSVC)
|
||||
target_compile_options(msi_winetest PRIVATE -Wno-format-overflow)
|
||||
endif()
|
||||
|
||||
# msi_winetest.rc: let rc.exe find custom.dll in its subdirectory, i.e. Debug.
|
||||
if (MSVC_IDE)
|
||||
target_include_directories(msi_winetest PRIVATE $<$<COMPILE_LANGUAGE:RC>:$<TARGET_FILE_DIR:custom>>)
|
||||
endif()
|
||||
|
||||
target_link_libraries(msi_winetest uuid)
|
||||
set_module_type(msi_winetest win32cui)
|
||||
add_importlibs(msi_winetest cabinet msi shell32 ole32 oleaut32 user32 advapi32 version msvcrt kernel32)
|
||||
|
|
|
@ -1,13 +1,4 @@
|
|||
|
||||
add_definitions(
|
||||
-DWINETEST_USE_DBGSTR_LONGLONG
|
||||
-D_CRT_NONSTDC_NO_DEPRECATE
|
||||
-D__msvcrt_ulong=ULONG)
|
||||
|
||||
if(GCC)
|
||||
add_compile_flags("-Wno-stringop-truncation")
|
||||
endif()
|
||||
|
||||
list(APPEND SOURCE
|
||||
cpp.c
|
||||
data.c
|
||||
|
@ -31,8 +22,16 @@ add_executable(msvcrt_winetest
|
|||
${SOURCE}
|
||||
${PCH_SKIP_SOURCE})
|
||||
|
||||
if(USE_CLANG_CL OR (NOT MSVC))
|
||||
target_compile_options(msvcrt_winetest PRIVATE "-Wno-format")
|
||||
target_compile_definitions(msvcrt_winetest PRIVATE
|
||||
WINETEST_USE_DBGSTR_LONGLONG
|
||||
_CRT_NONSTDC_NO_DEPRECATE
|
||||
__msvcrt_ulong=ULONG)
|
||||
|
||||
if ((NOT MSVC) OR USE_CLANG_CL)
|
||||
if (NOT USE_CLANG_CL)
|
||||
target_compile_options(msvcrt_winetest PRIVATE -Wno-stringop-truncation)
|
||||
endif()
|
||||
target_compile_options(msvcrt_winetest PRIVATE -Wno-format)
|
||||
endif()
|
||||
|
||||
set_module_type(msvcrt_winetest win32cui)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
if(GCC)
|
||||
add_compile_flags("-Wno-format-overflow")
|
||||
endif()
|
||||
|
||||
add_executable(services_winetest service.c testlist.c)
|
||||
set_module_type(services_winetest win32cui)
|
||||
add_importlibs(services_winetest user32 advapi32 msvcrt kernel32)
|
||||
add_rostests_file(TARGET services_winetest)
|
||||
|
||||
if (NOT MSVC)
|
||||
target_compile_options(services_winetest PRIVATE -Wno-format-overflow)
|
||||
endif()
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
|
||||
if(GCC)
|
||||
add_compile_flags("-Wno-format-overflow")
|
||||
endif()
|
||||
|
||||
list(APPEND SOURCE
|
||||
devinst.c
|
||||
dialog.c
|
||||
|
@ -20,3 +16,7 @@ set_module_type(setupapi_winetest win32cui)
|
|||
target_link_libraries(setupapi_winetest uuid)
|
||||
add_importlibs(setupapi_winetest advapi32 setupapi user32 shell32 msvcrt kernel32 ntdll)
|
||||
add_rostests_file(TARGET setupapi_winetest)
|
||||
|
||||
if (NOT MSVC)
|
||||
target_compile_options(setupapi_winetest PRIVATE -Wno-format-overflow)
|
||||
endif()
|
||||
|
|
|
@ -3,10 +3,6 @@ add_definitions(-DWINETEST_USE_DBGSTR_LONGLONG)
|
|||
|
||||
remove_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502)
|
||||
|
||||
if(GCC)
|
||||
add_compile_flags("-Wno-format-overflow")
|
||||
endif()
|
||||
|
||||
list(APPEND SOURCE
|
||||
appbar.c
|
||||
assoc.c
|
||||
|
@ -42,6 +38,8 @@ add_importlibs(shell32_winetest shell32 shlwapi ole32 oleaut32 user32 gdi32 adva
|
|||
|
||||
if(MSVC)
|
||||
add_importlibs(shell32_winetest ntdll)
|
||||
else()
|
||||
target_compile_options(shell32_winetest PRIVATE -Wno-format-overflow)
|
||||
endif()
|
||||
|
||||
add_pch(shell32_winetest precomp.h "${PCH_SKIP_SOURCE}")
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
|
||||
add_definitions(-DUSE_WINE_TODOS)
|
||||
|
||||
if(GCC)
|
||||
add_compile_flags("-Wno-format-overflow")
|
||||
endif()
|
||||
|
||||
list(APPEND SOURCE
|
||||
info.c
|
||||
install.c
|
||||
|
@ -14,7 +8,11 @@ add_executable(version_winetest ${SOURCE} version.rc)
|
|||
set_module_type(version_winetest win32cui)
|
||||
add_importlibs(version_winetest shell32 version msvcrt kernel32)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_definitions(version_winetest PRIVATE USE_WINE_TODOS)
|
||||
|
||||
if (NOT MSVC)
|
||||
target_compile_options(version_winetest PRIVATE -Wno-format-overflow)
|
||||
else()
|
||||
add_importlibs(version_winetest ntdll)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -48,19 +48,3 @@ function(add_target_link_flags _module _flags)
|
|||
endif()
|
||||
add_target_property(${_module} LINK_FLAGS ${_flags})
|
||||
endfunction()
|
||||
|
||||
# add_compile_flags
|
||||
# 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")
|
||||
function(add_compile_flags _flags)
|
||||
if(${ARGC} GREATER 1)
|
||||
message(FATAL_ERROR "Excess arguments to add_compile_flags! Args ${ARGN}")
|
||||
endif()
|
||||
# Adds the compiler flag for all code files: C, C++, and assembly
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flags}" PARENT_SCOPE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flags}" PARENT_SCOPE)
|
||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${_flags}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
|
|
@ -35,18 +35,17 @@ if(USE_DUMMY_PSEH)
|
|||
endif()
|
||||
|
||||
if(STACK_PROTECTOR)
|
||||
add_compile_flags(${MODULE} "-fstack-protector-all")
|
||||
add_compile_options(-fstack-protector-all)
|
||||
endif()
|
||||
|
||||
# Compiler Core
|
||||
add_compile_flags("-pipe -fms-extensions -fno-strict-aliasing")
|
||||
add_compile_options(-pipe -fms-extensions -fno-strict-aliasing)
|
||||
|
||||
# Prevent GCC from searching any of the default directories.
|
||||
# The case for C++ is handled through the reactos_c++ INTERFACE library
|
||||
add_compile_options("$<$<NOT:$<COMPILE_LANGUAGE:CXX>>:-nostdinc>")
|
||||
|
||||
add_compile_flags("-mstackrealign")
|
||||
add_compile_flags("-fno-aggressive-loop-optimizations")
|
||||
add_compile_options(-mstackrealign -fno-aggressive-loop-optimizations)
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_options("$<$<COMPILE_LANGUAGE:C>:-std=gnu99;-Wno-microsoft>")
|
||||
|
@ -72,81 +71,81 @@ endif()
|
|||
# Debugging
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
if(SEPARATE_DBG)
|
||||
add_compile_flags("-gdwarf-2 -ggdb")
|
||||
add_compile_options(-gdwarf-2 -ggdb)
|
||||
else()
|
||||
add_compile_flags("-gdwarf-2 -gstrict-dwarf")
|
||||
if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_flags("-femit-struct-debug-detailed=none -feliminate-unused-debug-symbols")
|
||||
add_compile_options(-gdwarf-2 -gstrict-dwarf)
|
||||
if(NOT CMAKE_C_COMPILER_ID STREQUAL Clang)
|
||||
add_compile_options(-femit-struct-debug-detailed=none -feliminate-unused-debug-symbols)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Tuning
|
||||
if(ARCH STREQUAL "i386")
|
||||
add_compile_flags("-march=${OARCH} -mtune=${TUNE}")
|
||||
add_compile_options(-march=${OARCH} -mtune=${TUNE})
|
||||
else()
|
||||
add_compile_flags("-march=${OARCH}")
|
||||
add_compile_options(-march=${OARCH})
|
||||
endif()
|
||||
|
||||
# Warnings, errors
|
||||
if((NOT CMAKE_BUILD_TYPE STREQUAL "Release") AND (NOT CMAKE_C_COMPILER_ID STREQUAL "Clang"))
|
||||
add_compile_flags("-Werror")
|
||||
if((NOT CMAKE_BUILD_TYPE STREQUAL "Release") AND (NOT CMAKE_C_COMPILER_ID STREQUAL Clang))
|
||||
add_compile_options(-Werror)
|
||||
endif()
|
||||
|
||||
add_compile_flags("-Wall -Wpointer-arith")
|
||||
add_compile_flags("-Wno-char-subscripts -Wno-multichar -Wno-unused-value")
|
||||
add_compile_flags("-Wno-unused-const-variable")
|
||||
add_compile_flags("-Wno-unused-local-typedefs")
|
||||
add_compile_flags("-Wno-deprecated")
|
||||
add_compile_options(-Wall -Wpointer-arith)
|
||||
add_compile_options(-Wno-char-subscripts -Wno-multichar -Wno-unused-value)
|
||||
add_compile_options(-Wno-unused-const-variable)
|
||||
add_compile_options(-Wno-unused-local-typedefs)
|
||||
add_compile_options(-Wno-deprecated)
|
||||
|
||||
if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_flags("-Wno-maybe-uninitialized")
|
||||
add_compile_options(-Wno-maybe-uninitialized)
|
||||
endif()
|
||||
|
||||
if(ARCH STREQUAL "amd64")
|
||||
add_compile_flags("-Wno-format")
|
||||
add_compile_options(-Wno-format)
|
||||
elseif(ARCH STREQUAL "arm")
|
||||
add_compile_flags("-Wno-attributes")
|
||||
add_compile_options(-Wno-attributes)
|
||||
endif()
|
||||
|
||||
# Optimizations
|
||||
# FIXME: Revisit this to see if we even need these levels
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
add_compile_flags("-O2 -DNDEBUG")
|
||||
add_compile_options(-O2 -DNDEBUG)
|
||||
else()
|
||||
if(OPTIMIZE STREQUAL "1")
|
||||
add_compile_flags("-Os -ftracer")
|
||||
add_compile_options(-Os -ftracer)
|
||||
elseif(OPTIMIZE STREQUAL "2")
|
||||
add_compile_flags("-Os")
|
||||
add_compile_options(-Os)
|
||||
elseif(OPTIMIZE STREQUAL "3")
|
||||
add_compile_flags("-Og")
|
||||
add_compile_options(-Og)
|
||||
elseif(OPTIMIZE STREQUAL "4")
|
||||
add_compile_flags("-O1")
|
||||
add_compile_options(-O1)
|
||||
elseif(OPTIMIZE STREQUAL "5")
|
||||
add_compile_flags("-O2")
|
||||
add_compile_options(-O2)
|
||||
elseif(OPTIMIZE STREQUAL "6")
|
||||
add_compile_flags("-O3")
|
||||
add_compile_options(-O3)
|
||||
elseif(OPTIMIZE STREQUAL "7")
|
||||
add_compile_flags("-Ofast")
|
||||
add_compile_options(-Ofast)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Link-time code generation
|
||||
if(LTCG)
|
||||
add_compile_flags("-flto -fno-fat-lto-objects")
|
||||
add_compile_options(-flto -fno-fat-lto-objects)
|
||||
endif()
|
||||
|
||||
if(ARCH STREQUAL "i386")
|
||||
add_compile_flags("-fno-optimize-sibling-calls -fno-omit-frame-pointer")
|
||||
add_compile_options(-fno-optimize-sibling-calls -fno-omit-frame-pointer)
|
||||
if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_flags("-mpreferred-stack-boundary=3 -fno-set-stack-executable")
|
||||
add_compile_options(-mpreferred-stack-boundary=3 -fno-set-stack-executable)
|
||||
endif()
|
||||
# FIXME: this doesn't work. CMAKE_BUILD_TYPE is always "Debug"
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_compile_flags("-momit-leaf-frame-pointer")
|
||||
add_compile_options(-momit-leaf-frame-pointer)
|
||||
endif()
|
||||
elseif(ARCH STREQUAL "amd64")
|
||||
add_compile_flags("-mpreferred-stack-boundary=4")
|
||||
add_compile_options(-mpreferred-stack-boundary=4)
|
||||
endif()
|
||||
|
||||
# Other
|
||||
|
|
|
@ -2,32 +2,29 @@
|
|||
#if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
# no optimization
|
||||
add_compile_flags("/Ob0 /Od")
|
||||
add_compile_options(/Ob0 /Od)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
add_compile_flags("/Ox /Ob2 /Ot /Oy /GT")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF /OPT:ICF")
|
||||
add_compile_options(/Ox /Ob2 /Ot /Oy /GT)
|
||||
elseif(OPTIMIZE STREQUAL "1")
|
||||
add_compile_flags("/O1")
|
||||
add_compile_options(/O1)
|
||||
elseif(OPTIMIZE STREQUAL "2")
|
||||
add_compile_flags("/O2")
|
||||
add_compile_options(/O2)
|
||||
elseif(OPTIMIZE STREQUAL "3")
|
||||
add_compile_flags("/Ot /Ox /GS-")
|
||||
add_compile_options(/Ot /Ox /GS-)
|
||||
elseif(OPTIMIZE STREQUAL "4")
|
||||
add_compile_flags("/Os /Ox /GS-")
|
||||
add_compile_options(/Os /Ox /GS-)
|
||||
elseif(OPTIMIZE STREQUAL "5")
|
||||
add_compile_flags("/Gy /Ob2 /Os /Ox /GS-")
|
||||
add_compile_options(/Gy /Ob2 /Os /Ox /GS-)
|
||||
endif()
|
||||
|
||||
# Always use string pooling: this helps reducing the binaries size since a lot
|
||||
# of redundancy come from the usage of __FILE__ / __RELFILE__ in the debugging
|
||||
# helper macros. Note also that GCC builds use string pooling by default.
|
||||
add_compile_flags("/GF")
|
||||
add_compile_options(/GF)
|
||||
|
||||
# Enable function level linking and comdat folding
|
||||
add_compile_flags("/Gy")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:REF /OPT:ICF")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /OPT:REF /OPT:ICF")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF /OPT:ICF")
|
||||
add_compile_options(/Gy)
|
||||
add_link_options(/OPT:REF /OPT:ICF)
|
||||
|
||||
if(ARCH STREQUAL "i386")
|
||||
add_definitions(/DWIN32 /D_WINDOWS)
|
||||
|
@ -37,12 +34,11 @@ add_definitions(/Dinline=__inline /D__STDC__=1)
|
|||
|
||||
# Ignore any "standard" include paths, and do not use any default CRT library.
|
||||
if(NOT USE_CLANG_CL)
|
||||
add_compile_flags("/X /Zl")
|
||||
add_compile_options(/X /Zl)
|
||||
endif()
|
||||
|
||||
# Disable RTTI, exception handling and buffer security checks by default.
|
||||
# These require run-time support that may not always be available.
|
||||
add_compile_flags("/GS-")
|
||||
# Disable buffer security checks by default.
|
||||
add_compile_options(/GS-)
|
||||
|
||||
if(USE_CLANG_CL)
|
||||
set(CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file: ")
|
||||
|
@ -53,29 +49,29 @@ endif()
|
|||
if(ARCH STREQUAL "i386")
|
||||
# Clang's IA32 means i386, which doesn't have cmpxchg8b
|
||||
if(USE_CLANG_CL)
|
||||
add_compile_flags("-march=${OARCH}")
|
||||
add_compile_options(-march=${OARCH})
|
||||
else()
|
||||
add_compile_flags("/arch:IA32")
|
||||
add_compile_options(/arch:IA32)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# VS 12+ requires /FS when used in parallel compilations
|
||||
if(NOT MSVC_IDE)
|
||||
add_compile_flags("/FS")
|
||||
add_compile_options(/FS)
|
||||
endif()
|
||||
|
||||
# VS14+ tries to use thread-safe initialization
|
||||
add_compile_flags("/Zc:threadSafeInit-")
|
||||
add_compile_options(/Zc:threadSafeInit-)
|
||||
|
||||
# HACK: Disable use of __CxxFrameHandler4 on VS 16.3+ (x64 only)
|
||||
# See https://developercommunity.visualstudio.com/content/problem/746534/visual-c-163-runtime-uses-an-unsupported-api-for-u.html
|
||||
if(ARCH STREQUAL "amd64" AND MSVC_VERSION GREATER 1922)
|
||||
add_compile_flags("/d2FH4-")
|
||||
add_link_options("/d2:-FH4-")
|
||||
add_compile_options(/d2FH4-)
|
||||
add_link_options(/d2:-FH4-)
|
||||
endif()
|
||||
|
||||
# Generate Warnings Level 3
|
||||
add_compile_flags("/W3")
|
||||
add_compile_options(/W3)
|
||||
|
||||
# Disable overly sensitive warnings as well as those that generally aren't
|
||||
# useful to us.
|
||||
|
@ -84,10 +80,10 @@ add_compile_flags("/W3")
|
|||
# - C4800: forcing value to bool 'true' or 'false' (performance warning)
|
||||
# - C4200: nonstandard extension used : zero-sized array in struct/union
|
||||
# - C4214: nonstandard extension used : bit field types other than int
|
||||
add_compile_flags("/wd4244 /wd4290 /wd4800 /wd4200 /wd4214")
|
||||
add_compile_options(/wd4244 /wd4290 /wd4800 /wd4200 /wd4214)
|
||||
|
||||
# FIXME: Temporarily disable C4018 until we fix more of the others. CORE-10113
|
||||
add_compile_flags("/wd4018")
|
||||
add_compile_options(/wd4018)
|
||||
|
||||
# The following warnings are treated as errors:
|
||||
# - C4013: implicit function declaration
|
||||
|
@ -122,19 +118,17 @@ endif()
|
|||
|
||||
# Enable warnings above the default level, but don't treat them as errors:
|
||||
# - C4115: named type definition in parentheses
|
||||
add_compile_flags("/w14115")
|
||||
add_compile_options(/w14115)
|
||||
|
||||
if(USE_CLANG_CL)
|
||||
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
|
||||
#if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
if(NOT (_PREFAST_ OR _VS_ANALYZE_))
|
||||
add_compile_flags("/Zi")
|
||||
add_compile_options(/Zi)
|
||||
endif()
|
||||
#elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
add_definitions("/D NDEBUG")
|
||||
endif()
|
||||
|
@ -155,12 +149,11 @@ endif()
|
|||
|
||||
if(RUNTIME_CHECKS)
|
||||
add_definitions(-D__RUNTIME_CHECKS__)
|
||||
add_compile_flags("/RTC1")
|
||||
add_compile_options(/RTC1)
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE ${_hotpatch_link_flag} /IGNORE:4039")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE ${_hotpatch_link_flag} /IGNORE:4104 /IGNORE:4039")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE ${_hotpatch_link_flag} /IGNORE:4039")
|
||||
add_link_options(/MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE ${_hotpatch_link_flag} /IGNORE:4039)
|
||||
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "")
|
||||
|
||||
# HACK: Remove the /implib argument, implibs are generated separately
|
||||
|
@ -202,7 +195,7 @@ endif()
|
|||
|
||||
if(_VS_ANALYZE_)
|
||||
message("VS static analysis enabled!")
|
||||
add_compile_flags("/analyze")
|
||||
add_compile_options(/analyze)
|
||||
elseif(_PREFAST_)
|
||||
message("PREFAST enabled!")
|
||||
set(CMAKE_C_COMPILE_OBJECT "prefast <CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <INCLUDES> <FLAGS> <DEFINES> /Fo<OBJECT> -c <SOURCE>${CMAKE_END_TEMP_FILE}"
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
|
||||
include_directories(include/internal/mingw-w64)
|
||||
|
||||
if(NOT MSVC)
|
||||
add_compile_flags("-Wno-main")
|
||||
if(LTCG)
|
||||
add_compile_flags("-fno-lto")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(APPEND MSVCRTEX_SOURCE
|
||||
startup/crtexe.c
|
||||
startup/wcrtexe.c
|
||||
|
@ -102,6 +95,14 @@ add_asm_files(msvcrtex_asm ${MSVCRTEX_ASM_SOURCE})
|
|||
|
||||
add_library(msvcrtex ${MSVCRTEX_SOURCE} ${msvcrtex_asm})
|
||||
target_compile_definitions(msvcrtex PRIVATE _DLL _MSVCRTEX_)
|
||||
|
||||
if ((NOT MSVC) OR USE_CLANG_CL)
|
||||
target_compile_options(msvcrtex PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wno-main>)
|
||||
if (LTCG)
|
||||
target_compile_options(msvcrtex PRIVATE -fno-lto)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_source_files_properties(startup/crtdll.c PROPERTIES COMPILE_DEFINITIONS CRTDLL)
|
||||
set_source_files_properties(startup/crtexe.c
|
||||
startup/wcrtexe.c PROPERTIES COMPILE_DEFINITIONS _M_CEE_PURE)
|
||||
|
|
|
@ -62,8 +62,6 @@ add_library(lwip ${SOURCE})
|
|||
add_dependencies(lwip bugcodes xdk)
|
||||
add_pch(lwip precomp.h SOURCE)
|
||||
|
||||
if(NOT MSVC)
|
||||
if(LTCG)
|
||||
add_compile_flags("-fno-builtin-malloc -fno-builtin-free")
|
||||
endif()
|
||||
if((NOT MSVC) AND LTCG)
|
||||
target_compile_options(lwip PRIVATE -fno-builtin-malloc -fno-builtin-free)
|
||||
endif()
|
||||
|
|
|
@ -12,11 +12,10 @@ if(MSVC)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
# Disable warning " unary minus operator applied to unsigned type, result still unsigned"
|
||||
add_compile_flags("/wd4146")
|
||||
|
||||
# Disable warning "'=': conversion from 'a' to 'b', possible loss of data"
|
||||
add_compile_flags("/wd4244")
|
||||
# Disable warnings
|
||||
add_compile_options(
|
||||
/wd4146 # " unary minus operator applied to unsigned type, result still unsigned"
|
||||
/wd4244) # "'=': conversion from 'a' to 'b', possible loss of data"
|
||||
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Reference in a new issue