all repos — mgba @ 4fb121bbe0e78bb664f19c463518c0513ee4d196

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 -stdlib=libc++")
  8endif()
  9
 10set(PLATFORM_SRC)
 11
 12if(BUILD_SDL)
 13	if(NOT SDL_FOUND AND NOT SDL2_FOUND)
 14		find_package(SDL 1.2 REQUIRED)
 15	endif()
 16	if(SDL2_FOUND)
 17		link_directories(${SDL2_LIBDIR})
 18	endif()
 19	list(APPEND PLATFORM_LIBRARY ${SDL_LIBRARY} ${SDLMAIN_LIBRARY})
 20	list(APPEND PLATFORM_SRC ${PLATFORM_SRC} ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-events.c ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-audio.c)
 21	include_directories(${SDL_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/src/platform/sdl)
 22endif()
 23
 24set(CMAKE_AUTOMOC ON)
 25set(CMAKE_INCLUDE_CURRENT_DIR ON)
 26
 27find_package(Qt5Multimedia)
 28find_package(Qt5OpenGL)
 29find_package(Qt5Widgets)
 30find_package(OpenGL)
 31
 32if(NOT Qt5OpenGL_FOUND OR NOT Qt5Widgets_FOUND OR NOT OPENGL_FOUND)
 33	message(WARNING "Cannot find Qt modules")
 34	set(BUILD_QT OFF PARENT_SCOPE)
 35	return()
 36endif()
 37
 38set(SOURCE_FILES
 39	AudioProcessor.cpp
 40	CheatsModel.cpp
 41	CheatsView.cpp
 42	ConfigController.cpp
 43	Display.cpp
 44	DisplayGL.cpp
 45	GBAApp.cpp
 46	GBAKeyEditor.cpp
 47	GIFView.cpp
 48	GameController.cpp
 49	GamepadAxisEvent.cpp
 50	GamepadButtonEvent.cpp
 51	InputController.cpp
 52	KeyEditor.cpp
 53	LoadSaveState.cpp
 54	LogView.cpp
 55	MultiplayerController.cpp
 56	OverrideView.cpp
 57	SavestateButton.cpp
 58	SensorView.cpp
 59	SettingsView.cpp
 60	ShortcutController.cpp
 61	ShortcutView.cpp
 62	Window.cpp
 63	VFileDevice.cpp
 64	VideoView.cpp)
 65
 66qt5_wrap_ui(UI_FILES
 67	CheatsView.ui
 68	GIFView.ui
 69	LoadSaveState.ui
 70	LogView.ui
 71	OverrideView.ui
 72	SensorView.ui
 73	SettingsView.ui
 74	ShortcutView.ui
 75	VideoView.ui)
 76
 77set(QT_LIBRARIES)
 78set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5widgets5,libqt5opengl5" PARENT_SCOPE)
 79
 80set(AUDIO_SRC)
 81if(BUILD_SDL)
 82	list(APPEND AUDIO_SRC AudioProcessorSDL.cpp)
 83endif()
 84
 85if(Qt5Multimedia_FOUND)
 86	list(APPEND AUDIO_SRC
 87		AudioProcessorQt.cpp
 88		AudioDevice.cpp)
 89	list(APPEND QT_LIBRARIES Qt5::Multimedia)
 90	add_definitions(-DBUILD_QT_MULTIMEDIA)
 91	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5multimedia5" PARENT_SCOPE)
 92endif()
 93
 94if(NOT AUDIO_SRC)
 95	message(WARNING "No supported audio modules found")
 96	set(BUILD_QT OFF PARENT_SCOPE)
 97	return()
 98endif()
 99
100if(USE_GDB_STUB)
101	list(APPEND PLATFORM_SRC GDBController.cpp GDBWindow.cpp)
102endif()
103set(MACOSX_BUNDLE_ICON_FILE mgba.icns)
104set(MACOSX_BUNDLE_BUNDLE_VERSION ${LIB_VERSION_STRING})
105set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
106set(MACOSX_BUNDLE_GUI_IDENTIFIER com.endrift.${BINARY_NAME}-qt)
107set_source_files_properties(${CMAKE_SOURCE_DIR}/res/mgba.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
108
109qt5_add_resources(RESOURCES resources.qrc)
110if(WIN32)
111	configure_file(${CMAKE_SOURCE_DIR}/res/mgba.rc.in ${CMAKE_BINARY_DIR}/res/mgba.rc)
112	list(APPEND RESOURCES ${CMAKE_BINARY_DIR}/res/mgba.rc)
113endif()
114add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_FILES} ${AUDIO_SRC} ${RESOURCES})
115set_target_properties(${BINARY_NAME}-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/info.plist.in COMPILE_DEFINITIONS "${FEATURE_DEFINES}")
116
117list(APPEND QT_LIBRARIES Qt5::Widgets Qt5::OpenGL)
118target_link_libraries(${BINARY_NAME}-qt ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES})
119
120install(TARGETS ${BINARY_NAME}-qt
121	RUNTIME DESTINATION bin COMPONENT ${BINARY_NAME}-qt
122	BUNDLE DESTINATION Applications COMPONENT ${BINARY_NAME}-qt)
123if(APPLE OR WIN32)
124	set_target_properties(${BINARY_NAME}-qt PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
125endif()
126if(APPLE)
127	set(DEPLOY_OPTIONS -p platforms/libqcocoa.dylib,audio/libqtaudio_coreaudio.dylib)
128	if(NOT CMAKE_INSTALL_NAME_TOOL EQUAL "install_name_tool")
129		set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -I ${CMAKE_INSTALL_NAME_TOOL})
130	endif()
131	if(DEFINED CMAKE_OTOOL AND NOT CMAKE_OTOOL EQUAL "otool")
132		set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -O ${CMAKE_OTOOL})
133	endif()
134	if(DEFINED CROSS_ROOT)
135		set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -R ${CROSS_ROOT})
136	endif()
137	add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND ${CMAKE_SOURCE_DIR}/tools/deploy-mac.py ${DEPLOY_OPTIONS} ${PROJECT_NAME}.app)
138endif()