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