all repos — mgba @ 12505766e1ab83954ab216a5828cd064834056e8

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