Skip to content

Commit

Permalink
Re-enable global /LTCG on Windows.
Browse files Browse the repository at this point in the history
With /LTCGOUT: empty path it should not try generating .iobj file,
and work on both 32 bit and 64 bit build with all static libs.
  • Loading branch information
john-preston committed Feb 8, 2023
1 parent aa1e0d8 commit 17951fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
21 changes: 5 additions & 16 deletions init_target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,29 @@ function(init_target_folder target_name folder_name)
endif()
endfunction()

function(init_target target_name) # init_target(my_target [cxx_std_..] [ltcg] folder_name)
function(init_target target_name) # init_target(my_target [cxx_std_..] folder_name)
set(argslist ${ARGV})
list(REMOVE_AT argslist 0)
set(standard ${MAXIMUM_CXX_STANDARD})
foreach (entry ${argslist})
if (${entry} STREQUAL cxx_std_14 OR ${entry} STREQUAL cxx_std_11 OR ${entry} STREQUAL cxx_std_17)
set(standard ${entry})
elseif (${entry} STREQUAL ltcg)
if (WIN32 AND NOT build_win64 AND DESKTOP_APP_SPECIAL_TARGET)
target_compile_options(${target_name}
PRIVATE
$<IF:$<CONFIG:Debug>,,/GL>
)
target_link_options(${target_name}
PRIVATE
$<IF:$<CONFIG:Debug>,,/LTCG>
)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY STATIC_LIBRARY_OPTIONS "$<IF:$<CONFIG:Debug>,,/LTCG>")
endif()
else()
init_target_folder(${target_name} ${entry})
endif()
endforeach()
target_compile_features(${target_name} PRIVATE ${standard})

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set_target_properties(${target_name} PROPERTIES
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
if (WIN32 AND DESKTOP_APP_SPECIAL_TARGET)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY STATIC_LIBRARY_OPTIONS "$<IF:$<CONFIG:Debug>,,/LTCG>")
endif()

target_link_libraries(${target_name} PRIVATE desktop-app::common_options)
set_target_properties(${target_name} PROPERTIES
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_WEAK YES
XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN YES
XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES
MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>
)
if (DESKTOP_APP_SPECIAL_TARGET)
set_target_properties(${target_name} PROPERTIES
Expand Down
12 changes: 12 additions & 0 deletions options_win.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
/LARGEADDRESSAWARE # Allow more than 2 GB in 32 bit application.
)
endif()

if (DESKTOP_APP_SPECIAL_TARGET)
target_compile_options(common_options
INTERFACE
$<IF:$<CONFIG:Debug>,,/GL>
)
target_link_options(common_options
INTERFACE
$<IF:$<CONFIG:Debug>,,/LTCG>
$<IF:$<CONFIG:Debug>,,/LTCGOUT:>
)
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_definitions(common_options
INTERFACE
Expand Down

0 comments on commit 17951fb

Please sign in to comment.