fix and simplify windows static build

This commit is contained in:
Nadia Holmquist Pedersen 2022-05-03 19:47:31 +02:00
parent 567bbeae6a
commit 277c7f6172
1 changed files with 7 additions and 26 deletions

View File

@ -56,27 +56,9 @@ if (WIN32)
endif()
if (USE_QT6)
if (BUILD_STATIC AND QT6_STATIC_DIR)
set(QT6_STATIC_BASE ${QT6_STATIC_DIR}/lib/cmake/Qt6)
set(Qt6_DIR ${QT6_STATIC_BASE})
set(Qt6Core_DIR ${QT6_STATIC_BASE}Core)
set(Qt6Gui_DIR ${QT6_STATIC_BASE}Gui)
set(Qt6Widgets_DIR ${QT6_STATIC_BASE}Widgets)
set(Qt6Network_DIR ${QT6_STATIC_BASE}Network)
set(Qt6OpenGL_DIR ${QT6_STATIC_BASE}OpenGL)
set(Qt6OpenGLWidgets_DIR ${QT6_STATIC_BASE}OpenGLWidgets)
endif()
find_package(Qt6 COMPONENTS Core Gui Widgets Network OpenGL OpenGLWidgets REQUIRED)
set(QT_LINK_LIBS Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Network Qt6::OpenGL Qt6::OpenGLWidgets)
else()
if (BUILD_STATIC AND QT5_STATIC_DIR)
set(QT5_STATIC_BASE ${QT5_STATIC_DIR}/lib/cmake/Qt5)
set(Qt5_DIR ${QT5_STATIC_BASE})
set(Qt5Core_DIR ${QT5_STATIC_BASE}Core)
set(Qt5Gui_DIR ${QT5_STATIC_BASE}Gui)
set(Qt5Widgets_DIR ${QT5_STATIC_BASE}Widgets)
set(Qt5Network_DIR ${QT5_STATIC_BASE}Network)
endif()
find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED)
set(QT_LINK_LIBS Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Network)
endif()
@ -85,6 +67,10 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
if (BUILD_STATIC)
list(APPEND PKG_CONFIG_EXECUTABLE "--static")
endif()
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(Iconv REQUIRED)
@ -112,6 +98,7 @@ target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../..")
target_link_libraries(melonDS PRIVATE core)
target_link_libraries(melonDS PRIVATE PkgConfig::SDL2 PkgConfig::Slirp PkgConfig::LibArchive)
target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS} ${CMAKE_DL_LIBS})
if (NOT Iconv_IS_BUILT_IN)
target_link_libraries(melonDS PRIVATE Iconv::Iconv)
@ -119,19 +106,13 @@ endif()
if (UNIX)
option(PORTABLE "Make a portable build that looks for its configuration in the current directory" OFF)
target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS} ${CMAKE_DL_LIBS})
elseif (WIN32)
option(PORTABLE "Make a portable build that looks for its configuration in the current directory" ON)
configure_file("${CMAKE_SOURCE_DIR}/res/melon.rc.in" "${CMAKE_SOURCE_DIR}/melon.rc")
target_sources(melonDS PUBLIC "${CMAKE_SOURCE_DIR}/melon.rc")
target_link_libraries(melonDS PRIVATE comctl32 d2d1 dwrite uxtheme ws2_32 iphlpapi gdi32)
if (BUILD_STATIC)
target_link_libraries(melonDS PRIVATE imm32 winmm version setupapi -static z zstd ${QT_LINK_LIBS})
else()
target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS})
endif()
target_link_libraries(melonDS PRIVATE ws2_32 iphlpapi)
endif()
if (PORTABLE)