all repos — mgba @ 903a8a654d4a7648e55f2b2e42525b89fda509b4

mGBA Game Boy Advance Emulator

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)
 14set(QT_STATIC OFF)
 15
 16if(BUILD_SDL)
 17	if(NOT SDL_FOUND AND NOT SDL2_FOUND)
 18		find_package(SDL 1.2 REQUIRED)
 19	endif()
 20	if(SDL2_FOUND)
 21		link_directories(${SDL2_LIBDIR})
 22	endif()
 23	list(APPEND PLATFORM_LIBRARY ${SDL_LIBRARY} ${SDLMAIN_LIBRARY})
 24	list(APPEND PLATFORM_SRC ${PLATFORM_SRC} ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-events.c ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-audio.c)
 25	include_directories(${SDL_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/src/platform/sdl)
 26endif()
 27
 28set(CMAKE_AUTOMOC ON)
 29set(CMAKE_INCLUDE_CURRENT_DIR ON)
 30
 31find_package(Qt5Multimedia)
 32find_package(Qt5OpenGL)
 33find_package(Qt5Widgets)
 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
 41if(BUILD_GL)
 42list(APPEND PLATFORM_SRC ${PLATFORM_SRC} ${CMAKE_SOURCE_DIR}/src/platform/opengl/gl.c)
 43endif()
 44
 45if(BUILD_GLES2)
 46list(APPEND PLATFORM_SRC ${PLATFORM_SRC} ${CMAKE_SOURCE_DIR}/src/platform/opengl/gles2.c)
 47endif()
 48
 49get_target_property(QT_TYPE Qt5::Core TYPE)
 50if(QT_TYPE STREQUAL STATIC_LIBRARY)
 51	set(QT_STATIC ON)
 52	add_definitions(-DQT_STATIC)
 53endif()
 54
 55set(SOURCE_FILES
 56	AboutScreen.cpp
 57	AudioProcessor.cpp
 58	CheatsModel.cpp
 59	CheatsView.cpp
 60	ConfigController.cpp
 61	Display.cpp
 62	DisplayGL.cpp
 63	DisplayQt.cpp
 64	GBAApp.cpp
 65	GBAKeyEditor.cpp
 66	GIFView.cpp
 67	GameController.cpp
 68	GamepadAxisEvent.cpp
 69	GamepadButtonEvent.cpp
 70	InputController.cpp
 71	InputProfile.cpp
 72	KeyEditor.cpp
 73	LoadSaveState.cpp
 74	LogController.cpp
 75	LogView.cpp
 76	MemoryModel.cpp
 77	MemoryView.cpp
 78	MessagePainter.cpp
 79	MultiplayerController.cpp
 80	OverrideView.cpp
 81	PaletteView.cpp
 82	SavestateButton.cpp
 83	SensorView.cpp
 84	SettingsView.cpp
 85	ShortcutController.cpp
 86	ShortcutView.cpp
 87	Swatch.cpp
 88	Window.cpp
 89	VFileDevice.cpp
 90	VideoView.cpp)
 91
 92qt5_wrap_ui(UI_FILES
 93	AboutScreen.ui
 94	CheatsView.ui
 95	GIFView.ui
 96	LoadSaveState.ui
 97	LogView.ui
 98	MemoryView.ui
 99	OverrideView.ui
100	PaletteView.ui
101	SensorView.ui
102	SettingsView.ui
103	ShortcutView.ui
104	VideoView.ui)
105
106set(QT_LIBRARIES)
107set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5widgets5,libqt5opengl5")
108
109set(AUDIO_SRC)
110if(BUILD_SDL)
111	list(APPEND AUDIO_SRC AudioProcessorSDL.cpp)
112endif()
113
114if(Qt5Multimedia_FOUND)
115	list(APPEND AUDIO_SRC
116		AudioProcessorQt.cpp
117		AudioDevice.cpp)
118	if (WIN32 AND QT_STATIC)
119		list(APPEND QT_LIBRARIES qtaudio_windows strmiids winmm)
120	endif()
121	list(APPEND QT_LIBRARIES Qt5::Multimedia)
122	add_definitions(-DBUILD_QT_MULTIMEDIA)
123	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5multimedia5")
124endif()
125
126if(NOT AUDIO_SRC)
127	message(WARNING "No supported audio modules found")
128	set(BUILD_QT OFF PARENT_SCOPE)
129	return()
130endif()
131
132if(USE_GDB_STUB)
133	list(APPEND PLATFORM_SRC GDBController.cpp GDBWindow.cpp)
134endif()
135set(MACOSX_BUNDLE_ICON_FILE mgba.icns)
136set(MACOSX_BUNDLE_BUNDLE_VERSION ${LIB_VERSION_STRING})
137set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
138set(MACOSX_BUNDLE_GUI_IDENTIFIER com.endrift.${BINARY_NAME}-qt)
139set_source_files_properties(${CMAKE_SOURCE_DIR}/res/mgba.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
140
141qt5_add_resources(RESOURCES resources.qrc)
142if(WIN32)
143	configure_file(${CMAKE_SOURCE_DIR}/res/mgba.rc.in ${CMAKE_BINARY_DIR}/res/mgba.rc)
144	list(APPEND RESOURCES ${CMAKE_BINARY_DIR}/res/mgba.rc)
145	if(QT_STATIC)
146		list(APPEND QT_LIBRARIES qwindows imm32)
147	endif()
148endif()
149add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_FILES} ${AUDIO_SRC} ${RESOURCES})
150set_target_properties(${BINARY_NAME}-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/info.plist.in COMPILE_DEFINITIONS "${FEATURE_DEFINES}")
151
152list(APPEND QT_LIBRARIES Qt5::Widgets Qt5::OpenGL)
153target_link_libraries(${BINARY_NAME}-qt ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES})
154set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}" PARENT_SCOPE)
155
156install(TARGETS ${BINARY_NAME}-qt
157	RUNTIME DESTINATION bin COMPONENT ${BINARY_NAME}-qt
158	BUNDLE DESTINATION Applications COMPONENT ${BINARY_NAME}-qt)
159if(UNIX AND NOT APPLE)
160	find_program(DESKTOP_FILE_INSTALL desktop-file-install)
161	if(DESKTOP_FILE_INSTALL)
162		install(CODE "execute_process(COMMAND ${DESKTOP_FILE_INSTALL} \"${CMAKE_SOURCE_DIR}/res/mgba-qt.desktop\" --dir \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/share/applications/\")")
163	endif()
164endif()
165if(APPLE OR WIN32)
166	set_target_properties(${BINARY_NAME}-qt PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
167endif()
168if(APPLE)
169	set(DEPLOY_OPTIONS -p platforms/libqcocoa.dylib,audio/libqtaudio_coreaudio.dylib)
170	if(NOT CMAKE_INSTALL_NAME_TOOL EQUAL "install_name_tool")
171		set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -I ${CMAKE_INSTALL_NAME_TOOL})
172	endif()
173	if(DEFINED CMAKE_OTOOL AND NOT CMAKE_OTOOL EQUAL "otool")
174		set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -O ${CMAKE_OTOOL})
175	endif()
176	if(DEFINED CROSS_ROOT)
177		set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -R ${CROSS_ROOT})
178	endif()
179	add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND ${CMAKE_SOURCE_DIR}/tools/deploy-mac.py ${DEPLOY_OPTIONS} ${PROJECT_NAME}.app)
180endif()