Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions README-CMAKE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion apriltag/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
1 change: 1 addition & 0 deletions cmake/modules/CompileWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ macro(wpilib_target_warnings target)
-pedantic
-Wextra
-Wno-unused-parameter
-Wformat=2
${WPILIB_TARGET_WARNINGS}
)
if(NOT NO_WERROR)
Expand Down
2 changes: 1 addition & 1 deletion wpiutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading