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