diff --git a/CMakeLists.txt b/CMakeLists.txt index 342119b24b..f4e2c302be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -789,79 +789,27 @@ if(NOT ANDROID) endif() if(NOT DISABLE_WX) - find_package(wxWidgets COMPONENTS core aui adv) + find_package(wxWidgets 3.1.0 COMPONENTS core aui adv) if(_ARCH_32) add_definitions(-DwxSIZE_T_IS_UINT) endif() if(wxWidgets_FOUND) - EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" - ${wxWidgets_CONFIG_OPTIONS} --version - OUTPUT_VARIABLE wxWidgets_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) - message(STATUS "Found wxWidgets version ${wxWidgets_VERSION}") - set(wxMIN_VERSION "3.1.0") - if(${wxWidgets_VERSION} VERSION_LESS ${wxMIN_VERSION}) - message(STATUS "At least ${wxMIN_VERSION} is required; ignoring found version") - unset(wxWidgets_FOUND) - endif() - endif() - - if(UNIX AND NOT APPLE AND NOT HAIKU) - # There is a bug in the FindGTK module in cmake version 2.8.2 that - # does not find gdk-pixbuf-2.0. On the other hand some 2.8.3 - # users have complained that pkg-config does not find - # gdk-pixbuf-2.0. On yet another hand, cmake version 2.8.3 in - # Ubuntu Natty does not find the glib libraries correctly. - # Ugly!!! - execute_process(COMMAND lsb_release -c -s - OUTPUT_VARIABLE DIST_NAME - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} - VERSION_EQUAL 2.8.2 OR "${DIST_NAME}" STREQUAL "natty") - check_lib(GTK2 gtk+-2.0 gtk+-2.0 gtk.h REQUIRED) - else() - find_package(GTK2) - if(GTK2_FOUND) - include_directories(${GTK2_INCLUDE_DIRS}) - list(APPEND LIBS ${GTK2_LIBRARIES}) - else() - message(FATAL_ERROR "GTK is required to build the WX UI. Please install the GTK development libraries.") - endif() - endif() - endif() - - if(wxWidgets_FOUND) - include(${wxWidgets_USE_FILE}) message(STATUS "wxWidgets found, enabling GUI build") + if(NOT TARGET wxWidgets::wxWidgets) + add_library(wxWidgets::wxWidgets INTERFACE IMPORTED) + set_target_properties(wxWidgets::wxWidgets PROPERTIES + INTERFACE_LINK_LIBRARIES "${wxWidgets_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${wxWidgets_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${wxWidgets_DEFINITIONS}" + INTERFACE_COMPILE_OPTIONS "${wxWidgets_CXX_FLAGS}" + ) + endif() else() message(STATUS "Using static wxWidgets from Externals") - - # These definitions and includes are used when building dolphin against wx, - # not when building wx itself (see wxw3 CMakeLists.txt for that) - if(APPLE) - elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD") - # Check for required libs - check_lib(GTHREAD2 gthread-2.0 gthread-2.0 glib/gthread.h REQUIRED) - check_lib(PANGOCAIRO pangocairo pangocairo pango/pangocairo.h REQUIRED) - # On Linux "backtrace" is part of glibc. FreeBSD has a separate library. - # Required for wxUSE_STACKWALKER in Externals/wxWidgets3/wx/wxgtk.h - find_package(Backtrace REQUIRED) - elseif(WIN32) - else() - message(FATAL_ERROR "wxWidgets in Externals is not compatible with your platform") - endif() - - include_directories(SYSTEM - Externals/wxWidgets3 - Externals/wxWidgets3/include) add_subdirectory(Externals/wxWidgets3) set(wxWidgets_FOUND TRUE) - set(wxWidgets_LIBRARIES "wx") endif() endif() diff --git a/Externals/wxWidgets3/CMakeLists.txt b/Externals/wxWidgets3/CMakeLists.txt index 113c8c511a..30fe4f587d 100644 --- a/Externals/wxWidgets3/CMakeLists.txt +++ b/Externals/wxWidgets3/CMakeLists.txt @@ -818,23 +818,20 @@ set(SRCS_UNIXGTK "src/unix/uiactionx11.cpp" "src/unix/utilsx11.cpp") -include_directories(.) -include_directories(include) - -set(SRCS - ${SRCS_AUI} - ${SRCS_COMMON} - ${SRCS_GENERIC}) +add_library(wx STATIC ${SRCS_AUI} ${SRCS_COMMON} ${SRCS_GENERIC}) +target_include_directories(wx PUBLIC . include) +target_compile_definitions(wx PRIVATE "WXBUILDING") +# wxWidgets warnings are not our problem. +target_compile_options(wx PRIVATE "-w") if(APPLE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++98") - add_definitions(-D__WXOSX_COCOA__) - set(SRCS - ${SRCS} + target_compile_definitions(wx PRIVATE "__WXOSX_COCOA__") + target_sources(wx PRIVATE ${SRCS_GENERICOSX} ${SRCS_OSX} - ${SRCS_UNIX}) - set(LIBS + ${SRCS_UNIX} + ) + target_link_libraries(wx PRIVATE png iconv ${APPKIT_LIBRARY} @@ -847,23 +844,32 @@ if(APPLE) ${OPENGL_LIBRARY} ) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") - if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - add_definitions(-D__LINUX__=1) + target_compile_options(wx PRIVATE "$<$:-std=gnu++11>") + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_compile_definitions(wx PRIVATE "__LINUX__=1") else() - add_definitions(-D__BSD__=1) + target_compile_definitions(wx PRIVATE "__BSD__=1") endif() - add_definitions(-D__WXGTK__) - set(SRCS - ${SRCS} + target_compile_definitions(wx PRIVATE "__WXGTK__") + target_sources(wx PRIVATE ${SRCS_GENERICGTK} ${SRCS_GTK} ${SRCS_UNIX} - ${SRCS_UNIXGTK}) + ${SRCS_UNIXGTK} + ) if (NOT X11_xf86vmode_FOUND OR NOT X11_Xinerama_FOUND) message(FATAL_ERROR "wxGTK2 needs Xinerama and Xxf86vm") endif() - set(LIBS + + find_package(GTK2 REQUIRED) + check_lib(GTHREAD2 gthread-2.0 gthread-2.0 glib/gthread.h REQUIRED) + check_lib(PANGOCAIRO pangocairo pangocairo pango/pangocairo.h REQUIRED) + # On Linux "backtrace" is part of glibc. FreeBSD has a separate library. + # Required for wxUSE_STACKWALKER in Externals/wxWidgets3/wx/wxgtk.h + find_package(Backtrace REQUIRED) + + target_include_directories(wx PUBLIC ${GTK2_INCLUDE_DIRS}) + target_link_libraries(wx PRIVATE png ${GTHREAD2_LIBRARIES} ${PANGOCAIRO_LIBRARIES} @@ -871,25 +877,22 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD") ${Backtrace_LIBRARY} ${X11_X11_LIB} ${X11_Xxf86vm_LIB} - ${X11_Xinerama_LIB}) -else() - add_definitions(-D__WXMSW__) - add_definitions(-DNOPCH) + ${X11_Xinerama_LIB} + ) +elseif(WIN32) remove_definitions(-DWIN32_LEAN_AND_MEAN) - set(SRCS - ${SRCS} + target_compile_definitions(wx PRIVATE "__WXMSW__" "NOPCH") + target_sources(wx PRIVATE ${SRCS_GENERICMSW} - ${SRCS_MSW}) - set(LIBS - Comctl32.lib + ${SRCS_MSW} + ) + target_link_libraries(wx PRIVATE + Comctl32.lib Rpcrt4.lib ${OPENGL_LIBRARIES} ) +else() + message(FATAL_ERROR "wxWidgets in Externals is not compatible with your platform") endif() -add_definitions(-DWXBUILDING) -# wxWidgets warnings are not our problem. -add_definitions(-w) - -add_library(wx STATIC ${PNG_SRCS} ${SRCS}) -target_link_libraries(wx ${LIBS}) +add_library(wxWidgets::wxWidgets ALIAS wx) diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt index 2cad94b5b3..9082085230 100644 --- a/Source/Core/DolphinWX/CMakeLists.txt +++ b/Source/Core/DolphinWX/CMakeLists.txt @@ -1,4 +1,8 @@ -set(GUI_SRCS +if(NOT wxWidgets_FOUND) + return() +endif() + +set(SRCS AboutDolphin.cpp ControllerConfigDiag.cpp Cheats/ActionReplayCodesPanel.cpp @@ -78,21 +82,14 @@ set(GUI_SRCS WxUtils.cpp ) -set(WXLIBS ${wxWidgets_LIBRARIES}) - -if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - set(WXLIBS ${WXLIBS} dl) -endif() - -list(APPEND LIBS core uicommon cpp-optparse) +set(LIBS + core + uicommon + cpp-optparse + wxWidgets::wxWidgets +) if(APPLE) - if(wxWidgets_FOUND) - list(APPEND WXLIBS - ${APPSERV_LIBRARY} - ${COCOA_LIBRARY} - ) - endif() # Add resource files to application bundle. set(RESOURCES resources/Dolphin.icns) list(APPEND SRCS ${RESOURCES}) @@ -107,88 +104,76 @@ if(WIN32) ) endif() +add_executable(dolphin-emu ${SRCS}) +target_link_libraries(dolphin-emu ${LIBS}) + +# Handle localization +find_package(Gettext) +if(GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE) + set(pot_file "${CMAKE_SOURCE_DIR}/Languages/po/dolphin-emu.pot") + file(GLOB LINGUAS ${CMAKE_SOURCE_DIR}/Languages/po/*.po) + + target_sources(dolphin-emu PRIVATE ${pot_file} ${LINGUAS}) + source_group("Localization" FILES ${LINGUAS}) + source_group("Localization\\\\Generated" FILES ${pot_file}) + + foreach(po ${LINGUAS}) + get_filename_component(lang ${po} NAME_WE) + set(mo_dir ${CMAKE_CURRENT_BINARY_DIR}/${lang}) + set(mo ${mo_dir}/dolphin-emu.mo) + + target_sources(dolphin-emu PRIVATE ${mo}) + source_group("Localization\\\\Generated" FILES ${mo}) + + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set_source_files_properties(${mo} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/${lang}.lproj") + else() + install(FILES ${mo} DESTINATION share/locale/${lang}/LC_MESSAGES) + endif() + + add_custom_command(OUTPUT ${mo} + COMMAND mkdir -p ${mo_dir} + COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${po} ${pot_file} + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${mo} ${po} + DEPENDS ${po} + ) + endforeach() +endif() + if(APPLE) - set(DOLPHIN_EXE_BASE Dolphin) + # Ask for an application bundle. + set_target_properties(dolphin-emu PROPERTIES + MACOSX_BUNDLE true + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in + OUTPUT_NAME Dolphin + ) + + # Copy resources in the bundle + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/Data/Sys") + file(GLOB_RECURSE resources RELATIVE "${CMAKE_SOURCE_DIR}/Data" "${CMAKE_SOURCE_DIR}/Data/Sys/*") + foreach(res ${resources}) + target_sources(dolphin-emu PRIVATE "${CMAKE_SOURCE_DIR}/Data/${res}") + get_filename_component(resdir "${res}" DIRECTORY) + set_source_files_properties("${CMAKE_SOURCE_DIR}/Data/${res}" PROPERTIES + MACOSX_PACKAGE_LOCATION "Resources/${resdir}") + source_group("Resources" FILES "${CMAKE_SOURCE_DIR}/Data/${res}") + endforeach() + + # Update library references to make the bundle portable + include(DolphinPostprocessBundle) + dolphin_postprocess_bundle(dolphin-emu) + + # Install bundle into systemwide /Applications directory. + install(TARGETS dolphin-emu DESTINATION /Applications) +elseif(WIN32) + set_target_properties(dolphin-emu PROPERTIES + WIN32_EXECUTABLE ON + ) + add_custom_command(TARGET dolphin-emu + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Data/Sys $/Sys + ) else() - set(DOLPHIN_EXE_BASE dolphin-emu) + install(TARGETS dolphin-emu RUNTIME DESTINATION ${bindir}) endif() -set(DOLPHIN_EXE ${DOLPHIN_EXE_BASE}) - - -if(wxWidgets_FOUND) - add_executable(${DOLPHIN_EXE} ${SRCS} ${GUI_SRCS}) - target_link_libraries(${DOLPHIN_EXE} ${LIBS} ${WXLIBS}) - - # Handle localization - find_package(Gettext) - if(GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE) - set(pot_file "${CMAKE_SOURCE_DIR}/Languages/po/dolphin-emu.pot") - file(GLOB LINGUAS ${CMAKE_SOURCE_DIR}/Languages/po/*.po) - - target_sources(${DOLPHIN_EXE} PRIVATE ${pot_file} ${LINGUAS}) - source_group("Localization" FILES ${LINGUAS}) - source_group("Localization\\\\Generated" FILES ${pot_file}) - - foreach(po ${LINGUAS}) - get_filename_component(lang ${po} NAME_WE) - set(mo_dir ${CMAKE_CURRENT_BINARY_DIR}/${lang}) - set(mo ${mo_dir}/dolphin-emu.mo) - - target_sources(${DOLPHIN_EXE} PRIVATE ${mo}) - source_group("Localization\\\\Generated" FILES ${mo}) - - if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set_source_files_properties(${mo} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/${lang}.lproj") - else() - install(FILES ${mo} DESTINATION share/locale/${lang}/LC_MESSAGES) - endif() - - add_custom_command(OUTPUT ${mo} - COMMAND mkdir -p ${mo_dir} - COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${po} ${pot_file} - COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${mo} ${po} - DEPENDS ${po} - ) - endforeach() - endif() - - if(APPLE) - set(BUNDLE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${DOLPHIN_EXE}.app) - - # Ask for an application bundle. - set_target_properties(${DOLPHIN_EXE} PROPERTIES - MACOSX_BUNDLE true - MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in - ) - - # Copy resources in the bundle - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/Data/Sys") - file(GLOB_RECURSE resources RELATIVE "${CMAKE_SOURCE_DIR}/Data" "${CMAKE_SOURCE_DIR}/Data/Sys/*") - foreach(res ${resources}) - target_sources(${DOLPHIN_EXE} PRIVATE "${CMAKE_SOURCE_DIR}/Data/${res}") - get_filename_component(resdir "${res}" DIRECTORY) - set_source_files_properties("${CMAKE_SOURCE_DIR}/Data/${res}" PROPERTIES - MACOSX_PACKAGE_LOCATION "Resources/${resdir}") - source_group("Resources" FILES "${CMAKE_SOURCE_DIR}/Data/${res}") - endforeach() - - # Update library references to make the bundle portable - include(DolphinPostprocessBundle) - dolphin_postprocess_bundle(${DOLPHIN_EXE}) - - # Install bundle into systemwide /Applications directory. - install(TARGETS ${DOLPHIN_EXE} DESTINATION /Applications) - elseif(WIN32) - set_target_properties(${DOLPHIN_EXE} PROPERTIES - WIN32_EXECUTABLE ON - ) - add_custom_command(TARGET ${DOLPHIN_EXE} - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Data/Sys $/Sys - ) - else() - install(TARGETS ${DOLPHIN_EXE} RUNTIME DESTINATION ${bindir}) - endif() - - set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} ${DOLPHIN_EXE}) -endif() +set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} dolphin-emu)