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(APPLE)
7 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7")
8 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
9 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
10 endif()
11endif()
12
13set(PLATFORM_SRC)
14
15if(BUILD_SDL)
16 if(NOT SDL_FOUND AND NOT SDL2_FOUND)
17 find_package(SDL 1.2 REQUIRED)
18 endif()
19 if(SDL2_FOUND)
20 link_directories(${SDL2_LIBDIR})
21 endif()
22 list(APPEND PLATFORM_LIBRARY ${SDL_LIBRARY} ${SDLMAIN_LIBRARY})
23 list(APPEND PLATFORM_SRC ${PLATFORM_SRC} ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-events.c ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-audio.c)
24 include_directories(${SDL_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/src/platform/sdl)
25endif()
26
27set(CMAKE_AUTOMOC ON)
28set(CMAKE_INCLUDE_CURRENT_DIR ON)
29
30find_package(Qt5Multimedia)
31find_package(Qt5OpenGL)
32find_package(Qt5Widgets)
33find_package(OpenGL)
34
35if(NOT Qt5OpenGL_FOUND OR NOT Qt5Widgets_FOUND OR NOT OPENGL_FOUND)
36 message(WARNING "Cannot find Qt modules")
37 set(BUILD_QT OFF PARENT_SCOPE)
38 return()
39endif()
40
41set(SOURCE_FILES
42 AudioProcessor.cpp
43 CheatsModel.cpp
44 CheatsView.cpp
45 ConfigController.cpp
46 Display.cpp
47 DisplayGL.cpp
48 DisplayQt.cpp
49 GBAApp.cpp
50 GBAKeyEditor.cpp
51 GIFView.cpp
52 GameController.cpp
53 GamepadAxisEvent.cpp
54 GamepadButtonEvent.cpp
55 InputController.cpp
56 KeyEditor.cpp
57 LoadSaveState.cpp
58 LogView.cpp
59 MemoryModel.cpp
60 MemoryView.cpp
61 MultiplayerController.cpp
62 OverrideView.cpp
63 PaletteView.cpp
64 SavestateButton.cpp
65 SensorView.cpp
66 SettingsView.cpp
67 ShortcutController.cpp
68 ShortcutView.cpp
69 Swatch.cpp
70 Window.cpp
71 VFileDevice.cpp
72 VideoView.cpp)
73
74qt5_wrap_ui(UI_FILES
75 CheatsView.ui
76 GIFView.ui
77 LoadSaveState.ui
78 LogView.ui
79 MemoryView.ui
80 OverrideView.ui
81 PaletteView.ui
82 SensorView.ui
83 SettingsView.ui
84 ShortcutView.ui
85 VideoView.ui)
86
87set(QT_LIBRARIES)
88set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5widgets5,libqt5opengl5")
89
90set(AUDIO_SRC)
91if(BUILD_SDL)
92 list(APPEND AUDIO_SRC AudioProcessorSDL.cpp)
93endif()
94
95if(Qt5Multimedia_FOUND)
96 list(APPEND AUDIO_SRC
97 AudioProcessorQt.cpp
98 AudioDevice.cpp)
99 list(APPEND QT_LIBRARIES Qt5::Multimedia)
100 add_definitions(-DBUILD_QT_MULTIMEDIA)
101 set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5multimedia5")
102endif()
103
104if(NOT AUDIO_SRC)
105 message(WARNING "No supported audio modules found")
106 set(BUILD_QT OFF PARENT_SCOPE)
107 return()
108endif()
109
110if(USE_GDB_STUB)
111 list(APPEND PLATFORM_SRC GDBController.cpp GDBWindow.cpp)
112endif()
113set(MACOSX_BUNDLE_ICON_FILE mgba.icns)
114set(MACOSX_BUNDLE_BUNDLE_VERSION ${LIB_VERSION_STRING})
115set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
116set(MACOSX_BUNDLE_GUI_IDENTIFIER com.endrift.${BINARY_NAME}-qt)
117set_source_files_properties(${CMAKE_SOURCE_DIR}/res/mgba.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
118
119qt5_add_resources(RESOURCES resources.qrc)
120if(WIN32)
121 configure_file(${CMAKE_SOURCE_DIR}/res/mgba.rc.in ${CMAKE_BINARY_DIR}/res/mgba.rc)
122 list(APPEND RESOURCES ${CMAKE_BINARY_DIR}/res/mgba.rc)
123endif()
124add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_FILES} ${AUDIO_SRC} ${RESOURCES})
125set_target_properties(${BINARY_NAME}-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/info.plist.in COMPILE_DEFINITIONS "${FEATURE_DEFINES}")
126
127list(APPEND QT_LIBRARIES Qt5::Widgets Qt5::OpenGL)
128target_link_libraries(${BINARY_NAME}-qt ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES})
129set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}" PARENT_SCOPE)
130
131install(TARGETS ${BINARY_NAME}-qt
132 RUNTIME DESTINATION bin COMPONENT ${BINARY_NAME}-qt
133 BUNDLE DESTINATION Applications COMPONENT ${BINARY_NAME}-qt)
134if(APPLE OR WIN32)
135 set_target_properties(${BINARY_NAME}-qt PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
136endif()
137if(APPLE)
138 set(DEPLOY_OPTIONS -p platforms/libqcocoa.dylib,audio/libqtaudio_coreaudio.dylib)
139 if(NOT CMAKE_INSTALL_NAME_TOOL EQUAL "install_name_tool")
140 set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -I ${CMAKE_INSTALL_NAME_TOOL})
141 endif()
142 if(DEFINED CMAKE_OTOOL AND NOT CMAKE_OTOOL EQUAL "otool")
143 set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -O ${CMAKE_OTOOL})
144 endif()
145 if(DEFINED CROSS_ROOT)
146 set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -R ${CROSS_ROOT})
147 endif()
148 add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND ${CMAKE_SOURCE_DIR}/tools/deploy-mac.py ${DEPLOY_OPTIONS} ${PROJECT_NAME}.app)
149endif()