From 068bbba570e192139c287c7934b1ab6ef2dad037 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Thu, 5 Mar 2026 18:16:55 +0500 Subject: [PATCH] change: use BUILDSYSTEM_TARGETS to apply warnings Co-authored-by: Seth Flynn Signed-off-by: Octol1ttle --- launcher/CMakeLists.txt | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 4de4f5474..133016978 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -1319,14 +1319,6 @@ if(WIN32) set(LAUNCHER_RCS ${CMAKE_CURRENT_BINARY_DIR}/../${Launcher_Branding_WindowsRC}) endif() -function(enable_warnings TARGET) - if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") - target_compile_options(${TARGET} PRIVATE /W4 /WX /permissive-) - else() - target_compile_options(${TARGET} PRIVATE -Wall -Wextra -Wpedantic -Werror) - endif() -endfunction() - ######## Precompiled Headers ########### if(${Launcher_USE_PCH}) @@ -1342,17 +1334,9 @@ endif() # Add executable add_library(Launcher_logic STATIC ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${LAUNCHER_UI} ${LAUNCHER_RESOURCES}) -enable_warnings(Launcher_logic) target_include_directories(Launcher_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_definitions(Launcher_logic PUBLIC LAUNCHER_APPLICATION) -# Disable some warnings due to being present in a lot of places. TODO: Fix them. -if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") - target_compile_options(Launcher_logic PRIVATE /wd4100) # C4100 - unused parameter -else() - target_compile_options(Launcher_logic PRIVATE -Wno-unused-parameter -Wno-missing-field-initializers) -endif() - if(${Launcher_USE_PCH}) target_precompile_headers(Launcher_logic PRIVATE ${PRECOMPILED_HEADERS}) endif() @@ -1470,7 +1454,6 @@ endif() if(Launcher_BUILD_UPDATER) # Updater add_library(prism_updater_logic STATIC ${PRISMUPDATER_SOURCES} ${TASKS_SOURCES} ${PRISMUPDATER_UI}) - enable_warnings(prism_updater_logic) target_include_directories(prism_updater_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) if(${Launcher_USE_PCH}) @@ -1523,7 +1506,6 @@ endif() if(WIN32 OR (DEFINED Launcher_BUILD_FILELINKER AND Launcher_BUILD_FILELINKER)) # File link add_library(filelink_logic STATIC ${LINKEXE_SOURCES}) - enable_warnings(filelink_logic) target_include_directories(filelink_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) @@ -1583,6 +1565,26 @@ if (UNIX AND APPLE AND Launcher_ENABLE_UPDATER) install(DIRECTORY ${MACOSX_SPARKLE_DIR}/Sparkle.framework DESTINATION ${FRAMEWORK_DEST_DIR} USE_SOURCE_PERMISSIONS) endif() +# Set basic compiler warning/error flags for all targets +get_property(Launcher_TARGETS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS) +foreach(target ${Launcher_TARGETS}) + message(STATUS "Enabling all warnings as errors for target '${target}'") + if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") + target_compile_options(${target} PRIVATE /W4 /WX /permissive-) + else() + target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic -Werror) + endif() +endforeach() + +# Disable some warnings in main launcher target due to being present in a lot of places. TODO: Fix them. +if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") + target_compile_options(Launcher_logic PRIVATE /wd4100) # C4100 - unused parameter + target_compile_options(${Launcher_Name} PRIVATE /wd4100) # C4100 - unused parameter +else() + target_compile_options(Launcher_logic PRIVATE -Wno-unused-parameter -Wno-missing-field-initializers) + target_compile_options(${Launcher_Name} PRIVATE -Wno-unused-parameter -Wno-missing-field-initializers) +endif() + #### The bundle mess! #### # Bundle utilities are used to complete packages for different platforms - they add all the libraries that would otherwise be missing on the target system. # NOTE: it seems that this absolutely has to be here, and nowhere else.