[build] CMake: add some compiler flags from native-utils (#6825)

This commit is contained in:
Gold856
2024-07-13 00:51:55 -04:00
committed by GitHub
parent 19c28c2a76
commit e00bb2f07b
5 changed files with 13 additions and 2 deletions

View File

@@ -30,6 +30,10 @@ include(CPack)
include(OptionValidation)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
if(MSVC)
add_compile_options(/Zc:__cplusplus)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${WPILIB_BINARY_DIR}/lib)

View File

@@ -71,6 +71,8 @@ The following build options are available:
* Set this option to the location of the archive of the OpenCV Java bindings (it should be called opencv-xxx.jar, with the x'es being version numbers). NOTE: set it to the LOCATION of the file, not the file itself!
* `NO_WERROR` (OFF Default)
* This option will disable the `-Werror` compilation flag for non-MSVC builds.
* `WPILIB_TARGET_WARNINGS`
* Add compiler flags to this option to customize compiler options like warnings.
## Build Setup

View File

@@ -134,7 +134,11 @@ if(MSVC)
else()
target_compile_options(
apriltag
PRIVATE -Wno-sign-compare -Wno-gnu-zero-variadic-macro-arguments -Wno-type-limits
PRIVATE
-Wno-sign-compare
-Wno-gnu-zero-variadic-macro-arguments
-Wno-type-limits
-Wno-format-nonliteral
)
endif()

View File

@@ -5,6 +5,7 @@ macro(wpilib_target_warnings target)
-pedantic
-Wextra
-Wno-unused-parameter
-Wformat=2
${WPILIB_TARGET_WARNINGS}
)
if(NOT NO_WERROR)

View File

@@ -151,7 +151,7 @@ target_compile_features(wpiutil PUBLIC cxx_std_20)
if(MSVC)
target_compile_options(
wpiutil
PUBLIC /permissive- /Zc:preprocessor /Zc:throwingNew /MP /bigobj
PUBLIC /permissive- /Zc:preprocessor /Zc:__cplusplus /Zc:throwingNew /MP /bigobj /utf-8
)
target_compile_definitions(wpiutil PRIVATE -D_CRT_SECURE_NO_WARNINGS)
endif()