All: Enable static linking for Windows

This commit is contained in:
Jeffrey Pfau 2015-05-28 00:20:02 -07:00
parent a0624b8b4f
commit 1559438deb
5 changed files with 30 additions and 4 deletions

View File

@ -42,6 +42,7 @@ Misc:
- All: Fix sanitize-deb script to set file permissions properly if run as (fake)root
- GBA SIO: Add a dummy driver for Normal mode
- GBA: GBARewind now returns how many states it has rewound
- All: Enable static linking for Windows
0.2.1: (2015-05-13)
Bugfixes:

View File

@ -102,7 +102,7 @@ else()
endif()
endif()
add_custom_target(version ALL touch ${CMAKE_SOURCE_DIR}/src/util/version.c.in
add_custom_target(version-info ALL touch ${CMAKE_SOURCE_DIR}/src/util/version.c.in
COMMAND ${CMAKE_COMMAND}
-DGIT_COMMIT=${GIT_COMMIT}
-DGIT_COMMIT_SHORT=${GIT_COMMIT_SHORT}
@ -368,15 +368,15 @@ if(BUILD_SHARED)
add_library(${BINARY_NAME}-static STATIC ${SRC})
set_target_properties(${BINARY_NAME}-static PROPERTIES COMPILE_DEFINITIONS "${FEATURE_DEFINES}")
install(TARGETS ${BINARY_NAME}-static DESTINATION lib COMPONENT lib${BINARY_NAME})
add_dependencies(${BINARY_NAME}-static version)
add_dependencies(${BINARY_NAME}-static version-info)
endif()
else()
add_library(${BINARY_NAME} STATIC ${SRC})
endif()
add_dependencies(${BINARY_NAME} version)
add_dependencies(${BINARY_NAME} version-info)
target_link_libraries(${BINARY_NAME} m ${DEBUGGER_LIB} ${OS_LIB} ${DEPENDENCY_LIB})
target_link_libraries(${BINARY_NAME} m ${DEBUGGER_LIB} ${DEPENDENCY_LIB} ${OS_LIB})
install(TARGETS ${BINARY_NAME} DESTINATION lib COMPONENT lib${BINARY_NAME})
set_target_properties(${BINARY_NAME} PROPERTIES VERSION ${LIB_VERSION_STRING} SOVERSION ${LIB_VERSION_ABI} COMPILE_DEFINITIONS "${FEATURE_DEFINES}")

View File

@ -11,6 +11,7 @@ if(APPLE)
endif()
set(PLATFORM_SRC)
set(QT_STATIC OFF)
if(BUILD_SDL)
if(NOT SDL_FOUND AND NOT SDL2_FOUND)
@ -38,6 +39,12 @@ if(NOT Qt5OpenGL_FOUND OR NOT Qt5Widgets_FOUND OR NOT OPENGL_FOUND)
return()
endif()
get_target_property(QT_TYPE Qt5::Core TYPE)
if(QT_TYPE STREQUAL STATIC_LIBRARY)
set(QT_STATIC ON)
add_definitions(-DQT_STATIC)
endif()
set(SOURCE_FILES
AudioProcessor.cpp
CheatsModel.cpp
@ -96,6 +103,9 @@ if(Qt5Multimedia_FOUND)
list(APPEND AUDIO_SRC
AudioProcessorQt.cpp
AudioDevice.cpp)
if (WIN32 AND QT_STATIC)
list(APPEND QT_LIBRARIES qtaudio_windows strmiids winmm)
endif()
list(APPEND QT_LIBRARIES Qt5::Multimedia)
add_definitions(-DBUILD_QT_MULTIMEDIA)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5multimedia5")
@ -120,6 +130,9 @@ qt5_add_resources(RESOURCES resources.qrc)
if(WIN32)
configure_file(${CMAKE_SOURCE_DIR}/res/mgba.rc.in ${CMAKE_BINARY_DIR}/res/mgba.rc)
list(APPEND RESOURCES ${CMAKE_BINARY_DIR}/res/mgba.rc)
if(QT_STATIC)
list(APPEND QT_LIBRARIES qwindows imm32)
endif()
endif()
add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_FILES} ${AUDIO_SRC} ${RESOURCES})
set_target_properties(${BINARY_NAME}-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/info.plist.in COMPILE_DEFINITIONS "${FEATURE_DEFINES}")

View File

@ -6,6 +6,14 @@
#include "GBAApp.h"
#include "Window.h"
#ifdef QT_STATIC
#include <QtPlugin>
#ifdef _WIN32
Q_IMPORT_PLUGIN (QWindowsIntegrationPlugin);
Q_IMPORT_PLUGIN (QWindowsAudioPlugin);
#endif
#endif
int main(int argc, char* argv[]) {
QGBA::GBAApp application(argc, argv);
return application.exec();

View File

@ -31,6 +31,10 @@ if(USE_PIXMAN)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libpixman-1.0" PARENT_SCOPE)
endif()
if(WIN32)
list(APPEND SDL_LIBRARY imm32 version winmm)
endif()
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libsdl${SDL_VERSION_DEBIAN}" PARENT_SCOPE)
file(GLOB PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-*.c)