src/platform/qt/CMakeLists.txt (view raw)
1cmake_minimum_required(VERSION 2.8.11)
2enable_language(CXX)
3
4set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11")
5
6if(BUILD_SDL)
7 if(NOT SDL_FOUND AND NOT SDL2_FOUND)
8 find_package(SDL 1.2 REQUIRED)
9 endif()
10 if(SDL2_FOUND)
11 link_directories(${SDL2_LIBDIR})
12 endif()
13 set(PLATFORM_LIBRARY "${PLATFORM_LIBRARY};${SDL_LIBRARY};${SDLMAIN_LIBRARY}")
14 set(PLATFORM_SRC ${PLATFORM_SRC} ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-events.c ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-audio.c)
15 include_directories(${SDL_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/src/platform/sdl)
16endif()
17
18set(CMAKE_AUTOMOC ON)
19set(CMAKE_INCLUDE_CURRENT_DIR ON)
20
21find_package(Qt5Multimedia)
22find_package(Qt5OpenGL)
23find_package(Qt5Widgets)
24find_package(OpenGL)
25
26if(NOT Qt5OpenGL_FOUND OR NOT Qt5Widgets_FOUND OR NOT OPENGL_FOUND)
27 message(WARNING "Cannot find Qt modules")
28 set(BUILD_QT OFF PARENT_SCOPE)
29 return()
30endif()
31
32set(SOURCE_FILES
33 AudioProcessor.cpp
34 ConfigController.cpp
35 Display.cpp
36 GBAApp.cpp
37 GBAKeyEditor.cpp
38 GIFView.cpp
39 GameController.cpp
40 InputController.cpp
41 KeyEditor.cpp
42 LoadSaveState.cpp
43 LogView.cpp
44 SavestateButton.cpp
45 Window.cpp
46 VFileDevice.cpp
47 VideoView.cpp)
48
49qt5_wrap_ui(UI_FILES
50 GIFView.ui
51 LoadSaveState.ui
52 LogView.ui
53 VideoView.ui)
54
55if(BUILD_SDL)
56 list(APPEND SOURCE_FILES AudioProcessorSDL.cpp)
57elseif(Qt5Multimedia_FOUND)
58 list(APPEND SOURCE_FILES
59 AudioProcessorQt.cpp
60 AudioDevice.cpp)
61else()
62 message(WARNING "No supported audio modules found")
63 set(BUILD_QT OFF PARENT_SCOPE)
64 return()
65endif()
66
67if(USE_GDB_STUB)
68 set(SOURCE_FILES ${PLATFORM_SRC} ${SOURCE_FILES} GDBController.cpp GDBWindow.cpp)
69endif()
70set(MACOSX_BUNDLE_ICON_FILE mgba.icns)
71set(MACOSX_BUNDLE_BUNDLE_VERSION ${LIB_VERSION_STRING})
72set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
73set(MACOSX_BUNDLE_GUI_IDENTIFIER com.endrift.${BINARY_NAME}-qt)
74set_source_files_properties(${CMAKE_SOURCE_DIR}/res/mgba.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
75
76qt5_add_resources(RESOURCES resources.qrc)
77if(WIN32)
78 list(APPEND RESOURCES ${CMAKE_SOURCE_DIR}/res/mgba.rc)
79endif()
80add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${UI_FILES} ${RESOURCES})
81set_target_properties(${BINARY_NAME}-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/info.plist.in)
82
83set(QT_LIBRARIES Qt5::Widgets Qt5::OpenGL)
84if(Qt5Multimedia_FOUND)
85 list(APPEND QT_LIBRARIES Qt5::Multimedia)
86endif()
87target_link_libraries(${BINARY_NAME}-qt ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES})
88
89install(TARGETS ${BINARY_NAME}-qt RUNTIME DESTINATION bin BUNDLE DESTINATION /Applications)
90if(APPLE OR WIN32)
91 set_target_properties(${BINARY_NAME}-qt PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
92endif()
93if(APPLE AND MACDEPLOYQT)
94 add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND ${MACDEPLOYQT} ${PROJECT_NAME}.app)
95 add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND rm -r ${PROJECT_NAME}.app/Contents/Plugins/bearer)
96 add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND rm -r ${PROJECT_NAME}.app/Contents/Plugins/imageformats)
97 add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND rm -r ${PROJECT_NAME}.app/Contents/Plugins/printsupport)
98endif()