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 Window.cpp
48 VFileDevice.cpp
49 VideoView.cpp)
50
51qt5_wrap_ui(UI_FILES
52 GIFView.ui
53 LoadSaveState.ui
54 LogView.ui
55 VideoView.ui)
56
57set(QT_LIBRARIES)
58set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5widgets5,libqt5opengl5" PARENT_SCOPE)
59if(BUILD_SDL)
60 list(APPEND SOURCE_FILES AudioProcessorSDL.cpp)
61elseif(Qt5Multimedia_FOUND)
62 list(APPEND SOURCE_FILES
63 AudioProcessorQt.cpp
64 AudioDevice.cpp)
65 list(APPEND QT_LIBRARIES Qt5::Multimedia)
66 set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5multimedia5" PARENT_SCOPE)
67else()
68 message(WARNING "No supported audio modules found")
69 set(BUILD_QT OFF PARENT_SCOPE)
70 return()
71endif()
72
73if(USE_GDB_STUB)
74 list(APPEND PLATFORM_SRC GDBController.cpp GDBWindow.cpp)
75endif()
76set(MACOSX_BUNDLE_ICON_FILE mgba.icns)
77set(MACOSX_BUNDLE_BUNDLE_VERSION ${LIB_VERSION_STRING})
78set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
79set(MACOSX_BUNDLE_GUI_IDENTIFIER com.endrift.${BINARY_NAME}-qt)
80set_source_files_properties(${CMAKE_SOURCE_DIR}/res/mgba.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
81
82qt5_add_resources(RESOURCES resources.qrc)
83if(WIN32)
84 list(APPEND RESOURCES ${CMAKE_SOURCE_DIR}/res/mgba.rc)
85endif()
86add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_FILES} ${RESOURCES})
87set_target_properties(${BINARY_NAME}-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/info.plist.in)
88
89list(APPEND QT_LIBRARIES Qt5::Widgets Qt5::OpenGL)
90target_link_libraries(${BINARY_NAME}-qt ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES})
91
92install(TARGETS ${BINARY_NAME}-qt RUNTIME DESTINATION bin BUNDLE DESTINATION /Applications)
93if(APPLE OR WIN32)
94 set_target_properties(${BINARY_NAME}-qt PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
95endif()
96if(APPLE AND MACDEPLOYQT)
97 add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND ${MACDEPLOYQT} ${PROJECT_NAME}.app)
98 add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND rm -r ${PROJECT_NAME}.app/Contents/Plugins/bearer)
99 add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND rm -r ${PROJECT_NAME}.app/Contents/Plugins/imageformats)
100 add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND rm -r ${PROJECT_NAME}.app/Contents/Plugins/printsupport)
101endif()