mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
[CMAKE] MSVC cmake settings improvements.
- Always use string pooling when building: this helps reducing the size of the binaries due to string redundancy coming from the usage of __FILE__ / __RELFILE__ in the debugging helper macros. Note also that GCC builds use string pooling by default. - Use suitable add_compile_flags() command. - Add some explanative comments for some settings. Some numbers (obtained with my local builds): Before / After => Reduction =========================== freeldr.sys : 443 KB ( 453.632 bytes) / 364 KB ( 372.736 bytes) => ~ 18% win32k.sys : 1877 KB (1.922.048 bytes) / 1562 KB (1.599.488 bytes) => ~ 17% ntoskrnl.exe : 2253 KB (2.307.072 bytes) / 1902 KB (1.947.136 bytes) => ~ 15.6% kernel32.dll : 3008 KB (3.080.192 bytes) / 2906 KB (2.975.744 bytes) => ~ 3.4%
This commit is contained in:
parent
363f5f26b1
commit
5e673f3118
3 changed files with 21 additions and 10 deletions
|
@ -6,7 +6,7 @@ set(OARCH "athlon64" CACHE STRING
|
|||
"Generate instructions for this CPU type. Specify one of:
|
||||
k8 opteron athlon64 athlon-fx")
|
||||
|
||||
set (OPTIMIZE "1" CACHE STRING
|
||||
set(OPTIMIZE "1" CACHE STRING
|
||||
"What level of optimization to use.
|
||||
0 = off
|
||||
1 = Default option, optimize for size (-Os) with some additional options
|
||||
|
|
|
@ -7,7 +7,7 @@ set(OARCH "armv7-a" CACHE STRING
|
|||
"Generate instructions for this CPU type. Specify one of:
|
||||
armv5te armv7-a")
|
||||
|
||||
set (OPTIMIZE "1" CACHE STRING
|
||||
set(OPTIMIZE "1" CACHE STRING
|
||||
"What level of optimization to use.
|
||||
0 = off
|
||||
1 = Default option, optimize for size (-Os) with some additional options
|
||||
|
|
|
@ -7,17 +7,22 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
|||
add_compile_flags("/Ox /Ob2 /Ot /Oy /GT /GF")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF /OPT:ICF")
|
||||
elseif(OPTIMIZE STREQUAL "1")
|
||||
add_definitions(/O1)
|
||||
add_compile_flags("/O1")
|
||||
elseif(OPTIMIZE STREQUAL "2")
|
||||
add_definitions(/O2)
|
||||
add_compile_flags("/O2")
|
||||
elseif(OPTIMIZE STREQUAL "3")
|
||||
add_definitions(/Ot /Ox /GS-)
|
||||
add_compile_flags("/Ot /Ox /GS-")
|
||||
elseif(OPTIMIZE STREQUAL "4")
|
||||
add_definitions(/Os /Ox /GS-)
|
||||
add_compile_flags("/Os /Ox /GS-")
|
||||
elseif(OPTIMIZE STREQUAL "5")
|
||||
add_definitions(/GF /Gy /Ob2 /Os /Ox /GS-)
|
||||
add_compile_flags("/GF /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")
|
||||
|
||||
# Enable function level linking and comdat folding
|
||||
add_compile_flags("/Gy")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:REF /OPT:ICF")
|
||||
|
@ -29,11 +34,14 @@ endif()
|
|||
|
||||
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")
|
||||
endif()
|
||||
|
||||
add_compile_flags("/GR- /EHs-c- /GS- /W3")
|
||||
# Disable RTTI, exception handling and buffer security checks by default.
|
||||
# These require run-time support that may not always be available.
|
||||
add_compile_flags("/GR- /EHs-c- /GS-")
|
||||
|
||||
if(USE_CLANG_CL)
|
||||
set(CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file: ")
|
||||
|
@ -55,6 +63,9 @@ if(MSVC_VERSION GREATER 1899)
|
|||
add_compile_flags("/Zc:threadSafeInit-")
|
||||
endif ()
|
||||
|
||||
# Generate Warnings Level 3
|
||||
add_compile_flags("/W3")
|
||||
|
||||
# Disable overly sensitive warnings as well as those that generally aren't
|
||||
# useful to us.
|
||||
# - C4244: implicit integer truncation
|
||||
|
@ -381,7 +392,7 @@ function(generate_import_lib _libname _dllname _spec_file)
|
|||
# Add our library
|
||||
if(MSVC_IDE)
|
||||
add_library(${_libname} STATIC EXCLUDE_FROM_ALL ${_asm_stubs_file}.obj)
|
||||
set_source_files_properties(${_asm_stubs_file}.obj PROPERTIES EXTERNAL_OBJECT 1)
|
||||
set_source_files_properties(${_asm_stubs_file}.obj PROPERTIES EXTERNAL_OBJECT TRUE)
|
||||
set_target_properties(${_libname} PROPERTIES LINKER_LANGUAGE "C")
|
||||
else()
|
||||
# NOTE: as stub file and def file are generated in one pass, depending on one is like depending on the other
|
||||
|
@ -522,7 +533,7 @@ macro(add_asm_files _target)
|
|||
OUTPUT ${_preprocessed_asm_file} ${_object_file}
|
||||
COMMAND cl /nologo /X /I${REACTOS_SOURCE_DIR}/sdk/include/asm /I${REACTOS_BINARY_DIR}/sdk/include/asm ${_directory_includes} ${_source_file_defines} ${_directory_defines} /D__ASM__ /D_USE_ML /EP /c ${_source_file_full_path} > ${_preprocessed_asm_file} && ${_pp_asm_compile_command}
|
||||
DEPENDS ${_source_file_full_path})
|
||||
set_source_files_properties(${_object_file} PROPERTIES EXTERNAL_OBJECT 1)
|
||||
set_source_files_properties(${_object_file} PROPERTIES EXTERNAL_OBJECT TRUE)
|
||||
list(APPEND ${_target} ${_object_file})
|
||||
endforeach()
|
||||
else()
|
||||
|
|
Loading…
Reference in a new issue