diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 17:06:32 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 17:06:32 +0000 |
commit | 2dad5357405ad33cfa792f04b3ab62a5d188841e (patch) | |
tree | b8f8893942060fe3cfb04ac374cda96fdfc8f453 /cmake | |
parent | Initial commit. (diff) | |
download | remmina-2dad5357405ad33cfa792f04b3ab62a5d188841e.tar.xz remmina-2dad5357405ad33cfa792f04b3ab62a5d188841e.zip |
Adding upstream version 1.4.34+dfsg.upstream/1.4.34+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake')
45 files changed, 3876 insertions, 0 deletions
diff --git a/cmake/CheckHasModule.cmake b/cmake/CheckHasModule.cmake new file mode 100644 index 0000000..df160d0 --- /dev/null +++ b/cmake/CheckHasModule.cmake @@ -0,0 +1,47 @@ +# Remmina - The GTK+ Remote Desktop Client +# +# Taken from stackoverflow https://stackoverflow.com/questions/15706318/check-if-cmake-module-exists +# +# This makes use of the fact that if a package configuration file isn't found for VAR, then a cache variable VAR_DIR is set to VAR_DIR-NOTFOUND. So if the package configuration file is found, either this variable isn't defined, or it's set to a valid path (regardless of whether the find_package finds the requested package). +# +# So, if you do +# +# CheckHasModule(Spurious) +# CheckHasModule(Threads) +# message("\${HAS_MODULE_Spurious} - ${HAS_MODULE_Spurious}") +# message("\${HAS_MODULE_Threads} - ${HAS_MODULE_Threads}") +# +# your output should be: +# +# ${HAS_MODULE_Spurious} - FALSE +# ${HAS_MODULE_Threads} - TRUE +# +# +# +# Copyright (C) 2019 Antenore Gatta, Giovanni Panozzo +# +# 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. + +function(CheckHasModule Module) + find_package(${Module} QUIET) + if(NOT DEFINED ${Module}_DIR) + set(HAS_MODULE_${Module} TRUE PARENT_SCOPE) + elseif(${Module}_DIR) + set(HAS_MODULE_${Module} TRUE PARENT_SCOPE) + else() + set(HAS_MODULE_${Module} FALSE PARENT_SCOPE) + endif() +endfunction() diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake new file mode 100644 index 0000000..a2844ca --- /dev/null +++ b/cmake/ConfigOptions.cmake @@ -0,0 +1,33 @@ +# Remmina - The GTK+ Remote Desktop Client +# +# Copyright (C) 2012 Jean-Louis Dupond +# +# 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((CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i686|x86|AMD64") AND (CMAKE_SIZEOF_VOID_P EQUAL 4)) + set(TARGET_ARCH "x86") +elseif((CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") AND (CMAKE_SIZEOF_VOID_P EQUAL 8)) + set(TARGET_ARCH "x64") +elseif((CMAKE_SYSTEM_PROCESSOR MATCHES "i386") AND (CMAKE_SIZEOF_VOID_P EQUAL 8) AND (APPLE)) + # Mac is weird like that. + set(TARGET_ARCH "x64") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm*") + set(TARGET_ARCH "ARM") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "sparc") + set(TARGET_ARCH "sparc") +endif() + +option(WITH_TRANSLATIONS "Generate translations." ON) diff --git a/cmake/FindAPPINDICATOR.cmake b/cmake/FindAPPINDICATOR.cmake new file mode 100644 index 0000000..b017d5a --- /dev/null +++ b/cmake/FindAPPINDICATOR.cmake @@ -0,0 +1,63 @@ +# Remmina - The GTK+ Remote Desktop Client +# +# Copyright (C) 2011 Marc-Andre Moreau +# Copyright (C) 2014-2015 Antenore Gatta, Fabio Castelli, Giovanni Panozzo +# Copyright (C) 2016-2023 Antenore Gatta, Giovanni Panozzo +# +# 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(FindPackageHandleStandardArgs) + +# Try with ayatana-libappindicator +pkg_check_modules(PC_AYATANA_APPINDICATOR ayatana-appindicator3-0.1) + +find_path(AYATANA_APPINDICATOR_INCLUDE_DIR NAMES libayatana-appindicator/app-indicator.h + HINTS ${PC_AYATANA_APPINDICATOR_INCLUDEDIR} ${PC_AYATANA_APPINDICATOR_INCLUDE_DIRS} + ) + +find_library(AYATANA_APPINDICATOR_LIBRARY NAMES ayatana-appindicator3 + HINTS ${PC_AYATANA_APPINDICATOR_LIBDIR} ${PC_AYATANA_APPINDICATOR_LIBRARY_DIRS} + ) + +if(AYATANA_APPINDICATOR_INCLUDE_DIR AND AYATANA_APPINDICATOR_LIBRARY) + find_package_handle_standard_args(APPINDICATOR DEFAULT_MSG AYATANA_APPINDICATOR_LIBRARY AYATANA_APPINDICATOR_INCLUDE_DIR) +endif() + +if(APPINDICATOR_FOUND) + add_definitions(-DHAVE_AYATANA_LIBAPPINDICATOR) + set(APPINDICATOR_LIBRARIES ${AYATANA_APPINDICATOR_LIBRARY}) + set(APPINDICATOR_INCLUDE_DIRS ${AYATANA_APPINDICATOR_INCLUDE_DIR}) +else() + # Try with normal libappindicator + pkg_check_modules(PC_APPINDICATOR appindicator3-0.1) + +find_path(APPINDICATOR_INCLUDE_DIR NAMES libappindicator/app-indicator.h + HINTS ${PC_APPINDICATOR_INCLUDEDIR} ${PC_APPINDICATOR_INCLUDE_DIRS} + ) + +find_library(APPINDICATOR_LIBRARY NAMES appindicator3 + HINTS ${PC_APPINDICATOR_LIBDIR} ${PC_APPINDICATOR_LIBRARY_DIRS} + ) + + find_package_handle_standard_args(APPINDICATOR DEFAULT_MSG APPINDICATOR_LIBRARY APPINDICATOR_INCLUDE_DIR) + + if(APPINDICATOR_FOUND) + set(APPINDICATOR_LIBRARIES ${APPINDICATOR_LIBRARY}) + set(APPINDICATOR_INCLUDE_DIRS ${APPINDICATOR_INCLUDE_DIR}) + endif() +endif() + +mark_as_advanced(APPINDICATOR_INCLUDE_DIR APPINDICATOR_LIBRARY) diff --git a/cmake/FindATK.cmake b/cmake/FindATK.cmake new file mode 100644 index 0000000..a618567 --- /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 new file mode 100644 index 0000000..b3d05b2 --- /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 0000000..9ff840c --- /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 0000000..9065fed --- /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/FindFeature.cmake b/cmake/FindFeature.cmake new file mode 100644 index 0000000..783971b --- /dev/null +++ b/cmake/FindFeature.cmake @@ -0,0 +1,59 @@ + +# types: DISABLED < RUNTIME < OPTIONAL < RECOMMENDED < REQUIRED + +macro(find_feature _feature _type _purpose _description) + + string(TOUPPER ${_feature} _feature_upper) + string(TOLOWER ${_type} _type_lower) + + if(${_type} STREQUAL "DISABLED") + set(_feature_default "OFF") + message(STATUS "Skipping ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + else() + if(${_type} STREQUAL "REQUIRED") + set(_feature_default "ON") + message(STATUS "Finding ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + find_package(${_feature} REQUIRED) + elseif(${_type} STREQUAL "RECOMMENDED") + if(NOT ${WITH_${_feature_upper}}) + set(_feature_default "OFF") + message(STATUS "Skipping ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + else() + set(_feature_default "ON") + message(STATUS "Finding ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + message(STATUS " Disable feature ${_feature} using \"-DWITH_${_feature_upper}=OFF\"") + find_package(${_feature}) + endif() + elseif(${_type} STREQUAL "OPTIONAL") + if(${WITH_${_feature_upper}}) + set(_feature_default "ON") + message(STATUS "Finding ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + find_package(${_feature} REQUIRED) + else() + set(_feature_default "OFF") + message(STATUS "Skipping ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + message(STATUS " Enable feature ${_feature} using \"-DWITH_${_feature_upper}=ON\"") + endif() + else() + set(_feature_default "ON") + message(STATUS "Finding ${_type_lower} feature ${_feature} for ${_purpose} (${_description})") + find_package(${_feature}) + endif() + + + if(NOT ${${_feature_upper}_FOUND}) + if(${_feature_default}) + message(WARNING " feature ${_feature} was requested but could not be found! ${_feature_default} / ${${_feature_upper}_FOUND}") + endif() + set(_feature_default "OFF") + endif() + + option(WITH_${_feature_upper} "Enable feature ${_feature} for ${_purpose}" ${_feature_default}) + + set_package_properties(${_feature} PROPERTIES + TYPE ${_type} + PURPOSE "${_purpose}" + DESCRIPTION "${_description}") + endif() +endmacro(find_feature) + diff --git a/cmake/FindGCRYPT.cmake b/cmake/FindGCRYPT.cmake new file mode 100644 index 0000000..468e92e --- /dev/null +++ b/cmake/FindGCRYPT.cmake @@ -0,0 +1,32 @@ +# 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. + +find_path(GCRYPT_INCLUDE_DIR NAMES gcrypt.h) + +find_library(GCRYPT_LIBRARY NAMES gcrypt) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(GCRYPT DEFAULT_MSG GCRYPT_LIBRARY GCRYPT_INCLUDE_DIR) + +set(GCRYPT_LIBRARIES ${GCRYPT_LIBRARY}) +set(GCRYPT_INCLUDE_DIRS ${GCRYPT_INCLUDE_DIR}) + +mark_as_advanced(GCRYPT_INCLUDE_DIR GCRYPT_LIBRARY) + diff --git a/cmake/FindGDK3.cmake b/cmake/FindGDK3.cmake new file mode 100644 index 0000000..ee6b6c6 --- /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 0000000..726a515 --- /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 0000000..17e0a38 --- /dev/null +++ b/cmake/FindGIO.cmake @@ -0,0 +1,205 @@ +# 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}) + + if(NOT APPLE) + find_path(GIO-UNIX_INCLUDE_DIR "gio/gdesktopappinfo.h" + HINTS ${GIO-UNIX_PKG_INCLUDE_DIRS}) + list(APPEND GIO_INCLUDE_DIRS ${GIO-UNIX_INCLUDE_DIR}) + endif() + + find_package(GLib) + find_package(GObject) + set(GIO_VERSION "${GLib_VERSION}") + + list(APPEND GIO_DEPS_FOUND_VARS "GObject_FOUND") + list(APPEND GIO_INCLUDE_DIRS ${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/FindGLib.cmake b/cmake/FindGLib.cmake new file mode 100644 index 0000000..fec8e64 --- /dev/null +++ b/cmake/FindGLib.cmake @@ -0,0 +1,96 @@ +# 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}) + list(APPEND GLib_INCLUDE_DIRS ${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/FindGNOMEKEYRING.cmake b/cmake/FindGNOMEKEYRING.cmake new file mode 100644 index 0000000..99c2268 --- /dev/null +++ b/cmake/FindGNOMEKEYRING.cmake @@ -0,0 +1,35 @@ +# 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. + +find_path(GNOMEKEYRING_INCLUDE_DIR NAMES gnome-keyring.h + PATH_SUFFIXES gnome-keyring-1) + +find_library(GNOMEKEYRING_LIBRARY NAMES gnome-keyring) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(GNOMEKEYRING DEFAULT_MSG GNOMEKEYRING_LIBRARY GNOMEKEYRING_INCLUDE_DIR) + +if(GNOMEKEYRING_FOUND) + set(GNOMEKEYRING_LIBRARIES ${GNOMEKEYRING_LIBRARY}) + set(GNOMEKEYRING_INCLUDE_DIRS ${GNOMEKEYRING_INCLUDE_DIR}) +endif() + +mark_as_advanced(GNOMEKEYRING_INCLUDE_DIR GNOMEKEYRING_LIBRARY) + diff --git a/cmake/FindGObject.cmake b/cmake/FindGObject.cmake new file mode 100644 index 0000000..7da3430 --- /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-VNC.cmake b/cmake/FindGTK-VNC.cmake new file mode 100644 index 0000000..864fba1 --- /dev/null +++ b/cmake/FindGTK-VNC.cmake @@ -0,0 +1,96 @@ +# Remmina - The GTK+ Remote Desktop Client +# +# Copyright (C) 2015-2023 Antenore Gatta +# +# 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. +# +# In addition, as a special exception, the copyright holders give +# permission to link the code of portions of this program with the +# OpenSSL library under certain conditions as described in each +# individual source file, and distribute linked combinations +# including the two. +# You must obey the GNU General Public License in all respects +# for all of the code used other than OpenSSL. * If you modify +# file(s) with this exception, you may extend this exception to your +# version of the file(s), but you are not obligated to do so. * If you +# do not wish to do so, delete this exception statement from your +# version. * If you delete this exception statement from all source +# files in the program, then also delete it here. + +find_package(PkgConfig) + +if(PKG_CONFIG_FOUND) + pkg_check_modules(_GVNC gvnc-1.0) + pkg_check_modules(_GVNCPULSE gvncpulse-1.0) + pkg_check_modules(_GTK-VNC gtk-vnc-2.0) +endif(PKG_CONFIG_FOUND) + +# libgtk-vnc-2.0.so contains the GTK+ 3 bindings for Gtk VNC. +# libgvnc-1.0.so contains the GObject bindings for Gtk VNC. +# libgvncpulse-1.0.so is the PulseAudio bridge for Gtk VNC. + +find_library(GVNC_LIB gvnc-1.0 + HINTS + ${_GVNC_LIBRARY_DIRS} + ${COMMON_LIB_DIR} +) + +find_library(GVNCPULSE_LIB gvncpulse-1.0 + HINTS + ${_GVNCPULSE_LIBRARY_DIRS} + ${COMMON_LIB_DIR} +) + +find_library(GTK-VNC_LIB gtk-vnc-2.0 + HINTS + ${_GTK-VNC_LIBRARY_DIRS} + ${COMMON_LIB_DIR} +) + +if(GVNC_LIB AND GVNCPULSE_LIB AND GTK-VNC_LIB) + set(GTK-VNC_LIBRARIES ${GVNC_LIB} ${GVNCPULSE_LIB} ${GTK-VNC_LIB}) + message(STATUS "GTK-VNC-Libs: ${GTK-VNC_LIBRARIES}") +endif() + +find_path(GVNC_INCLUDE_DIR gvnc.h + PATH_SUFFIXES gvnc-1.0 + PATHS + ${_GVNC_INCLUDE_DIRS} + ${COMMON_INCLUDE_DIR} +) + +find_path(GVNCPULSE_INCLUDE_DIR gvncpulse.h + PATH_SUFFIXES gvncpulse-1.0 + PATHS + ${_GVNCPULSE_INCLUDE_DIRS} + ${COMMON_INCLUDE_DIR} +) + +find_path(GTK-VNC_INCLUDE_DIR gtk-vnc.h + PATH_SUFFIXES gtk-vnc-2.0 + PATHS + ${_GTK-VNC_INCLUDE_DIRS} + ${COMMON_INCLUDE_DIR} +) + +if(GVNC_INCLUDE_DIR AND GVNCPULSE_INCLUDE_DIR AND GTK-VNC_INCLUDE_DIR) + set(GTK-VNC_INCLUDE_DIRS ${GVNC_INCLUDE_DIR} ${GVNCPULSE_INCLUDE_DIR} ${GTK-VNC_INCLUDE_DIR}) + message(STATUS "GTK-VNC-Include-Dirs: ${GTK-VNC_INCLUDE_DIRS}") +endif() + +if(GTK-VNC_INCLUDE_DIRS) + set(GTK-VNC_FOUND TRUE) +endif() diff --git a/cmake/FindGTK3.cmake b/cmake/FindGTK3.cmake new file mode 100644 index 0000000..049a276 --- /dev/null +++ b/cmake/FindGTK3.cmake @@ -0,0 +1,93 @@ +# FindGTK3.cmake +# <https://github.com/nemequ/gnome-cmake> +# +# CMake support for GTK+ 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(GTK3_DEPS + GIO + ATK + GDK3 + Pango + Cairo + GDKPixbuf) + +if(PKG_CONFIG_FOUND) + pkg_search_module(GTK3_PKG QUIET gtk+-3.0) +endif() + +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() + +set(GTK3_DEPS_FOUND_VARS) +foreach(gtk3_dep ${GTK3_DEPS}) + find_package(${gtk3_dep}) + + list(APPEND GTK3_DEPS_FOUND_VARS "${gtk3_dep}_FOUND") + list(APPEND GTK3_INCLUDE_DIRS ${${gtk3_dep}_INCLUDE_DIRS}) + + set_property (TARGET "${GTK3}" APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${${gtk3_dep}}") +endforeach(gtk3_dep) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GTK3 + REQUIRED_VARS + GTK3_LIBRARY + GTK3_INCLUDE_DIRS + ${GTK3_DEPS_FOUND_VARS} + VERSION_VAR + GTK3_VERSION) + +unset(GTK3_DEPS_FOUND_VARS) diff --git a/cmake/FindJSONGLIB.cmake b/cmake/FindJSONGLIB.cmake new file mode 100644 index 0000000..d2f5442 --- /dev/null +++ b/cmake/FindJSONGLIB.cmake @@ -0,0 +1,44 @@ +# Remmina - The GTK+ Remote Desktop Client +# +# Copyright (C) 2011 Marc-Andre Moreau +# Copyright (C) 2014-2015 Antenore Gatta, Fabio Castelli, Giovanni Panozzo +# Copyright (C) 2016-2023 Antenore Gatta, Giovanni Panozzo +# +# 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(FindPackageHandleStandardArgs) + +pkg_check_modules(PC_JSONGLIB json-glib-1.0) + +find_path(JSONGLIB_INCLUDE_DIR NAMES json-glib/json-glib.h + HINTS ${PC_JSONGLIB_INCLUDEDIR} ${PC_JSONGLIB_INCLUDE_DIRS} +) + +find_library(JSONGLIB_LIBRARY NAMES json-glib-1.0 + HINTS ${PC_JSONGLIB_LIBDIR} ${PC_JSONGLIB_LIBRARY_DIRS} +) + +if (JSONGLIB_INCLUDE_DIR AND JSONGLIB_LIBRARY) + find_package_handle_standard_args(JSONGLIB DEFAULT_MSG JSONGLIB_LIBRARY JSONGLIB_INCLUDE_DIR) +endif() + +if (JSONGLIB_FOUND) + set(JSONGLIB_LIBRARIES ${JSONGLIB_LIBRARY}) + set(JSONGLIB_INCLUDE_DIRS ${JSONGLIB_INCLUDE_DIR}) +endif() + +mark_as_advanced(JSONGLIB_INCLUDE_DIR JSONGLIB_LIBRARY) + diff --git a/cmake/FindLIBSOUP.cmake b/cmake/FindLIBSOUP.cmake new file mode 100644 index 0000000..df91a91 --- /dev/null +++ b/cmake/FindLIBSOUP.cmake @@ -0,0 +1,43 @@ +# Remmina - The GTK+ Remote Desktop Client +# +# Copyright (C) 2016-2023 Antenore Gatta, Giovanni Panozzo +# +# 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(FindPackageHandleStandardArgs) + +pkg_search_module(PC_LIBSOUP REQUIRED libsoup-3.0 libsoup-2.4) + +find_path(LIBSOUP_INCLUDE_DIR NAMES libsoup/soup.h + HINTS ${PC_LIBSOUP_INCLUDEDIR} ${PC_LIBSOUP_INCLUDE_DIRS} +) + +find_library(LIBSOUP_LIBRARY + NAMES soup soup-3.0 soup-2.4 + HINTS ${PC_LIBSOUP_LIBDIR} ${PC_LIBSOUP_LIBRARY_DIRS} + ) + +if (LIBSOUP_INCLUDE_DIR AND LIBSOUP_LIBRARY) + find_package_handle_standard_args(LIBSOUP DEFAULT_MSG LIBSOUP_LIBRARY LIBSOUP_INCLUDE_DIR) +endif() + +if (LIBSOUP_FOUND) + set(LIBSOUP_LIBRARIES ${LIBSOUP_LIBRARY}) + set(LIBSOUP_INCLUDE_DIRS ${LIBSOUP_INCLUDE_DIR}) +endif() + +mark_as_advanced(LIBSOUP_INCLUDE_DIR LIBSOUP_LIBRARY) + diff --git a/cmake/FindLIBSSH.cmake b/cmake/FindLIBSSH.cmake new file mode 100644 index 0000000..d1bfe23 --- /dev/null +++ b/cmake/FindLIBSSH.cmake @@ -0,0 +1,62 @@ +# 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(LibFindMacros) + +# Dependencies +find_package(PkgConfig) + +# Use pkg-config to get hints about paths +libfind_pkg_check_modules(PC_LIBSSH libssh>=0.6) + + +set(LIBSSH_DEFINITIONS ${PC_LIBSSH_CFLAGS_OTHER}) + +# Include dir +find_path(LIBSSH_INCLUDE_DIR + NAMES libssh/libssh.h + #HINTS ${PC_LIBSSH_INCLUDEDIR} ${PC_LIBSSH_INCLUDE_DIRS} + PATHS ${PC_LIBSSH_PKGCONF_INCLUDE_DIRS} +) + +# The library itself +find_library(LIBSSH_LIBRARY + NAMES ssh + #HINTS ${PC_LIBSSH_LIBDIR} ${PC_LIBSSH_LIBRARY_DIRS} + PATHS ${PC_LIBSSH_PKGCONF_LIBRARY_DIRS} +) + +find_library(LIBSSH_THREADS_LIBRARY + NAMES ssh_threads + PATHS ${PC_LIBSSH_LIBDIR} ${PC_LIBSSH_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(LIBSSH DEFAULT_MSG LIBSSH_LIBRARY LIBSSH_INCLUDE_DIR) + +if (LIBSSH_THREADS_LIBRARY) + set(LIBSSH_LIBRARIES ${LIBSSH_LIBRARY} ${LIBSSH_THREADS_LIBRARY}) +else() + set(LIBSSH_LIBRARIES ${LIBSSH_LIBRARY}) +endif() +set(LIBSSH_INCLUDE_DIRS ${LIBSSH_INCLUDE_DIR}) + +mark_as_advanced(LIBSSH_INCLUDE_DIR LIBSSH_LIBRARY) + diff --git a/cmake/FindLIBVNCSERVER.cmake b/cmake/FindLIBVNCSERVER.cmake new file mode 100644 index 0000000..3918e1a --- /dev/null +++ b/cmake/FindLIBVNCSERVER.cmake @@ -0,0 +1,50 @@ +# Remmina - The GTK+ Remote Desktop Client +# +# Copyright (C) 2012 Luca Falavigna +# +# 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. + +find_package(PkgConfig) +pkg_check_modules(PC_LIBVNCSERVER libvncserver) +pkg_check_modules(PC_LIBVNCCLIENT libvncclient) + +find_path(LIBVNCSERVER_INCLUDE_DIR NAMES rfb/rfb.h + HINTS ${PC_LIBVNCSERVER_INCLUDEDIR} ${PC_LIBVNCSERVER_INCLUDE_DIRS}) + +find_library(LIBVNCSERVER_LIBRARY NAMES vncserver + HINTS ${PC_LIBVNCSERVER_LIBDIR} ${PC_LIBVNCSERVER_LIBRARY_DIRS}) + +find_library(LIBVNCCLIENT_LIBRARY NAMES vncclient + HINTS ${PC_LIBVNCCLIENT_LIBDIR} ${PC_LIBVNCCLIENT_LIBRARY_DIRS}) + +include(FindPackageHandleStandardArgs) + +#libvnc defines their version as a string, not an int, so we parse it here to allow +#for proper c preprocessing to work +string(REPLACE "." ";" VERSION_LIST ${PC_LIBVNCSERVER_VERSION}) +list(GET VERSION_LIST 0 MY_PROGRAM_VERSION_MAJOR) +list(GET VERSION_LIST 1 MY_PROGRAM_VERSION_MINOR) +list(GET VERSION_LIST 2 MY_PROGRAM_VERSION_PATCH) + +add_compile_definitions(LIBVNC_INT_MAJOR=${MY_PROGRAM_VERSION_MAJOR}) +add_compile_definitions(LIBVNC_INT_MINOR=${MY_PROGRAM_VERSION_MINOR}) +add_compile_definitions(LIBVNC_INT_PATCH=${MY_PROGRAM_VERSION_PATCH}) +find_package_handle_standard_args(LIBVNCSERVER DEFAULT_MSG LIBVNCSERVER_LIBRARY LIBVNCSERVER_INCLUDE_DIR) + +set(LIBVNCSERVER_LIBRARIES ${LIBVNCSERVER_LIBRARY} ${LIBVNCCLIENT_LIBRARY}) +set(LIBVNCSERVER_INCLUDE_DIRS ${LIBVNCSERVER_INCLUDE_DIR}) + +mark_as_advanced(LIBVNCSERVER_INCLUDE_DIR LIBVNCSERVER_LIBRARY) diff --git a/cmake/FindLibsecret.cmake b/cmake/FindLibsecret.cmake new file mode 100644 index 0000000..562b202 --- /dev/null +++ b/cmake/FindLibsecret.cmake @@ -0,0 +1,61 @@ +# - Try to find libsecret +# Once done, this will define +# +# LIBSECRET_FOUND - system has libsecret +# LIBSECRET_INCLUDE_DIRS - the libsecret include directories +# LIBSECRET_LIBRARIES - link these to use libsecret +# +# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org> +# Copyright (C) 2014 Igalia S.L. +# +# 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 HOLDER AND ITS 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 HOLDER OR ITS +# 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. + +#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) +endforeach(i) +set(LIBSECRET_LIBRARIES ${LIBSECRET_LIBRARY}) +unset(LIBSECRET_LIBRARY CACHE) + +set(VERSION_OK TRUE) +if (LIBSECRET_VERSION) + if (LIBSECRET_FIND_VERSION_EXACT) + if (NOT("${LIBSECRET_FIND_VERSION}" VERSION_EQUAL "${LIBSECRET_VERSION}")) + set(VERSION_OK FALSE) + endif () + else () + if ("${LIBSECRET_VERSION}" VERSION_LESS "${LIBSECRET_FIND_VERSION}") + set(VERSION_OK FALSE) + endif () + endif () + if (${LIBSECRET_VERSION} VERSION_GREATER "0.18.0") + 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) diff --git a/cmake/FindOptionalPackage.cmake b/cmake/FindOptionalPackage.cmake new file mode 100644 index 0000000..3e543bd --- /dev/null +++ b/cmake/FindOptionalPackage.cmake @@ -0,0 +1,51 @@ +# - FindOptionalPackage +# Enable or disable optional packages. Also force optional packages. +# +# This module defines the following macros: +# find_required_package : find a required package, can not be disabled +# find_suggested_package : find a suggested package - required but can be disabled +# find_optional_package : find an optional package - required only if enabled +# + +#============================================================================= +# Copyright 2011 Nils Andresen <nils@nils-andresen.de> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +macro(find_required_package _normal_package) + find_package(${_normal_package} REQUIRED) +endmacro(find_required_package) + +macro(find_suggested_package _normal_package) + string(TOUPPER ${_normal_package} _upper_package) + option(WITH_${_upper_package} "Add dependency to ${_normal_package} - recommended" ON) + + if(WITH_${_upper_package}) + message(STATUS "Finding suggested package ${_normal_package}.") + message(STATUS " Disable this using \"-DWITH_${_upper_package}=OFF\".") + find_package(${_normal_package} REQUIRED) + endif(WITH_${_upper_package}) +endmacro(find_suggested_package) + +macro(find_optional_package _normal_package) + string(TOUPPER ${_normal_package} _upper_package) + option(WITH_${_upper_package} "Add dependency to ${_normal_package}" OFF) + + if(WITH_${_upper_package}) + find_package(${_normal_package} REQUIRED) + else(WITH_${_upper_package}) + message(STATUS "Skipping optional package ${_normal_package}.") + message(STATUS " Enable this using \"-DWITH_${_upper_package}=ON\".") + endif(WITH_${_upper_package}) +endmacro(find_optional_package) diff --git a/cmake/FindPCRE2.cmake b/cmake/FindPCRE2.cmake new file mode 100644 index 0000000..1dccb41 --- /dev/null +++ b/cmake/FindPCRE2.cmake @@ -0,0 +1,56 @@ +# Remmina - The GTK+ Remote Desktop Client +# +# Copyright (C) 2022-2023 Antenore Gatta, Giovanni Panozzo, Matteo F. Vescovi +# +# 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. + +# +# PCRE2_INCLUDE_DIRS +# PCRE2_LIBRARIES +# PCRE2_CFLAGS + +find_package(PkgConfig) + +if(PKG_CONFIG_FOUND) + pkg_check_modules(_PCRE2 libpcre2-8) +endif(PKG_CONFIG_FOUND) + +find_library(PCRE2_LIB pcre + HINTS + ${_PCRE2_LIBRARY_DIRS} + ${COMMON_LIB_DIR} +) + +if(PCRE2_LIB) + set(PCRE2_LIBRARIES ${PCRE2_LIB}) + message(STATUS "PCRE2-Libs: ${PCRE2_LIBRARIES}") +endif() + +find_path(PCRE2_INCLUDE_DIR pcre2.h + PATHS + ${_PCRE2_INCLUDE_DIRS} + ${COMMON_INCLUDE_DIR} +) + + +if(PCRE2_INCLUDE_DIR) + set(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR}) + message(STATUS "PCRE2-Include-Dirs: ${PCRE2_INCLUDE_DIRS}") +endif() + +if(PCRE2_INCLUDE_DIRS) + set(PCRE2_FOUND TRUE) +endif() diff --git a/cmake/FindPango.cmake b/cmake/FindPango.cmake new file mode 100644 index 0000000..82ca253 --- /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/FindSharedMimeInfo.cmake b/cmake/FindSharedMimeInfo.cmake new file mode 100644 index 0000000..ee64956 --- /dev/null +++ b/cmake/FindSharedMimeInfo.cmake @@ -0,0 +1,76 @@ +# - Try to find the shared-mime-info package +# +# SHARED_MIME_INFO_MINIMUM_VERSION - Set this to the minimum version you need, default is 0.18 +# +# Once done this will define +# +# SHARED_MIME_INFO_FOUND - system has the shared-mime-info package +# UPDATE_MIME_DATABASE_EXECUTABLE - the update-mime-database executable + +# Copyright (c) 2007, Pino Toscano, <toscano.pino@tiscali.it> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# the minimum version of shared-mime-database we require +if (NOT SHARED_MIME_INFO_MINIMUM_VERSION) + set(SHARED_MIME_INFO_MINIMUM_VERSION "0.18") +endif (NOT SHARED_MIME_INFO_MINIMUM_VERSION) + +if (UPDATE_MIME_DATABASE_EXECUTABLE) + + # in cache already + set(SHARED_MIME_INFO_FOUND TRUE) + +else (UPDATE_MIME_DATABASE_EXECUTABLE) + + include (MacroEnsureVersion) + + find_program (UPDATE_MIME_DATABASE_EXECUTABLE NAMES update-mime-database) + + if (UPDATE_MIME_DATABASE_EXECUTABLE) + + exec_program (${UPDATE_MIME_DATABASE_EXECUTABLE} ARGS -v RETURN_VALUE _null OUTPUT_VARIABLE _smiVersionRaw) + + string(REGEX REPLACE "update-mime-database \\([a-zA-Z\\-]+\\) ([0-9]\\.[0-9]+).*" + "\\1" smiVersion "${_smiVersionRaw}") + set (SHARED_MIME_INFO_FOUND TRUE) + endif (UPDATE_MIME_DATABASE_EXECUTABLE) + + if (SHARED_MIME_INFO_FOUND) + if (NOT SharedMimeInfo_FIND_QUIETLY) + message(STATUS "Found shared-mime-info version: ${smiVersion}") + macro_ensure_version(${SHARED_MIME_INFO_MINIMUM_VERSION} ${smiVersion} _smiVersion_OK) + if (NOT _smiVersion_OK) + message(FATAL_ERROR "The found version of shared-mime-info (${smiVersion}) is below the minimum required (${SHARED_MIME_INFO_MINIMUM_VERSION})") + endif (NOT _smiVersion_OK) + + endif (NOT SharedMimeInfo_FIND_QUIETLY) + else (SHARED_MIME_INFO_FOUND) + if (SharedMimeInfo_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find shared-mime-info. See http://freedesktop.org/wiki/Software/shared-mime-info.") + endif (SharedMimeInfo_FIND_REQUIRED) + endif (SHARED_MIME_INFO_FOUND) + +endif (UPDATE_MIME_DATABASE_EXECUTABLE) + +mark_as_advanced(UPDATE_MIME_DATABASE_EXECUTABLE) + + +macro(UPDATE_XDG_MIMETYPES _path) + get_filename_component(_xdgmimeDir "${_path}" NAME) + if("${_xdgmimeDir}" STREQUAL packages ) + get_filename_component(_xdgmimeDir "${_path}" PATH) + else("${_xdgmimeDir}" STREQUAL packages ) + set(_xdgmimeDir "${_path}") + endif("${_xdgmimeDir}" STREQUAL packages ) + + install(CODE " + set(DESTDIR_VALUE \"\$ENV{DESTDIR}\") + if (NOT DESTDIR_VALUE) + # under Windows relative paths are used, that's why it runs from CMAKE_INSTALL_PREFIX + execute_process(COMMAND ${UPDATE_MIME_DATABASE_EXECUTABLE} ${_xdgmimeDir} + WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\") + endif (NOT DESTDIR_VALUE) + ") +endmacro (UPDATE_XDG_MIMETYPES) diff --git a/cmake/FindSpice.cmake b/cmake/FindSpice.cmake new file mode 100644 index 0000000..9d6417a --- /dev/null +++ b/cmake/FindSpice.cmake @@ -0,0 +1,87 @@ +# Remmina - The GTK+ Remote Desktop Client +# +# Copyright (C) 2016-2018 Denis Ollier +# +# 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. +# +# In addition, as a special exception, the copyright holders give +# permission to link the code of portions of this program with the +# OpenSSL library under certain conditions as described in each +# individual source file, and distribute linked combinations +# including the two. +# You must obey the GNU General Public License in all respects +# for all of the code used other than OpenSSL. * If you modify +# file(s) with this exception, you may extend this exception to your +# version of the file(s), but you are not obligated to do so. * If you +# do not wish to do so, delete this exception statement from your +# version. * If you delete this exception statement from all source +# files in the program, then also delete it here. + +find_package(PkgConfig) + +if(PKG_CONFIG_FOUND) + #pkg_check_modules(PC_SPICE_PROTOCOL spice-protocol) + pkg_check_modules(_SPICE spice-client-gtk-3.0) +endif(PKG_CONFIG_FOUND) + +find_library(SPICE_CLIENT_GTK3_LIB NAMES spice-client-gtk-3.0 + PATHS + ${_SPICE_LIBRARY_DIRS} + ${COMMON_LIB_DIR} +) + +find_library(SPICE_CLIENT_GLIB_LIB NAMES spice-client-glib-2.0 + PATHS + ${_SPICE_LIBRARY_DIRS} + ${COMMON_LIB_DIR} +) + +if(SPICE_CLIENT_GTK3_LIB AND SPICE_CLIENT_GLIB_LIB) + set(SPICE_LIBRARIES ${SPICE_CLIENT_GTK3_LIB} ${SPICE_CLIENT_GLIB_LIB}) + message(STATUS "Spice-Libs: ${SPICE_LIBRARIES}") +endif() + + +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/FindTELEPATHY.cmake b/cmake/FindTELEPATHY.cmake new file mode 100644 index 0000000..504f706 --- /dev/null +++ b/cmake/FindTELEPATHY.cmake @@ -0,0 +1,38 @@ +# 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. + +find_package(PkgConfig) +pkg_check_modules(PC_TELEPATHY telepathy-glib) +set(TELEPATHY_DEFINITIONS ${PC_TELEPATHY_CFLAGS_OTHER}) + +find_path(TELEPATHY_INCLUDE_DIR NAMES telepathy-glib/telepathy-glib.h + HINTS ${PC_TELEPATHY_INCLUDEDIR} ${PC_TELEPATHY_INCLUDE_DIRS} + PATH_SUFFIXES telepathy-1.0) + +find_library(TELEPATHY_LIBRARY NAMES telepathy-glib) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(TELEPATHY DEFAULT_MSG TELEPATHY_LIBRARY TELEPATHY_INCLUDE_DIR) + +set(TELEPATHY_LIBRARIES ${TELEPATHY_LIBRARY}) +set(TELEPATHY_INCLUDE_DIRS ${PC_TELEPATHY_INCLUDE_DIRS}) + +mark_as_advanced(TELEPATHY_INCLUDE_DIR TELEPATHY_LIBRARY) + diff --git a/cmake/FindVTE.cmake b/cmake/FindVTE.cmake new file mode 100644 index 0000000..b83d8eb --- /dev/null +++ b/cmake/FindVTE.cmake @@ -0,0 +1,52 @@ +# 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. + +if(NOT _VTE_VERSION_NUM) + set(_VTE_LIB_NAME vte) + set(_VTE_VERSION vte) +else() + if(${_VTE_VERSION_NUM} VERSION_LESS 2.91) + set(_VTE_LIB_NAME vte${_VTE_VERSION_NUM}) + else() + set(_VTE_LIB_NAME vte-${_VTE_VERSION_NUM}) + endif() + set(_VTE_VERSION vte-${_VTE_VERSION_NUM}) +endif() + +if(${_VTE_VERSION_NUM} VERSION_LESS 2.91) + string(REPLACE . _ _VTE_LIB_NAME ${_VTE_LIB_NAME}) +endif() + +pkg_check_modules(PC_VTE ${_VTE_VERSION}) + +find_path(VTE_INCLUDE_DIR NAMES vte/vte.h + HINTS ${PC_VTE_INCLUDEDIR} ${PC_VTE_INCLUDE_DIRS} + PATH_SUFFIXES ${_VTE_VERSION}) + +find_library(VTE_LIBRARY NAMES ${_VTE_LIB_NAME}) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(VTE DEFAULT_MSG VTE_LIBRARY VTE_INCLUDE_DIR) + +set(VTE_LIBRARIES ${VTE_LIBRARY}) +set(VTE_INCLUDE_DIRS ${VTE_INCLUDE_DIR}) + +mark_as_advanced(VTE_INCLUDE_DIR VTE_LIBRARY) + diff --git a/cmake/FindWEBKIT2GTK.cmake b/cmake/FindWEBKIT2GTK.cmake new file mode 100644 index 0000000..7cd415e --- /dev/null +++ b/cmake/FindWEBKIT2GTK.cmake @@ -0,0 +1,71 @@ +# Remmina - The GTK+ Remote Desktop Client +# +# Copyright (C) 2015-2023 Antenore Gatta, Giovanni Panozzo +# +# 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. +# +# In addition, as a special exception, the copyright holders give +# permission to link the code of portions of this program with the +# OpenSSL library under certain conditions as described in each +# individual source file, and distribute linked combinations +# including the two. +# You must obey the GNU General Public License in all respects +# for all of the code used other than OpenSSL. * If you modify +# file(s) with this exception, you may extend this exception to your +# version of the file(s), but you are not obligated to do so. * If you +# do not wish to do so, delete this exception statement from your +# version. * If you delete this exception statement from all source +# files in the program, then also delete it here. + +find_package(PkgConfig) + +if(PKG_CONFIG_FOUND) + pkg_search_module(_WEBKIT2GTK webkit2gtk-4.1 webkit2gtk-4.0) +endif(PKG_CONFIG_FOUND) + +set(WEBKIT2GTK_DEFINITIONS ${_WEBKIT2GTK_CFLAGS_OTHER}) + +find_path(WEBKIT2GTK_INCLUDE_DIR NAMES webkit2/webkit2.h + HINTS ${_WEBKIT2GTK_INCLUDEDIR} ${_WEBKIT2GTK_INCLUDE_DIRS} +) + +find_library(WEBKIT2GTK_LIB + NAMES webkit2gtk-4.1 webkit2gtk-4.0 + HINTS + ${_WEBKIT2GTK_LIBDIR} + ${_WEBKIT2GTK_LIBRARY_DIRS} +) + + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(WEBKIT2GTK DEFAULT_MSG WEBKIT2GTK_LIB WEBKIT2GTK_INCLUDE_DIR) + +if(WEBKIT2GTK_LIB) + set(WEBKIT2GTK_LIBRARIES ${WEBKIT2GTK_LIB}) + message(STATUS "WEBKIT2GTK-Libs: ${WEBKIT2GTK_LIBRARIES}") +endif() + +if(WEBKIT2GTK_INCLUDE_DIR) + set(WEBKIT2GTK_INCLUDE_DIRS ${WEBKIT2GTK_INCLUDE_DIR}) + message(STATUS "WEBKIT2GTK-Include-Dirs: ${WEBKIT2GTK_INCLUDE_DIRS}") +endif() + +if(WEBKIT2GTK_INCLUDE_DIRS) + set(WEBKIT2GTK_FOUND TRUE) +endif() + +mark_as_advanced(WEBKIT2GTK_INCLUDE_DIR WEBKIT2GTK_LIB) diff --git a/cmake/FindWayland.cmake b/cmake/FindWayland.cmake new file mode 100644 index 0000000..e351733 --- /dev/null +++ b/cmake/FindWayland.cmake @@ -0,0 +1,69 @@ +# - Finds Wayland +# Find the Wayland libraries that are needed for UWAC +# +# This module defines the following variables: +# WAYLAND_FOUND - true if UWAC has been found +# WAYLAND_LIBS - Set to the full path to wayland client libraries +# WAYLAND_INCLUDE_DIR - Set to the include directories for wayland +# XKBCOMMON_LIBS - Set to the full path to xkbcommon libraries +# XKBCOMMON_INCLUDE_DIR - Set to the include directories for xkbcommon +# + +#============================================================================= +# Copyright 2015 David Fort <contact@hardening-consulting.com> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +include(FindPkgConfig) + +if(PKG_CONFIG_FOUND) + pkg_check_modules(WAYLAND_SCANNER_PC wayland-scanner) + pkg_check_modules(WAYLAND_CLIENT_PC wayland-client) + pkg_check_modules(WAYLAND_CURSOR_PC wayland-cursor) + pkg_check_modules(XKBCOMMON_PC xkbcommon) +endif() + +find_program(WAYLAND_SCANNER wayland-scanner + HINTS "${WAYLAND_SCANNER_PC_PREFIX}/bin" +) + +find_path(WAYLAND_INCLUDE_DIR wayland-client.h + HINTS ${WAYLAND_CLIENT_PC_INCLUDE_DIRS} +) + +find_library(WAYLAND_CLIENT_LIB + NAMES "wayland-client" + HINTS "${WAYLAND_CLIENT_PC_LIBRARY_DIRS}" +) + +find_library(WAYLAND_CURSOR_LIB + NAMES "wayland-cursor" + HINTS "${WAYLAND_CURSOR_PC_LIBRARY_DIRS}" +) + +if (WAYLAND_CLIENT_LIB AND WAYLAND_CURSOR_LIB) + list(APPEND WAYLAND_LIBS ${WAYLAND_CLIENT_LIB} ${WAYLAND_CURSOR_LIB}) +endif (WAYLAND_CLIENT_LIB AND WAYLAND_CURSOR_LIB) + +find_path(XKBCOMMON_INCLUDE_DIR xkbcommon/xkbcommon.h + HINTS ${XKBCOMMON_PC_INCLUDE_DIRS} +) + +find_library(XKBCOMMON_LIBS + NAMES xkbcommon + HINTS "${XKBCOMMON_PC_LIBRARY_DIRS}" +) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND DEFAULT_MSG WAYLAND_SCANNER WAYLAND_INCLUDE_DIR WAYLAND_LIBS XKBCOMMON_INCLUDE_DIR XKBCOMMON_LIBS) diff --git a/cmake/FindXKBFILE.cmake b/cmake/FindXKBFILE.cmake new file mode 100644 index 0000000..487c71b --- /dev/null +++ b/cmake/FindXKBFILE.cmake @@ -0,0 +1,38 @@ +# 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. + +find_package(PkgConfig) +pkg_check_modules(PC_XKBFILE xkbfile) + +find_path(XKBFILE_INCLUDE_DIR NAMES XKBfile.h + HINTS ${PC_XKBFILE_INCLUDEDIR} ${PC_XKBFILE_INCLUDE_DIRS} + PATH_SUFFIXES X11/extensions) + +find_library(XKBFILE_LIBRARY NAMES xkbfile + HINTS ${PC_XKBFILE_LIBDIR} ${PC_XKBFILE_LIBRARY_DIRS}) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(XKBFILE DEFAULT_MSG XKBFILE_LIBRARY XKBFILE_INCLUDE_DIR) + +set(XKBFILE_LIBRARIES ${XKBFILE_LIBRARY}) +set(XKBFILE_INCLUDE_DIRS ${XKBFILE_INCLUDE_DIR}) + +mark_as_advanced(XKBFILE_INCLUDE_DIR XKBFILE_LIBRARY) + diff --git a/cmake/Findsodium.cmake b/cmake/Findsodium.cmake new file mode 100644 index 0000000..0667920 --- /dev/null +++ b/cmake/Findsodium.cmake @@ -0,0 +1,288 @@ +# Written in 2016 by Henrik Steffen Gaßmann <henrik@gassmann.onl> +# +# To the extent possible under law, the author(s) have dedicated all +# copyright and related and neighboring rights to this software to the +# public domain worldwide. This software is distributed without any warranty. +# +# You should have received a copy of the CC0 Public Domain Dedication +# along with this software. If not, see +# +# http://creativecommons.org/publicdomain/zero/1.0/ +# +######################################################################## +# Tries to find the local libsodium installation. +# +# On Windows the sodium_DIR environment variable is used as a default +# hint which can be overridden by setting the corresponding cmake variable. +# +# Once done the following variables will be defined: +# +# sodium_FOUND +# sodium_INCLUDE_DIR +# sodium_LIBRARY_DEBUG +# sodium_LIBRARY_RELEASE +# +# +# Furthermore an imported "sodium" target is created. +# + +if (CMAKE_C_COMPILER_ID STREQUAL "GNU" + OR CMAKE_C_COMPILER_ID STREQUAL "Clang") + set(_GCC_COMPATIBLE 1) +endif() + +# static library option +if (NOT DEFINED sodium_USE_STATIC_LIBS) + option(sodium_USE_STATIC_LIBS "enable to statically link against sodium" OFF) +endif() +if(NOT (sodium_USE_STATIC_LIBS EQUAL sodium_USE_STATIC_LIBS_LAST)) + unset(sodium_LIBRARY CACHE) + unset(sodium_LIBRARY_DEBUG CACHE) + unset(sodium_LIBRARY_RELEASE CACHE) + unset(sodium_DLL_DEBUG CACHE) + unset(sodium_DLL_RELEASE CACHE) + set(sodium_USE_STATIC_LIBS_LAST ${sodium_USE_STATIC_LIBS} CACHE INTERNAL "internal change tracking variable") +endif() + + +######################################################################## +# UNIX +if (UNIX) + # import pkg-config + find_package(PkgConfig QUIET) + if (PKG_CONFIG_FOUND) + pkg_check_modules(sodium_PKG QUIET libsodium) + endif() + + if(sodium_USE_STATIC_LIBS) + if (sodium_PKG_STATIC_LIBRARIES) + foreach(_libname ${sodium_PKG_STATIC_LIBRARIES}) + if (NOT _libname MATCHES "^lib.*\\.a$") # ignore strings already ending with .a + list(INSERT sodium_PKG_STATIC_LIBRARIES 0 "lib${_libname}.a") + endif() + endforeach() + list(REMOVE_DUPLICATES sodium_PKG_STATIC_LIBRARIES) + else() + # if pkgconfig for libsodium doesn't provide + # static lib info, then override PKG_STATIC here.. + set(sodium_PKG_STATIC_LIBRARIES libsodium.a) + endif() + + set(XPREFIX sodium_PKG_STATIC) + else() + if (sodium_PKG_LIBRARIES STREQUAL "") + set(sodium_PKG_LIBRARIES sodium) + endif() + + set(XPREFIX sodium_PKG) + endif() + + find_path(sodium_INCLUDE_DIR sodium.h + HINTS ${${XPREFIX}_INCLUDE_DIRS} + ) + find_library(sodium_LIBRARY_DEBUG NAMES ${${XPREFIX}_LIBRARIES} + HINTS ${${XPREFIX}_LIBRARY_DIRS} + ) + find_library(sodium_LIBRARY_RELEASE NAMES ${${XPREFIX}_LIBRARIES} + HINTS ${${XPREFIX}_LIBRARY_DIRS} + ) + + +######################################################################## +# Windows +elseif (WIN32) + set(sodium_DIR "$ENV{sodium_DIR}" CACHE FILEPATH "sodium install directory") + mark_as_advanced(sodium_DIR) + + find_path(sodium_INCLUDE_DIR sodium.h + HINTS ${sodium_DIR} + PATH_SUFFIXES include + ) + + if (MSVC) + # detect target architecture + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arch.c" [=[ + #if defined _M_IX86 + #error ARCH_VALUE x86_32 + #elif defined _M_X64 + #error ARCH_VALUE x86_64 + #endif + #error ARCH_VALUE unknown + ]=]) + try_compile(_UNUSED_VAR "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/arch.c" + OUTPUT_VARIABLE _COMPILATION_LOG + ) + string(REGEX REPLACE ".*ARCH_VALUE ([a-zA-Z0-9_]+).*" "\\1" _TARGET_ARCH "${_COMPILATION_LOG}") + + # construct library path + if (_TARGET_ARCH STREQUAL "x86_32") + string(APPEND _PLATFORM_PATH "Win32") + elseif(_TARGET_ARCH STREQUAL "x86_64") + string(APPEND _PLATFORM_PATH "x64") + else() + message(FATAL_ERROR "the ${_TARGET_ARCH} architecture is not supported by Findsodium.cmake.") + endif() + string(APPEND _PLATFORM_PATH "/$$CONFIG$$") + + if (MSVC_VERSION LESS 1900) + math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60") + else() + math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50") + endif() + string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}") + + if (sodium_USE_STATIC_LIBS) + string(APPEND _PLATFORM_PATH "/static") + else() + string(APPEND _PLATFORM_PATH "/dynamic") + endif() + + string(REPLACE "$$CONFIG$$" "Debug" _DEBUG_PATH_SUFFIX "${_PLATFORM_PATH}") + string(REPLACE "$$CONFIG$$" "Release" _RELEASE_PATH_SUFFIX "${_PLATFORM_PATH}") + + find_library(sodium_LIBRARY_DEBUG libsodium.lib + HINTS ${sodium_DIR} + PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX} + ) + find_library(sodium_LIBRARY_RELEASE libsodium.lib + HINTS ${sodium_DIR} + PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX} + ) + if (NOT sodium_USE_STATIC_LIBS) + set(CMAKE_FIND_LIBRARY_SUFFIXES_BCK ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll") + find_library(sodium_DLL_DEBUG libsodium + HINTS ${sodium_DIR} + PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX} + ) + find_library(sodium_DLL_RELEASE libsodium + HINTS ${sodium_DIR} + PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX} + ) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_BCK}) + endif() + + elseif(_GCC_COMPATIBLE) + if (sodium_USE_STATIC_LIBS) + find_library(sodium_LIBRARY_DEBUG libsodium.a + HINTS ${sodium_DIR} + PATH_SUFFIXES lib + ) + find_library(sodium_LIBRARY_RELEASE libsodium.a + HINTS ${sodium_DIR} + PATH_SUFFIXES lib + ) + else() + find_library(sodium_LIBRARY_DEBUG libsodium.dll.a + HINTS ${sodium_DIR} + PATH_SUFFIXES lib + ) + find_library(sodium_LIBRARY_RELEASE libsodium.dll.a + HINTS ${sodium_DIR} + PATH_SUFFIXES lib + ) + + file(GLOB _DLL + LIST_DIRECTORIES false + RELATIVE "${sodium_DIR}/bin" + "${sodium_DIR}/bin/libsodium*.dll" + ) + find_library(sodium_DLL_DEBUG ${_DLL} libsodium + HINTS ${sodium_DIR} + PATH_SUFFIXES bin + ) + find_library(sodium_DLL_RELEASE ${_DLL} libsodium + HINTS ${sodium_DIR} + PATH_SUFFIXES bin + ) + endif() + else() + message(FATAL_ERROR "this platform is not supported by FindSodium.cmake") + endif() + + +######################################################################## +# unsupported +else() + message(FATAL_ERROR "this platform is not supported by FindSodium.cmake") +endif() + + +######################################################################## +# common stuff + +# extract sodium version +if (sodium_INCLUDE_DIR) + set(_VERSION_HEADER "${_INCLUDE_DIR}/sodium/version.h") + if (EXISTS _VERSION_HEADER) + file(READ "${_VERSION_HEADER}" _VERSION_HEADER_CONTENT) + string(REGEX REPLACE ".*#[ \t]*define[ \t]*SODIUM_VERSION_STRING[ \t]*\"([^\n]*)\".*" "\\1" + sodium_VERSION "${_VERSION_HEADER_CONTENT}") + set(sodium_VERSION "${sodium_VERSION}" PARENT_SCOPE) + endif() +endif() + +# communicate results +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(sodium + REQUIRED_VARS + sodium_LIBRARY_RELEASE + sodium_LIBRARY_DEBUG + sodium_INCLUDE_DIR + VERSION_VAR + sodium_VERSION +) + +# mark file paths as advanced +mark_as_advanced(sodium_INCLUDE_DIR) +mark_as_advanced(sodium_LIBRARY_DEBUG) +mark_as_advanced(sodium_LIBRARY_RELEASE) +if (WIN32) + mark_as_advanced(sodium_DLL_DEBUG) + mark_as_advanced(sodium_DLL_RELEASE) +endif() + +# create imported target +if(sodium_USE_STATIC_LIBS) + set(_LIB_TYPE STATIC) +else() + set(_LIB_TYPE SHARED) +endif() +add_library(sodium ${_LIB_TYPE} IMPORTED) + +set_target_properties(sodium PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${sodium_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" +) + +if (sodium_USE_STATIC_LIBS) + set_target_properties(sodium PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "SODIUM_STATIC" + IMPORTED_LOCATION "${sodium_LIBRARY_RELEASE}" + IMPORTED_LOCATION_DEBUG "${sodium_LIBRARY_DEBUG}" + ) +else() + if (UNIX) + set_target_properties(sodium PROPERTIES + IMPORTED_LOCATION "${sodium_LIBRARY_RELEASE}" + IMPORTED_LOCATION_DEBUG "${sodium_LIBRARY_DEBUG}" + ) + elseif (WIN32) + set_target_properties(sodium PROPERTIES + IMPORTED_IMPLIB "${sodium_LIBRARY_RELEASE}" + IMPORTED_IMPLIB_DEBUG "${sodium_LIBRARY_DEBUG}" + ) + if (NOT (sodium_DLL_DEBUG MATCHES ".*-NOTFOUND")) + set_target_properties(sodium PROPERTIES + IMPORTED_LOCATION_DEBUG "${sodium_DLL_DEBUG}" + ) + endif() + if (NOT (sodium_DLL_RELEASE MATCHES ".*-NOTFOUND")) + set_target_properties(sodium PROPERTIES + IMPORTED_LOCATION_RELWITHDEBINFO "${sodium_DLL_RELEASE}" + IMPORTED_LOCATION_MINSIZEREL "${sodium_DLL_RELEASE}" + IMPORTED_LOCATION_RELEASE "${sodium_DLL_RELEASE}" + ) + endif() + endif() +endif() diff --git a/cmake/GETTEXT.cmake b/cmake/GETTEXT.cmake new file mode 100644 index 0000000..368a6be --- /dev/null +++ b/cmake/GETTEXT.cmake @@ -0,0 +1,36 @@ +# 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. + +find_suggested_package(Gettext) + +function(gettext po_dir package_name) + set(mo_files) + file(GLOB po_files ${po_dir}/*.po) + foreach(po_file ${po_files}) + get_filename_component(lang ${po_file} NAME_WE) + if(("$ENV{LINGUAS}" MATCHES "(^| )${lang}( |$)") OR (NOT DEFINED ENV{LINGUAS})) + set(mo_file ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo) + add_custom_command(OUTPUT ${mo_file} COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${mo_file} ${po_file} DEPENDS ${po_file}) + install(FILES ${mo_file} DESTINATION ${CMAKE_INSTALL_LOCALEDIR}/${lang}/LC_MESSAGES RENAME ${package_name}.mo) + set(mo_files ${mo_files} ${mo_file}) + endif() + endforeach() + set(translations-target "${package_name}-translations") + add_custom_target(${translations-target} ALL DEPENDS ${mo_files}) +endfunction() diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake new file mode 100644 index 0000000..5e0847b --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake @@ -0,0 +1,141 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe(<var> [<additional arguments to git describe> ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_get_exact_tag(<var> [<additional arguments to git describe> ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net> +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar) + set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + # check if this is a submodule + if(NOT IS_DIRECTORY ${GIT_DIR}) + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) + endif() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" + @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() + +function(git_rev_parse _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + if(NOT GIT_FOUND) + set(${_var} "n/a" PARENT_SCOPE) + return() + endif() + get_git_head_revision(refspec hash) + if(NOT hash) + set(${_var} "n/a" PARENT_SCOPE) + return() + endif() + + execute_process(COMMAND "${GIT_EXECUTABLE}" rev-parse ${ARGN} ${hash} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE res + OUTPUT_VARIABLE out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "n/a") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + if(NOT GIT_FOUND) + set(${_var} "n/a" PARENT_SCOPE) + return() + endif() + get_git_head_revision(refspec hash) + if(NOT hash) + set(${_var} "n/a" PARENT_SCOPE) + return() + endif() + + execute_process(COMMAND "${GIT_EXECUTABLE}" describe ${hash} ${ARGN} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE res + OUTPUT_VARIABLE out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "n/a") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out --exact-match ${ARGN}) + set(${_var} "${out}" PARENT_SCOPE) +endfunction() diff --git a/cmake/GetGitRevisionDescription.cmake.in b/cmake/GetGitRevisionDescription.cmake.in new file mode 100644 index 0000000..c08762d --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake.in @@ -0,0 +1,39 @@ + +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net> +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}") + configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + set(HEAD_HASH "${HEAD_REF}") + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/cmake/GtkUpdateIconCache.cmake b/cmake/GtkUpdateIconCache.cmake new file mode 100644 index 0000000..7a284fb --- /dev/null +++ b/cmake/GtkUpdateIconCache.cmake @@ -0,0 +1,36 @@ +# Copyright 2015 Volker Krause <vkrause@kde.org> +# +# 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 copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + +find_program(GTK_UPDATE_ICON_CACHE_EXEC NAMES gtk-update-icon-cache) +macro(gtk_update_icon_cache _dir) + if (GTK_UPDATE_ICON_CACHE_EXEC) + install(CODE " + set(DESTDIR_VALUE \"\$ENV{DESTDIR}\") + if (NOT DESTDIR_VALUE) + execute_process(COMMAND ${GTK_UPDATE_ICON_CACHE_EXEC} -qfit ${_dir}) + endif() + ") + endif() +endmacro() diff --git a/cmake/LibFindMacros.cmake b/cmake/LibFindMacros.cmake new file mode 100644 index 0000000..81fef7d --- /dev/null +++ b/cmake/LibFindMacros.cmake @@ -0,0 +1,265 @@ +# Version 2.2 +# Public Domain, originally written by Lasse Kärkkäinen <tronic> +# Maintained at https://github.com/Tronic/cmake-modules +# Please send your improvements as pull requests on Github. + +# Find another package and make it a dependency of the current package. +# This also automatically forwards the "REQUIRED" argument. +# Usage: libfind_package(<prefix> <another package> [extra args to find_package]) +macro (libfind_package PREFIX PKG) + set(${PREFIX}_args ${PKG} ${ARGN}) + if (${PREFIX}_FIND_REQUIRED) + set(${PREFIX}_args ${${PREFIX}_args} REQUIRED) + endif() + find_package(${${PREFIX}_args}) + set(${PREFIX}_DEPENDENCIES ${${PREFIX}_DEPENDENCIES};${PKG}) + unset(${PREFIX}_args) +endmacro() + +# A simple wrapper to make pkg-config searches a bit easier. +# Works the same as CMake's internal pkg_check_modules but is always quiet. +macro (libfind_pkg_check_modules) + find_package(PkgConfig QUIET) + if (PKG_CONFIG_FOUND) + pkg_check_modules(${ARGN} QUIET) + endif() +endmacro() + +# Avoid useless copy&pasta by doing what most simple libraries do anyway: +# pkg-config, find headers, find library. +# Usage: libfind_pkg_detect(<prefix> <pkg-config args> FIND_PATH <name> [other args] FIND_LIBRARY <name> [other args]) +# E.g. libfind_pkg_detect(SDL2 sdl2 FIND_PATH SDL.h PATH_SUFFIXES SDL2 FIND_LIBRARY SDL2) +function (libfind_pkg_detect PREFIX) + # Parse arguments + set(argname pkgargs) + foreach (i ${ARGN}) + if ("${i}" STREQUAL "FIND_PATH") + set(argname pathargs) + elseif ("${i}" STREQUAL "FIND_LIBRARY") + set(argname libraryargs) + else() + set(${argname} ${${argname}} ${i}) + endif() + endforeach() + if (NOT pkgargs) + message(FATAL_ERROR "libfind_pkg_detect requires at least a pkg_config package name to be passed.") + endif() + # Find library + libfind_pkg_check_modules(${PREFIX}_PKGCONF ${pkgargs}) + if (pathargs) + find_path(${PREFIX}_INCLUDE_DIR NAMES ${pathargs} HINTS ${${PREFIX}_PKGCONF_INCLUDE_DIRS}) + endif() + if (libraryargs) + find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}) + endif() +endfunction() + +# Extracts a version #define from a version.h file, output stored to <PREFIX>_VERSION. +# Usage: libfind_version_header(Foobar foobar/version.h FOOBAR_VERSION_STR) +# Fourth argument "QUIET" may be used for silently testing different define names. +# This function does nothing if the version variable is already defined. +function (libfind_version_header PREFIX VERSION_H DEFINE_NAME) + # Skip processing if we already have a version or if the include dir was not found + if (${PREFIX}_VERSION OR NOT ${PREFIX}_INCLUDE_DIR) + return() + endif() + set(quiet ${${PREFIX}_FIND_QUIETLY}) + # Process optional arguments + foreach(arg ${ARGN}) + if (arg STREQUAL "QUIET") + set(quiet TRUE) + else() + message(AUTHOR_WARNING "Unknown argument ${arg} to libfind_version_header ignored.") + endif() + endforeach() + # Read the header and parse for version number + set(filename "${${PREFIX}_INCLUDE_DIR}/${VERSION_H}") + if (NOT EXISTS ${filename}) + if (NOT quiet) + message(AUTHOR_WARNING "Unable to find ${${PREFIX}_INCLUDE_DIR}/${VERSION_H}") + endif() + return() + endif() + file(READ "${filename}" header) + string(REGEX REPLACE ".*#[ \t]*define[ \t]*${DEFINE_NAME}[ \t]*\"([^\n]*)\".*" "\\1" match "${header}") + # No regex match? + if (match STREQUAL header) + if (NOT quiet) + message(AUTHOR_WARNING "Unable to find \#define ${DEFINE_NAME} \"<version>\" from ${${PREFIX}_INCLUDE_DIR}/${VERSION_H}") + endif() + return() + endif() + # Export the version string + set(${PREFIX}_VERSION "${match}" PARENT_SCOPE) +endfunction() + +# Do the final processing once the paths have been detected. +# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain +# all the variables, each of which contain one include directory. +# Ditto for ${PREFIX}_PROCESS_LIBS and library files. +# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES. +# Also handles errors in case library detection was required, etc. +function (libfind_process PREFIX) + # Skip processing if already processed during this configuration run + if (${PREFIX}_FOUND) + return() + endif() + + set(found TRUE) # Start with the assumption that the package was found + + # Did we find any files? Did we miss includes? These are for formatting better error messages. + set(some_files FALSE) + set(missing_headers FALSE) + + # Shorthands for some variables that we need often + set(quiet ${${PREFIX}_FIND_QUIETLY}) + set(required ${${PREFIX}_FIND_REQUIRED}) + set(exactver ${${PREFIX}_FIND_VERSION_EXACT}) + set(findver "${${PREFIX}_FIND_VERSION}") + set(version "${${PREFIX}_VERSION}") + + # Lists of config option names (all, includes, libs) + unset(configopts) + set(includeopts ${${PREFIX}_PROCESS_INCLUDES}) + set(libraryopts ${${PREFIX}_PROCESS_LIBS}) + + # Process deps to add to + foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES}) + if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS) + # The package seems to export option lists that we can use, woohoo! + list(APPEND includeopts ${${i}_INCLUDE_OPTS}) + list(APPEND libraryopts ${${i}_LIBRARY_OPTS}) + else() + # If plural forms don't exist or they equal singular forms + if ((NOT DEFINED ${i}_INCLUDE_DIRS AND NOT DEFINED ${i}_LIBRARIES) OR + ({i}_INCLUDE_DIR STREQUAL ${i}_INCLUDE_DIRS AND ${i}_LIBRARY STREQUAL ${i}_LIBRARIES)) + # Singular forms can be used + if (DEFINED ${i}_INCLUDE_DIR) + list(APPEND includeopts ${i}_INCLUDE_DIR) + endif() + if (DEFINED ${i}_LIBRARY) + list(APPEND libraryopts ${i}_LIBRARY) + endif() + else() + # Oh no, we don't know the option names + message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!") + endif() + endif() + endforeach() + + if (includeopts) + list(REMOVE_DUPLICATES includeopts) + endif() + + if (libraryopts) + list(REMOVE_DUPLICATES libraryopts) + endif() + + string(REGEX REPLACE ".*[ ;]([^ ;]*(_INCLUDE_DIRS|_LIBRARIES))" "\\1" tmp "${includeopts} ${libraryopts}") + if (NOT tmp STREQUAL "${includeopts} ${libraryopts}") + message(AUTHOR_WARNING "Plural form ${tmp} found in config options of ${PREFIX}. This works as before but is now deprecated. Please only use singular forms INCLUDE_DIR and LIBRARY, and update your find scripts for LibFindMacros > 2.0 automatic dependency system (most often you can simply remove the PROCESS variables entirely).") + endif() + + # Include/library names separated by spaces (notice: not CMake lists) + unset(includes) + unset(libs) + + # Process all includes and set found false if any are missing + foreach (i ${includeopts}) + list(APPEND configopts ${i}) + if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND") + list(APPEND includes "${${i}}") + else() + set(found FALSE) + set(missing_headers TRUE) + endif() + endforeach() + + # Process all libraries and set found false if any are missing + foreach (i ${libraryopts}) + list(APPEND configopts ${i}) + if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND") + list(APPEND libs "${${i}}") + else() + set (found FALSE) + endif() + endforeach() + + # Version checks + if (found AND findver) + if (NOT version) + message(WARNING "The find module for ${PREFIX} does not provide version information, so we'll just assume that it is OK. Please fix the module or remove package version requirements to get rid of this warning.") + elseif (version VERSION_LESS findver OR (exactver AND NOT version VERSION_EQUAL findver)) + set(found FALSE) + set(version_unsuitable TRUE) + endif() + endif() + + # If all-OK, hide all config options, export variables, print status and exit + if (found) + foreach (i ${configopts}) + mark_as_advanced(${i}) + endforeach() + if (NOT quiet) + message(STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}") + if (LIBFIND_DEBUG) + message(STATUS " ${PREFIX}_DEPENDENCIES=${${PREFIX}_DEPENDENCIES}") + message(STATUS " ${PREFIX}_INCLUDE_OPTS=${includeopts}") + message(STATUS " ${PREFIX}_INCLUDE_DIRS=${includes}") + message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}") + message(STATUS " ${PREFIX}_LIBRARIES=${libs}") + endif() + set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE) + set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE) + set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE) + set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE) + set (${PREFIX}_FOUND TRUE PARENT_SCOPE) + endif() + return() + endif() + + # Format messages for debug info and the type of error + set(vars "Relevant CMake configuration variables:\n") + foreach (i ${configopts}) + mark_as_advanced(CLEAR ${i}) + set(val ${${i}}) + if ("${val}" STREQUAL "${i}-NOTFOUND") + set (val "<not found>") + elseif (val AND NOT EXISTS ${val}) + set (val "${val} (does not exist)") + else() + set(some_files TRUE) + endif() + set(vars "${vars} ${i}=${val}\n") + endforeach() + set(vars "${vars}You may use CMake GUI, cmake -D or ccmake to modify the values. Delete CMakeCache.txt to discard all values and force full re-detection if necessary.\n") + if (version_unsuitable) + set(msg "${PREFIX} ${${PREFIX}_VERSION} was found but") + if (exactver) + set(msg "${msg} only version ${findver} is acceptable.") + else() + set(msg "${msg} version ${findver} is the minimum requirement.") + endif() + else() + if (missing_headers) + set(msg "We could not find development headers for ${PREFIX}. Do you have the necessary dev package installed?") + elseif (some_files) + set(msg "We only found some files of ${PREFIX}, not all of them. Perhaps your installation is incomplete or maybe we just didn't look in the right place?") + if(findver) + set(msg "${msg} This could also be caused by incompatible version (if it helps, at least ${PREFIX} ${findver} should work).") + endif() + else() + set(msg "We were unable to find package ${PREFIX}.") + endif() + endif() + + # Fatal error out if REQUIRED + if (required) + set(msg "REQUIRED PACKAGE NOT FOUND\n${msg} This package is REQUIRED and you need to install it or adjust CMake configuration in order to continue building ${CMAKE_PROJECT_NAME}.") + message(FATAL_ERROR "${msg}\n${vars}") + endif() + # Otherwise just print a nasty warning + if (NOT quiet) + message(WARNING "WARNING: MISSING PACKAGE\n${msg} This package is NOT REQUIRED and you may ignore this warning but by doing so you may miss some functionality of ${CMAKE_PROJECT_NAME}. \n${vars}") + endif() +endfunction() diff --git a/cmake/MacroEnsureVersion.cmake b/cmake/MacroEnsureVersion.cmake new file mode 100644 index 0000000..a4f1c52 --- /dev/null +++ b/cmake/MacroEnsureVersion.cmake @@ -0,0 +1,115 @@ +# This file defines the following macros for developers to use in ensuring +# that installed software is of the right version: +# +# MACRO_ENSURE_VERSION - test that a version number is greater than +# or equal to some minimum +# MACRO_ENSURE_VERSION_RANGE - test that a version number is greater than +# or equal to some minimum and less than some +# maximum +# MACRO_ENSURE_VERSION2 - deprecated, do not use in new code +# + +# MACRO_ENSURE_VERSION +# This macro compares version numbers of the form "x.y.z" or "x.y" +# MACRO_ENSURE_VERSION( FOO_MIN_VERSION FOO_VERSION_FOUND FOO_VERSION_OK) +# will set FOO_VERSION_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION +# Leading and trailing text is ok, e.g. +# MACRO_ENSURE_VERSION( "2.5.31" "flex 2.5.4a" VERSION_OK) +# which means 2.5.31 is required and "flex 2.5.4a" is what was found on the system + +# Copyright (c) 2006, David Faure, <faure@kde.org> +# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# MACRO_ENSURE_VERSION_RANGE +# This macro ensures that a version number of the form +# "x.y.z" or "x.y" falls within a range defined by +# min_version <= found_version < max_version. +# If this expression holds, FOO_VERSION_OK will be set TRUE +# +# Example: MACRO_ENSURE_VERSION_RANGE3( "0.1.0" ${FOOCODE_VERSION} "0.7.0" FOO_VERSION_OK ) +# +# This macro will break silently if any of x,y,z are greater than 100. +# +# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# NORMALIZE_VERSION +# Helper macro to convert version numbers of the form "x.y.z" +# to an integer equal to 10^4 * x + 10^2 * y + z +# +# This macro will break silently if any of x,y,z are greater than 100. +# +# Copyright (c) 2006, David Faure, <faure@kde.org> +# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# CHECK_RANGE_INCLUSIVE_LOWER +# Helper macro to check whether x <= y < z +# +# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +MACRO(NORMALIZE_VERSION _requested_version _normalized_version) + STRING(REGEX MATCH "[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" _threePartMatch "${_requested_version}") + if (_threePartMatch) + # parse the parts of the version string + STRING(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major_vers "${_requested_version}") + STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor_vers "${_requested_version}") + STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch_vers "${_requested_version}") + else (_threePartMatch) + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+" "\\1" _major_vers "${_requested_version}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)" "\\1" _minor_vers "${_requested_version}") + set(_patch_vers "0") + endif (_threePartMatch) + + # compute an overall version number which can be compared at once + MATH(EXPR ${_normalized_version} "${_major_vers}*10000 + ${_minor_vers}*100 + ${_patch_vers}") +ENDMACRO(NORMALIZE_VERSION) + +MACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER _lower_limit _value _upper_limit _ok) + if (${_value} LESS ${_lower_limit}) + set( ${_ok} FALSE ) + elseif (${_value} EQUAL ${_lower_limit}) + set( ${_ok} TRUE ) + elseif (${_value} EQUAL ${_upper_limit}) + set( ${_ok} FALSE ) + elseif (${_value} GREATER ${_upper_limit}) + set( ${_ok} FALSE ) + else (${_value} LESS ${_lower_limit}) + set( ${_ok} TRUE ) + endif (${_value} LESS ${_lower_limit}) +ENDMACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER) + +MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) + NORMALIZE_VERSION( ${requested_version} req_vers_num ) + NORMALIZE_VERSION( ${found_version} found_vers_num ) + + if (found_vers_num LESS req_vers_num) + set( ${var_too_old} FALSE ) + else (found_vers_num LESS req_vers_num) + set( ${var_too_old} TRUE ) + endif (found_vers_num LESS req_vers_num) + +ENDMACRO(MACRO_ENSURE_VERSION) + +MACRO(MACRO_ENSURE_VERSION2 requested_version2 found_version2 var_too_old2) + MACRO_ENSURE_VERSION( ${requested_version2} ${found_version2} ${var_too_old2}) +ENDMACRO(MACRO_ENSURE_VERSION2) + +MACRO(MACRO_ENSURE_VERSION_RANGE min_version found_version max_version var_ok) + NORMALIZE_VERSION( ${min_version} req_vers_num ) + NORMALIZE_VERSION( ${found_version} found_vers_num ) + NORMALIZE_VERSION( ${max_version} max_vers_num ) + + MACRO_CHECK_RANGE_INCLUSIVE_LOWER( ${req_vers_num} ${found_vers_num} ${max_vers_num} ${var_ok}) +ENDMACRO(MACRO_ENSURE_VERSION_RANGE) diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in new file mode 100644 index 0000000..c780c8d --- /dev/null +++ b/cmake/cmake_uninstall.cmake.in @@ -0,0 +1,82 @@ +# 'delete_empty_folder' function +function(delete_empty_folder DIR) + if(NOT EXISTS ${DIR}) + return() + endif() + + # check if folder is empty + file(GLOB RESULT "${DIR}/*") + list(LENGTH RESULT RES_LEN) + if(RES_LEN EQUAL 0) + if(WITH_CLEANUP) + message(STATUS "Deleting empty folder ${DIR}") + file(REMOVE_RECURSE ${DIR}) + else() + message(STATUS " ${DIR}") + endif() + else() + #message(STATUS "${DIR} is not empty! It won't be removed.") + # message(STATUS "FILES = ${RESULT}") + endif() +endfunction(delete_empty_folder) + +if( NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" ) + message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") +endif( NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" ) + +file( READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +string( REGEX REPLACE "\n" ";" files "${files}" ) + +foreach(file ${files}) + + message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + if(EXISTS "$ENV{DESTDIR}${file}") + + exec_program( "@CMAKE_COMMAND@" + ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if( NOT "${rm_retval}" STREQUAL 0 ) + message( FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"" ) + endif( NOT "${rm_retval}" STREQUAL 0 ) + + else(EXISTS "$ENV{DESTDIR}${file}") + + message( STATUS "File \"$ENV{DESTDIR}${file}\" does not exist." ) + + endif(EXISTS "$ENV{DESTDIR}${file}") + + get_filename_component(FOLDER $ENV{DESTDIR}${file} DIRECTORY) + set(FOLDERS ${FOLDERS} ${FOLDER}) + +endforeach(file) + +# remove empty folders +message(STATUS "") +if(WITH_CLEANUP) + message(STATUS "Removing empty folders") +else() + message(STATUS "Empty folders that may be safely removed:") +endif() + +list(APPEND FOLDERS + "@INSTALL_LIB_DIR@/CMake" + "@CMAKE_INSTALL_FULL_LIBDIR@/remmina" + "@REMMINA_DATADIR@/remmina" + ) + +list(REMOVE_DUPLICATES FOLDERS) +foreach(dir ${FOLDERS}) + # message(STATUS ${dir}) + delete_empty_folder(${dir}) + # message(STATUS "") +endforeach(dir) + +# delete_empty_folder("@INSTALL_INCLUDE_DIR@") +# delete_empty_folder("@INSTALL_BIN_DIR@") +# delete_empty_folder("@INSTALL_LIB_DIR@/CMake") +# delete_empty_folder("@INSTALL_LIB_DIR@") +# delete_empty_folder("@CMAKE_INSTALL_FULL_LIBDIR@/remmina") +# delete_empty_folder("@REMMINA_DATADIR@/remmina") +message(STATUS "") diff --git a/cmake/macros/BuildTargetScript.cmake b/cmake/macros/BuildTargetScript.cmake new file mode 100644 index 0000000..7243449 --- /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 0000000..fd7c6b3 --- /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 0000000..b3f1a30 --- /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 0000000..2950af3 --- /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 0000000..ee144bc --- /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() |