Summary: X-link: https://github.com/facebook/react-native/pull/41044 The reference Clang/GCC build has a pretty strict set of warnings enabled. The reference MSVC build has less strict warnings, which can be a problem for MSVC users building at higher warning levels (e.g. React Native for Windows in OSS uses `/W4` as its baseline warning level). This bumps up the MSVC warning level to `/W4`, since we are nearly clean already. There are some limitations. E.g. we don't test binary with MSVC (some issues I didn't work out), and only test building statically linked. But but we do have a minimal C benchmark we compile with MSVC. Pull Request resolved: https://github.com/facebook/yoga/pull/1432 Test Plan: GitHub Actions running benchmark MSVC build. Reviewed By: yungsters Differential Revision: D50398443 Pulled By: NickGerleman fbshipit-source-id: 6616034d79b1a308b32d5d3387bae70f40b7b5ab
53 lines
1.4 KiB
CMake
53 lines
1.4 KiB
CMake
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
#
|
|
# This source code is licensed under the MIT license found in the
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
add_compile_definitions($<$<CONFIG:DEBUG>:DEBUG>)
|
|
|
|
if(MSVC)
|
|
|
|
add_compile_options(
|
|
# Don't omit frame pointers (e.g. for crash dumps)
|
|
/Oy-
|
|
# "Standard C++ exception handling" (C++ stack unwinding including extern c)
|
|
/EHsc
|
|
# Enable warnings and warnings as errors
|
|
/W4
|
|
/WX
|
|
# Disable RTTI
|
|
$<$<COMPILE_LANGUAGE:CXX>:/GR->
|
|
# Use /O2 (Maximize Speed)
|
|
$<$<CONFIG:RELEASE>:/O2>)
|
|
|
|
else()
|
|
|
|
add_compile_options(
|
|
# Don't omit frame pointers (e.g. for crash dumps)
|
|
-fno-omit-frame-pointer
|
|
# Enable exception handling
|
|
-fexceptions
|
|
# Enable warnings and warnings as errors
|
|
-Wall
|
|
-Wextra
|
|
-Werror
|
|
-Wconversion
|
|
# Disable RTTI
|
|
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
|
|
# Use -O2 (prioritize speed)
|
|
$<$<CONFIG:RELEASE>:-O2>
|
|
# Enable separate sections per function/data item
|
|
$<$<CONFIG:RELEASE>:-ffunction-sections>
|
|
$<$<CONFIG:RELEASE>:-fdata-sections>)
|
|
|
|
add_link_options(
|
|
# Discard unused sections
|
|
$<$<CONFIG:RELEASE>:$<$<CXX_COMPILER_ID:Clang,GNU>:-Wl,--gc-sections>>
|
|
$<$<CONFIG:RELEASE>:$<$<CXX_COMPILER_ID:AppleClang>:-Wl,-dead_strip>>)
|
|
|
|
endif()
|