all repos — mgba @ 5fcba6a8b2ae695721a697449ffc9043abe8ce8b

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	MultiplayerController.cpp
 71	OverrideView.cpp
 72	PaletteView.cpp
 73	SavestateButton.cpp
 74	SensorView.cpp
 75	SettingsView.cpp
 76	ShortcutController.cpp
 77	ShortcutView.cpp
 78	Swatch.cpp
 79	Window.cpp
 80	VFileDevice.cpp
 81	VideoView.cpp)
 82
 83qt5_wrap_ui(UI_FILES
 84	CheatsView.ui
 85	GIFView.ui
 86	LoadSaveState.ui
 87	LogView.ui
 88	MemoryView.ui
 89	OverrideView.ui
 90	PaletteView.ui
 91	SensorView.ui
 92	SettingsView.ui
 93	ShortcutView.ui
 94	VideoView.ui)
 95
 96set(QT_LIBRARIES)
 97set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5widgets5,libqt5opengl5")
 98
 99set(AUDIO_SRC)
100if(BUILD_SDL)
101	list(APPEND AUDIO_SRC AudioProcessorSDL.cpp)
102endif()
103
104if(Qt5Multimedia_FOUND)
105	list(APPEND AUDIO_SRC
106		AudioProcessorQt.cpp
107		AudioDevice.cpp)
108	if (WIN32 AND QT_STATIC)
109		list(APPEND QT_LIBRARIES qtaudio_windows strmiids winmm)
110	endif()
111	list(APPEND QT_LIBRARIES Qt5::Multimedia)
112	add_definitions(-DBUILD_QT_MULTIMEDIA)
113	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5multimedia5")
114endif()
115
116if(NOT AUDIO_SRC)
117	message(WARNING "No supported audio modules found")
118	set(BUILD_QT OFF PARENT_SCOPE)
119	return()
120endif()
121
122if(USE_GDB_STUB)
123	list(APPEND PLATFORM_SRC GDBController.cpp GDBWindow.cpp)
124endif()
125set(MACOSX_BUNDLE_ICON_FILE mgba.icns)
126set(MACOSX_BUNDLE_BUNDLE_VERSION ${LIB_VERSION_STRING})
127set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
128set(MACOSX_BUNDLE_GUI_IDENTIFIER com.endrift.${BINARY_NAME}-qt)
129set_source_files_properties(${CMAKE_SOURCE_DIR}/res/mgba.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
130
131qt5_add_resources(RESOURCES resources.qrc)
132if(WIN32)
133	configure_file(${CMAKE_SOURCE_DIR}/res/mgba.rc.in ${CMAKE_BINARY_DIR}/res/mgba.rc)
134	list(APPEND RESOURCES ${CMAKE_BINARY_DIR}/res/mgba.rc)
135	if(QT_STATIC)
136		list(APPEND QT_LIBRARIES qwindows imm32)
137	endif()
138endif()
139add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_FILES} ${AUDIO_SRC} ${RESOURCES})
140set_target_properties(${BINARY_NAME}-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/info.plist.in COMPILE_DEFINITIONS "${FEATURE_DEFINES}")
141
142list(APPEND QT_LIBRARIES Qt5::Widgets Qt5::OpenGL)
143target_link_libraries(${BINARY_NAME}-qt ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES})
144set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}" PARENT_SCOPE)
145
146install(TARGETS ${BINARY_NAME}-qt
147	RUNTIME DESTINATION bin COMPONENT ${BINARY_NAME}-qt
148	BUNDLE DESTINATION Applications COMPONENT ${BINARY_NAME}-qt)
149if(UNIX AND NOT APPLE)
150	find_program(DESKTOP_FILE_INSTALL desktop-file-install)
151	if(DESKTOP_FILE_INSTALL)
152		install(CODE "execute_process(COMMAND ${DESKTOP_FILE_INSTALL} \"${CMAKE_SOURCE_DIR}/res/mgba-qt.desktop\" --dir \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/share/applications/\")")
153	endif()
154endif()
155if(APPLE OR WIN32)
156	set_target_properties(${BINARY_NAME}-qt PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
157endif()
158if(APPLE)
159	set(DEPLOY_OPTIONS -p platforms/libqcocoa.dylib,audio/libqtaudio_coreaudio.dylib)
160	if(NOT CMAKE_INSTALL_NAME_TOOL EQUAL "install_name_tool")
161		set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -I ${CMAKE_INSTALL_NAME_TOOL})
162	endif()
163	if(DEFINED CMAKE_OTOOL AND NOT CMAKE_OTOOL EQUAL "otool")
164		set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -O ${CMAKE_OTOOL})
165	endif()
166	if(DEFINED CROSS_ROOT)
167		set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -R ${CROSS_ROOT})
168	endif()
169	add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND ${CMAKE_SOURCE_DIR}/tools/deploy-mac.py ${DEPLOY_OPTIONS} ${PROJECT_NAME}.app)
170endif()