all repos — mgba @ fe845d1ee8f35b03281625b82b95dd45518c9706

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