all repos — mgba @ 37d21b24b813f88ea266c3aa2c9f72b6a3b461f3

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