All: Enable static linking for Windows
Jeffrey Pfau jeffrey@endrift.com
Thu, 28 May 2015 00:20:02 -0700
5 files changed,
30 insertions(+),
4 deletions(-)
M
CHANGES
→
CHANGES
@@ -42,6 +42,7 @@ - Qt: Show version info in window title
- 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:
M
CMakeLists.txt
→
CMakeLists.txt
@@ -102,7 +102,7 @@ set(VERSION_STRING ${LIB_VERSION_ABI}-${VERSION_STRING})
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_STATIC)
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}")
M
src/platform/qt/CMakeLists.txt
→
src/platform/qt/CMakeLists.txt
@@ -11,6 +11,7 @@ endif()
endif() set(PLATFORM_SRC) +set(QT_STATIC OFF) if(BUILD_SDL) if(NOT SDL_FOUND AND NOT SDL2_FOUND)@@ -36,6 +37,12 @@ if(NOT Qt5OpenGL_FOUND OR NOT Qt5Widgets_FOUND OR NOT OPENGL_FOUND)
message(WARNING "Cannot find Qt modules") set(BUILD_QT OFF PARENT_SCOPE) 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@@ -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}")
M
src/platform/qt/main.cpp
→
src/platform/qt/main.cpp
@@ -6,6 +6,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#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();
M
src/platform/sdl/CMakeLists.txt
→
src/platform/sdl/CMakeLists.txt
@@ -31,6 +31,10 @@ add_definitions(-DUSE_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)