mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-27 13:36:12 +01:00
Set compiler warnings on a per-target basis
This commit is contained in:
1 parent
65165dbc55
commit
5e3d87858f
3 files changed
+6
-10
No files matched your search
@@ -2,8 +2,8 @@
|
|||||||
#
|
#
|
||||||
# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md
|
# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md
|
||||||
|
|
||||||
# Helper function to enable compiler warnings for a specific set of files
|
# Helper function to enable compiler warnings for a specific target
|
||||||
function(set_file_warnings)
|
function(set_target_warnings target)
|
||||||
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" FALSE)
|
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" FALSE)
|
||||||
|
|
||||||
set(MSVC_WARNINGS
|
set(MSVC_WARNINGS
|
||||||
@@ -97,7 +97,5 @@ function(set_file_warnings)
|
|||||||
message(AUTHOR_WARNING "No compiler warnings set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
|
message(AUTHOR_WARNING "No compiler warnings set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
foreach(WARNING ${FILE_WARNINGS})
|
target_compile_options(${target} PRIVATE ${FILE_WARNINGS})
|
||||||
set_property(SOURCE ${ARGV} APPEND_STRING PROPERTY COMPILE_FLAGS " ${WARNING}")
|
|
||||||
endforeach()
|
|
||||||
endfunction()
|
endfunction()
|
||||||
+1
-1
@@ -17,7 +17,7 @@ macro(csfml_add_library target)
|
|||||||
target_include_directories(${target} PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
target_include_directories(${target} PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
# add warnings
|
# add warnings
|
||||||
set_file_warnings(${THIS_SOURCES})
|
set_target_warnings(${target})
|
||||||
|
|
||||||
# require C11 and C++17
|
# require C11 and C++17
|
||||||
target_compile_features(${target} PUBLIC c_std_11 cxx_std_17)
|
target_compile_features(${target} PUBLIC c_std_11 cxx_std_17)
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
set(SRC example.c)
|
add_executable(example example.c)
|
||||||
|
|
||||||
add_executable(example ${SRC})
|
|
||||||
target_link_libraries(example PRIVATE csfml-graphics csfml-audio)
|
target_link_libraries(example PRIVATE csfml-graphics csfml-audio)
|
||||||
set_file_warnings(${SRC})
|
set_target_warnings(example)
|
||||||
Reference in new issue
Block a user