@@ -38,10 +38,12 @@ endfunction()
3838# TARGET_COMPILE_DEFINITIONS - Compile definitions for each configuration
3939#
4040function (generate_build_configurations)
41- # These variables will be set in the parent scope
42- set (BUILD_CONFIGS "" PARENT_SCOPE)
43- set (TARGET_COMPILE_OPTIONS "$<$<NOT:$<COMPILE_LANGUAGE:ASM_MASM>>:${DEFAULT_COMPILER_FLAGS} >" PARENT_SCOPE)
44- set (TARGET_LINK_OPTIONS "${DEFAULT_EXE_LINKER_FLAGS} " "${DEFAULT_SHARED_LINKER_FLAGS} " PARENT_SCOPE)
41+ # Determine if we're using a multi-config generator (Visual Studio, Xcode) or single-config (Ninja, Makefiles)
42+ get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
43+
44+ # These variables will be built up in _LOCAL variants and set in parent scope at the end
45+ set (TARGET_COMPILE_OPTIONS_LOCAL "" )
46+ set (TARGET_LINK_OPTIONS_LOCAL "" )
4547 set (TARGET_COMPILE_DEFINITIONS_LOCAL ${TARGET_COMPILE_DEFINITIONS} )
4648
4749 # Build configs to return
@@ -78,7 +80,9 @@ function(generate_build_configurations)
7880 set (CMAKE_CXX_FLAGS_${triplet_upper} "${CMAKE_CXX_FLAGS_${triplet_upper} } ${final_compiler_flags} " CACHE STRING "" FORCE)
7981 set (CMAKE_C_FLAGS_${triplet_upper} "${CMAKE_C_FLAGS_${triplet_upper} } ${final_compiler_flags} " CACHE STRING "" FORCE)
8082
81- list (APPEND TARGET_COMPILE_OPTIONS_LOCAL "$<$<NOT:$<COMPILE_LANGUAGE:ASM_MASM>>:$<$<STREQUAL:$<CONFIG>,${triplet} >:${compiler_flags} >>" )
83+ # Combine DEFAULT_COMPILER_FLAGS with per-config flags for propagation to external consumers
84+ # This ensures both base flags (like /W3, /Zc:inline) and config-specific flags (like /O2) propagate
85+ list (APPEND TARGET_COMPILE_OPTIONS_LOCAL "$<$<NOT:$<COMPILE_LANGUAGE:ASM_MASM>>:$<$<STREQUAL:$<CONFIG>,${triplet} >:${DEFAULT_COMPILER_FLAGS} ;${compiler_flags} >>" )
8286
8387 # Set up linker flags
8488 set (linker_flags
@@ -96,13 +100,19 @@ function(generate_build_configurations)
96100 # Append to existing flags to preserve CMake's defaults (including standard libraries)
97101 set (CMAKE_EXE_LINKER_FLAGS_${triplet_upper} "${CMAKE_EXE_LINKER_FLAGS_${triplet_upper} } ${exe_linker_flags} " CACHE STRING "" FORCE)
98102 set (CMAKE_SHARED_LINKER_FLAGS_${triplet_upper} "${CMAKE_SHARED_LINKER_FLAGS_${triplet_upper} } ${shared_linker_flags} " CACHE STRING "" FORCE)
99- list (APPEND TARGET_LINK_OPTIONS_LOCAL "$<$<STREQUAL:$<CONFIG>,${triplet} >:${linker_flags} >" )
103+ # Include default linker flags for propagation to external consumers
104+ # UE4SS is a SHARED library, so use DEFAULT_SHARED_LINKER_FLAGS (which is currently empty)
105+ # But also include DEFAULT_EXE_LINKER_FLAGS (/DEBUG:FULL) for completeness
106+ list (APPEND TARGET_LINK_OPTIONS_LOCAL "$<$<STREQUAL:$<CONFIG>,${triplet} >:${DEFAULT_EXE_LINKER_FLAGS} ;${linker_flags} >" )
100107 elseif ("${CMAKE_BUILD_TYPE} " STREQUAL "${triplet} " )
101- # For single-config, append to base flags (don't use TARGET_LINK_OPTIONS to avoid duplication)
108+ # For single-config, append to base flags including DEFAULT_EXE_LINKER_FLAGS
102109 # Preserve CMake's defaults including standard libraries
103- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${exe_linker_flags} " CACHE STRING "" FORCE)
104- set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${shared_linker_flags} " CACHE STRING "" FORCE)
110+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${DEFAULT_EXE_LINKER_FLAGS} ${ exe_linker_flags} " CACHE STRING "" FORCE)
111+ set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${DEFAULT_SHARED_LINKER_FLAGS} ${ shared_linker_flags} " CACHE STRING "" FORCE)
105112 message (STATUS "Single-config: Applied ${triplet} linker flags to base CMAKE linker flags" )
113+ # Also add to TARGET_LINK_OPTIONS for propagation to external consumers
114+ list (APPEND TARGET_LINK_OPTIONS_LOCAL "${DEFAULT_EXE_LINKER_FLAGS} " )
115+ list (APPEND TARGET_LINK_OPTIONS_LOCAL "${linker_flags} " )
106116 endif ()
107117
108118 # Set platform-specific variables
0 commit comments