From ac4b018a2970d4da9d2e83198274137fac497548 Mon Sep 17 00:00:00 2001 From: houz Date: Sun, 16 Aug 2015 02:13:02 +0200 Subject: Added translations to the cmake build (1451236) Fixed bugs: - https://launchpad.net/bugs/1451236 (bzr r14304) --- CMakeScripts/ConfigChecks.cmake | 1 - CMakeScripts/ConfigPaths.cmake | 4 +- CMakeScripts/DefineDependsandFlags.cmake | 13 ++ CMakeScripts/FindGettext.cmake | 237 +++++++++++++++++++++++++++++++ 4 files changed, 253 insertions(+), 2 deletions(-) create mode 100644 CMakeScripts/FindGettext.cmake (limited to 'CMakeScripts') diff --git a/CMakeScripts/ConfigChecks.cmake b/CMakeScripts/ConfigChecks.cmake index 905465448..7ec6863eb 100644 --- a/CMakeScripts/ConfigChecks.cmake +++ b/CMakeScripts/ConfigChecks.cmake @@ -19,7 +19,6 @@ CHECK_FUNCTION_EXISTS(fpsetmask HAVE_FPSETMASK) CHECK_INCLUDE_FILES(gc/gc.h HAVE_GC_GC_H) CHECK_INCLUDE_FILES(gc.h HAVE_GC_H) CHECK_INCLUDE_FILES(getopt.h HAVE_GETOPT_H) -CHECK_FUNCTION_EXISTS(gettext HAVE_GETTEXT) CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY) CHECK_FUNCTION_EXISTS(gtk_window_fullscreen HAVE_GTK_WINDOW_FULLSCREEN) CHECK_FUNCTION_EXISTS(gtk_window_set_default_icon_from_file HAVE_GTK_WINDOW_SET_DEFAULT_ICON_FROM_FILE) diff --git a/CMakeScripts/ConfigPaths.cmake b/CMakeScripts/ConfigPaths.cmake index 770e0c6ad..848e293f4 100644 --- a/CMakeScripts/ConfigPaths.cmake +++ b/CMakeScripts/ConfigPaths.cmake @@ -5,7 +5,9 @@ IF(WIN32) set(SHARE_INSTALL "share" CACHE STRING "Data file install path. Must be a relative path (from CMAKE_INSTALL_PREFIX), with no trailing slash.") ELSE(WIN32) # TODO: check and change this to correct value: - SET(PACKAGE_LOCALE_DIR "locale") + if(NOT PACKAGE_LOCALE_DIR) + SET(PACKAGE_LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale") # packagers might overwrite this + endif(NOT PACKAGE_LOCALE_DIR) if(NOT SHARE_INSTALL) set(SHARE_INSTALL "share" CACHE STRING "Data file install path. Must be a relative path (from CMAKE_INSTALL_PREFIX), with no trailing slash.") diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index a4dad21b1..8d6405265 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -355,6 +355,19 @@ if(WITH_IMAGE_MAGICK) endif() include(${CMAKE_CURRENT_LIST_DIR}/IncludeJava.cmake) + +set(ENABLE_NLS OFF) +if(WITH_NLS) + find_package(Gettext) + if(GETTEXT_FOUND) + message(STATUS "Found gettext + msgfmt to convert language files. Translation enabled") + set(ENABLE_NLS ON) + else(GETTEXT_FOUND) + message(STATUS "Cannot find gettext + msgfmt to convert language file. Translation won't be enabled") + endif(GETTEXT_FOUND) +endif(WITH_NLS) + + # end Dependencies list(REMOVE_DUPLICATES INKSCAPE_LIBS) diff --git a/CMakeScripts/FindGettext.cmake b/CMakeScripts/FindGettext.cmake new file mode 100644 index 000000000..753040b40 --- /dev/null +++ b/CMakeScripts/FindGettext.cmake @@ -0,0 +1,237 @@ +#.rst: +# FindGettext +# ----------- +# +# Find GNU gettext tools +# +# This module looks for the GNU gettext tools. This module defines the +# following values: +# +# :: +# +# GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool. +# GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool. +# GETTEXT_FOUND: True if gettext has been found. +# GETTEXT_VERSION_STRING: the version of gettext found (since CMake 2.8.8) +# +# +# +# Additionally it provides the following macros: +# GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN ) +# +# :: +# +# This will create a target "translations" which will convert the +# given input po files into the binary output mo file. If the +# ALL option is used, the translations will also be created when +# building the default target. +# +# GETTEXT_PROCESS_POT( [ALL] [INSTALL_DESTINATION ] +# LANGUAGES ... ) +# +# :: +# +# Process the given pot file to mo files. +# If INSTALL_DESTINATION is given then automatically install rules will be created, +# the language subdirectory will be taken into account (by default use share/locale/). +# If ALL is specified, the pot file is processed when building the all traget. +# It creates a custom target "potfile". +# +# GETTEXT_PROCESS_PO_FILES( [ALL] [INSTALL_DESTINATION ] +# PO_FILES ... ) +# +# :: +# +# Process the given po files to mo files for the given language. +# If INSTALL_DESTINATION is given then automatically install rules will be created, +# the language subdirectory will be taken into account (by default use share/locale/). +# If ALL is specified, the po files are processed when building the all traget. +# It creates a custom target "pofiles". + +#============================================================================= +# Copyright 2007-2009 Kitware, Inc. +# Copyright 2007 Alexander Neundorf +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) +#============================================================================= +# This file got changed for Inkscape's purposes to name the .mo files installed with +# GETTEXT_PROCESS_PO_FILES ${CMAKE_PROJECT_NAME}.mo instead of .mo + +find_program(GETTEXT_MSGMERGE_EXECUTABLE msgmerge) + +find_program(GETTEXT_MSGFMT_EXECUTABLE msgfmt) + +if(GETTEXT_MSGMERGE_EXECUTABLE) + execute_process(COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --version + OUTPUT_VARIABLE gettext_version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (gettext_version MATCHES "^msgmerge \\(.*\\) [0-9]") + string(REGEX REPLACE "^msgmerge \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*" "\\1" GETTEXT_VERSION_STRING "${gettext_version}") + endif() + unset(gettext_version) +endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext + REQUIRED_VARS GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE + VERSION_VAR GETTEXT_VERSION_STRING) + +include(CMakeParseArguments) + +function(_GETTEXT_GET_UNIQUE_TARGET_NAME _name _unique_name) + set(propertyName "_GETTEXT_UNIQUE_COUNTER_${_name}") + get_property(currentCounter GLOBAL PROPERTY "${propertyName}") + if(NOT currentCounter) + set(currentCounter 1) + endif() + set(${_unique_name} "${_name}_${currentCounter}" PARENT_SCOPE) + math(EXPR currentCounter "${currentCounter} + 1") + set_property(GLOBAL PROPERTY ${propertyName} ${currentCounter} ) +endfunction() + +macro(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg) + # make it a real variable, so we can modify it here + set(_firstPoFile "${_firstPoFileArg}") + + set(_gmoFiles) + get_filename_component(_potName ${_potFile} NAME) + string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName}) + get_filename_component(_absPotFile ${_potFile} ABSOLUTE) + + set(_addToAll) + if(${_firstPoFile} STREQUAL "ALL") + set(_addToAll "ALL") + set(_firstPoFile) + endif() + + foreach (_currentPoFile ${_firstPoFile} ${ARGN}) + get_filename_component(_absFile ${_currentPoFile} ABSOLUTE) + get_filename_component(_abs_PATH ${_absFile} PATH) + get_filename_component(_lang ${_absFile} NAME_WE) + set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo) + + add_custom_command( + OUTPUT ${_gmoFile} + COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile} + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile} + DEPENDS ${_absPotFile} ${_absFile} + ) + + install(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo) + set(_gmoFiles ${_gmoFiles} ${_gmoFile}) + + endforeach () + + if(NOT TARGET translations) + add_custom_target(translations) + endif() + + _GETTEXT_GET_UNIQUE_TARGET_NAME(translations uniqueTargetName) + + add_custom_target(${uniqueTargetName} ${_addToAll} DEPENDS ${_gmoFiles}) + + add_dependencies(translations ${uniqueTargetName}) + +endmacro() + + +function(GETTEXT_PROCESS_POT_FILE _potFile) + set(_gmoFiles) + set(_options ALL) + set(_oneValueArgs INSTALL_DESTINATION) + set(_multiValueArgs LANGUAGES) + + CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + + get_filename_component(_potName ${_potFile} NAME) + string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName}) + get_filename_component(_absPotFile ${_potFile} ABSOLUTE) + + foreach (_lang ${_parsedArguments_LANGUAGES}) + set(_poFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.po") + set(_gmoFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo") + + add_custom_command( + OUTPUT "${_poFile}" + COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_poFile} ${_absPotFile} + DEPENDS ${_absPotFile} + ) + + add_custom_command( + OUTPUT "${_gmoFile}" + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_poFile} + DEPENDS ${_absPotFile} ${_poFile} + ) + + if(_parsedArguments_INSTALL_DESTINATION) + install(FILES ${_gmoFile} DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo) + endif() + list(APPEND _gmoFiles ${_gmoFile}) + endforeach () + + if(NOT TARGET potfiles) + add_custom_target(potfiles) + endif() + + _GETTEXT_GET_UNIQUE_TARGET_NAME( potfiles uniqueTargetName) + + if(_parsedArguments_ALL) + add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles}) + else() + add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles}) + endif() + + add_dependencies(potfiles ${uniqueTargetName}) + +endfunction() + + +function(GETTEXT_PROCESS_PO_FILES _lang) + set(_options ALL) + set(_oneValueArgs INSTALL_DESTINATION) + set(_multiValueArgs PO_FILES) + set(_gmoFiles) + + CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + + foreach(_current_PO_FILE ${_parsedArguments_PO_FILES}) + get_filename_component(_name ${_current_PO_FILE} NAME) + string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name}) + set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo) + add_custom_command(OUTPUT ${_gmoFile} + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + DEPENDS ${_current_PO_FILE} + ) + + if(_parsedArguments_INSTALL_DESTINATION) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/ RENAME ${CMAKE_PROJECT_NAME}.mo) + endif() + list(APPEND _gmoFiles ${_gmoFile}) + endforeach() + + + if(NOT TARGET pofiles) + add_custom_target(pofiles) + endif() + + _GETTEXT_GET_UNIQUE_TARGET_NAME( pofiles uniqueTargetName) + + if(_parsedArguments_ALL) + add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles}) + else() + add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles}) + endif() + + add_dependencies(pofiles ${uniqueTargetName}) + +endfunction() -- cgit v1.2.3 From 5d1bc1e7ad9fdfac1d044616a5c5c072fb86a3ee Mon Sep 17 00:00:00 2001 From: houz Date: Wed, 2 Sep 2015 15:40:51 +0200 Subject: remove unneccessary include from r14304 (bzr r14340) --- CMakeScripts/FindGettext.cmake | 237 --------------------------------- CMakeScripts/Modules/FindGettext.cmake | 237 +++++++++++++++++++++++++++++++++ 2 files changed, 237 insertions(+), 237 deletions(-) delete mode 100644 CMakeScripts/FindGettext.cmake create mode 100644 CMakeScripts/Modules/FindGettext.cmake (limited to 'CMakeScripts') diff --git a/CMakeScripts/FindGettext.cmake b/CMakeScripts/FindGettext.cmake deleted file mode 100644 index 753040b40..000000000 --- a/CMakeScripts/FindGettext.cmake +++ /dev/null @@ -1,237 +0,0 @@ -#.rst: -# FindGettext -# ----------- -# -# Find GNU gettext tools -# -# This module looks for the GNU gettext tools. This module defines the -# following values: -# -# :: -# -# GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool. -# GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool. -# GETTEXT_FOUND: True if gettext has been found. -# GETTEXT_VERSION_STRING: the version of gettext found (since CMake 2.8.8) -# -# -# -# Additionally it provides the following macros: -# GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN ) -# -# :: -# -# This will create a target "translations" which will convert the -# given input po files into the binary output mo file. If the -# ALL option is used, the translations will also be created when -# building the default target. -# -# GETTEXT_PROCESS_POT( [ALL] [INSTALL_DESTINATION ] -# LANGUAGES ... ) -# -# :: -# -# Process the given pot file to mo files. -# If INSTALL_DESTINATION is given then automatically install rules will be created, -# the language subdirectory will be taken into account (by default use share/locale/). -# If ALL is specified, the pot file is processed when building the all traget. -# It creates a custom target "potfile". -# -# GETTEXT_PROCESS_PO_FILES( [ALL] [INSTALL_DESTINATION ] -# PO_FILES ... ) -# -# :: -# -# Process the given po files to mo files for the given language. -# If INSTALL_DESTINATION is given then automatically install rules will be created, -# the language subdirectory will be taken into account (by default use share/locale/). -# If ALL is specified, the po files are processed when building the all traget. -# It creates a custom target "pofiles". - -#============================================================================= -# Copyright 2007-2009 Kitware, Inc. -# Copyright 2007 Alexander Neundorf -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) -#============================================================================= -# This file got changed for Inkscape's purposes to name the .mo files installed with -# GETTEXT_PROCESS_PO_FILES ${CMAKE_PROJECT_NAME}.mo instead of .mo - -find_program(GETTEXT_MSGMERGE_EXECUTABLE msgmerge) - -find_program(GETTEXT_MSGFMT_EXECUTABLE msgfmt) - -if(GETTEXT_MSGMERGE_EXECUTABLE) - execute_process(COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --version - OUTPUT_VARIABLE gettext_version - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (gettext_version MATCHES "^msgmerge \\(.*\\) [0-9]") - string(REGEX REPLACE "^msgmerge \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*" "\\1" GETTEXT_VERSION_STRING "${gettext_version}") - endif() - unset(gettext_version) -endif() - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext - REQUIRED_VARS GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE - VERSION_VAR GETTEXT_VERSION_STRING) - -include(CMakeParseArguments) - -function(_GETTEXT_GET_UNIQUE_TARGET_NAME _name _unique_name) - set(propertyName "_GETTEXT_UNIQUE_COUNTER_${_name}") - get_property(currentCounter GLOBAL PROPERTY "${propertyName}") - if(NOT currentCounter) - set(currentCounter 1) - endif() - set(${_unique_name} "${_name}_${currentCounter}" PARENT_SCOPE) - math(EXPR currentCounter "${currentCounter} + 1") - set_property(GLOBAL PROPERTY ${propertyName} ${currentCounter} ) -endfunction() - -macro(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg) - # make it a real variable, so we can modify it here - set(_firstPoFile "${_firstPoFileArg}") - - set(_gmoFiles) - get_filename_component(_potName ${_potFile} NAME) - string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName}) - get_filename_component(_absPotFile ${_potFile} ABSOLUTE) - - set(_addToAll) - if(${_firstPoFile} STREQUAL "ALL") - set(_addToAll "ALL") - set(_firstPoFile) - endif() - - foreach (_currentPoFile ${_firstPoFile} ${ARGN}) - get_filename_component(_absFile ${_currentPoFile} ABSOLUTE) - get_filename_component(_abs_PATH ${_absFile} PATH) - get_filename_component(_lang ${_absFile} NAME_WE) - set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo) - - add_custom_command( - OUTPUT ${_gmoFile} - COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile} - COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile} - DEPENDS ${_absPotFile} ${_absFile} - ) - - install(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo) - set(_gmoFiles ${_gmoFiles} ${_gmoFile}) - - endforeach () - - if(NOT TARGET translations) - add_custom_target(translations) - endif() - - _GETTEXT_GET_UNIQUE_TARGET_NAME(translations uniqueTargetName) - - add_custom_target(${uniqueTargetName} ${_addToAll} DEPENDS ${_gmoFiles}) - - add_dependencies(translations ${uniqueTargetName}) - -endmacro() - - -function(GETTEXT_PROCESS_POT_FILE _potFile) - set(_gmoFiles) - set(_options ALL) - set(_oneValueArgs INSTALL_DESTINATION) - set(_multiValueArgs LANGUAGES) - - CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) - - get_filename_component(_potName ${_potFile} NAME) - string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName}) - get_filename_component(_absPotFile ${_potFile} ABSOLUTE) - - foreach (_lang ${_parsedArguments_LANGUAGES}) - set(_poFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.po") - set(_gmoFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo") - - add_custom_command( - OUTPUT "${_poFile}" - COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_poFile} ${_absPotFile} - DEPENDS ${_absPotFile} - ) - - add_custom_command( - OUTPUT "${_gmoFile}" - COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_poFile} - DEPENDS ${_absPotFile} ${_poFile} - ) - - if(_parsedArguments_INSTALL_DESTINATION) - install(FILES ${_gmoFile} DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo) - endif() - list(APPEND _gmoFiles ${_gmoFile}) - endforeach () - - if(NOT TARGET potfiles) - add_custom_target(potfiles) - endif() - - _GETTEXT_GET_UNIQUE_TARGET_NAME( potfiles uniqueTargetName) - - if(_parsedArguments_ALL) - add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles}) - else() - add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles}) - endif() - - add_dependencies(potfiles ${uniqueTargetName}) - -endfunction() - - -function(GETTEXT_PROCESS_PO_FILES _lang) - set(_options ALL) - set(_oneValueArgs INSTALL_DESTINATION) - set(_multiValueArgs PO_FILES) - set(_gmoFiles) - - CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) - - foreach(_current_PO_FILE ${_parsedArguments_PO_FILES}) - get_filename_component(_name ${_current_PO_FILE} NAME) - string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name}) - set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo) - add_custom_command(OUTPUT ${_gmoFile} - COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE} - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - DEPENDS ${_current_PO_FILE} - ) - - if(_parsedArguments_INSTALL_DESTINATION) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/ RENAME ${CMAKE_PROJECT_NAME}.mo) - endif() - list(APPEND _gmoFiles ${_gmoFile}) - endforeach() - - - if(NOT TARGET pofiles) - add_custom_target(pofiles) - endif() - - _GETTEXT_GET_UNIQUE_TARGET_NAME( pofiles uniqueTargetName) - - if(_parsedArguments_ALL) - add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles}) - else() - add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles}) - endif() - - add_dependencies(pofiles ${uniqueTargetName}) - -endfunction() diff --git a/CMakeScripts/Modules/FindGettext.cmake b/CMakeScripts/Modules/FindGettext.cmake new file mode 100644 index 000000000..753040b40 --- /dev/null +++ b/CMakeScripts/Modules/FindGettext.cmake @@ -0,0 +1,237 @@ +#.rst: +# FindGettext +# ----------- +# +# Find GNU gettext tools +# +# This module looks for the GNU gettext tools. This module defines the +# following values: +# +# :: +# +# GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool. +# GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool. +# GETTEXT_FOUND: True if gettext has been found. +# GETTEXT_VERSION_STRING: the version of gettext found (since CMake 2.8.8) +# +# +# +# Additionally it provides the following macros: +# GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN ) +# +# :: +# +# This will create a target "translations" which will convert the +# given input po files into the binary output mo file. If the +# ALL option is used, the translations will also be created when +# building the default target. +# +# GETTEXT_PROCESS_POT( [ALL] [INSTALL_DESTINATION ] +# LANGUAGES ... ) +# +# :: +# +# Process the given pot file to mo files. +# If INSTALL_DESTINATION is given then automatically install rules will be created, +# the language subdirectory will be taken into account (by default use share/locale/). +# If ALL is specified, the pot file is processed when building the all traget. +# It creates a custom target "potfile". +# +# GETTEXT_PROCESS_PO_FILES( [ALL] [INSTALL_DESTINATION ] +# PO_FILES ... ) +# +# :: +# +# Process the given po files to mo files for the given language. +# If INSTALL_DESTINATION is given then automatically install rules will be created, +# the language subdirectory will be taken into account (by default use share/locale/). +# If ALL is specified, the po files are processed when building the all traget. +# It creates a custom target "pofiles". + +#============================================================================= +# Copyright 2007-2009 Kitware, Inc. +# Copyright 2007 Alexander Neundorf +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) +#============================================================================= +# This file got changed for Inkscape's purposes to name the .mo files installed with +# GETTEXT_PROCESS_PO_FILES ${CMAKE_PROJECT_NAME}.mo instead of .mo + +find_program(GETTEXT_MSGMERGE_EXECUTABLE msgmerge) + +find_program(GETTEXT_MSGFMT_EXECUTABLE msgfmt) + +if(GETTEXT_MSGMERGE_EXECUTABLE) + execute_process(COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --version + OUTPUT_VARIABLE gettext_version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (gettext_version MATCHES "^msgmerge \\(.*\\) [0-9]") + string(REGEX REPLACE "^msgmerge \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*" "\\1" GETTEXT_VERSION_STRING "${gettext_version}") + endif() + unset(gettext_version) +endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext + REQUIRED_VARS GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE + VERSION_VAR GETTEXT_VERSION_STRING) + +include(CMakeParseArguments) + +function(_GETTEXT_GET_UNIQUE_TARGET_NAME _name _unique_name) + set(propertyName "_GETTEXT_UNIQUE_COUNTER_${_name}") + get_property(currentCounter GLOBAL PROPERTY "${propertyName}") + if(NOT currentCounter) + set(currentCounter 1) + endif() + set(${_unique_name} "${_name}_${currentCounter}" PARENT_SCOPE) + math(EXPR currentCounter "${currentCounter} + 1") + set_property(GLOBAL PROPERTY ${propertyName} ${currentCounter} ) +endfunction() + +macro(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg) + # make it a real variable, so we can modify it here + set(_firstPoFile "${_firstPoFileArg}") + + set(_gmoFiles) + get_filename_component(_potName ${_potFile} NAME) + string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName}) + get_filename_component(_absPotFile ${_potFile} ABSOLUTE) + + set(_addToAll) + if(${_firstPoFile} STREQUAL "ALL") + set(_addToAll "ALL") + set(_firstPoFile) + endif() + + foreach (_currentPoFile ${_firstPoFile} ${ARGN}) + get_filename_component(_absFile ${_currentPoFile} ABSOLUTE) + get_filename_component(_abs_PATH ${_absFile} PATH) + get_filename_component(_lang ${_absFile} NAME_WE) + set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo) + + add_custom_command( + OUTPUT ${_gmoFile} + COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile} + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile} + DEPENDS ${_absPotFile} ${_absFile} + ) + + install(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo) + set(_gmoFiles ${_gmoFiles} ${_gmoFile}) + + endforeach () + + if(NOT TARGET translations) + add_custom_target(translations) + endif() + + _GETTEXT_GET_UNIQUE_TARGET_NAME(translations uniqueTargetName) + + add_custom_target(${uniqueTargetName} ${_addToAll} DEPENDS ${_gmoFiles}) + + add_dependencies(translations ${uniqueTargetName}) + +endmacro() + + +function(GETTEXT_PROCESS_POT_FILE _potFile) + set(_gmoFiles) + set(_options ALL) + set(_oneValueArgs INSTALL_DESTINATION) + set(_multiValueArgs LANGUAGES) + + CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + + get_filename_component(_potName ${_potFile} NAME) + string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName}) + get_filename_component(_absPotFile ${_potFile} ABSOLUTE) + + foreach (_lang ${_parsedArguments_LANGUAGES}) + set(_poFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.po") + set(_gmoFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo") + + add_custom_command( + OUTPUT "${_poFile}" + COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_poFile} ${_absPotFile} + DEPENDS ${_absPotFile} + ) + + add_custom_command( + OUTPUT "${_gmoFile}" + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_poFile} + DEPENDS ${_absPotFile} ${_poFile} + ) + + if(_parsedArguments_INSTALL_DESTINATION) + install(FILES ${_gmoFile} DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo) + endif() + list(APPEND _gmoFiles ${_gmoFile}) + endforeach () + + if(NOT TARGET potfiles) + add_custom_target(potfiles) + endif() + + _GETTEXT_GET_UNIQUE_TARGET_NAME( potfiles uniqueTargetName) + + if(_parsedArguments_ALL) + add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles}) + else() + add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles}) + endif() + + add_dependencies(potfiles ${uniqueTargetName}) + +endfunction() + + +function(GETTEXT_PROCESS_PO_FILES _lang) + set(_options ALL) + set(_oneValueArgs INSTALL_DESTINATION) + set(_multiValueArgs PO_FILES) + set(_gmoFiles) + + CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + + foreach(_current_PO_FILE ${_parsedArguments_PO_FILES}) + get_filename_component(_name ${_current_PO_FILE} NAME) + string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name}) + set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo) + add_custom_command(OUTPUT ${_gmoFile} + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + DEPENDS ${_current_PO_FILE} + ) + + if(_parsedArguments_INSTALL_DESTINATION) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/ RENAME ${CMAKE_PROJECT_NAME}.mo) + endif() + list(APPEND _gmoFiles ${_gmoFile}) + endforeach() + + + if(NOT TARGET pofiles) + add_custom_target(pofiles) + endif() + + _GETTEXT_GET_UNIQUE_TARGET_NAME( pofiles uniqueTargetName) + + if(_parsedArguments_ALL) + add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles}) + else() + add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles}) + endif() + + add_dependencies(pofiles ${uniqueTargetName}) + +endfunction() -- cgit v1.2.3 From 6e64fe28600be374c09f456d6b0076a5fc02f02c Mon Sep 17 00:00:00 2001 From: su_v Date: Wed, 2 Sep 2015 19:25:24 +0200 Subject: cmake: make JPEG optional; fix using it (if found) (bzr r14341) --- CMakeScripts/DefineDependsandFlags.cmake | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'CMakeScripts') diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index 8d6405265..e6089daa4 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -181,13 +181,12 @@ if(WITH_LIBCDR) endif() endif() -FIND_PACKAGE(JPEG REQUIRED) -#IF(JPEG_FOUND) - #INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR}) - #TARGET_LINK_LIBRARIES(mpo ${JPEG_LIBRARIES}) -#ENDIF() -list(APPEND INKSCAPE_INCS_SYS ${JPEG_INCLUDE_DIR}) -list(APPEND INKSCAPE_LIBS ${JPEG_LIBRARIES}) +FIND_PACKAGE(JPEG) +IF(JPEG_FOUND) + list(APPEND INKSCAPE_INCS_SYS ${JPEG_INCLUDE_DIR}) + list(APPEND INKSCAPE_LIBS ${JPEG_LIBRARIES}) + set(HAVE_JPEG ON) +ENDIF() find_package(PNG REQUIRED) list(APPEND INKSCAPE_INCS_SYS ${PNG_PNG_INCLUDE_DIR}) -- cgit v1.2.3 From 0d4e511c524d9102d90adbf2defea4f644eb3edd Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Mon, 26 Oct 2015 23:50:52 +0100 Subject: add gtk3 experimental support in CMake Fixed bugs: - https://launchpad.net/bugs/1509969 (bzr r14430) --- CMakeScripts/DefineDependsandFlags.cmake | 148 +++++++++++++++++++++---------- 1 file changed, 100 insertions(+), 48 deletions(-) (limited to 'CMakeScripts') diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index e6089daa4..63e4315b8 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -220,55 +220,107 @@ endif() # CMake's builtin # ---------------------------------------------------------------------------- +SET (TRY_GTKSPELL 1) # Include dependencies: # use patched version until GTK2_CAIROMMCONFIG_INCLUDE_DIR is added -find_package(GTK2 COMPONENTS gtk gtkmm REQUIRED) -list(APPEND INKSCAPE_INCS_SYS - ${GTK2_GDK_INCLUDE_DIR} - ${GTK2_GDKMM_INCLUDE_DIR} - ${GTK2_GDK_PIXBUF_INCLUDE_DIR} - ${GTK2_GDKCONFIG_INCLUDE_DIR} - ${GTK2_GDKMMCONFIG_INCLUDE_DIR} - ${GTK2_GLIB_INCLUDE_DIR} - ${GTK2_GLIBCONFIG_INCLUDE_DIR} - ${GTK2_GLIBMM_INCLUDE_DIR} - ${GTK2_GLIBMMCONFIG_INCLUDE_DIR} - ${GTK2_GTK_INCLUDE_DIR} - ${GTK2_GTKMM_INCLUDE_DIR} - ${GTK2_GTKMMCONFIG_INCLUDE_DIR} - ${GTK2_ATK_INCLUDE_DIR} - ${GTK2_ATKMM_INCLUDE_DIR} - ${GTK2_PANGO_INCLUDE_DIR} - ${GTK2_PANGOMM_INCLUDE_DIR} - ${GTK2_PANGOMMCONFIG_INCLUDE_DIR} - ${GTK2_CAIRO_INCLUDE_DIR} - ${GTK2_CAIROMM_INCLUDE_DIR} - ${GTK2_CAIROMMCONFIG_INCLUDE_DIR} # <-- not in cmake 2.8.4 - ${GTK2_GIOMM_INCLUDE_DIR} - ${GTK2_GIOMMCONFIG_INCLUDE_DIR} - ${GTK2_SIGC++_INCLUDE_DIR} - ${GTK2_SIGC++CONFIG_INCLUDE_DIR} -) - -list(APPEND INKSCAPE_LIBS - ${GTK2_GDK_LIBRARY} - ${GTK2_GDKMM_LIBRARY} - ${GTK2_GDK_PIXBUF_LIBRARY} - ${GTK2_GLIB_LIBRARY} - ${GTK2_GLIBMM_LIBRARY} - ${GTK2_GTK_LIBRARY} - ${GTK2_GTKMM_LIBRARY} - ${GTK2_ATK_LIBRARY} - ${GTK2_ATKMM_LIBRARY} - ${GTK2_PANGO_LIBRARY} - ${GTK2_PANGOMM_LIBRARY} - ${GTK2_CAIRO_LIBRARY} - ${GTK2_CAIROMM_LIBRARY} - ${GTK2_GIOMM_LIBRARY} - ${GTK2_SIGC++_LIBRARY} - ${GTK2_GOBJECT_LIBRARY} -) - +IF ("${WITH_GTK3_EXPERIMENTAL}") + pkg_check_modules( + GTK + REQUIRED + gtkmm-3.0>=3.2 + gdkmm-3.0>=3.2 + gtk+-3.0>=3.2 + gdk-3.0>=3.2 + gdl-3.0>=3.3.5 + ) + message("Using EXPERIMENTAL Gtkmm 3 build") + SET (WITH_GTKMM_3_0 1) + message("Using external GDL") + SET(WITH_EXT_GDL 1) + + # Check whether we can use new features in Gtkmm 3.10 + # TODO: Drop this test and bump the version number in the GTK test above + # as soon as all supported distributions provide Gtkmm >= 3.10 + pkg_check_modules(GTKMM_3_10 + gtkmm-3.0>=3.10, + ) + + IF ("${GTKMM_3_10_FOUND}") + message("Using Gtkmm 3.10 build") + SET (WITH_GTKMM_3_10 1) + ENDIF() + + pkg_check_modules(GDL_3_6 gdl-3.0>=3.6) + + IF ("${GDL_3_6_FOUND}") + message("Using Gdl 3.6 or higher") + SET (WITH_GDL_3_6 1) + ENDIF() + + SET (TRY_GTKSPELL ) + pkg_check_modules(GTKSPELL3 gtkspell3-3.0) + + IF ("${GTKSPELL3_FOUND}") + message("Using GtkSpell3 3.0") + SET (WITH_GTKSPELL 1) + ENDIF() + list(APPEND INKSCAPE_INCS_SYS + ${GTK_INCLUDE_DIRS} + ${GTKSPELL3_INCLUDE_DIRS} + ) + + list(APPEND INKSCAPE_LIBS + ${GTK_LIBRARIES} + ${GTKSPELL3_LIBRARIES} + ) +ELSE() + find_package(GTK2 COMPONENTS gtk gtkmm REQUIRED) + list(APPEND INKSCAPE_INCS_SYS + ${GTK2_GDK_INCLUDE_DIR} + ${GTK2_GDKMM_INCLUDE_DIR} + ${GTK2_GDK_PIXBUF_INCLUDE_DIR} + ${GTK2_GDKCONFIG_INCLUDE_DIR} + ${GTK2_GDKMMCONFIG_INCLUDE_DIR} + ${GTK2_GLIB_INCLUDE_DIR} + ${GTK2_GLIBCONFIG_INCLUDE_DIR} + ${GTK2_GLIBMM_INCLUDE_DIR} + ${GTK2_GLIBMMCONFIG_INCLUDE_DIR} + ${GTK2_GTK_INCLUDE_DIR} + ${GTK2_GTKMM_INCLUDE_DIR} + ${GTK2_GTKMMCONFIG_INCLUDE_DIR} + ${GTK2_ATK_INCLUDE_DIR} + ${GTK2_ATKMM_INCLUDE_DIR} + ${GTK2_PANGO_INCLUDE_DIR} + ${GTK2_PANGOMM_INCLUDE_DIR} + ${GTK2_PANGOMMCONFIG_INCLUDE_DIR} + ${GTK2_CAIRO_INCLUDE_DIR} + ${GTK2_CAIROMM_INCLUDE_DIR} + ${GTK2_CAIROMMCONFIG_INCLUDE_DIR} # <-- not in cmake 2.8.4 + ${GTK2_GIOMM_INCLUDE_DIR} + ${GTK2_GIOMMCONFIG_INCLUDE_DIR} + ${GTK2_SIGC++_INCLUDE_DIR} + ${GTK2_SIGC++CONFIG_INCLUDE_DIR} + ) + + list(APPEND INKSCAPE_LIBS + ${GTK2_GDK_LIBRARY} + ${GTK2_GDKMM_LIBRARY} + ${GTK2_GDK_PIXBUF_LIBRARY} + ${GTK2_GLIB_LIBRARY} + ${GTK2_GLIBMM_LIBRARY} + ${GTK2_GTK_LIBRARY} + ${GTK2_GTKMM_LIBRARY} + ${GTK2_ATK_LIBRARY} + ${GTK2_ATKMM_LIBRARY} + ${GTK2_PANGO_LIBRARY} + ${GTK2_PANGOMM_LIBRARY} + ${GTK2_CAIRO_LIBRARY} + ${GTK2_CAIROMM_LIBRARY} + ${GTK2_GIOMM_LIBRARY} + ${GTK2_SIGC++_LIBRARY} + ${GTK2_GOBJECT_LIBRARY} + ) +ENDIF() find_package(Freetype REQUIRED) list(APPEND INKSCAPE_INCS_SYS ${FREETYPE_INCLUDE_DIRS}) @@ -286,7 +338,7 @@ if(ASPELL_FOUND) set(HAVE_ASPELL TRUE) endif() -if(WITH_GTKSPELL) +if("${TRY_GTKSPELL}" AND "${WITH_GTKSPELL}") find_package(GtkSpell) if(GTKSPELL_FOUND) list(APPEND INKSCAPE_INCS_SYS ${GTKSPELL_INCLUDE_DIR}) -- cgit v1.2.3 From 6484d2580d5facccf1b4bd7719c5d26fb8d07602 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 9 Nov 2015 00:03:27 +0000 Subject: Add CMake check for Potrace from OSP: http://goo.gl/AEzbkQ Fixed bugs: - https://launchpad.net/bugs/1156664 (bzr r14449.1.3) --- CMakeScripts/DefineDependsandFlags.cmake | 4 ++++ CMakeScripts/Modules/FindPotrace.cmake | 36 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 CMakeScripts/Modules/FindPotrace.cmake (limited to 'CMakeScripts') diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index 63e4315b8..e0857f265 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -197,6 +197,10 @@ list(APPEND INKSCAPE_INCS_SYS ${POPT_INCLUDE_DIR}) list(APPEND INKSCAPE_LIBS ${POPT_LIBRARIES}) add_definitions(${POPT_DEFINITIONS}) +find_package(Potrace REQUIRED) +list(APPEND INKSCAPE_INCS_SYS ${POTRACE_INCLUDE_DIR}) +list(APPEND INKSCAPE_LIBS ${POTRACE_LIBRARIES}) + if(WITH_DBUS) find_package(DBus REQUIRED) if(DBUS_FOUND) diff --git a/CMakeScripts/Modules/FindPotrace.cmake b/CMakeScripts/Modules/FindPotrace.cmake new file mode 100644 index 000000000..a542394fe --- /dev/null +++ b/CMakeScripts/Modules/FindPotrace.cmake @@ -0,0 +1,36 @@ +# POTRACE_FOUND - system has Potrace +# POTRACE_INCLUDE_DIR - the Potrace include directory +# POTRACE_LIBRARIES - The libraries needed to use Potrace + +FIND_PATH(POTRACE_INCLUDE_DIR potracelib.h + /usr/include + /usr/local/include +) + +FIND_LIBRARY(POTRACE_LIBRARY NAMES potrace libpotrace + PATHS + /usr/lib + /usr/local/lib +) + +if (POTRACE_INCLUDE_DIR AND POTRACE_LIBRARY) + set(POTRACE_FOUND TRUE) + set(POTRACE_LIBRARIES ${POTRACE_LIBRARY}) +else (POTRACE_INCLUDE_DIR AND POTRACE_LIBRARY) + set(POTRACE_FOUND FALSE) +endif (POTRACE_INCLUDE_DIR AND POTRACE_LIBRARY) + +if (POTRACE_FOUND) + if (NOT Potrace_FIND_QUIETLY) + message(STATUS "Found potrace: ${POTRACE_LIBRARIES}") + endif (NOT Potrace_FIND_QUIETLY) +else (POTRACE_FOUND) + if (NOT Potrace_FIND_QUIETLY) + + message(STATUS "don't find potrace") + + endif (NOT Potrace_FIND_QUIETLY) +endif (POTRACE_FOUND) + +MARK_AS_ADVANCED(POTRACE_INCLUDE_DIR POTRACE_LIBRARIES POTRACE_LIBRARY) + -- cgit v1.2.3 From ac1a99494b6afaf5673f260f0e75559eff3b5ff5 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 12 Nov 2015 22:35:18 +0000 Subject: Update cmake Potrace module to match style of others (bzr r14449.1.5) --- CMakeScripts/DefineDependsandFlags.cmake | 2 +- CMakeScripts/Modules/FindPotrace.cmake | 92 ++++++++++++++++++++------------ 2 files changed, 60 insertions(+), 34 deletions(-) (limited to 'CMakeScripts') diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index e0857f265..ea0867535 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -198,7 +198,7 @@ list(APPEND INKSCAPE_LIBS ${POPT_LIBRARIES}) add_definitions(${POPT_DEFINITIONS}) find_package(Potrace REQUIRED) -list(APPEND INKSCAPE_INCS_SYS ${POTRACE_INCLUDE_DIR}) +list(APPEND INKSCAPE_INCS_SYS ${POTRACE_INCLUDE_DIRS}) list(APPEND INKSCAPE_LIBS ${POTRACE_LIBRARIES}) if(WITH_DBUS) diff --git a/CMakeScripts/Modules/FindPotrace.cmake b/CMakeScripts/Modules/FindPotrace.cmake index a542394fe..9ab995278 100644 --- a/CMakeScripts/Modules/FindPotrace.cmake +++ b/CMakeScripts/Modules/FindPotrace.cmake @@ -1,36 +1,62 @@ # POTRACE_FOUND - system has Potrace -# POTRACE_INCLUDE_DIR - the Potrace include directory +# POTRACE_INCLUDE_DIRS - the Potrace include directory # POTRACE_LIBRARIES - The libraries needed to use Potrace -FIND_PATH(POTRACE_INCLUDE_DIR potracelib.h - /usr/include - /usr/local/include -) - -FIND_LIBRARY(POTRACE_LIBRARY NAMES potrace libpotrace - PATHS - /usr/lib - /usr/local/lib -) - -if (POTRACE_INCLUDE_DIR AND POTRACE_LIBRARY) - set(POTRACE_FOUND TRUE) - set(POTRACE_LIBRARIES ${POTRACE_LIBRARY}) -else (POTRACE_INCLUDE_DIR AND POTRACE_LIBRARY) - set(POTRACE_FOUND FALSE) -endif (POTRACE_INCLUDE_DIR AND POTRACE_LIBRARY) - -if (POTRACE_FOUND) - if (NOT Potrace_FIND_QUIETLY) - message(STATUS "Found potrace: ${POTRACE_LIBRARIES}") - endif (NOT Potrace_FIND_QUIETLY) -else (POTRACE_FOUND) - if (NOT Potrace_FIND_QUIETLY) - - message(STATUS "don't find potrace") - - endif (NOT Potrace_FIND_QUIETLY) -endif (POTRACE_FOUND) - -MARK_AS_ADVANCED(POTRACE_INCLUDE_DIR POTRACE_LIBRARIES POTRACE_LIBRARY) - +IF (POTRACE_LIBRARIES AND POTRACE_INCLUDE_DIRS) + # in cache already + SET(POTRACE_FOUND TRUE) +ELSE (POTRACE_LIBRARIES AND POTRACE_INCLUDE_DIRS) + FIND_PATH (POTRACE_INCLUDE_DIR + NAMES + potracelib.h + PATHS + /usr/include + /usr/local/include + $ENV{DEVLIBS_PATH}/include + PATH_SUFFIXES + potrace + ) + + FIND_LIBRARY (POTRACE_LIBRARY + NAMES + potrace + libpotrace + PATHS + /usr/lib + /usr/local/lib + $ENV{DEVLIBS_PATH}/lib + ) + + if (POTRACE_LIBRARY) + set (POTRACE_FOUND TRUE) + endif (POTRACE_LIBRARY) + + set (POTRACE_INCLUDE_DIRS + ${POTRACE_INCLUDE_DIR} + ) + + if (POTRACE_FOUND) + set(POTRACE_LIBRARIES + ${POTRACE_LIBRARIES} + ${POTRACE_LIBRARY} + ) + endif (POTRACE_FOUND) + + if (POTRACE_INCLUDE_DIRS AND POTRACE_LIBRARIES) + set(POTRACE_FOUND TRUE) + endif (POTRACE_INCLUDE_DIRS AND POTRACE_LIBRARIES) + + if (POTRACE_FOUND) + if (NOT Potrace_FIND_QUIETLY) + message(STATUS "Found Potrace: ${POTRACE_LIBRARIES}") + endif (NOT Potrace_FIND_QUIETLY) + else (POTRACE_FOUND) + if (Potrace_FIND_REQUIRED) + message(FATAL_ERROR "Could not find potrace") + endif (Potrace_FIND_REQUIRED) + endif (POTRACE_FOUND) + + # show the POTRACE_INCLUDE_DIRS and POTRACE_LIBRARIES variables only in the advanced view + MARK_AS_ADVANCED(POTRACE_INCLUDE_DIRS POTRACE_LIBRARIES) + +endif (POTRACE_LIBRARIES AND POTRACE_INCLUDE_DIRS) -- cgit v1.2.3 From ec3c0a24bb14d96bfcef72cdd72326fce2790eff Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 12 Nov 2015 23:44:26 +0000 Subject: Fix CMake build (bzr r14449.1.6) --- CMakeScripts/DefineDependsandFlags.cmake | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'CMakeScripts') diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index ea0867535..3f1d06e4c 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -197,9 +197,13 @@ list(APPEND INKSCAPE_INCS_SYS ${POPT_INCLUDE_DIR}) list(APPEND INKSCAPE_LIBS ${POPT_LIBRARIES}) add_definitions(${POPT_DEFINITIONS}) -find_package(Potrace REQUIRED) -list(APPEND INKSCAPE_INCS_SYS ${POTRACE_INCLUDE_DIRS}) -list(APPEND INKSCAPE_LIBS ${POTRACE_LIBRARIES}) +find_package(Potrace) +if(POTRACE_FOUND) + list(APPEND INKSCAPE_INCS_SYS ${POTRACE_INCLUDE_DIRS}) + list(APPEND INKSCAPE_LIBS ${POTRACE_LIBRARIES}) + set(HAVE_POTRACE ON) + add_definitions(-DHAVE_POTRACE) +endif() if(WITH_DBUS) find_package(DBus REQUIRED) -- cgit v1.2.3 From d4f332ed03e831ee781c1ba169bd7a35b2869989 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 21 Nov 2015 12:39:06 +0000 Subject: Add warning about missing Potrace to CMake build (bzr r14449.1.8) --- CMakeScripts/DefineDependsandFlags.cmake | 3 +++ 1 file changed, 3 insertions(+) (limited to 'CMakeScripts') diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index 3f1d06e4c..f4992de5d 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -203,6 +203,9 @@ if(POTRACE_FOUND) list(APPEND INKSCAPE_LIBS ${POTRACE_LIBRARIES}) set(HAVE_POTRACE ON) add_definitions(-DHAVE_POTRACE) +else(POTRACE_FOUND) + set(HAVE_POTRACE OFF) + message(STATUS "Could not locate the Potrace library headers: the Trace Bitmap and Paintbucket tools will be disabled") endif() if(WITH_DBUS) -- cgit v1.2.3