Skip to content

When using CMake >= 3.24 use CMAKE_COMPILE_WARNING_AS_ERROR variable instead of setting -Werror directly #2

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

Merged
merged 1 commit into from
Apr 8, 2025
Merged
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
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@
cmake_minimum_required(VERSION 3.16)
project(ffmpeg_encoder_decoder)

add_compile_options(-Wall -Wextra -Wpedantic -Werror)
add_compile_options(-Wall -Wextra -Wpedantic)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0")
option(CMAKE_COMPILE_WARNING_AS_ERROR "Treat compiler warnings as errors." ON)
mark_as_advanced(CMAKE_COMPILE_WARNING_AS_ERROR)
else()
add_compile_options(-Werror)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
Expand Down Expand Up @@ -148,4 +154,4 @@ ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
ament_export_targets(${PROJECT_NAME}Targets HAS_LIBRARY_TARGET)

ament_package(CONFIG_EXTRAS cmake/${PROJECT_NAME}-extras.cmake.in)
ament_package(CONFIG_EXTRAS cmake/${PROJECT_NAME}-extras.cmake.in)
Loading