diff options
30 files changed, 1984 insertions, 428 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ecd67b5ec..c942c0edc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,9 +29,13 @@ # this exception statement from all source files in the program, then also # delete it here. -cmake_minimum_required(VERSION 3.0.0) +cmake_minimum_required(VERSION 3.4.0) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/macros) set(CMAKE_COLOR_MAKEFILE ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) project(Remmina C CXX) @@ -42,13 +46,12 @@ include(CheckSymbolExists) include(FindPkgConfig) include(GNUInstallDirs) -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/) - include(FindOptionalPackage) include(ConfigOptions) include(GtkUpdateIconCache) include(CheckHasModule) include(FindPCRE2) +include(GlibCompileResourcesSupport) #--------------------------------------------------------------------- # Package creation with CMake depends on the value of umask - if permissions @@ -343,12 +346,25 @@ endif() # Uninstall support configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) add_custom_target(uninstall "${CMAKE_COMMAND}" -P - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") + +#find_required_package(GTK) +find_package(GLib REQUIRED) +if(NOT GLib_FOUND) + message(FATAL_ERROR "GLIB2 library not found") +endif(NOT GLib_FOUND) +include_directories(${GLib_INCLUDE_DIRS}) + +find_package(GTK3 3.14.0 REQUIRED) +if(NOT GTK3_FOUND) + message(FATAL_ERROR "GTK3 library not found") +endif(NOT GTK3_FOUND) +include_directories(${GTK3_INCLUDE_DIRS}) +set(GTK_LIBRARIES ${GTK3_LIBRARY} ${GDK3_LIBRARY} ${GDKPixbuf_LIBRARY} ${Pango_LIBRARY} ${Cairo_LIBRARY} ${GObject_LIBRARY} ${GLib_LIBRARY} ${GIO_LIBRARY} ${Gmodule_LIBRARIES}) -find_required_package(GTK) set(CMAKE_THREAD_PREFER_PTHREAD TRUE) find_package(Threads REQUIRED) @@ -378,7 +394,6 @@ elseif("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" AND WITH_GCC_PROFILING) endif() find_suggested_package(GCRYPT) -find_suggested_package(AVAHI) find_package(OpenSSL) find_package(sodium REQUIRED) if(sodium_FOUND) @@ -414,9 +429,15 @@ if(GCRYPT_FOUND) add_definitions(-DHAVE_LIBGCRYPT) endif() -if(AVAHI_FOUND) - add_definitions(-DHAVE_LIBAVAHI_UI) - add_definitions(-DHAVE_LIBAVAHI_CLIENT) +#avahi for discovery over mDNS/DNS-SD daemon +if (UNIX AND NOT APPLE) + find_suggested_package(Avahi) + if(AVAHI_FOUND) + message(STATUS "AVAHI_INCLUDE_DIRS=${AVAHI_INCLUDE_DIRS}") + message(STATUS "AVAHI_LIBRARIES=${AVAHI_LIBRARIES}") + add_definitions(-DHAVE_LIBAVAHI_UI) + add_definitions(-DHAVE_LIBAVAHI_CLIENT) + endif() endif() option(WITH_ICON_CACHE "Generate the icon cache during install target" ON) @@ -444,13 +465,13 @@ else() message(STATUS "Desktop MIME types cache database won't be generated") endif() -if(GTK_FOUND) - pkg_check_modules(gio REQUIRED gio-2.0) - pkg_check_modules(gio-unix REQUIRED gio-unix-2.0) - add_subdirectory(src) - add_subdirectory(data) - add_subdirectory(plugins) - add_subdirectory(plugins/secret) +if(GTK3_FOUND) + #pkg_check_modules(gio REQUIRED gio-2.0) + #pkg_check_modules(gio-unix REQUIRED gio-unix-2.0) + add_subdirectory(src) + add_subdirectory(data) + add_subdirectory(plugins) + add_subdirectory(plugins/secret) endif() if(WITH_TRANSLATIONS) diff --git a/cmake/FindATK.cmake b/cmake/FindATK.cmake new file mode 100644 index 000000000..a61856763 --- /dev/null +++ b/cmake/FindATK.cmake @@ -0,0 +1,86 @@ +# FindPango.cmake +# <https://github.com/nemequ/gnome-cmake> +# +# CMake support for ATK. +# +# License: +# +# Copyright (c) 2016 Evan Nemerson <evan@nemerson.com> +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +find_package(PkgConfig) + +set(ATK_DEPS + GLib) + +if(PKG_CONFIG_FOUND) + pkg_search_module(ATK_PKG atk) +endif() + +find_library(ATK_LIBRARY atk-1.0 HINTS ${ATK_PKG_LIBRARY_DIRS}) +set(ATK "atk-1.0") + +if(ATK_LIBRARY AND NOT ATK_FOUND) + add_library(${ATK} SHARED IMPORTED) + set_property(TARGET ${ATK} PROPERTY IMPORTED_LOCATION "${ATK_LIBRARY}") + set_property(TARGET ${ATK} PROPERTY INTERFACE_COMPILE_OPTIONS "${ATK_PKG_CFLAGS_OTHER}") + + find_path(ATK_INCLUDE_DIR "atk/atk.h" + HINTS ${ATK_PKG_INCLUDE_DIRS}) + + if(ATK_INCLUDE_DIR) + file(STRINGS "${ATK_INCLUDE_DIR}/atk/atkversion.h" ATK_MAJOR_VERSION REGEX "^#define ATK_MAJOR_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define ATK_MAJOR_VERSION \\(([0-9]+)\\)$" "\\1" ATK_MAJOR_VERSION "${ATK_MAJOR_VERSION}") + file(STRINGS "${ATK_INCLUDE_DIR}/atk/atkversion.h" ATK_MINOR_VERSION REGEX "^#define ATK_MINOR_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define ATK_MINOR_VERSION \\(([0-9]+)\\)$" "\\1" ATK_MINOR_VERSION "${ATK_MINOR_VERSION}") + file(STRINGS "${ATK_INCLUDE_DIR}/atk/atkversion.h" ATK_MICRO_VERSION REGEX "^#define ATK_MICRO_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define ATK_MICRO_VERSION \\(([0-9]+)\\)$" "\\1" ATK_MICRO_VERSION "${ATK_MICRO_VERSION}") + set(ATK_VERSION "${ATK_MAJOR_VERSION}.${ATK_MINOR_VERSION}.${ATK_MICRO_VERSION}") + unset(ATK_MAJOR_VERSION) + unset(ATK_MINOR_VERSION) + unset(ATK_MICRO_VERSION) + + list(APPEND ATK_INCLUDE_DIRS ${ATK_INCLUDE_DIR}) + set_property(TARGET ${ATK} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${ATK_INCLUDE_DIR}") + endif() +endif() + +set(ATK_DEPS_FOUND_VARS) +foreach(atk_dep ${ATK_DEPS}) + find_package(${atk_dep}) + + list(APPEND ATK_DEPS_FOUND_VARS "${atk_dep}_FOUND") + list(APPEND ATK_INCLUDE_DIRS ${${atk_dep}_INCLUDE_DIRS}) + + set_property (TARGET "${ATK}" APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${${atk_dep}}") +endforeach(atk_dep) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ATK + REQUIRED_VARS + ATK_LIBRARY + ATK_INCLUDE_DIRS + ${ATK_DEPS_FOUND_VARS} + VERSION_VAR + ATK_VERSION) + +unset(ATK_DEPS_FOUND_VARS) diff --git a/cmake/FindAVAHI.cmake b/cmake/FindAVAHI.cmake deleted file mode 100644 index d7ec2940d..000000000 --- a/cmake/FindAVAHI.cmake +++ /dev/null @@ -1,55 +0,0 @@ -# Remmina - The GTK+ Remote Desktop Client -# -# Copyright (C) 2011 Marc-Andre Moreau -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. - -include(FindPkgConfig) - -if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_AVAHI_CLIENT avahi-client) - if(GTK3_FOUND) - set(_AVAHI_UI_LIB_NAME avahi-ui-gtk3) - set(_AVAHI_UI_PKG_NAME avahi-ui-gtk3>=0.6.30 avahi-client>=0.6.30) - endif() - pkg_check_modules(PC_AVAHI_UI ${_AVAHI_UI_PKG_NAME}) -endif() - - -find_library(AVAHI_COMMON_LIBRARY NAMES avahi-common PATHS ${PC_AVAHI_CLIENT_LIBRARY_DIRS}) -if(AVAHI_COMMON_LIBRARY) - set(AVAHI_COMMON_FOUND TRUE) -endif() - -find_library(AVAHI_CLIENT_LIBRARY NAMES avahi-client PATHS ${PC_AVAHI_CLIENT_LIBRARY_DIRS}) -if(AVAHI_CLIENT_LIBRARY) - set(AVAHI_CLIENT_FOUND TRUE) -endif() - -find_path(AVAHI_UI_INCLUDE_DIR avahi-ui/avahi-ui.h PATHS ${PC_AVAHI_UI_INCLUDE_DIRS}) -find_library(AVAHI_UI_LIBRARY NAMES ${_AVAHI_UI_LIB_NAME} PATHS ${PC_AVAHI_UI_LIBRARY_DIRS}) -if(AVAHI_UI_INCLUDE_DIR AND AVAHI_UI_LIBRARY) - set(AVAHI_UI_FOUND TRUE) -endif() - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(AVAHI DEFAULT_MSG AVAHI_COMMON_FOUND AVAHI_CLIENT_FOUND AVAHI_UI_FOUND) - -if (AVAHI_FOUND) - set(AVAHI_INCLUDE_DIRS ${AVAHI_UI_INCLUDE_DIR}) - set(AVAHI_LIBRARIES ${AVAHI_COMMON_LIBRARY} ${AVAHI_CLIENT_LIBRARY} ${AVAHI_UI_LIBRARY}) -endif() - -mark_as_advanced(AVAHI_INCLUDE_DIRS AVAHI_LIBRARIES) diff --git a/cmake/FindAvahi.cmake b/cmake/FindAvahi.cmake new file mode 100644 index 000000000..b3d05b230 --- /dev/null +++ b/cmake/FindAvahi.cmake @@ -0,0 +1,68 @@ +# Try to find the Avahi libraries and headers +# Once done this will define: +# +# AVAHI_FOUND - system has the avahi libraries +# AVAHI_INCLUDE_DIRS - the avahi include directories +# AVAHI_LIBRARIES - The libraries needed to use avahi + +# use pkg-config to get the directories and then use these values +# in the find_path() and find_library() calls +find_package(PkgConfig) + +if(PKG_CONFIG_FOUND) + pkg_check_modules(_AVAHI avahi-client) +endif(PKG_CONFIG_FOUND) + +find_library(AVAHI_COMMON_LIB NAMES avahi-common + PATHS + ${_AVAHI_LIBRARY_DIRS} + ${COMMON_LIB_DIR} +) + +find_library(AVAHI_CLIENT_LIB NAMES avahi-client + PATHS + ${_AVAHI_LIBRARY_DIRS} + ${CLIENT_LIB_DIR} +) + +find_library(AVAHI_UI_LIB NAMES avahi-ui-gtk3 + PATHS + ${_AVAHI_LIBRARY_DIRS} + ${UI_LIB_DIR} +) + + +if(AVAHI_COMMON_LIB AND AVAHI_CLIENT_LIB AND AVAHI_UI_LIB) + set(AVAHI_LIBRARIES ${AVAHI_COMMON_LIB} ${AVAHI_CLIENT_LIB} ${AVAHI_UI_LIB}) + message(STATUS "Avahi-Libs found: ${AVAHI_LIBRARIES}") +endif() + +find_path(COMMON_INCLUDE_DIR watch.h + PATH_SUFFIXES avahi-common + PATHS + ${_AVAHI_INCLUDE_DIRS} + ${COMMON_INCLUDE_DIR} +) + +find_path(CLIENT_INCLUDE_DIR client.h + PATH_SUFFIXES avahi-client + PATHS + ${_AVAHI_INCLUDE_DIRS} + ${CLIENT_INCLUDE_DIR} +) + +find_path(UI_INCLUDE_DIR avahi-ui.h + PATH_SUFFIXES avahi-ui + PATHS + ${_AVAHI_INCLUDE_DIRS} + ${UI_INCLUDE_DIR} +) + +if(COMMON_INCLUDE_DIR AND CLIENT_INCLUDE_DIR AND UI_INCLUDE_DIR) + set(AVAHI_INCLUDE_DIRS ${COMMON_INCLUDE_DIR} ${CLIENT_INCLUDE_DIR} ${UI_INCLUDE_DIR}) + message(STATUS "Avahi-Include-Dirs found: ${AVAHI_INCLUDE_DIRS}") +endif() + +if(AVAHI_LIBRARIES AND AVAHI_INCLUDE_DIRS) + set(AVAHI_FOUND TRUE) +endif() diff --git a/cmake/FindCairo.cmake b/cmake/FindCairo.cmake new file mode 100644 index 000000000..9ff840c09 --- /dev/null +++ b/cmake/FindCairo.cmake @@ -0,0 +1,87 @@ +# FindCairo.cmake +# <https://github.com/nemequ/gnome-cmake> +# +# CMake support for Cairo. +# +# License: +# +# Copyright (c) 2016 Evan Nemerson <evan@nemerson.com> +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +find_package(PkgConfig) + +set(Cairo_DEPS) + +if(PKG_CONFIG_FOUND) + pkg_search_module(Cairo_PKG cairo) +endif() + +find_library(Cairo_LIBRARY cairo HINTS ${Cairo_PKG_LIBRARY_DIRS}) +set(Cairo cairo) + +if(Cairo_LIBRARY) + add_library(${Cairo} SHARED IMPORTED) + set_property(TARGET ${Cairo} PROPERTY IMPORTED_LOCATION "${Cairo_LIBRARY}") + set_property(TARGET ${Cairo} PROPERTY INTERFACE_COMPILE_OPTIONS "${Cairo_PKG_CFLAGS_OTHER}") + + set(Cairo_INCLUDE_DIRS) + + find_path(Cairo_INCLUDE_DIR "cairo.h" + HINTS ${Cairo_PKG_INCLUDE_DIRS}) + + if(Cairo_INCLUDE_DIR) + file(STRINGS "${Cairo_INCLUDE_DIR}/cairo-version.h" Cairo_VERSION_MAJOR REGEX "^#define CAIRO_VERSION_MAJOR +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define CAIRO_VERSION_MAJOR \\(?([0-9]+)\\)?$" "\\1" Cairo_VERSION_MAJOR "${Cairo_VERSION_MAJOR}") + file(STRINGS "${Cairo_INCLUDE_DIR}/cairo-version.h" Cairo_VERSION_MINOR REGEX "^#define CAIRO_VERSION_MINOR +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define CAIRO_VERSION_MINOR \\(?([0-9]+)\\)?$" "\\1" Cairo_VERSION_MINOR "${Cairo_VERSION_MINOR}") + file(STRINGS "${Cairo_INCLUDE_DIR}/cairo-version.h" Cairo_VERSION_MICRO REGEX "^#define CAIRO_VERSION_MICRO +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define CAIRO_VERSION_MICRO \\(?([0-9]+)\\)?$" "\\1" Cairo_VERSION_MICRO "${Cairo_VERSION_MICRO}") + set(Cairo_VERSION "${Cairo_VERSION_MAJOR}.${Cairo_VERSION_MINOR}.${Cairo_VERSION_MICRO}") + unset(Cairo_VERSION_MAJOR) + unset(Cairo_VERSION_MINOR) + unset(Cairo_VERSION_MICRO) + + list(APPEND Cairo_INCLUDE_DIRS ${Cairo_INCLUDE_DIR}) + set_property(TARGET ${Cairo} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${Cairo_INCLUDE_DIR}") + endif() +endif() + +set(Cairo_DEPS_FOUND_VARS) +foreach(cairo_dep ${Cairo_DEPS}) + find_package(${cairo_dep}) + + list(APPEND Cairo_DEPS_FOUND_VARS "${cairo_dep}_FOUND") + list(APPEND Cairo_INCLUDE_DIRS ${${cairo_dep}_INCLUDE_DIRS}) + + set_property (TARGET ${Cairo} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${${cairo_dep}}") +endforeach(cairo_dep) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Cairo + REQUIRED_VARS + Cairo_LIBRARY + Cairo_INCLUDE_DIRS + ${Cairo_DEPS_FOUND_VARS} + VERSION_VAR + Cairo_VERSION) + +unset(Cairo_DEPS_FOUND_VARS) diff --git a/cmake/FindFFMPEG.cmake b/cmake/FindFFMPEG.cmake new file mode 100644 index 000000000..9065fed64 --- /dev/null +++ b/cmake/FindFFMPEG.cmake @@ -0,0 +1,141 @@ +# - Try to find FFMPEG +# Once done this will define +# FFMPEG_FOUND - System has FFMPEG +# FFMPEG_INCLUDE_DIRS - The FFMPEG include directories +# FFMPEG_LIBRARIES - The libraries needed to use FFMPEG +# FFMPEG_LIBRARY_DIRS - The directory to find FFMPEG libraries +# +# written by Roy Shilkrot 2013 http://www.morethantechnical.com/ +# + +find_package(PkgConfig) + + +MACRO(FFMPEG_FIND varname shortname headername) + + IF(NOT WIN32) + PKG_CHECK_MODULES(PC_${varname} ${shortname}) + + FIND_PATH(${varname}_INCLUDE_DIR "${shortname}/${headername}" + HINTS ${PC_${varname}_INCLUDEDIR} ${PC_${varname}_INCLUDE_DIRS} + NO_DEFAULT_PATH + ) + ELSE() + FIND_PATH(${varname}_INCLUDE_DIR "${shortname}/${headername}") + ENDIF() + + IF(${varname}_INCLUDE_DIR STREQUAL "${varname}_INCLUDE_DIR-NOTFOUND") + message(STATUS "Look for newer structure") + IF(NOT WIN32) + PKG_CHECK_MODULES(PC_${varname} "lib${shortname}") + + FIND_PATH(${varname}_INCLUDE_DIR "lib${shortname}/${headername}" + HINTS ${PC_${varname}_INCLUDEDIR} ${PC_${varname}_INCLUDE_DIRS} + NO_DEFAULT_PATH + ) + ELSE() + FIND_PATH(${varname}_INCLUDE_DIR "lib${shortname}/${headername}") + IF(${${varname}_INCLUDE_DIR} STREQUAL "${varname}_INCLUDE_DIR-NOTFOUND") + #Desperate times call for desperate measures + MESSAGE(STATUS "globbing...") + FILE(GLOB_RECURSE ${varname}_INCLUDE_DIR "/ffmpeg*/${headername}") + MESSAGE(STATUS "found: ${${varname}_INCLUDE_DIR}") + IF(${varname}_INCLUDE_DIR) + GET_FILENAME_COMPONENT(${varname}_INCLUDE_DIR "${${varname}_INCLUDE_DIR}" PATH) + GET_FILENAME_COMPONENT(${varname}_INCLUDE_DIR "${${varname}_INCLUDE_DIR}" PATH) + ELSE() + SET(${varname}_INCLUDE_DIR "${varname}_INCLUDE_DIR-NOTFOUND") + ENDIF() + ENDIF() + ENDIF() + ENDIF() + + + IF(${${varname}_INCLUDE_DIR} STREQUAL "${varname}_INCLUDE_DIR-NOTFOUND") + MESSAGE(STATUS "Can't find includes for ${shortname}...") + ELSE() + MESSAGE(STATUS "Found ${shortname} include dirs: ${${varname}_INCLUDE_DIR}") + +# GET_DIRECTORY_PROPERTY(FFMPEG_PARENT DIRECTORY ${${varname}_INCLUDE_DIR} PARENT_DIRECTORY) + GET_FILENAME_COMPONENT(FFMPEG_PARENT ${${varname}_INCLUDE_DIR} PATH) + MESSAGE(STATUS "Using FFMpeg dir parent as hint: ${FFMPEG_PARENT}") + + IF(NOT WIN32) + FIND_LIBRARY(${varname}_LIBRARIES NAMES ${shortname} + HINTS ${PC_${varname}_LIBDIR} ${PC_${varname}_LIBRARY_DIR} ${FFMPEG_PARENT}) + ELSE() +# FIND_PATH(${varname}_LIBRARIES "${shortname}.dll.a" HINTS ${FFMPEG_PARENT}) + FILE(GLOB_RECURSE ${varname}_LIBRARIES "${FFMPEG_PARENT}/*${shortname}.lib") + # GLOBing is very bad... but windows sux, this is the only thing that works + ENDIF() + + IF(${varname}_LIBRARIES STREQUAL "${varname}_LIBRARIES-NOTFOUND") + MESSAGE(STATUS "look for newer structure for library") + FIND_LIBRARY(${varname}_LIBRARIES NAMES lib${shortname} + HINTS ${PC_${varname}_LIBDIR} ${PC_${varname}_LIBRARY_DIR} ${FFMPEG_PARENT}) + ENDIF() + + + IF(${varname}_LIBRARIES STREQUAL "${varname}_LIBRARIES-NOTFOUND") + MESSAGE(STATUS "Can't find lib for ${shortname}...") + ELSE() + MESSAGE(STATUS "Found ${shortname} libs: ${${varname}_LIBRARIES}") + ENDIF() + + + IF(NOT ${varname}_INCLUDE_DIR STREQUAL "${varname}_INCLUDE_DIR-NOTFOUND" + AND NOT ${varname}_LIBRARIES STREQUAL ${varname}_LIBRARIES-NOTFOUND) + + MESSAGE(STATUS "found ${shortname}: include ${${varname}_INCLUDE_DIR} lib ${${varname}_LIBRARIES}") + SET(FFMPEG_${varname}_FOUND 1) + SET(FFMPEG_${varname}_INCLUDE_DIRS ${${varname}_INCLUDE_DIR}) + SET(FFMPEG_${varname}_LIBS ${${varname}_LIBRARIES}) + ELSE() + MESSAGE(STATUS "Can't find ${shortname}") + ENDIF() + + ENDIF() + +ENDMACRO(FFMPEG_FIND) + +FFMPEG_FIND(LIBAVFORMAT avformat avformat.h) +FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h) +FFMPEG_FIND(LIBAVUTIL avutil avutil.h) +FFMPEG_FIND(LIBSWRESAMPLE swresample swresample.h) + +SET(FFMPEG_FOUND "NO") +IF (FFMPEG_LIBAVFORMAT_FOUND AND + FFMPEG_LIBAVCODEC_FOUND AND + FFMPEG_LIBAVUTIL_FOUND AND + FFMPEG_LIBSWRESAMPLE_FOUND +) + + + SET(FFMPEG_FOUND "YES") + + SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}) + + SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS}) + + SET(FFMPEG_LIBRARIES + ${FFMPEG_LIBAVFORMAT_LIBS} + ${FFMPEG_LIBAVCODEC_LIBS} + ${FFMPEG_LIBAVUTIL_LIBS} + ${FFMPEG_LIBSWRESAMPLE_LIBS} + ) + +ELSE () + + MESSAGE(STATUS "Could not find FFMPEG") + +ENDIF() + +message(STATUS ${FFMPEG_LIBRARIES} ${FFMPEG_LIBAVFORMAT_LIBRARIES}) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set FFMPEG_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(FFMPEG DEFAULT_MSG + FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS) + +mark_as_advanced(FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARY_DIRS FFMPEG_LIBRARIES) diff --git a/cmake/FindGDK3.cmake b/cmake/FindGDK3.cmake new file mode 100644 index 000000000..ee6b6c634 --- /dev/null +++ b/cmake/FindGDK3.cmake @@ -0,0 +1,88 @@ +# FindGDK3.cmake +# <https://github.com/nemequ/gnome-cmake> +# +# CMake support for GDK 3. +# +# License: +# +# Copyright (c) 2016 Evan Nemerson <evan@nemerson.com> +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +find_package(PkgConfig) + +set(GDK3_DEPS + Pango) + +if(PKG_CONFIG_FOUND) + pkg_search_module(GDK3_PKG gdk-3.0) +endif() + +find_library(GDK3_LIBRARY gdk-3 HINTS ${GDK3_PKG_LIBRARY_DIRS}) +set(GDK3 "gdk-3") + +if(GDK3_LIBRARY) + add_library(${GDK3} SHARED IMPORTED) + set_property(TARGET ${GDK3} PROPERTY IMPORTED_LOCATION "${GDK3_LIBRARY}") + set_property(TARGET ${GDK3} PROPERTY INTERFACE_COMPILE_OPTIONS "${GDK3_PKG_CFLAGS_OTHER}") + + set(GDK3_INCLUDE_DIRS) + + find_path(GDK3_INCLUDE_DIR "gdk/gdk.h" + HINTS ${GDK3_PKG_INCLUDE_DIRS}) + + if(GDK3_INCLUDE_DIR) + file(STRINGS "${GDK3_INCLUDE_DIR}/gdk/gdkversionmacros.h" GDK3_MAJOR_VERSION REGEX "^#define GDK_MAJOR_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define GDK_MAJOR_VERSION \\(?([0-9]+)\\)?$" "\\1" GDK3_MAJOR_VERSION "${GDK3_MAJOR_VERSION}") + file(STRINGS "${GDK3_INCLUDE_DIR}/gdk/gdkversionmacros.h" GDK3_MINOR_VERSION REGEX "^#define GDK_MINOR_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define GDK_MINOR_VERSION \\(?([0-9]+)\\)?$" "\\1" GDK3_MINOR_VERSION "${GDK3_MINOR_VERSION}") + file(STRINGS "${GDK3_INCLUDE_DIR}/gdk/gdkversionmacros.h" GDK3_MICRO_VERSION REGEX "^#define GDK_MICRO_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define GDK_MICRO_VERSION \\(?([0-9]+)\\)?$" "\\1" GDK3_MICRO_VERSION "${GDK3_MICRO_VERSION}") + set(GDK3_VERSION "${GDK3_MAJOR_VERSION}.${GDK3_MINOR_VERSION}.${GDK3_MICRO_VERSION}") + unset(GDK3_MAJOR_VERSION) + unset(GDK3_MINOR_VERSION) + unset(GDK3_MICRO_VERSION) + + list(APPEND GDK3_INCLUDE_DIRS ${GDK3_INCLUDE_DIR}) + set_property(TARGET ${GDK3} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GDK3_INCLUDE_DIR}") + endif() +endif() + +set(GDK3_DEPS_FOUND_VARS) +foreach(gdk3_dep ${GDK3_DEPS}) + find_package(${gdk3_dep}) + + list(APPEND GDK3_DEPS_FOUND_VARS "${gdk3_dep}_FOUND") + list(APPEND GDK3_INCLUDE_DIRS ${${gdk3_dep}_INCLUDE_DIRS}) + + set_property (TARGET ${GDK3} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${${gdk3_dep}}") +endforeach(gdk3_dep) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GDK3 + REQUIRED_VARS + GDK3_LIBRARY + GDK3_INCLUDE_DIRS + ${GDK3_DEPS_FOUND_VARS} + VERSION_VAR + GDK3_VERSION) + +unset(GDK3_DEPS_FOUND_VARS) diff --git a/cmake/FindGDKPixbuf.cmake b/cmake/FindGDKPixbuf.cmake new file mode 100644 index 000000000..726a515ce --- /dev/null +++ b/cmake/FindGDKPixbuf.cmake @@ -0,0 +1,80 @@ +# FindGDKPixbuf.cmake +# <https://github.com/nemequ/gnome-cmake> +# +# CMake support for GDK Pixbuf. +# +# License: +# +# Copyright (c) 2016 Evan Nemerson <evan@nemerson.com> +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +find_package(PkgConfig) + +set(GDKPixbuf_DEPS + GLib) + +if(PKG_CONFIG_FOUND) + pkg_search_module(GDKPixbuf_PKG gdk-pixbuf-2.0) +endif() + +find_library(GDKPixbuf_LIBRARY gdk_pixbuf-2.0 HINTS ${GDKPixbuf_PKG_LIBRARY_DIRS}) +set(GDKPixbuf "gdk_pixbuf-2.0") + +if(GDKPixbuf_LIBRARY) + add_library(${GDKPixbuf} SHARED IMPORTED) + set_property(TARGET ${GDKPixbuf} PROPERTY IMPORTED_LOCATION "${GDKPixbuf_LIBRARY}") + set_property(TARGET ${GDKPixbuf} PROPERTY INTERFACE_COMPILE_OPTIONS "${GDKPixbuf_PKG_CFLAGS_OTHER}") + + set(GDKPixbuf_INCLUDE_DIRS) + + find_path(GDKPixbuf_INCLUDE_DIR "gdk-pixbuf/gdk-pixbuf.h" + HINTS ${GDKPixbuf_PKG_INCLUDE_DIRS}) + + if(GDKPixbuf_INCLUDE_DIR) + file(STRINGS "${GDKPixbuf_INCLUDE_DIR}/gdk-pixbuf/gdk-pixbuf-features.h" GDKPixbuf_VERSION REGEX "^#define GDKPIXBUF_VERSION \\\"[^\\\"]+\\\"") + string(REGEX REPLACE "^#define GDKPIXBUF_VERSION \\\"([0-9]+)\\.([0-9]+)\\.([0-9]+)\\\"$" "\\1.\\2.\\3" GDKPixbuf_VERSION "${GDKPixbuf_VERSION}") + + list(APPEND GDKPixbuf_INCLUDE_DIRS ${GDKPixbuf_INCLUDE_DIR}) + set_property(TARGET ${GDKPixbuf} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GDKPixbuf_INCLUDE_DIR}") + endif() +endif() + +set(GDKPixbuf_DEPS_FOUND_VARS) +foreach(gdkpixbuf_dep ${GDKPixbuf_DEPS}) + find_package(${gdkpixbuf_dep}) + + list(APPEND GDKPixbuf_DEPS_FOUND_VARS "${gdkpixbuf_dep}_FOUND") + list(APPEND GDKPixbuf_INCLUDE_DIRS ${${gdkpixbuf_dep}_INCLUDE_DIRS}) + + set_property (TARGET ${GDKPixbuf} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${${gdkpixbuf_dep}}") +endforeach(gdkpixbuf_dep) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GDKPixbuf + REQUIRED_VARS + GDKPixbuf_LIBRARY + GDKPixbuf_INCLUDE_DIRS + ${GDKPixbuf_DEPS_FOUND_VARS} + VERSION_VAR + GDKPixbuf_VERSION) + +unset(GDKPixbuf_DEPS_FOUND_VARS) diff --git a/cmake/FindGIO.cmake b/cmake/FindGIO.cmake new file mode 100644 index 000000000..bbf6481e1 --- /dev/null +++ b/cmake/FindGIO.cmake @@ -0,0 +1,203 @@ +# FindGIO.cmake +# <https://github.com/nemequ/gnome-cmake> +# +# CMake support for GIO. +# +# License: +# +# Copyright (c) 2016 Evan Nemerson <evan@nemerson.com> +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +find_package(PkgConfig) + +set(GIO_DEPS + GObject) + +if(PKG_CONFIG_FOUND) + pkg_search_module(GIO_PKG gio-2.0) + pkg_check_modules(GIO-UNIX_PKG REQUIRED gio-unix-2.0) +endif() + +find_library(GIO_LIBRARY gio-2.0 HINTS ${GIO_PKG_LIBRARY_DIRS}) +set(GIO "gio-2.0") + +if(GIO_LIBRARY AND NOT GIO_FOUND) + add_library(${GIO} SHARED IMPORTED) + set_property(TARGET ${GIO} PROPERTY IMPORTED_LOCATION "${GIO_LIBRARY}") + set_property(TARGET ${GIO} PROPERTY INTERFACE_COMPILE_OPTIONS "${GIO_PKG_CFLAGS_OTHER}") + + find_path(GIO_INCLUDE_DIR "gio/gio.h" + HINTS ${GIO_PKG_INCLUDE_DIRS}) + +find_path(GIO-UNIX_INCLUDE_DIR "gio/gdesktopappinfo.h" + HINTS ${GIO-UNIX_PKG_INCLUDE_DIRS}) + + + find_package(GLib) + find_package(GObject) + set(GIO_VERSION "${GLib_VERSION}") + + list(APPEND GIO_DEPS_FOUND_VARS "GObject_FOUND") + list(APPEND GIO_INCLUDE_DIRS ${GIO-UNIX_INCLUDE_DIR} ${GObject_INCLUDE_DIRS}) + + set_property (TARGET "${GIO}" APPEND PROPERTY INTERFACE_LINK_LIBRARIES "gobject-2.0") + set_property(TARGET ${GIO} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GIO_INCLUDE_DIR}") +endif() + +find_program(GLib_COMPILE_SCHEMAS glib-compile-schemas) +if(GLib_COMPILE_SCHEMAS AND NOT GLib_FOUND) + add_executable(glib-compile-schemas IMPORTED) + set_property(TARGET glib-compile-schemas PROPERTY IMPORTED_LOCATION "${GLib_COMPILE_SCHEMAS}") +endif() + +# glib_install_schemas( +# [DESTINATION directory] +# schemas…) +# +# Validate and install the listed schemas. +function(glib_install_schemas) + set (options) + set (oneValueArgs DESTINATION) + set (multiValueArgs) + cmake_parse_arguments(GSCHEMA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + unset (options) + unset (oneValueArgs) + unset (multiValueArgs) + + foreach(schema ${GSCHEMA_UNPARSED_ARGUMENTS}) + get_filename_component(schema_name "${schema}" NAME) + string(REGEX REPLACE "^(.+)\.gschema.xml$" "\\1" schema_name "${schema_name}") + set(schema_output "${CMAKE_CURRENT_BINARY_DIR}/${schema_name}.gschema.xml.valid") + + add_custom_command( + OUTPUT "${schema_output}" + COMMAND glib-compile-schemas + --strict + --dry-run + --schema-file="${schema}" + COMMAND "${CMAKE_COMMAND}" ARGS -E touch "${schema_output}" + DEPENDS "${schema}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Validating ${schema}") + + add_custom_target("gsettings-schema-${schema_name}" ALL + DEPENDS "${schema_output}") + + if(CMAKE_INSTALL_FULL_DATADIR) + set(SCHEMADIR "${CMAKE_INSTALL_FULL_DATADIR}/glib-2.0/schemas") + else() + set(SCHEMADIR "${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas") + endif() + install(FILES "${schema}" + DESTINATION "${SCHEMADIR}") + install(CODE "execute_process(COMMAND \"${GLib_COMPILE_SCHEMAS}\" \"${SCHEMADIR}\")") + endforeach() +endfunction() + +find_program(GLib_COMPILE_RESOURCES glib-compile-resources) +if(GLib_COMPILE_RESOURCES AND NOT GLib_FOUND) + add_executable(glib-compile-resources IMPORTED) + set_property(TARGET glib-compile-resources PROPERTY IMPORTED_LOCATION "${GLib_COMPILE_RESOURCES}") +endif() + +function(glib_compile_resources SPEC_FILE) + set (options INTERNAL) + set (oneValueArgs TARGET SOURCE_DIR HEADER SOURCE C_NAME) + set (multiValueArgs) + cmake_parse_arguments(GLib_COMPILE_RESOURCES "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + unset (options) + unset (oneValueArgs) + unset (multiValueArgs) + + if(NOT GLib_COMPILE_RESOURCES_SOURCE_DIR) + set(GLib_COMPILE_RESOURCES_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + endif() + + set(FLAGS) + + if(GLib_COMPILE_RESOURCES_INTERNAL) + list(APPEND FLAGS "--internal") + endif() + + if(GLib_COMPILE_RESOURCES_C_NAME) + list(APPEND FLAGS "--c-name" "${GLib_COMPILE_RESOURCES_C_NAME}") + endif() + + get_filename_component(SPEC_FILE "${SPEC_FILE}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + + execute_process( + COMMAND glib-compile-resources + --generate-dependencies + --sourcedir "${GLib_COMPILE_RESOURCES_SOURCE_DIR}" + "${SPEC_FILE}" + OUTPUT_VARIABLE deps + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REPLACE "\n" ";" deps ${deps}) + + if(GLib_COMPILE_RESOURCES_HEADER) + get_filename_component(GLib_COMPILE_RESOURCES_HEADER "${GLib_COMPILE_RESOURCES_HEADER}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") + + add_custom_command( + OUTPUT "${GLib_COMPILE_RESOURCES_HEADER}" + COMMAND glib-compile-resources + --sourcedir "${GLib_COMPILE_RESOURCES_SOURCE_DIR}" + --generate-header + --target "${GLib_COMPILE_RESOURCES_HEADER}" + ${FLAGS} + "${SPEC_FILE}" + DEPENDS "${SPEC_FILE}" ${deps} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + endif() + + if(GLib_COMPILE_RESOURCES_SOURCE) + get_filename_component(GLib_COMPILE_RESOURCES_SOURCE "${GLib_COMPILE_RESOURCES_SOURCE}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") + + add_custom_command( + OUTPUT "${GLib_COMPILE_RESOURCES_SOURCE}" + COMMAND glib-compile-resources + --sourcedir "${GLib_COMPILE_RESOURCES_SOURCE_DIR}" + --generate-source + --target "${GLib_COMPILE_RESOURCES_SOURCE}" + ${FLAGS} + "${SPEC_FILE}" + DEPENDS "${SPEC_FILE}" ${deps} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + endif() +endfunction() + +find_program(GDBUS_CODEGEN gdbus-codegen) +if(GDBUS_CODEGEN AND NOT GLib_FOUND) + add_executable(gdbus-codegen IMPORTED) + set_property(TARGET gdbus-codegen PROPERTY IMPORTED_LOCATION "${GDBUS_CODEGEN}") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GIO + REQUIRED_VARS + GIO_LIBRARY + GIO_INCLUDE_DIRS + ${GIO_DEPS_FOUND_VARS} + VERSION_VAR + GIO_VERSION) + +unset(GIO_DEPS_FOUND_VARS) diff --git a/cmake/FindGLIB2.cmake b/cmake/FindGLIB2.cmake deleted file mode 100644 index 139e6ec9f..000000000 --- a/cmake/FindGLIB2.cmake +++ /dev/null @@ -1,120 +0,0 @@ -# Remmina - The GTK+ Remote Desktop Client -# -# Copyright (C) 2012 Andrey Gankov -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. - -set(_GLIB_found_all true) - -# Glib - -pkg_check_modules(PC_GLIB2 glib-2.0>=2.30) - -if(NOT PC_GLIB2_FOUND) - set(_GLIB_found_all false) -endif() - -find_path(GLIB2_INCLUDE_DIR_PART1 NAMES glib.h - HINTS ${PC_GLIB2_INCLUDEDIR} ${PC_GLIB2_INCLUDE_DIRS} - PATH_SUFFIXES glib-2.0) - -find_path(GLIB2_INCLUDE_DIR_PART2 NAMES glibconfig.h - HINTS ${PC_GLIB2_INCLUDEDIR} ${PC_GLIB2_INCLUDE_DIRS} - PATH_SUFFIXES glib-2.0/include) - -set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR_PART1} ${GLIB2_INCLUDE_DIR_PART2}) - -find_library(GLIB2_LIBRARY NAMES glib-2.0) - -# GIO - -pkg_check_modules(PC_GIO gio-2.0) - -if(NOT PC_GIO_FOUND) - set(_GLIB_found_all false) -endif() - -find_path(GIO_INCLUDE_DIR gio/gio.h - HINTS ${PC_GIO_INCLUDEDIR} ${PC_GIO_INCLUDE_DIRS} - PATH_SUFFIXES gio-2.0) - -find_library(GIO_LIBRARY NAMES gio-2.0 - HINTS ${PC_GIO_LIBDIR} ${PC_GIO_LIBRARY_DIRS}) - -# gobject - -pkg_check_modules(PC_GOBJECT gobject-2.0) - -if(NOT PC_GOBJECT_FOUND) - set(_GLIB_found_all false) -endif() - -find_path(GOBJECT_INCLUDE_DIR gobject/gobject.h - HINTS ${PC_GOBJECT_INCLUDEDIR} ${PC_GOBJECT_INCLUDE_DIRS} - PATH_SUFFIXES gobject-2.0) - -find_library(GOBJECT_LIBRARY NAMES gobject-2.0 - HINTS ${PC_GOBJECT_LIBDIR} ${PC_GOBJECT_LIBRARY_DIRS}) - -# gmodule - -pkg_check_modules(PC_GMODULE gmodule-2.0) - -if(NOT PC_GMODULE_FOUND) - set(_GLIB_found_all false) -endif() - -find_path(GMODULE_INCLUDE_DIR gmodule.h - HINTS ${PC_GMODULE_INCLUDEDIR} ${PC_GMODULE_INCLUDE_DIRS} - PATH_SUFFIXES gmodule-2.0) - -find_library(GMODULE_LIBRARY NAMES gmodule-2.0 - HINTS ${PC_GMODULE_LIBDIR} ${PC_GMODULE_LIBRARY_DIRS}) - -# gthread - -pkg_check_modules(PC_GTHREAD gthread-2.0) - -if(NOT PC_GTHREAD_FOUND) - set(_GLIB_found_all false) -endif() - -find_path(GTHREAD_INCLUDE_DIR glib/gthread.h - HINTS ${PC_GTHREAD_INCLUDEDIR} ${PC_GTHREAD_INCLUDE_DIRS} - PATH_SUFFIXES gthread-2.0) - -find_library(GTHREAD_LIBRARY NAMES gthread-2.0 - HINTS ${PC_GTHREAD_LIBDIR} ${PC_GTHREAD_LIBRARY_DIRS}) - -# Finalize - -if(_GLIB_found_all) - include(FindPackageHandleStandardArgs) - - find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARY GLIB2_INCLUDE_DIR) - - set(GLIB2_LIBRARIES ${GLIB2_LIBRARY} ${GIO_LIBRARY} ${GOBJECT_LIBRARY} ${GMODULE_LIBRARY} ${GTHREAD_LIBRARY}) - set(GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIR} ${GIO_INCLUDE_DIR} ${GOBJECT_INCLUDE_DIR} ${GMODULE_INCLUDE_DIR} ${GTHREAD_INCLUDE_DIR}) - - mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARY) - - set(GLIB_FOUND true) -else() - unset(GLIB2_LIBRARY) - unset(GLIB2_INCLUDE_DIR) - - set(GLIB_FOUND false) -endif() diff --git a/cmake/FindGLib.cmake b/cmake/FindGLib.cmake new file mode 100644 index 000000000..050b9eb79 --- /dev/null +++ b/cmake/FindGLib.cmake @@ -0,0 +1,95 @@ +# FindGLib.cmake +# <https://github.com/nemequ/gnome-cmake> +# +# CMake support for GLib/GObject/GIO. +# +# License: +# +# Copyright (c) 2016 Evan Nemerson <evan@nemerson.com> +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +find_package(PkgConfig) + +if(PKG_CONFIG_FOUND) + pkg_search_module(GLib_PKG glib-2.0) + pkg_check_modules(PC_GMODULE gmodule-2.0) +endif() + +find_library(GLib_LIBRARY glib-2.0 HINTS ${GLib_PKG_LIBRARY_DIRS}) +set(GLib glib-2.0) + +# gmodule + +find_path(GMODULE_INCLUDE_DIR gmodule.h + HINTS ${PC_GMODULE_INCLUDEDIR} ${PC_GMODULE_INCLUDE_DIRS} + PATH_SUFFIXES gmodule-2.0) + +find_library(GMODULE_LIBRARY NAMES gmodule-2.0 + HINTS ${PC_GMODULE_LIBDIR} ${PC_GMODULE_LIBRARY_DIRS}) + +if(GLib_LIBRARY AND NOT GLib_FOUND) + add_library(${GLib} SHARED IMPORTED) + set_property(TARGET ${GLib} PROPERTY IMPORTED_LOCATION "${GLib_LIBRARY}") + set_property(TARGET ${GLib} PROPERTY INTERFACE_COMPILE_OPTIONS "${GLib_PKG_CFLAGS_OTHER}") + + find_path(GLib_INCLUDE_DIRS "glib.h" + HINTS ${GLib_PKG_INCLUDE_DIRS} + PATH_SUFFIXES "glib-2.0") + + get_filename_component(GLib_LIBDIR "${GLib}" DIRECTORY) + find_path(GLib_CONFIG_INCLUDE_DIR "glibconfig.h" + HINTS + ${GLib_LIBDIR} + ${GLib_PKG_INCLUDE_DIRS} + PATHS + "${CMAKE_LIBRARY_PATH}" + PATH_SUFFIXES + "glib-2.0/include" + "glib-2.0") + unset(GLib_LIBDIR) + + if(GLib_CONFIG_INCLUDE_DIR) + file(STRINGS "${GLib_CONFIG_INCLUDE_DIR}/glibconfig.h" GLib_MAJOR_VERSION REGEX "^#define GLIB_MAJOR_VERSION +([0-9]+)") + string(REGEX REPLACE "^#define GLIB_MAJOR_VERSION ([0-9]+)$" "\\1" GLib_MAJOR_VERSION "${GLib_MAJOR_VERSION}") + file(STRINGS "${GLib_CONFIG_INCLUDE_DIR}/glibconfig.h" GLib_MINOR_VERSION REGEX "^#define GLIB_MINOR_VERSION +([0-9]+)") + string(REGEX REPLACE "^#define GLIB_MINOR_VERSION ([0-9]+)$" "\\1" GLib_MINOR_VERSION "${GLib_MINOR_VERSION}") + file(STRINGS "${GLib_CONFIG_INCLUDE_DIR}/glibconfig.h" GLib_MICRO_VERSION REGEX "^#define GLIB_MICRO_VERSION +([0-9]+)") + string(REGEX REPLACE "^#define GLIB_MICRO_VERSION ([0-9]+)$" "\\1" GLib_MICRO_VERSION "${GLib_MICRO_VERSION}") + set(GLib_VERSION "${GLib_MAJOR_VERSION}.${GLib_MINOR_VERSION}.${GLib_MICRO_VERSION}") + unset(GLib_MAJOR_VERSION) + unset(GLib_MINOR_VERSION) + unset(GLib_MICRO_VERSION) + + list(APPEND GLib_INCLUDE_DIRS ${GMODULE_INCLUDE_DIR} ${GLib_CONFIG_INCLUDE_DIR}) + set_property(TARGET ${GLib} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GLib_INCLUDE_DIRS}") + endif() +endif() + +list (APPEND GLib_LIBRARY ${GMODULE_LIBRARY}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GLib + REQUIRED_VARS + GLib_LIBRARY + GLib_INCLUDE_DIRS + VERSION_VAR + GLib_VERSION) diff --git a/cmake/FindGObject.cmake b/cmake/FindGObject.cmake new file mode 100644 index 000000000..7da343098 --- /dev/null +++ b/cmake/FindGObject.cmake @@ -0,0 +1,81 @@ +# FindGObject.cmake +# <https://github.com/nemequ/gnome-cmake> +# +# CMake support for GObject. +# +# License: +# +# Copyright (c) 2016 Evan Nemerson <evan@nemerson.com> +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +find_package(PkgConfig) + +set(GObject_DEPS + GLib) + +if(PKG_CONFIG_FOUND) + pkg_search_module(GObject_PKG gobject-2.0) +endif() + +find_library(GObject_LIBRARY gobject-2.0 HINTS ${GObject_PKG_LIBRARY_DIRS}) +set(GObject gobject-2.0) + +if(GObject_LIBRARY AND NOT GObject_FOUND) + add_library(${GObject} SHARED IMPORTED) + set_property(TARGET ${GObject} PROPERTY IMPORTED_LOCATION "${GObject_LIBRARY}") + set_property(TARGET ${GObject} PROPERTY INTERFACE_COMPILE_OPTIONS "${GObject_PKG_CFLAGS_OTHER}") + + find_path(GObject_INCLUDE_DIR "gobject/gobject.h" + HINTS ${GObject_PKG_INCLUDE_DIRS}) + + find_package(GLib) + set(GObject_VERSION "${GLib_VERSION}") + + list(APPEND GObject_DEPS_FOUND_VARS "GLib_FOUND") + list(APPEND GObject_INCLUDE_DIRS ${GLib_INCLUDE_DIRS}) + set_property(TARGET ${GObject} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GObject_INCLUDE_DIR}") + + set_property (TARGET "${GObject}" APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${GLib}") +endif() + +find_program(GLib_GENMARSHAL glib-genmarshal) +if(GLib_GENMARSHAL AND NOT GLib_FOUND) + add_executable(glib-genmarshal IMPORTED) + set_property(TARGET glib-genmarshal PROPERTY IMPORTED_LOCATION "${GLib_GENMARSHAL}") +endif() + +find_program(GLib_MKENUMS glib-mkenums) +if(GLib_MKENUMS AND NOT GLib_FOUND) + add_executable(glib-mkenums IMPORTED) + set_property(TARGET glib-mkenums PROPERTY IMPORTED_LOCATION "${GLib_MKENUMS}") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GObject + REQUIRED_VARS + GObject_LIBRARY + GObject_INCLUDE_DIRS + ${GObject_DEPS_FOUND_VARS} + VERSION_VAR + GObject_VERSION) + +unset(GObject_DEPS_FOUND_VARS) diff --git a/cmake/FindGTK.cmake b/cmake/FindGTK.cmake deleted file mode 100644 index 8d430f8d5..000000000 --- a/cmake/FindGTK.cmake +++ /dev/null @@ -1,55 +0,0 @@ -# Remmina - The GTK+ Remote Desktop Client -# -# Copyright (C) 2012 Daniel M. Weeks -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. - -if(GTK_VERSION) - find_required_package(GTK${GTK_VERSION}) - if(GTK${GTK_VERSION}_FOUND) - set(GTK_FOUND true) - else() - set(GTK_FOUND false) - endif() -else() - find_package(GTK3 QUIET) - if(GTK3_FOUND) - set(GTK_VERSION 3) - set(GTK_FOUND true) - endif() -endif() - -if(GTK_VERSION) - set(_GTK_ERR_MESSAGE "GTK ${GTK_VERSION} not found.") -else() - set(_GTK_ERR_MESSAGE "No GTK not found.") -endif() - -if (GTK_FOUND) - set(GTK_LIBRARIES ${GTK${GTK_VERSION}_LIBRARIES}) - unset(GTK${GTK_VERSION}_LIBRARIES) - - set(GTK_INCLUDE_DIRS ${GTK${GTK_VERSION}_INCLUDE_DIRS}) - unset(GTK${GTK_VERSION}_INCLUDE_DIRS) -else() - if(GTK_FIND_REQUIRED) - message(FATAL_ERROR ${_GTK_ERR_MESSAGE}) - else() - if(NOT VTK_FIND_QUIETLY) - message(STATUS ${_GTK_ERR_MESSAGE}) - endif() - endif() -endif() diff --git a/cmake/FindGTK3.cmake b/cmake/FindGTK3.cmake index 42c68566c..049a276fc 100644 --- a/cmake/FindGTK3.cmake +++ b/cmake/FindGTK3.cmake @@ -1,142 +1,93 @@ -# Remmina - The GTK+ Remote Desktop Client +# FindGTK3.cmake +# <https://github.com/nemequ/gnome-cmake> # -# Copyright (C) 2011 Marc-Andre Moreau -# Copyright (C) 2019 Antenore Gatta, Giovanni Panozzo +# CMake support for GTK+ 3. # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# License: # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# Copyright (c) 2016 Evan Nemerson <evan@nemerson.com> # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. - -set(_GTK3_found_all true) - -# Gtk - -pkg_check_modules(PC_GTK3 gtk+-3.0) - -if(NOT PC_GTK3_FOUND) - set(_GTK3_found_all false) -endif() - -find_path(GTK3_INCLUDE_DIR NAMES gtk/gtk.h - PATH_SUFFIXES gtk-3.0) - -find_library(GTK3_LIBRARY NAMES gtk-3) - -# Gdk - -find_library(GDK3_LIBRARY NAMES gdk-3) - -# Gdk-Pixbuf - -pkg_check_modules(PC_GDKPIXBUF gdk-pixbuf-2.0) - -if(NOT PC_GDKPIXBUF_FOUND) - set(_GTK3_found_all false) -endif() - -find_path(GDKPIXBUF_INCLUDE_DIR gdk-pixbuf/gdk-pixbuf.h - HINTS ${PC_GDKPIXBUF_INCLUDEDIR} ${PC_GDKPIXBUF_INCLUDE_DIRS} - PATH_SUFFIXES gdk-pixbuf-2.0) - -find_library(GDKPIXBUF_LIBRARY NAMES gdk_pixbuf-2.0 - HINTS ${PC_GDKPIXBUF_LIBDIR} ${PC_GDKPIXBUF_LIBRARY_DIRS}) - -# Wayland client, if GTK3's pkg-config suggests it. We only need -# the include dir - -find_path(WAYLAND_INCLUDE_DIR wayland-client.h - PATHS ${PC_GTK3_INCLUDE_DIRS}) - -# Glib - -find_required_package(GLIB2) -if(NOT GLIB2_FOUND) - set(_GTK3_found_all false) -endif() - -# Harfbuzz - -pkg_check_modules(PC_HB harfbuzz) -find_path(HB_INCLUDE_DIR - NAMES hb.h - HINTS ${PC_HB_INCLUDE_DIRS} - PATH_SUFFIXES harfbuzz -) - -# Pango - -pkg_check_modules(PC_PANGO pango) - -if(NOT PC_PANGO_FOUND) - set(_GTK3_found_all false) +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +find_package(PkgConfig) + +set(GTK3_DEPS + GIO + ATK + GDK3 + Pango + Cairo + GDKPixbuf) + +if(PKG_CONFIG_FOUND) + pkg_search_module(GTK3_PKG QUIET gtk+-3.0) endif() -find_path(PANGO_INCLUDE_DIR pango/pango.h - HINTS ${PC_PANGO_INCLUDEDIR} ${PC_PANGO_INCLUDE_DIRS} - PATH_SUFFIXES pango-1.0) - -find_library(PANGO_LIBRARY NAMES pango-1.0 - HINTS ${PC_PANGO_LIBDIR} ${PC_PANGO_LIBRARY_DIRS}) - -# Cairo - -set(CAIRO_DEFINITIONS ${PC_CAIRO_CXXFLAGS_OTHER}) - -find_path(CAIRO_INCLUDE_DIR cairo.h - HINTS ${PC_CAIRO_INCLUDEDIR} ${PC_CAIRO_INCLUDE_DIRS} - PATH_SUFFIXES cairo) - -find_library(CAIRO_LIBRARY NAMES cairo - HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS}) - -# Atk - -pkg_check_modules(PC_ATK atk) - -if(NOT PC_ATK_FOUND) - set(_GTK3_found_all false) +find_library(GTK3_LIBRARY gtk-3 HINTS ${GTK3_PKG_LIBRARY_DIRS}) +set(GTK3 gtk-3) + +if(GTK3_LIBRARY) + add_library(${GTK3} SHARED IMPORTED) + set_property(TARGET ${GTK3} PROPERTY IMPORTED_LOCATION "${GTK3_LIBRARY}") + set_property(TARGET ${GTK3} PROPERTY INTERFACE_COMPILE_OPTIONS "${GTK3_PKG_CFLAGS_OTHER}") + + set(GTK3_INCLUDE_DIRS) + + find_path(GTK3_INCLUDE_DIR "gtk/gtk.h" + HINTS ${GTK3_PKG_INCLUDE_DIRS}) + + if(GTK3_INCLUDE_DIR) + file(STRINGS "${GTK3_INCLUDE_DIR}/gtk/gtkversion.h" GTK3_MAJOR_VERSION REGEX "^#define GTK_MAJOR_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define GTK_MAJOR_VERSION \\(?([0-9]+)\\)?$" "\\1" GTK3_MAJOR_VERSION "${GTK3_MAJOR_VERSION}") + file(STRINGS "${GTK3_INCLUDE_DIR}/gtk/gtkversion.h" GTK3_MINOR_VERSION REGEX "^#define GTK_MINOR_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define GTK_MINOR_VERSION \\(?([0-9]+)\\)?$" "\\1" GTK3_MINOR_VERSION "${GTK3_MINOR_VERSION}") + file(STRINGS "${GTK3_INCLUDE_DIR}/gtk/gtkversion.h" GTK3_MICRO_VERSION REGEX "^#define GTK_MICRO_VERSION +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define GTK_MICRO_VERSION \\(?([0-9]+)\\)?$" "\\1" GTK3_MICRO_VERSION "${GTK3_MICRO_VERSION}") + set(GTK3_VERSION "${GTK3_MAJOR_VERSION}.${GTK3_MINOR_VERSION}.${GTK3_MICRO_VERSION}") + unset(GTK3_MAJOR_VERSION) + unset(GTK3_MINOR_VERSION) + unset(GTK3_MICRO_VERSION) + + list(APPEND GTK3_INCLUDE_DIRS ${GTK3_INCLUDE_DIR}) + set_property(TARGET ${GTK3} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GTK3_INCLUDE_DIR}") + endif() endif() -find_path(ATK_INCLUDE_DIR atk/atk.h - HINTS ${PC_ATK_INCLUDEDIR} ${PC_ATK_INCLUDE_DIRS} - PATH_SUFFIXES atk-1.0) - -find_library(ATK_LIBRARY NAMES atk-1.0 - HINTS ${PC_ATK_LIBDIR} ${PC_ATK_LIBRARY_DIRS}) +set(GTK3_DEPS_FOUND_VARS) +foreach(gtk3_dep ${GTK3_DEPS}) + find_package(${gtk3_dep}) -# Finalize + list(APPEND GTK3_DEPS_FOUND_VARS "${gtk3_dep}_FOUND") + list(APPEND GTK3_INCLUDE_DIRS ${${gtk3_dep}_INCLUDE_DIRS}) -if(_GTK3_found_all) - include(FindPackageHandleStandardArgs) + set_property (TARGET "${GTK3}" APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${${gtk3_dep}}") +endforeach(gtk3_dep) - find_package_handle_standard_args(GTK3 DEFAULT_MSG GTK3_LIBRARY GTK3_INCLUDE_DIR) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GTK3 + REQUIRED_VARS + GTK3_LIBRARY + GTK3_INCLUDE_DIRS + ${GTK3_DEPS_FOUND_VARS} + VERSION_VAR + GTK3_VERSION) - set(GTK3_LIBRARIES ${GTK3_LIBRARY} ${GDK3_LIBRARY} ${GLIB2_LIBRARIES} ${PANGO_LIBRARY} ${CAIRO_LIBRARY} ${GDKPIXBUF_LIBRARY} ${ATK_LIBRARY}) - set(GTK3_INCLUDE_DIRS ${GTK3_INCLUDE_DIR} ${GLIB2_INCLUDE_DIRS} ${HB_INCLUDE_DIR} ${PANGO_INCLUDE_DIR} ${CAIRO_INCLUDE_DIR} ${GDKPIXBUF_INCLUDE_DIR} ${ATK_INCLUDE_DIR}) - if (WAYLAND_INCLUDE_DIR) - set(GTK3_INCLUDE_DIRS ${GTK3_INCLUDE_DIRS} ${WAYLAND_INCLUDE_DIR}) - endif() - - mark_as_advanced(GTK3_INCLUDE_DIR GTK3_LIBRARY) - - set(GTK3_FOUND true) -else() - unset(GTK3_LIBRARY) - unset(GTK3_INCLUDE_DIR) - - unset(GDK3_LIBRARY) - unset(GDK3_INCLUDE_DIR) - - set(GTK3_FOUND false) -endif() +unset(GTK3_DEPS_FOUND_VARS) diff --git a/cmake/FindLibsecret.cmake b/cmake/FindLibsecret.cmake index 056b0ad21..562b202b4 100644 --- a/cmake/FindLibsecret.cmake +++ b/cmake/FindLibsecret.cmake @@ -29,12 +29,14 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -include(LibFindMacros) -libfind_pkg_check_modules(LIBSECRET libsecret-1) +#include(LibFindMacros) +#libfind_pkg_check_modules(LIBSECRET libsecret-1) +find_package(PkgConfig) +pkg_check_modules(LIBSECRET libsecret-1) foreach(i ${LIBSECRET_LIBRARIES}) - find_library(_libsecret_LIBRARY NAMES ${i} HINTS ${LIBSECRET_LIBRARY_DIRS}) - LIST(APPEND LIBSECRET_LIBRARY ${_libsecret_LIBRARY}) - unset(_libsecret_LIBRARY CACHE) + find_library(_libsecret_LIBRARY NAMES ${i} HINTS ${LIBSECRET_LIBRARY_DIRS}) + LIST(APPEND LIBSECRET_LIBRARY ${_libsecret_LIBRARY}) + unset(_libsecret_LIBRARY CACHE) endforeach(i) set(LIBSECRET_LIBRARIES ${LIBSECRET_LIBRARY}) unset(LIBSECRET_LIBRARY CACHE) @@ -51,9 +53,9 @@ if (LIBSECRET_VERSION) endif () endif () if (${LIBSECRET_VERSION} VERSION_GREATER "0.18.0") - add_definitions(-DLIBSECRET_VERSION_0_18) + add_definitions(-DLIBSECRET_VERSION_0_18) endif() endif () include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBSECRET DEFAULT_MSG LIBSECRET_INCLUDE_DIRS LIBSECRET_LIBRARIES VERSION_OK) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libsecret DEFAULT_MSG LIBSECRET_INCLUDE_DIRS LIBSECRET_LIBRARIES VERSION_OK) diff --git a/cmake/FindPango.cmake b/cmake/FindPango.cmake new file mode 100644 index 000000000..82ca25354 --- /dev/null +++ b/cmake/FindPango.cmake @@ -0,0 +1,94 @@ +# FindPango.cmake +# <https://github.com/nemequ/gnome-cmake> +# +# CMake support for Pango. +# +# License: +# +# Copyright (c) 2016 Evan Nemerson <evan@nemerson.com> +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +find_package(PkgConfig) + +set(Pango_DEPS + GLib) + +# Harfbuzz +pkg_check_modules(PC_HB harfbuzz) +find_path(HB_INCLUDE_DIR + NAMES hb.h + HINTS ${PC_HB_INCLUDE_DIRS} + PATH_SUFFIXES harfbuzz + ) + +if(PKG_CONFIG_FOUND) + pkg_search_module(Pango_PKG pango) +endif() + +find_library(Pango_LIBRARY pango-1.0 HINTS ${Pango_PKG_LIBRARY_DIRS}) +set(Pango pango-1.0) + +if(Pango_LIBRARY AND NOT Pango_FOUND) + add_library(${Pango} SHARED IMPORTED) + set_property(TARGET ${Pango} PROPERTY IMPORTED_LOCATION "${Pango_LIBRARY}") + set_property(TARGET ${Pango} PROPERTY INTERFACE_COMPILE_OPTIONS "${Pango_PKG_CFLAGS_OTHER}") + + find_path(Pango_INCLUDE_DIR "pango/pango.h" + HINTS ${Pango_PKG_INCLUDE_DIRS}) + + if(Pango_INCLUDE_DIR) + file(STRINGS "${Pango_INCLUDE_DIR}/pango/pango-features.h" Pango_MAJOR_VERSION REGEX "^#define PANGO_VERSION_MAJOR +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define PANGO_VERSION_MAJOR \\(?([0-9]+)\\)?" "\\1" Pango_MAJOR_VERSION "${Pango_MAJOR_VERSION}") + file(STRINGS "${Pango_INCLUDE_DIR}/pango/pango-features.h" Pango_MINOR_VERSION REGEX "^#define PANGO_VERSION_MINOR +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define PANGO_VERSION_MINOR \\(?([0-9]+)\\)?" "\\1" Pango_MINOR_VERSION "${Pango_MINOR_VERSION}") + file(STRINGS "${Pango_INCLUDE_DIR}/pango/pango-features.h" Pango_MICRO_VERSION REGEX "^#define PANGO_VERSION_MICRO +\\(?([0-9]+)\\)?$") + string(REGEX REPLACE "^#define PANGO_VERSION_MICRO \\(?([0-9]+)\\)?" "\\1" Pango_MICRO_VERSION "${Pango_MICRO_VERSION}") + set(Pango_VERSION "${Pango_MAJOR_VERSION}.${Pango_MINOR_VERSION}.${Pango_MICRO_VERSION}") + unset(Pango_MAJOR_VERSION) + unset(Pango_MINOR_VERSION) + unset(Pango_MICRO_VERSION) + + list(APPEND Pango_INCLUDE_DIRS ${PC_HB_INCLUDE_DIRS} ${Pango_INCLUDE_DIR}) + set_property(TARGET ${Pango} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${Pango_INCLUDE_DIR}") + endif() +endif() + +set(Pango_DEPS_FOUND_VARS) +foreach(pango_dep ${Pango_DEPS}) + find_package(${pango_dep}) + + list(APPEND Pango_DEPS_FOUND_VARS "${pango_dep}_FOUND") + list(APPEND Pango_INCLUDE_DIRS ${${pango_dep}_INCLUDE_DIRS}) + + set_property (TARGET "${Pango}" APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${${pango_dep}}") +endforeach(pango_dep) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Pango + REQUIRED_VARS + Pango_LIBRARY + Pango_INCLUDE_DIRS + ${Pango_DEPS_FOUND_VARS} + VERSION_VAR + Pango_VERSION) + +unset(Pango_DEPS_FOUND_VARS) diff --git a/cmake/FindSPICE.cmake b/cmake/FindSpice.cmake index 97053f140..cb8c13514 100644 --- a/cmake/FindSPICE.cmake +++ b/cmake/FindSpice.cmake @@ -30,17 +30,52 @@ # version. * If you delete this exception statement from all source # files in the program, then also delete it here. -include(FindPkgConfig) +find_package(PkgConfig) if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_SPICE_PROTOCOL spice-protocol) + #pkg_check_modules(PC_SPICE_PROTOCOL spice-protocol) + pkg_check_modules(_SPICE spice-client-gtk-3.0) +endif(PKG_CONFIG_FOUND) - pkg_check_modules(PC_SPICE_CLIENT spice-client-gtk-3.0) +find_library(SPICE_CLIENT_GTK3_LIB NAMES spice-client-gtk-3.0 + PATHS + ${_SPICE_LIBRARY_DIRS} + ${COMMON_LIB_DIR} +) + +if(SPICE_CLIENT_GTK3_LIB) + set(SPICE_LIBRARIES ${SPICE_CLIENT_GTK3_LIB}) + message(STATUS "Spice-Libs: ${SPICE_LIBRARIES}") endif() -if(PC_SPICE_CLIENT_FOUND) - set(SPICE_LIBRARIES ${PC_SPICE_CLIENT_LIBRARIES}) - set(SPICE_INCLUDE_DIRS ${PC_SPICE_CLIENT_INCLUDE_DIRS}) - set(SPICE_FOUND TRUE) +find_path(SPICE_CLIENT_GTK3_INCLUDE_DIR spice-client-gtk.h + PATH_SUFFIXES spice-client-gtk-3.0 + PATHS + ${_SPICE_INCLUDE_DIRS} + ${COMMON_INCLUDE_DIR} +) + +find_path(SPICE_CLIENT_GLIB_INCLUDE_DIR spice-client.h + PATH_SUFFIXES spice-client-glib-2.0 + PATHS + ${_SPICE_INCLUDE_DIRS} + ${COMMON_INCLUDE_DIR} +) + +find_path(SPICE_PROTO_INCLUDE_DIR spice/enums.h + PATH_SUFFIXES spice-1 + PATHS + ${_SPICE_INCLUDE_DIRS} + ${COMMON_INCLUDE_DIR} +) + + +if(SPICE_CLIENT_GTK3_INCLUDE_DIR AND SPICE_CLIENT_GLIB_INCLUDE_DIR AND SPICE_PROTO_INCLUDE_DIR) + set(SPICE_INCLUDE_DIRS ${SPICE_CLIENT_GTK3_INCLUDE_DIR} ${SPICE_CLIENT_GLIB_INCLUDE_DIR} ${SPICE_PROTO_INCLUDE_DIR}) + message(STATUS "Spice-Include-Dirs: ${SPICE_INCLUDE_DIRS}") +endif() + +if(SPICE_LIBRARIES AND SPICE_INCLUDE_DIRS) + set(SPICE_FOUND TRUE) endif() diff --git a/cmake/Gettext.cmake b/cmake/Gettext.cmake new file mode 100644 index 000000000..11b4a7a00 --- /dev/null +++ b/cmake/Gettext.cmake @@ -0,0 +1,143 @@ +# Gettext support: Create/Update pot file and +# +# To use: INCLUDE(Gettext) +# +# Most of the gettext support code is from FindGettext.cmake of cmake, +# but it is included here because: +# +# 1. Some system like RHEL5 does not have FindGettext.cmake +# 2. Bug of GETTEXT_CREATE_TRANSLATIONS make it unable to be include in 'All' +# 3. It does not support xgettext +# +#=================================================================== +# Variables: +# XGETTEXT_OPTIONS: Options pass to xgettext +# Default: --language=C --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 +# GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool. +# GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool. +# GETTEXT_FOUND: True if gettext has been found. +# XGETTEXT_EXECUTABLE: the full path to the xgettext. +# XGETTEXT_FOUND: True if xgettext has been found. +# +#=================================================================== +# Macros: +# GETTEXT_CREATE_POT(potFile +# [OPTION xgettext_options] +# SRC list_of_source_file_that_contains_msgid +# ) +# +# Generate .pot file. +# OPTION xgettext_options: Override XGETTEXT_OPTIONS +# +# * Produced targets: pot_file +# +#------------------------------------------------------------------- +# GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] locale1 ... localeN +# [COMMENT comment] ) +# +# This will create a target "translations" which will convert the +# given input po files into the binary output mo file. If the +# ALL option is used, the translations will also be created when +# building the default target. +# +# * Produced targets: translations +#------------------------------------------------------------------- +FIND_PROGRAM(GETTEXT_MSGMERGE_EXECUTABLE msgmerge) +FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt) +FIND_PROGRAM(XGETTEXT_EXECUTABLE xgettext) +IF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE ) + SET(GETTEXT_FOUND TRUE) +ELSE (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE) + SET(GETTEXT_FOUND FALSE) + IF (GetText_REQUIRED) + MESSAGE(FATAL_ERROR "GetText not found") + ENDIF (GetText_REQUIRED) +ENDIF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE ) +IF(XGETTEXT_EXECUTABLE) + SET(XGETTEXT_FOUND TRUE) +ELSE(XGETTEXT_EXECUTABLE) + MESSAGE(STATUS "xgettext not found.") + SET(XGETTTEXT_FOUND FALSE) +ENDIF(XGETTEXT_EXECUTABLE) +IF(NOT DEFINED XGETTEXT_OPTIONS) + SET(XGETTEXT_OPTIONS --language=C --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 -s) +ENDIF(NOT DEFINED XGETTEXT_OPTIONS) +IF(XGETTEXT_FOUND) + MACRO(GETTEXT_CREATE_POT _potFile _pot_options ) + SET(_xgettext_options_list) + SET(_src_list) + SET(_src_list_abs) + SET(_stage "SRC") + FOREACH(_pot_option ${_pot_options} ${ARGN}) + IF(_pot_option STREQUAL "OPTION") + SET(_stage "OPTION") + ELSEIF(_pot_option STREQUAL "SRC") + SET(_stage "SRC") + ELSE(_pot_option STREQUAL "OPTION") + IF(_stage STREQUAL "OPTION") + SET(_xgettext_options_list ${_xgettext_options_list} ${_pot_option}) + ELSE(_stage STREQUAL "OPTION") + FILE(RELATIVE_PATH _relFile ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${_pot_option}) + GET_FILENAME_COMPONENT(_absFile ${_pot_option} ABSOLUTE) + SET(_src_list ${_src_list} ${_relFile}) + SET(_src_list_abs ${_src_list_abs} ${_absFile}) + ENDIF(_stage STREQUAL "OPTION") + ENDIF(_pot_option STREQUAL "OPTION") + ENDFOREACH(_pot_option ${_pot_options} ${ARGN}) + IF (_xgettext_options_list) + SET(_xgettext_options ${_xgettext_options_list}) + ELSE(_xgettext_options_list) + SET(_xgettext_options ${XGETTEXT_OPTIONS}) + ENDIF(_xgettext_options_list) + #MESSAGE("${XGETTEXT_EXECUTABLE} ${_xgettext_options_list} -o ${_potFile} ${_src_list}") + ADD_CUSTOM_COMMAND(OUTPUT ${_potFile} + COMMAND ${XGETTEXT_EXECUTABLE} ${_xgettext_options} -o ${_potFile} ${_src_list} + DEPENDS ${_src_list_abs} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + ADD_CUSTOM_TARGET(pot_file + COMMAND ${XGETTEXT_EXECUTABLE} ${_xgettext_options_list} -o ${_potFile} ${_src_list} + DEPENDS ${_src_list_abs} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Extract translatable messages to ${_potFile}" + ) + ENDMACRO(GETTEXT_CREATE_POT _potFile _pot_options) + MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstLang) + SET(_gmoFiles) + GET_FILENAME_COMPONENT(_potBasename ${_potFile} NAME_WE) + GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE) + SET(_addToAll) + SET(_is_comment FALSE) + FOREACH (_currentLang ${_firstLang} ${ARGN}) + IF(_currentLang STREQUAL "ALL") + SET(_addToAll "ALL") + ELSEIF(_currentLang STREQUAL "COMMENT") + SET(_is_comment TRUE) + ELSEIF(_is_comment) + SET(_is_comment FALSE) + SET(_comment ${_currentLang}) + ELSE() + SET(_lang ${_currentLang}) + GET_FILENAME_COMPONENT(_absFile ${_currentLang}.po ABSOLUTE) + GET_FILENAME_COMPONENT(_abs_PATH ${_absFile} PATH) + SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo) + #MESSAGE("_absFile=${_absFile} _abs_PATH=${_abs_PATH} _lang=${_lang} curr_bin=${CMAKE_CURRENT_BINARY_DIR}") + ADD_CUSTOM_COMMAND( + OUTPUT ${_gmoFile} + COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile} + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile} + DEPENDS ${_absPotFile} ${_absFile} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + INSTALL(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo) + SET(_gmoFiles ${_gmoFiles} ${_gmoFile}) + ENDIF() + ENDFOREACH (_currentLang ) + IF(DEFINED _comment) + ADD_CUSTOM_TARGET(translations ${_addToAll} DEPENDS ${_gmoFiles} COMMENT ${_comment}) + ELSE(DEFINED _comment) + ADD_CUSTOM_TARGET(translations ${_addToAll} DEPENDS ${_gmoFiles}) + ENDIF(DEFINED _comment) + ENDMACRO(GETTEXT_CREATE_TRANSLATIONS ) +ENDIF(XGETTEXT_FOUND) + diff --git a/cmake/macros/BuildTargetScript.cmake b/cmake/macros/BuildTargetScript.cmake new file mode 100644 index 000000000..72434498f --- /dev/null +++ b/cmake/macros/BuildTargetScript.cmake @@ -0,0 +1,57 @@ +# This file is used to be invoked at build time. It generates the needed +# resource XML file. + +# Input variables that need to provided when invoking this script: +# GXML_OUTPUT The output file path where to save the XML file. +# GXML_COMPRESS_ALL Sets all COMPRESS flags in all resources in resource +# list. +# GXML_NO_COMPRESS_ALL Removes all COMPRESS flags in all resources in +# resource list. +# GXML_STRIPBLANKS_ALL Sets all STRIPBLANKS flags in all resources in +# resource list. +# GXML_NO_STRIPBLANKS_ALL Removes all STRIPBLANKS flags in all resources in +# resource list. +# GXML_TOPIXDATA_ALL Sets all TOPIXDATA flags i nall resources in resource +# list. +# GXML_NO_TOPIXDATA_ALL Removes all TOPIXDATA flags in all resources in +# resource list. +# GXML_PREFIX Overrides the resource prefix that is prepended to +# each relative name in registered resources. +# GXML_RESOURCES The list of resource files. Whether absolute or +# relative path is equal. + +# Include the GENERATE_GXML() function. +include(${CMAKE_CURRENT_LIST_DIR}/GenerateGXML.cmake) + +# Set flags to actual invocation flags. +if(GXML_COMPRESS_ALL) + set(GXML_COMPRESS_ALL COMPRESS_ALL) +endif() +if(GXML_NO_COMPRESS_ALL) + set(GXML_NO_COMPRESS_ALL NO_COMPRESS_ALL) +endif() +if(GXML_STRIPBLANKS_ALL) + set(GXML_STRIPBLANKS_ALL STRIPBLANKS_ALL) +endif() +if(GXML_NO_STRIPBLANKS_ALL) + set(GXML_NO_STRIPBLANKS_ALL NO_STRIPBLANKS_ALL) +endif() +if(GXML_TOPIXDATA_ALL) + set(GXML_TOPIXDATA_ALL TOPIXDATA_ALL) +endif() +if(GXML_NO_TOPIXDATA_ALL) + set(GXML_NO_TOPIXDATA_ALL NO_TOPIXDATA_ALL) +endif() + +# Replace " " with ";" to import the list over the command line. Otherwise +# CMake would interprete the passed resources as a whole string. +string(REPLACE " " ";" GXML_RESOURCES ${GXML_RESOURCES}) + +# Invoke the gresource XML generation function. +generate_gxml(${GXML_OUTPUT} + ${GXML_COMPRESS_ALL} ${GXML_NO_COMPRESS_ALL} + ${GXML_STRIPBLANKS_ALL} ${GXML_NO_STRIPBLANKS_ALL} + ${GXML_TOPIXDATA_ALL} ${GXML_NO_TOPIXDATA_ALL} + PREFIX ${GXML_PREFIX} + RESOURCES ${GXML_RESOURCES}) + diff --git a/cmake/macros/CompileGResources.cmake b/cmake/macros/CompileGResources.cmake new file mode 100644 index 000000000..fd7c6b31f --- /dev/null +++ b/cmake/macros/CompileGResources.cmake @@ -0,0 +1,231 @@ +include(CMakeParseArguments) + +# Path to this file. +set(GCR_CMAKE_MACRO_DIR ${CMAKE_CURRENT_LIST_DIR}) + +# Compiles a gresource resource file from given resource files. Automatically +# creates the XML controlling file. +# The type of resource to generate (header, c-file or bundle) is automatically +# determined from TARGET file ending, if no TYPE is explicitly specified. +# The output file is stored in the provided variable "output". +# "xml_out" contains the variable where to output the XML path. Can be used to +# create custom targets or doing postprocessing. +# If you want to use preprocessing, you need to manually check the existence +# of the tools you use. This function doesn't check this for you, it just +# generates the XML file. glib-compile-resources will then throw a +# warning/error. +function(COMPILE_GRESOURCES output xml_out) + # Available options: + # COMPRESS_ALL, NO_COMPRESS_ALL Overrides the COMPRESS flag in all + # registered resources. + # STRIPBLANKS_ALL, NO_STRIPBLANKS_ALL Overrides the STRIPBLANKS flag in all + # registered resources. + # TOPIXDATA_ALL, NO_TOPIXDATA_ALL Overrides the TOPIXDATA flag in all + # registered resources. + set(CG_OPTIONS COMPRESS_ALL NO_COMPRESS_ALL + STRIPBLANKS_ALL NO_STRIPBLANKS_ALL + TOPIXDATA_ALL NO_TOPIXDATA_ALL) + + # Available one value options: + # TYPE Type of resource to create. Valid options are: + # EMBED_C: A C-file that can be compiled with your project. + # EMBED_H: A header that can be included into your project. + # BUNDLE: Generates a resource bundle file that can be loaded + # at runtime. + # AUTO: Determine from target file ending. Need to specify + # target argument. + # PREFIX Overrides the resource prefix that is prepended to each + # relative file name in registered resources. + # SOURCE_DIR Overrides the resources base directory to search for resources. + # Normally this is set to the source directory with that CMake + # was invoked (CMAKE_CURRENT_SOURCE_DIR). + # TARGET Overrides the name of the output file/-s. Normally the output + # names from glib-compile-resources tool is taken. + set(CG_ONEVALUEARGS TYPE PREFIX SOURCE_DIR TARGET) + + # Available multi-value options: + # RESOURCES The list of resource files. Whether absolute or relative path is + # equal, absolute paths are stripped down to relative ones. If the + # absolute path is not inside the given base directory SOURCE_DIR + # or CMAKE_CURRENT_SOURCE_DIR (if SOURCE_DIR is not overriden), + # this function aborts. + # OPTIONS Extra command line options passed to glib-compile-resources. + set(CG_MULTIVALUEARGS RESOURCES OPTIONS) + + # Parse the arguments. + cmake_parse_arguments(CG_ARG + "${CG_OPTIONS}" + "${CG_ONEVALUEARGS}" + "${CG_MULTIVALUEARGS}" + "${ARGN}") + + # Variable to store the double-quote (") string. Since escaping + # double-quotes in strings is not possible we need a helper variable that + # does this job for us. + set(Q \") + + # Check invocation validity with the <prefix>_UNPARSED_ARGUMENTS variable. + # If other not recognized parameters were passed, throw error. + if (CG_ARG_UNPARSED_ARGUMENTS) + set(CG_WARNMSG "Invocation of COMPILE_GRESOURCES with unrecognized") + set(CG_WARNMSG "${CG_WARNMSG} parameters. Parameters are:") + set(CG_WARNMSG "${CG_WARNMSG} ${CG_ARG_UNPARSED_ARGUMENTS}.") + message(WARNING ${CG_WARNMSG}) + endif() + + # Check invocation validity depending on generation mode (EMBED_C, EMBED_H + # or BUNDLE). + if ("${CG_ARG_TYPE}" STREQUAL "EMBED_C") + # EMBED_C mode, output compilable C-file. + set(CG_GENERATE_COMMAND_LINE "--generate-source") + set(CG_TARGET_FILE_ENDING "c") + elseif ("${CG_ARG_TYPE}" STREQUAL "EMBED_H") + # EMBED_H mode, output includable header file. + set(CG_GENERATE_COMMAND_LINE "--generate-header") + set(CG_TARGET_FILE_ENDING "h") + elseif ("${CG_ARG_TYPE}" STREQUAL "BUNDLE") + # BUNDLE mode, output resource bundle. Don't do anything since + # glib-compile-resources outputs a bundle when not specifying + # something else. + set(CG_TARGET_FILE_ENDING "gresource") + else() + # Everything else is AUTO mode, determine from target file ending. + if (CG_ARG_TARGET) + set(CG_GENERATE_COMMAND_LINE "--generate") + else() + set(CG_ERRMSG "AUTO mode given, but no target specified. Can't") + set(CG_ERRMSG "${CG_ERRMSG} determine output type. In function") + set(CG_ERRMSG "${CG_ERRMSG} COMPILE_GRESOURCES.") + message(FATAL_ERROR ${CG_ERRMSG}) + endif() + endif() + + # Check flag validity. + if (CG_ARG_COMPRESS_ALL AND CG_ARG_NO_COMPRESS_ALL) + set(CG_ERRMSG "COMPRESS_ALL and NO_COMPRESS_ALL simultaneously set. In") + set(CG_ERRMSG "${CG_ERRMSG} function COMPILE_GRESOURCES.") + message(FATAL_ERROR ${CG_ERRMSG}) + endif() + if (CG_ARG_STRIPBLANKS_ALL AND CG_ARG_NO_STRIPBLANKS_ALL) + set(CG_ERRMSG "STRIPBLANKS_ALL and NO_STRIPBLANKS_ALL simultaneously") + set(CG_ERRMSG "${CG_ERRMSG} set. In function COMPILE_GRESOURCES.") + message(FATAL_ERROR ${CG_ERRMSG}) + endif() + if (CG_ARG_TOPIXDATA_ALL AND CG_ARG_NO_TOPIXDATA_ALL) + set(CG_ERRMSG "TOPIXDATA_ALL and NO_TOPIXDATA_ALL simultaneously set.") + set(CG_ERRMSG "${CG_ERRMSG} In function COMPILE_GRESOURCES.") + message(FATAL_ERROR ${CG_ERRMSG}) + endif() + + # Check if there are any resources. + if (NOT CG_ARG_RESOURCES) + set(CG_ERRMSG "No resource files to process. In function") + set(CG_ERRMSG "${CG_ERRMSG} COMPILE_GRESOURCES.") + message(FATAL_ERROR ${CG_ERRMSG}) + endif() + + # Extract all dependencies for targets from resource list. + foreach(res ${CG_ARG_RESOURCES}) + if (NOT(("${res}" STREQUAL "COMPRESS") OR + ("${res}" STREQUAL "STRIPBLANKS") OR + ("${res}" STREQUAL "TOPIXDATA"))) + + list(APPEND CG_RESOURCES_DEPENDENCIES "${res}") + endif() + endforeach() + + + # Create source directory automatically if not set. + if (NOT CG_ARG_SOURCE_DIR) + set(CG_ARG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + endif() + + # Replace paths + foreach(res ${CG_ARG_RESOURCES}) + if (NOT(("${res}" STREQUAL "COMPRESS") OR + ("${res}" STREQUAL "STRIPBLANKS") OR + ("${res}" STREQUAL "TOPIXDATA"))) + + string(REPLACE "${CG_ARG_SOURCE_DIR}/" "" RES_FILTERED "${res}") + list(APPEND CG_RESOURCES_FILTERED "${RES_FILTERED}") + else() + list(APPEND CG_RESOURCES_FILTERED "${res}") + endif() + endforeach() + + # Construct .gresource.xml path. + set(CG_XML_FILE_PATH "${CMAKE_CURRENT_BINARY_DIR}/.gresource.xml") + + # Generate gresources XML target. + list(APPEND CG_CMAKE_SCRIPT_ARGS "-D") + list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_OUTPUT=${Q}${CG_XML_FILE_PATH}${Q}") + if(CG_ARG_COMPRESS_ALL) + list(APPEND CG_CMAKE_SCRIPT_ARGS "-D") + list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_COMPRESS_ALL") + endif() + if(CG_ARG_NO_COMPRESS_ALL) + list(APPEND CG_CMAKE_SCRIPT_ARGS "-D") + list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_NO_COMPRESS_ALL") + endif() + if(CG_ARG_STRPIBLANKS_ALL) + list(APPEND CG_CMAKE_SCRIPT_ARGS "-D") + list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_STRIPBLANKS_ALL") + endif() + if(CG_ARG_NO_STRIPBLANKS_ALL) + list(APPEND CG_CMAKE_SCRIPT_ARGS "-D") + list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_NO_STRIPBLANKS_ALL") + endif() + if(CG_ARG_TOPIXDATA_ALL) + list(APPEND CG_CMAKE_SCRIPT_ARGS "-D") + list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_TOPIXDATA_ALL") + endif() + if(CG_ARG_NO_TOPIXDATA_ALL) + list(APPEND CG_CMAKE_SCRIPT_ARGS "-D") + list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_NO_TOPIXDATA_ALL") + endif() + list(APPEND CG_CMAKE_SCRIPT_ARGS "-D") + list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_PREFIX=${Q}${CG_ARG_PREFIX}${Q}") + list(APPEND CG_CMAKE_SCRIPT_ARGS "-D") + list(APPEND CG_CMAKE_SCRIPT_ARGS + "GXML_RESOURCES=${Q}${CG_RESOURCES_FILTERED}${Q}") + list(APPEND CG_CMAKE_SCRIPT_ARGS "-P") + list(APPEND CG_CMAKE_SCRIPT_ARGS + "${Q}${GCR_CMAKE_MACRO_DIR}/BuildTargetScript.cmake${Q}") + + get_filename_component(CG_XML_FILE_PATH_ONLY_NAME + "${CG_XML_FILE_PATH}" NAME) + set(CG_XML_CUSTOM_COMMAND_COMMENT + "Creating gresources XML file (${CG_XML_FILE_PATH_ONLY_NAME})") + add_custom_command(OUTPUT ${CG_XML_FILE_PATH} + COMMAND ${CMAKE_COMMAND} + ARGS ${CG_CMAKE_SCRIPT_ARGS} + DEPENDS ${CG_RESOURCES_DEPENDENCIES} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT ${CG_XML_CUSTOM_COMMAND_COMMENT}) + + # Create target manually if not set (to make sure glib-compile-resources + # doesn't change behaviour with it's naming standards). + if (NOT CG_ARG_TARGET) + set(CG_ARG_TARGET "${CMAKE_CURRENT_BINARY_DIR}/resources") + set(CG_ARG_TARGET "${CG_ARG_TARGET}.${CG_TARGET_FILE_ENDING}") + endif() + + + # Add compilation target for resources. + add_custom_command(OUTPUT ${CG_ARG_TARGET} + COMMAND ${GLIB_COMPILE_RESOURCES_EXECUTABLE} + ARGS + ${OPTIONS} + "--target=${Q}${CG_ARG_TARGET}${Q}" + "--sourcedir=${Q}${CG_ARG_SOURCE_DIR}${Q}" + ${CG_GENERATE_COMMAND_LINE} + ${CG_XML_FILE_PATH} + MAIN_DEPENDENCY ${CG_XML_FILE_PATH} + DEPENDS ${CG_RESOURCES_DEPENDENCIES} + WORKING_DIRECTORY ${CMAKE_BUILD_DIR}) + + # Set output and XML_OUT to parent scope. + set(${xml_out} ${CG_XML_FILE_PATH} PARENT_SCOPE) + set(${output} ${CG_ARG_TARGET} PARENT_SCOPE) + +endfunction() diff --git a/cmake/macros/GenerateGXML.cmake b/cmake/macros/GenerateGXML.cmake new file mode 100644 index 000000000..b3f1a305c --- /dev/null +++ b/cmake/macros/GenerateGXML.cmake @@ -0,0 +1,124 @@ +include(CMakeParseArguments) + +# Generates the resource XML controlling file from resource list (and saves it +# to xml_path). It's not recommended to use this function directly, since it +# doesn't handle invalid arguments. It is used by the function +# COMPILE_GRESOURCES() to create a custom command, so that this function is +# invoked at build-time in script mode from CMake. +function(GENERATE_GXML xml_path) + # Available options: + # COMPRESS_ALL, NO_COMPRESS_ALL Overrides the COMPRESS flag in all + # registered resources. + # STRIPBLANKS_ALL, NO_STRIPBLANKS_ALL Overrides the STRIPBLANKS flag in all + # registered resources. + # TOPIXDATA_ALL, NO_TOPIXDATA_ALL Overrides the TOPIXDATA flag in all + # registered resources. + set(GXML_OPTIONS COMPRESS_ALL NO_COMPRESS_ALL + STRIPBLANKS_ALL NO_STRIPBLANKS_ALL + TOPIXDATA_ALL NO_TOPIXDATA_ALL) + + # Available one value options: + # PREFIX Overrides the resource prefix that is prepended to each + # relative file name in registered resources. + set(GXML_ONEVALUEARGS PREFIX) + + # Available multi-value options: + # RESOURCES The list of resource files. Whether absolute or relative path is + # equal, absolute paths are stripped down to relative ones. If the + # absolute path is not inside the given base directory SOURCE_DIR + # or CMAKE_CURRENT_SOURCE_DIR (if SOURCE_DIR is not overriden), + # this function aborts. + set(GXML_MULTIVALUEARGS RESOURCES) + + # Parse the arguments. + cmake_parse_arguments(GXML_ARG + "${GXML_OPTIONS}" + "${GXML_ONEVALUEARGS}" + "${GXML_MULTIVALUEARGS}" + "${ARGN}") + + # Variable to store the double-quote (") string. Since escaping + # double-quotes in strings is not possible we need a helper variable that + # does this job for us. + set(Q \") + + # Process resources and generate XML file. + # Begin with the XML header and header nodes. + set(GXML_XML_FILE "<?xml version=${Q}1.0${Q} encoding=${Q}UTF-8${Q}?>") + set(GXML_XML_FILE "${GXML_XML_FILE}<gresources><gresource prefix=${Q}") + + # Set the prefix for the resources. Depending on the user-override we choose + # the standard prefix "/" or the override. + if (GXML_ARG_PREFIX) + set(GXML_XML_FILE "${GXML_XML_FILE}${GXML_ARG_PREFIX}") + else() + set(GXML_XML_FILE "${GXML_XML_FILE}/") + endif() + + set(GXML_XML_FILE "${GXML_XML_FILE}${Q}>") + + # Process each resource. + foreach(res ${GXML_ARG_RESOURCES}) + if ("${res}" STREQUAL "COMPRESS") + set(GXML_COMPRESSION_FLAG ON) + elseif ("${res}" STREQUAL "STRIPBLANKS") + set(GXML_STRIPBLANKS_FLAG ON) + elseif ("${res}" STREQUAL "TOPIXDATA") + set(GXML_TOPIXDATA_FLAG ON) + else() + # The file name. + set(GXML_RESOURCE_PATH "${res}") + + # Append to real resource file dependency list. + list(APPEND GXML_RESOURCES_DEPENDENCIES ${GXML_RESOURCE_PATH}) + + # Assemble <file> node. + set(GXML_RES_LINE "<file") + if ((GXML_ARG_COMPRESS_ALL OR GXML_COMPRESSION_FLAG) AND NOT + GXML_ARG_NO_COMPRESS_ALL) + set(GXML_RES_LINE "${GXML_RES_LINE} compressed=${Q}true${Q}") + endif() + + # Check preprocess flag validity. + if ((GXML_ARG_STRIPBLANKS_ALL OR GXML_STRIPBLANKS_FLAG) AND + (GXML_ARG_TOPIXDATA_ALL OR GXML_TOPIXDATA_FLAG)) + set(GXML_ERRMSG "Resource preprocessing option conflict. Tried") + set(GXML_ERRMSG "${GXML_ERRMSG} to specify both, STRIPBLANKS") + set(GXML_ERRMSG "${GXML_ERRMSG} and TOPIXDATA. In resource") + set(GXML_ERRMSG "${GXML_ERRMSG} ${GXML_RESOURCE_PATH} in") + set(GXML_ERRMSG "${GXML_ERRMSG} function COMPILE_GRESOURCES.") + message(FATAL_ERROR ${GXML_ERRMSG}) + endif() + + if ((GXML_ARG_STRIPBLANKS_ALL OR GXML_STRIPBLANKS_FLAG) AND NOT + GXML_ARG_NO_STRIPBLANKS_ALL) + set(GXML_RES_LINE "${GXML_RES_LINE} preprocess=") + set(GXML_RES_LINE "${GXML_RES_LINE}${Q}xml-stripblanks${Q}") + elseif((GXML_ARG_TOPIXDATA_ALL OR GXML_TOPIXDATA_FLAG) AND NOT + GXML_ARG_NO_TOPIXDATA_ALL) + set(GXML_RES_LINE "${GXML_RES_LINE} preprocess=") + set(GXML_RES_LINE "${GXML_RES_LINE}${Q}to-pixdata${Q}") + endif() + + set(GXML_RES_LINE "${GXML_RES_LINE}>${GXML_RESOURCE_PATH}</file>") + + # Append to file string. + set(GXML_XML_FILE "${GXML_XML_FILE}${GXML_RES_LINE}") + + # Unset variables. + unset(GXML_COMPRESSION_FLAG) + unset(GXML_STRIPBLANKS_FLAG) + unset(GXML_TOPIXDATA_FLAG) + endif() + + endforeach() + + # Append closing nodes. + set(GXML_XML_FILE "${GXML_XML_FILE}</gresource></gresources>") + + # Use "file" function to generate XML controlling file. + get_filename_component(xml_path_only_name "${xml_path}" NAME) + file(WRITE ${xml_path} ${GXML_XML_FILE}) + +endfunction() + diff --git a/cmake/macros/GlibCompileResourcesSupport.cmake b/cmake/macros/GlibCompileResourcesSupport.cmake new file mode 100644 index 000000000..2950af343 --- /dev/null +++ b/cmake/macros/GlibCompileResourcesSupport.cmake @@ -0,0 +1,11 @@ +# Path to this file. +set(GCR_CMAKE_MACRO_DIR ${CMAKE_CURRENT_LIST_DIR}) + +# Finds the glib-compile-resources executable. +find_program(GLIB_COMPILE_RESOURCES_EXECUTABLE glib-compile-resources) +mark_as_advanced(GLIB_COMPILE_RESOURCES_EXECUTABLE) + +# Include the cmake files containing the functions. +include(${GCR_CMAKE_MACRO_DIR}/CompileGResources.cmake) +include(${GCR_CMAKE_MACRO_DIR}/GenerateGXML.cmake) + diff --git a/cmake/macros/TargetArch.cmake b/cmake/macros/TargetArch.cmake new file mode 100644 index 000000000..ee144bc1f --- /dev/null +++ b/cmake/macros/TargetArch.cmake @@ -0,0 +1,169 @@ +# Copyright (c) 2014 PCSX2 Dev Team +# Copyright (c) 2012 Petroules Corporation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# https://github.com/petroules/solar-cmake/blob/master/TargetArch.cmake +# +# Based on the Qt 5 processor detection code, so should be very accurate +# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h +# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64) + +# Regarding POWER/PowerPC, just as is noted in the Qt source, +# "There are many more known variants/revisions that we do not handle/detect." + +set(archdetect_c_code " +#if defined(__arm__) || defined(__TARGET_ARCH_ARM) + #if defined(__ARM_ARCH_7__) \\ + || defined(__ARM_ARCH_7A__) \\ + || defined(__ARM_ARCH_7R__) \\ + || defined(__ARM_ARCH_7M__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) + #error cmake_ARCH armv7 + #elif defined(__ARM_ARCH_6__) \\ + || defined(__ARM_ARCH_6J__) \\ + || defined(__ARM_ARCH_6T2__) \\ + || defined(__ARM_ARCH_6Z__) \\ + || defined(__ARM_ARCH_6K__) \\ + || defined(__ARM_ARCH_6ZK__) \\ + || defined(__ARM_ARCH_6M__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6) + #error cmake_ARCH armv6 + #elif defined(__ARM_ARCH_5TEJ__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) + #error cmake_ARCH armv5 + #else + #error cmake_ARCH arm + #endif +#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) + #error cmake_ARCH i386 +#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) + #error cmake_ARCH x86_64 +#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) + #error cmake_ARCH ia64 +#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\ + || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\ + || defined(_M_MPPC) || defined(_M_PPC) + #if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__) + #error cmake_ARCH ppc64 + #else + #error cmake_ARCH ppc + #endif +#endif + +#error cmake_ARCH unknown +") + +# Set ppc_support to TRUE before including this file or ppc and ppc64 +# will be treated as invalid architectures since they are no longer supported by Apple + +function(target_architecture output_var) + if(APPLE AND CMAKE_OSX_ARCHITECTURES) + # On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set + # First let's normalize the order of the values + + # Note that it's not possible to compile PowerPC applications if you are using + # the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we + # disable it by default + # See this page for more information: + # http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4 + + # Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime. + # On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise. + + LIST(LENGTH CMAKE_OSX_ARCHITECTURES osx_arch_num) + if(NOT (osx_arch_num EQUAL 1)) + message(FATAL_ERROR "Currently ${CMAKE_PROJECT_NAME} does not support multiple architectures in CMAKE_OSX_ARCHITECTURES") + endif() + + foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES}) + if("${osx_arch}" STREQUAL "ppc" AND ppc_support) + set(osx_arch_ppc TRUE) + elseif("${osx_arch}" STREQUAL "i386") + set(osx_arch_i386 TRUE) + elseif("${osx_arch}" STREQUAL "x86_64") + set(osx_arch_x86_64 TRUE) + elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support) + set(osx_arch_ppc64 TRUE) + else() + message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}") + endif() + endforeach() + + # Now add all the architectures in our normalized order + if(osx_arch_ppc) + list(APPEND ARCH ppc) + endif() + + if(osx_arch_i386) + list(APPEND ARCH i386) + endif() + + if(osx_arch_x86_64) + list(APPEND ARCH x86_64) + endif() + + if(osx_arch_ppc64) + list(APPEND ARCH ppc64) + endif() + + LIST(LENGTH ARCH osx_arch_num) + if(osx_arch_num LESS 1) + message(FATAL_ERROR "Invalid CMAKE_OSX_ARCHITECTURES: ${CMAKE_OSX_ARCHITECTURES}") + endif() + else() + file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}") + + enable_language(C) + + # Detect the architecture in a rather creative way... + # This compiles a small C program which is a series of ifdefs that selects a + # particular #error preprocessor directive whose message string contains the + # target architecture. The program will always fail to compile (both because + # file is not a valid C program, and obviously because of the presence of the + # #error preprocessor directives... but by exploiting the preprocessor in this + # way, we can detect the correct target architecture even when cross-compiling, + # since the program itself never needs to be run (only the compiler/preprocessor) + try_run( + run_result_unused + compile_result_unused + "${CMAKE_BINARY_DIR}" + "${CMAKE_BINARY_DIR}/arch.c" + COMPILE_OUTPUT_VARIABLE ARCH + CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + ) + + # Parse the architecture name from the compiler output + string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}") + + # Get rid of the value marker leaving just the architecture name + string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}") + + # If we are compiling with an unknown architecture this variable should + # already be set to "unknown" but in the case that it's empty (i.e. due + # to a typo in the code), then set it to unknown + if (NOT ARCH) + set(ARCH unknown) + endif() + endif() + + set(${output_var} "${ARCH}" PARENT_SCOPE) +endfunction() diff --git a/data/ui/remmina_main.glade b/data/ui/remmina_main.glade index 7b65d33e6..70838833e 100644 --- a/data/ui/remmina_main.glade +++ b/data/ui/remmina_main.glade @@ -567,6 +567,33 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. </object> </child> <child> + <object class="GtkToggleButton" id="search_toggle"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="tooltip-text" translatable="yes">Show search bar</property> + <property name="action-name">main.search</property> + <property name="image">find_toggle_image</property> + <property name="active">True</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button_news"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="action-name">app.news</property> + <property name="image">image_news</property> + <property name="always-show-image">True</property> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + <child> <object class="GtkMenuButton" id="menu_header_button"> <property name="visible">True</property> <property name="can-focus">True</property> @@ -591,21 +618,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. </object> <packing> <property name="pack-type">end</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkToggleButton" id="search_toggle"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">False</property> - <property name="tooltip-text" translatable="yes">Show search bar</property> - <property name="action-name">main.search</property> - <property name="image">find_toggle_image</property> - <property name="active">True</property> - </object> - <packing> - <property name="position">1</property> + <property name="position">3</property> </packing> </child> <child> @@ -619,20 +632,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. </object> <packing> <property name="pack-type">end</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkButton" id="button_news"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">True</property> - <property name="action-name">app.news</property> - <property name="image">image_news</property> - <property name="always-show-image">True</property> - </object> - <packing> - <property name="position">3</property> + <property name="position">4</property> </packing> </child> <child> diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index c186fd81c..0b1665316 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -39,8 +39,8 @@ include_directories(${CMAKE_SOURCE_DIR}/plugins) set(APPICONSCALE_EMBLEMS_DIR "${REMMINA_DATADIR}/icons/hicolor/scalable/emblems") -set(REMMINA_COMMON_INCLUDE_DIRS ${GTK_INCLUDE_DIRS}) -set(REMMINA_COMMON_LIBRARIES ${GTK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +set(REMMINA_COMMON_INCLUDE_DIRS ${GTK3_INCLUDE_DIRS}) +set(REMMINA_COMMON_LIBRARIES ${GTK3_LIBRARY} ${GDK3_LIBRARY} ${GDKPixbuf_LIBRARY} ${Pango_LIBRARY} ${Cairo_LIBRARY} ${GObject_LIBRARY} ${GLib_LIBRARY} ${GIO_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) find_suggested_package(LIBSSH) if(LIBSSH_FOUND) @@ -85,7 +85,7 @@ if(LIBVNCSERVER_FOUND) add_subdirectory(vnc) endif() -find_suggested_package(SPICE) +find_suggested_package(Spice) if(SPICE_FOUND) add_subdirectory(spice) endif() diff --git a/plugins/secret/CMakeLists.txt b/plugins/secret/CMakeLists.txt index f0ddab82a..bb1e6ebd1 100644 --- a/plugins/secret/CMakeLists.txt +++ b/plugins/secret/CMakeLists.txt @@ -40,11 +40,11 @@ if(LIBSECRET_FOUND) set_target_properties(remmina-plugin-secret PROPERTIES PREFIX "") set_target_properties(remmina-plugin-secret PROPERTIES NO_SONAME 1) - include_directories(${GTK_INCLUDE_DIRS}) - target_link_libraries(remmina-plugin-secret ${GTK_LIBRARY_DIRS}) + include_directories(${GTK3_INCLUDE_DIRS}) + target_link_libraries(remmina-plugin-secret ${GTK3_LIBRARY} ${GDK3_LIBRARY} ${GDKPixbuf_LIBRARY} ${Pango_LIBRARY} ${Cairo_LIBRARY} ${GObject_LIBRARY} ${GLib_LIBRARY} ${GIO_LIBRARY}) include_directories(SYSTEM ${LIBSECRET_INCLUDE_DIRS}) - target_link_libraries(remmina-plugin-secret ${LIBSECRET_LIBRARIES} ${GLIB2_LIBRARY}) + target_link_libraries(remmina-plugin-secret ${LIBSECRET_LIBRARIES} ${GLIB_LIBRARY}) install(TARGETS remmina-plugin-secret DESTINATION ${REMMINA_PLUGINDIR}) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0cdba7659..294a8edbe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -161,7 +161,7 @@ endif() message(DEBUG "Source list set to: " ${REMMINA_SRCS}) add_executable(remmina ${REMMINA_SRCS}) -include_directories(${GTK_INCLUDE_DIRS} ${gio_INCLUDE_DIRS} ${gio-unix_INCLUDE_DIRS}) +#include_directories(${GTK_INCLUDE_DIRS} ${gio_INCLUDE_DIRS} ${gio-unix_INCLUDE_DIRS}) target_link_libraries(remmina ${GTK_LIBRARIES}) if(WITH_PYTHONLIBS) diff --git a/src/remmina_main.c b/src/remmina_main.c index 05155611a..aa833d78a 100644 --- a/src/remmina_main.c +++ b/src/remmina_main.c @@ -1385,6 +1385,7 @@ GtkWidget *remmina_main_new(void) remminamain->priv = g_new0(RemminaMainPriv, 1); /* Assign UI widgets to the private members */ remminamain->builder = remmina_public_gtk_builder_new_from_file("remmina_main.glade"); + //remminamain->builder = remmina_public_gtk_builder_new_from_resource ("/org.remmina.Remmina/data/ui/remmina_main.glade"); remminamain->window = GTK_WINDOW(RM_GET_OBJECT("RemminaMain")); if (kioskmode && kioskmode == TRUE) { gtk_window_set_position(remminamain->window, GTK_WIN_POS_CENTER_ALWAYS); diff --git a/src/remmina_public.c b/src/remmina_public.c index 25a058ad6..bb29f9837 100644 --- a/src/remmina_public.c +++ b/src/remmina_public.c @@ -573,6 +573,21 @@ GtkBuilder* remmina_public_gtk_builder_new_from_file(gchar *filename) return builder; } +/* Load a GtkBuilder object from a resource */ +GtkBuilder* remmina_public_gtk_builder_new_from_resource(gchar *resource) +{ + TRACE_CALL(__func__); + GError *err = NULL; + GtkBuilder *builder = gtk_builder_new(); + gtk_builder_add_from_resource (builder, resource, &err); + if (err != NULL) { + g_print("Error adding build from resource. Error: %s", err->message); + g_error_free(err); + } + return builder; +} + + /* Change parent container for a widget * If possible use this function instead of the deprecated gtk_widget_reparent */ void remmina_public_gtk_widget_reparent(GtkWidget *widget, GtkContainer *container) diff --git a/src/remmina_public.h b/src/remmina_public.h index de58e2e1e..445dacdcd 100644 --- a/src/remmina_public.h +++ b/src/remmina_public.h @@ -37,6 +37,7 @@ #pragma once #include "config.h" +#include <gtk/gtk.h> #define IDLE_ADD gdk_threads_add_idle #define TIMEOUT_ADD gdk_threads_add_timeout @@ -102,6 +103,8 @@ guint16 remmina_public_get_keycode_for_keyval(GdkKeymap *keymap, guint keyval); gboolean remmina_public_get_modifier_for_keycode(GdkKeymap *keymap, guint16 keycode); /* Load a GtkBuilder object from a filename */ GtkBuilder *remmina_public_gtk_builder_new_from_file(gchar *filename); +/* Load a GtkBuilder object from a resource */ +GtkBuilder *remmina_public_gtk_builder_new_from_resource(gchar *resource); /* Change parent container for a widget */ void remmina_public_gtk_widget_reparent(GtkWidget *widget, GtkContainer *container); /* Used to send desktop notifications */ |