Set compiler warnings on a per-target basis

This commit is contained in:
Chris Thrasher committed 2024-03-29 09:58:28 -05:00
1 parent 65165dbc55
commit 5e3d87858f
3 files changed
+6 -10

No files matched your search

+3 -5
View File
@@ -2,8 +2,8 @@
#
# 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
function(set_file_warnings)
# Helper function to enable compiler warnings for a specific target
function(set_target_warnings target)
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" FALSE)
set(MSVC_WARNINGS
@@ -97,7 +97,5 @@ function(set_file_warnings)
message(AUTHOR_WARNING "No compiler warnings set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
endif()
foreach(WARNING ${FILE_WARNINGS})
set_property(SOURCE ${ARGV} APPEND_STRING PROPERTY COMPILE_FLAGS " ${WARNING}")
endforeach()
target_compile_options(${target} PRIVATE ${FILE_WARNINGS})
endfunction()
+1 -1
View File
@@ -17,7 +17,7 @@ macro(csfml_add_library target)
target_include_directories(${target} PUBLIC ${PROJECT_SOURCE_DIR}/include)
# add warnings
set_file_warnings(${THIS_SOURCES})
set_target_warnings(${target})
# require C11 and C++17
target_compile_features(${target} PUBLIC c_std_11 cxx_std_17)