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 MultiplayerController.cpp
60 OverrideView.cpp
61 SavestateButton.cpp
62 SensorView.cpp
63 SettingsView.cpp
64 ShortcutController.cpp
65 ShortcutView.cpp
66 Window.cpp
67 VFileDevice.cpp
68 VideoView.cpp)
69
70qt5_wrap_ui(UI_FILES
71 CheatsView.ui
72 GIFView.ui
73 LoadSaveState.ui
74 LogView.ui
75 OverrideView.ui
76 SensorView.ui
77 SettingsView.ui
78 ShortcutView.ui
79 VideoView.ui)
80
81set(QT_LIBRARIES)
82set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5widgets5,libqt5opengl5" PARENT_SCOPE)
83
84set(AUDIO_SRC)
85if(BUILD_SDL)
86 list(APPEND AUDIO_SRC AudioProcessorSDL.cpp)
87endif()
88
89if(Qt5Multimedia_FOUND)
90 list(APPEND AUDIO_SRC
91 AudioProcessorQt.cpp
92 AudioDevice.cpp)
93 list(APPEND QT_LIBRARIES Qt5::Multimedia)
94 add_definitions(-DBUILD_QT_MULTIMEDIA)
95 set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5multimedia5" PARENT_SCOPE)
96endif()
97
98if(NOT AUDIO_SRC)
99 message(WARNING "No supported audio modules found")
100 set(BUILD_QT OFF PARENT_SCOPE)
101 return()
102endif()
103
104if(USE_GDB_STUB)
105 list(APPEND PLATFORM_SRC GDBController.cpp GDBWindow.cpp)
106endif()
107set(MACOSX_BUNDLE_ICON_FILE mgba.icns)
108set(MACOSX_BUNDLE_BUNDLE_VERSION ${LIB_VERSION_STRING})
109set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
110set(MACOSX_BUNDLE_GUI_IDENTIFIER com.endrift.${BINARY_NAME}-qt)
111set_source_files_properties(${CMAKE_SOURCE_DIR}/res/mgba.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
112
113qt5_add_resources(RESOURCES resources.qrc)
114if(WIN32)
115 configure_file(${CMAKE_SOURCE_DIR}/res/mgba.rc.in ${CMAKE_BINARY_DIR}/res/mgba.rc)
116 list(APPEND RESOURCES ${CMAKE_BINARY_DIR}/res/mgba.rc)
117endif()
118add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_FILES} ${AUDIO_SRC} ${RESOURCES})
119set_target_properties(${BINARY_NAME}-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/info.plist.in COMPILE_DEFINITIONS "${FEATURE_DEFINES}")
120
121list(APPEND QT_LIBRARIES Qt5::Widgets Qt5::OpenGL)
122target_link_libraries(${BINARY_NAME}-qt ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES})
123
124install(TARGETS ${BINARY_NAME}-qt
125 RUNTIME DESTINATION bin COMPONENT ${BINARY_NAME}-qt
126 BUNDLE DESTINATION Applications COMPONENT ${BINARY_NAME}-qt)
127if(APPLE OR WIN32)
128 set_target_properties(${BINARY_NAME}-qt PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
129endif()
130if(APPLE)
131 set(DEPLOY_OPTIONS -p platforms/libqcocoa.dylib,audio/libqtaudio_coreaudio.dylib)
132 if(NOT CMAKE_INSTALL_NAME_TOOL EQUAL "install_name_tool")
133 set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -I ${CMAKE_INSTALL_NAME_TOOL})
134 endif()
135 if(DEFINED CMAKE_OTOOL AND NOT CMAKE_OTOOL EQUAL "otool")
136 set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -O ${CMAKE_OTOOL})
137 endif()
138 if(DEFINED CROSS_ROOT)
139 set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -R ${CROSS_ROOT})
140 endif()
141 add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND ${CMAKE_SOURCE_DIR}/tools/deploy-mac.py ${DEPLOY_OPTIONS} ${PROJECT_NAME}.app)
142endif()