1
0
Fork 0

Add DESKTOP_APP_USE_PACKAGED support for Windows

This commit is contained in:
Ilya Fedin 2020-05-09 21:59:36 +04:00 committed by John Preston
parent a10bb86dcd
commit 4ea254886e
7 changed files with 59 additions and 33 deletions

View file

@ -7,7 +7,7 @@
add_library(external_auto_updates INTERFACE IMPORTED GLOBAL) add_library(external_auto_updates INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_auto_updates ALIAS external_auto_updates) add_library(desktop-app::external_auto_updates ALIAS external_auto_updates)
if (WIN32) if (WIN32 AND NOT DESKTOP_APP_USE_PACKAGED)
add_subdirectory(lzma) add_subdirectory(lzma)
target_link_libraries(external_auto_updates target_link_libraries(external_auto_updates
INTERFACE INTERFACE

View file

@ -12,7 +12,7 @@ if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
pkg_check_modules(MINIZIP REQUIRED IMPORTED_TARGET minizip) pkg_check_modules(MINIZIP REQUIRED IMPORTED_TARGET minizip)
target_link_libraries(external_minizip INTERFACE PkgConfig::MINIZIP) target_link_libraries(external_minizip INTERFACE PkgConfig::MINIZIP)
elseif (NOT WIN32) elseif (NOT WIN32 OR DESKTOP_APP_USE_PACKAGED_LAZY)
add_library(external_minizip_bundled STATIC) add_library(external_minizip_bundled STATIC)
init_target(external_minizip_bundled "(external)") init_target(external_minizip_bundled "(external)")

View file

@ -15,12 +15,12 @@ else()
INTERFACE INTERFACE
${third_party_loc}/range-v3/include ${third_party_loc}/range-v3/include
) )
endif()
if (WIN32) if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(external_ranges target_compile_options(external_ranges
INTERFACE INTERFACE
/experimental:preprocessor # need for range-v3 see https://github.com/ericniebler/range-v3#supported-compilers /experimental:preprocessor # need for range-v3 see https://github.com/ericniebler/range-v3#supported-compilers
/wd5105 # needed for `/experimental:preprocessor`, suppressing C5105 "macro expansion producing 'defined' has undefined behavior" /wd5105 # needed for `/experimental:preprocessor`, suppressing C5105 "macro expansion producing 'defined' has undefined behavior"
) )
endif()
endif() endif()

View file

@ -124,7 +124,7 @@ else()
) )
endif() endif()
if (WIN32) if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(external_rlottie target_compile_options(external_rlottie
PRIVATE PRIVATE
/w44244 # 'initializing': conversion from 'double' to 'float' /w44244 # 'initializing': conversion from 'double' to 'float'

View file

@ -5,7 +5,7 @@
# https://github.com/desktop-app/legal/blob/master/LEGAL # https://github.com/desktop-app/legal/blob/master/LEGAL
set(MAXIMUM_CXX_STANDARD cxx_std_20) set(MAXIMUM_CXX_STANDARD cxx_std_20)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(MAXIMUM_CXX_STANDARD cxx_std_17) set(MAXIMUM_CXX_STANDARD cxx_std_17)
endif() endif()
@ -26,7 +26,7 @@ function(init_target target_name) # init_target(my_target folder_name)
else() else()
target_compile_features(${target_name} PUBLIC ${MAXIMUM_CXX_STANDARD}) target_compile_features(${target_name} PUBLIC ${MAXIMUM_CXX_STANDARD})
endif() endif()
if (WIN32) if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set_target_properties(${target_name} PROPERTIES set_target_properties(${target_name} PROPERTIES
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif() endif()
@ -45,7 +45,7 @@ function(init_target target_name) # init_target(my_target folder_name)
XCODE_ATTRIBUTE_LLVM_LTO $<IF:$<CONFIG:Debug>,NO,YES> XCODE_ATTRIBUTE_LLVM_LTO $<IF:$<CONFIG:Debug>,NO,YES>
) )
endif() endif()
if (WIN32 OR DESKTOP_APP_ENABLE_IPO_OPTIMIZATIONS) if (DESKTOP_APP_ENABLE_IPO_OPTIMIZATIONS)
set_target_properties(${target_name} PROPERTIES set_target_properties(${target_name} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE True INTERPROCEDURAL_OPTIMIZATION_RELEASE True
INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO True INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO True

View file

@ -13,8 +13,9 @@ INTERFACE
UNICODE UNICODE
_UNICODE _UNICODE
) )
target_compile_options(common_options if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
INTERFACE target_compile_options(common_options
INTERFACE
/permissive- /permissive-
# /Qspectre # /Qspectre
/W1 /W1
@ -27,12 +28,37 @@ INTERFACE
/wd4068 # Disable "warning C4068: unknown pragma" /wd4068 # Disable "warning C4068: unknown pragma"
/Zc:wchar_t- # don't tread wchar_t as builtin type /Zc:wchar_t- # don't tread wchar_t as builtin type
/Zi /Zi
) )
target_link_options(common_options target_link_options(common_options
INTERFACE INTERFACE
$<IF:$<CONFIG:Debug>,/NODEFAULTLIB:LIBCMT,/DEBUG;/OPT:REF> $<IF:$<CONFIG:Debug>,/NODEFAULTLIB:LIBCMT,/DEBUG;/OPT:REF>
) )
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_definitions(common_options
INTERFACE
WINVER=0x0601
_WIN32_WINNT=0x0601
)
target_compile_options(common_options
INTERFACE
-fpermissive
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(common_options
INTERFACE
-fms-extensions
-femulated-tls
)
target_link_options(common_options
INTERFACE
-fuse-ld=lld
)
endif()
endif()
target_link_libraries(common_options target_link_libraries(common_options
INTERFACE INTERFACE

View file

@ -36,7 +36,7 @@ option(DESKTOP_APP_USE_PACKAGED_FONTS "Use preinstalled fonts instead of bundled
option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF) option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF)
option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell. (Linux only)" OFF) option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell. (Linux only)" OFF)
option(DESKTOP_APP_ENABLE_IPO_OPTIMIZATIONS "Enable IPO build optimizations." OFF) option(DESKTOP_APP_ENABLE_IPO_OPTIMIZATIONS "Enable IPO build optimizations." ${WIN32})
if (DESKTOP_APP_ENABLE_IPO_OPTIMIZATIONS AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") if (DESKTOP_APP_ENABLE_IPO_OPTIMIZATIONS AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(WARNING "Clang cannot build Qt applications with IPO enabled due to upstream bug: https://bugreports.qt.io/browse/QTBUG-61710.") message(WARNING "Clang cannot build Qt applications with IPO enabled due to upstream bug: https://bugreports.qt.io/browse/QTBUG-61710.")
set(DESKTOP_APP_ENABLE_IPO_OPTIMIZATIONS OFF) set(DESKTOP_APP_ENABLE_IPO_OPTIMIZATIONS OFF)