Skip to content
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
8 changes: 3 additions & 5 deletions cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion cmake/Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
set(SRC example.c)

add_executable(example ${SRC})
add_executable(example example.c)
target_link_libraries(example PRIVATE csfml-graphics csfml-audio)
set_file_warnings(${SRC})
set_target_warnings(example)