diff --git a/validate_special_target.cmake b/validate_special_target.cmake index dc55e50..00f180d 100644 --- a/validate_special_target.cmake +++ b/validate_special_target.cmake @@ -4,19 +4,58 @@ # For license and copyright information please follow this link: # https://github.com/desktop-app/legal/blob/master/LEGAL +include(CMakeDependentOption) + set(DESKTOP_APP_SPECIAL_TARGET "" CACHE STRING "Use special platform target, like 'macstore' for Mac App Store.") -set(no_special_target 0) -if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "") - set(no_special_target 1) -endif() -option(DESKTOP_APP_USE_PACKAGED "Find libraries using CMake instead of exact paths." ${no_special_target}) +set(build_macstore 0) +set(build_winstore 0) # 32 or 64 bit +set(build_win64 0) # normal or uwp +set(build_winstore64 0) -set(default_to_qt6 1) if (WIN32) - set(default_to_qt6 0) + if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "win64") + set(build_win64 1) + elseif (DESKTOP_APP_SPECIAL_TARGET STREQUAL "uwp") + set(build_winstore 1) + elseif (DESKTOP_APP_SPECIAL_TARGET STREQUAL "uwp64") + set(build_win64 1) + set(build_winstore 1) + set(build_winstore64 1) + elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(build_win64 1) + endif() +elseif (APPLE) + if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "macstore") + set(build_macstore 1) + endif() +else() + if (DESKTOP_APP_SPECIAL_TARGET) + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(CMAKE_AR "gcc-ar") + set(CMAKE_RANLIB "gcc-ranlib") + set(CMAKE_NM "gcc-nm") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(CMAKE_AR "llvm-ar") + set(CMAKE_RANLIB "llvm-ranlib") + set(CMAKE_NM "llvm-nm") + endif() + endif() endif() -option(DESKTOP_APP_QT6 "Build with Qt 6" ${default_to_qt6}) + +if (build_win64) + get_filename_component(libs_loc "../Libraries/win64" REALPATH) +else() + get_filename_component(libs_loc "../Libraries" REALPATH) +endif() + +set(libs_loc_exists 0) +if (EXISTS ${libs_loc}) + set(libs_loc_exists 1) +endif() + +cmake_dependent_option(DESKTOP_APP_USE_PACKAGED "Find libraries using CMake instead of exact paths." OFF libs_loc_exists ON) +cmake_dependent_option(DESKTOP_APP_QT6 "Build with Qt 6." ON "NOT WIN32" OFF) function(report_bad_special_target) if (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "") diff --git a/variables.cmake b/variables.cmake index 0f4f412..9a201fb 100644 --- a/variables.cmake +++ b/variables.cmake @@ -4,6 +4,8 @@ # For license and copyright information please follow this link: # https://github.com/desktop-app/legal/blob/master/LEGAL +include(CMakeDependentOption) + set(no_special_target 0) if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "") set(no_special_target 1) @@ -18,30 +20,28 @@ if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "" endif() option(DESKTOP_APP_LOTTIE_USE_CACHE "Use caching in lottie animations." ON) -option(DESKTOP_APP_DISABLE_DBUS_INTEGRATION "Disable all code for D-Bus integration (Linux only)." OFF) -option(DESKTOP_APP_DISABLE_X11_INTEGRATION "Disable all code for X11 integration (Linux only)." OFF) -option(DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION "Disable all code for Wayland integration (Linux only)." OFF) -option(DESKTOP_APP_USE_ALLOCATION_TRACER "Use simple allocation tracer (Linux only)." OFF) -option(DESKTOP_APP_USE_PACKAGED_LAZY "Bundle recommended Qt plugins for self-contained packages. (Linux only)" OFF) +cmake_dependent_option(DESKTOP_APP_DISABLE_DBUS_INTEGRATION "Disable all code for D-Bus integration." OFF LINUX ON) +cmake_dependent_option(DESKTOP_APP_DISABLE_X11_INTEGRATION "Disable all code for X11 integration." OFF LINUX ON) +# QtWaylandScanner cmake integration from Qt 6 is used +cmake_dependent_option(DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION "Disable all code for Wayland integration." OFF "LINUX; DESKTOP_APP_QT6" ON) +cmake_dependent_option(DESKTOP_APP_USE_ALLOCATION_TRACER "Use simple allocation tracer." OFF LINUX OFF) +cmake_dependent_option(DESKTOP_APP_USE_PACKAGED_LAZY "Bundle recommended Qt plugins for self-contained packages." OFF LINUX OFF) option(DESKTOP_APP_USE_PACKAGED_FONTS "Use preinstalled fonts instead of bundled patched ones." OFF) option(DESKTOP_APP_USE_PACKAGED_RLOTTIE "Find rlottie using CMake instead of bundled patched one." OFF) option(DESKTOP_APP_DISABLE_SPELLCHECK "Disable spellcheck library." OFF) option(DESKTOP_APP_DISABLE_CRASH_REPORTS "Disable crash report generation." ${no_special_target}) option(DESKTOP_APP_DISABLE_AUTOUPDATE "Disable autoupdate." ${disable_autoupdate}) 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_NO_PDB "Disable PDB file generation. (Windows only)" OFF) -option(DESKTOP_APP_DISABLE_JEMALLOC "Disable jemalloc, use system malloc (Linux only)." OFF) +cmake_dependent_option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell." OFF LINUX OFF) +cmake_dependent_option(DESKTOP_APP_NO_PDB "Disable PDB file generation." OFF WIN32 OFF) +cmake_dependent_option(DESKTOP_APP_DISABLE_JEMALLOC "Disable jemalloc, use system malloc." OFF LINUX OFF) -if (DESKTOP_APP_USE_PACKAGED AND DEFINED CMAKE_OSX_ARCHITECTURES) - set(DESKTOP_APP_MAC_ARCH "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING "Target macOS arch. (macOS only)") -else() - set(DESKTOP_APP_MAC_ARCH "x86_64;arm64" CACHE STRING "Target macOS arch. (macOS only)") -endif() - -# QtWaylandScanner cmake integration from Qt 6 is used -if (NOT DESKTOP_APP_QT6) - set(DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION ON) +if (APPLE) + if (DESKTOP_APP_USE_PACKAGED AND DEFINED CMAKE_OSX_ARCHITECTURES) + set(DESKTOP_APP_MAC_ARCH "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING "Target macOS arch.") + else() + set(DESKTOP_APP_MAC_ARCH "x86_64;arm64" CACHE STRING "Target macOS arch.") + endif() endif() set(add_hunspell_library 0) @@ -51,44 +51,3 @@ if ((WIN32 AND NOT DESKTOP_APP_DISABLE_SPELLCHECK) set(add_hunspell_library 1) endif() - -set(build_macstore 0) -set(build_winstore 0) # 32 or 64 bit -set(build_win64 0) # normal or uwp -set(build_winstore64 0) - -if (WIN32) - if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "win64") - set(build_win64 1) - elseif (DESKTOP_APP_SPECIAL_TARGET STREQUAL "uwp") - set(build_winstore 1) - elseif (DESKTOP_APP_SPECIAL_TARGET STREQUAL "uwp64") - set(build_win64 1) - set(build_winstore 1) - set(build_winstore64 1) - elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) - set(build_win64 1) - endif() -elseif (APPLE) - if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "macstore") - set(build_macstore 1) - endif() -else() - if (DESKTOP_APP_SPECIAL_TARGET) - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(CMAKE_AR "gcc-ar") - set(CMAKE_RANLIB "gcc-ranlib") - set(CMAKE_NM "gcc-nm") - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(CMAKE_AR "llvm-ar") - set(CMAKE_RANLIB "llvm-ranlib") - set(CMAKE_NM "llvm-nm") - endif() - endif() -endif() - -if (build_win64) - get_filename_component(libs_loc "../Libraries/win64" REALPATH) -else() - get_filename_component(libs_loc "../Libraries" REALPATH) -endif()