Skip to content

Commit 04ae649

Browse files
traversaroberndpfrommer
authored andcommitted
When using CMake >= 3.24 use CMAKE_COMPILE_WARNING_AS_ERROR variable
1 parent 129e027 commit 04ae649

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616
cmake_minimum_required(VERSION 3.16)
1717
project(ffmpeg_encoder_decoder)
1818

19-
add_compile_options(-Wall -Wextra -Wpedantic -Werror)
19+
add_compile_options(-Wall -Wextra -Wpedantic)
20+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0")
21+
option(CMAKE_COMPILE_WARNING_AS_ERROR "Treat compiler warnings as errors." ON)
22+
mark_as_advanced(CMAKE_COMPILE_WARNING_AS_ERROR)
23+
else()
24+
add_compile_options(-Werror)
25+
endif()
2026

2127
# find dependencies
2228
find_package(ament_cmake REQUIRED)
@@ -148,4 +154,4 @@ ament_export_include_directories(include)
148154
ament_export_libraries(${PROJECT_NAME})
149155
ament_export_targets(${PROJECT_NAME}Targets HAS_LIBRARY_TARGET)
150156

151-
ament_package(CONFIG_EXTRAS cmake/${PROJECT_NAME}-extras.cmake.in)
157+
ament_package(CONFIG_EXTRAS cmake/${PROJECT_NAME}-extras.cmake.in)

0 commit comments

Comments
 (0)