all repos — mgba @ e40709538914ef853405e7336ee2a62455d8a5b8

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	Window.cpp
 48	VFileDevice.cpp
 49	VideoView.cpp)
 50
 51qt5_wrap_ui(UI_FILES
 52	GIFView.ui
 53	LoadSaveState.ui
 54	LogView.ui
 55	VideoView.ui)
 56
 57set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5widgets5,libqt5opengl5" PARENT_SCOPE)
 58if(BUILD_SDL)
 59	list(APPEND SOURCE_FILES AudioProcessorSDL.cpp)
 60elseif(Qt5Multimedia_FOUND)
 61	list(APPEND SOURCE_FILES
 62	AudioProcessorQt.cpp
 63	AudioDevice.cpp)
 64	list(APPEND QT_LIBRARIES Qt5::Multimedia)
 65	set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5multimedia5" PARENT_SCOPE)
 66else()
 67	message(WARNING "No supported audio modules found")
 68	set(BUILD_QT OFF PARENT_SCOPE)
 69	return()
 70endif()
 71
 72if(USE_GDB_STUB)
 73	list(APPEND PLATFORM_SRC GDBController.cpp GDBWindow.cpp)
 74endif()
 75set(MACOSX_BUNDLE_ICON_FILE mgba.icns)
 76set(MACOSX_BUNDLE_BUNDLE_VERSION ${LIB_VERSION_STRING})
 77set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
 78set(MACOSX_BUNDLE_GUI_IDENTIFIER com.endrift.${BINARY_NAME}-qt)
 79set_source_files_properties(${CMAKE_SOURCE_DIR}/res/mgba.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
 80
 81qt5_add_resources(RESOURCES resources.qrc)
 82if(WIN32)
 83	list(APPEND RESOURCES ${CMAKE_SOURCE_DIR}/res/mgba.rc)
 84endif()
 85add_executable(${BINARY_NAME}-qt WIN32 MACOSX_BUNDLE main.cpp ${CMAKE_SOURCE_DIR}/res/mgba.icns ${SOURCE_FILES} ${PLATFORM_SRC} ${UI_FILES} ${RESOURCES})
 86set_target_properties(${BINARY_NAME}-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/info.plist.in)
 87
 88set(QT_LIBRARIES Qt5::Widgets Qt5::OpenGL)
 89target_link_libraries(${BINARY_NAME}-qt ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES})
 90
 91install(TARGETS ${BINARY_NAME}-qt RUNTIME DESTINATION bin BUNDLE DESTINATION /Applications)
 92if(APPLE OR WIN32)
 93	set_target_properties(${BINARY_NAME}-qt PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
 94endif()
 95if(APPLE AND MACDEPLOYQT)
 96	add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND ${MACDEPLOYQT} ${PROJECT_NAME}.app)
 97	add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND rm -r ${PROJECT_NAME}.app/Contents/Plugins/bearer)
 98	add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND rm -r ${PROJECT_NAME}.app/Contents/Plugins/imageformats)
 99	add_custom_command(TARGET ${BINARY_NAME}-qt POST_BUILD COMMAND rm -r ${PROJECT_NAME}.app/Contents/Plugins/printsupport)
100endif()