all repos — mgba @ 12fce1fba0adf92d61d95a279324e31e27fef03b

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	ConfigController.cpp
 41	Display.cpp
 42	GBAApp.cpp
 43	GBAKeyEditor.cpp
 44	GIFView.cpp
 45	GameController.cpp
 46	GamePakView.cpp
 47	GamepadAxisEvent.cpp
 48	GamepadButtonEvent.cpp
 49	InputController.cpp
 50	KeyEditor.cpp
 51	LoadSaveState.cpp
 52	LogView.cpp
 53	SavestateButton.cpp
 54	SettingsView.cpp
 55	ShortcutController.cpp
 56	ShortcutView.cpp
 57	Window.cpp
 58	VFileDevice.cpp
 59	VideoView.cpp)
 60
 61qt5_wrap_ui(UI_FILES
 62	GIFView.ui
 63	GamePakView.ui
 64	LoadSaveState.ui
 65	LogView.ui
 66	SettingsView.ui
 67	ShortcutView.ui
 68	VideoView.ui)
 69
 70set(QT_LIBRARIES)
 71set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5widgets5,libqt5opengl5" PARENT_SCOPE)
 72if(BUILD_SDL)
 73	list(APPEND SOURCE_FILES AudioProcessorSDL.cpp)
 74elseif(Qt5Multimedia_FOUND)
 75	list(APPEND SOURCE_FILES
 76		AudioProcessorQt.cpp
 77		AudioDevice.cpp)
 78	list(APPEND QT_LIBRARIES Qt5::Multimedia)
 79	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5multimedia5" PARENT_SCOPE)
 80else()
 81	message(WARNING "No supported audio modules found")
 82	set(BUILD_QT OFF PARENT_SCOPE)
 83	return()
 84endif()
 85
 86if(USE_GDB_STUB)
 87	list(APPEND PLATFORM_SRC GDBController.cpp GDBWindow.cpp)
 88endif()
 89set(MACOSX_BUNDLE_ICON_FILE mgba.icns)
 90set(MACOSX_BUNDLE_BUNDLE_VERSION ${LIB_VERSION_STRING})
 91set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
 92set(MACOSX_BUNDLE_GUI_IDENTIFIER com.endrift.${BINARY_NAME}-qt)
 93set_source_files_properties(${CMAKE_SOURCE_DIR}/res/mgba.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
 94
 95qt5_add_resources(RESOURCES resources.qrc)
 96if(WIN32)
 97	list(APPEND RESOURCES ${CMAKE_SOURCE_DIR}/res/mgba.rc)
 98endif()
 99add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_FILES} ${RESOURCES})
100set_target_properties(${BINARY_NAME}-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/info.plist.in)
101
102list(APPEND QT_LIBRARIES Qt5::Widgets Qt5::OpenGL)
103target_link_libraries(${BINARY_NAME}-qt ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES})
104
105install(TARGETS ${BINARY_NAME}-qt
106	RUNTIME DESTINATION bin COMPONENT ${BINARY_NAME}-qt
107	BUNDLE DESTINATION Applications COMPONENT ${BINARY_NAME}-qt)
108if(APPLE OR WIN32)
109	set_target_properties(${BINARY_NAME}-qt PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
110endif()
111if(APPLE)
112	set(DEPLOY_OPTIONS -p platforms/libqcocoa.dylib,audio/libqtaudio_coreaudio.dylib)
113	if(NOT CMAKE_INSTALL_NAME_TOOL EQUAL "install_name_tool")
114		set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -I ${CMAKE_INSTALL_NAME_TOOL})
115	endif()
116	if(DEFINED CMAKE_OTOOL AND NOT CMAKE_OTOOL EQUAL "otool")
117		set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -O ${CMAKE_OTOOL})
118	endif()
119	if(DEFINED CROSS_ROOT)
120		set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -R ${CROSS_ROOT})
121	endif()
122	add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND ${CMAKE_SOURCE_DIR}/tools/deploy-mac.py ${DEPLOY_OPTIONS} ${PROJECT_NAME}.app)
123endif()