Bump the CMake version requirement, fix Windows

- Add a missing runtime library for gettext-tools.
 - Remove the no longer necessary customized FindGettext.cmake,
   since the downloaded gettext binaries are new enough.
 - Make the installer at least ask to uninstall previous versions.
 - Adjust the PATH of tests so that they'll run on Windows directly.
 - Fix quoting so that the project will build inside paths with spaces.
 - Resolve a GSettings deprecation warning.
 - Update the README's build instructions as appropriate.
 - Require CMake 3.9 because of the README's suggestion to fix
   FindPkgConfig.cmake manually using separate_arguments(UNIX_COMMAND).

Tested build configurations:
 - native Arch Linux,
 - native Windows XP with the newest NSIS,
 - Arch Linux Mingw-w64 i686 Win32Depends.cmake NSIS cross-build + XP,
 - Arch Linux Mingw-w64 x86_64 MSYS2 NSIS cross-build + Windows 10.

Detected issues:
 - The file save dialog will not add the extension automatically,
   seen with MSYS2.
This commit is contained in:
Přemysl Eric Janouch 2021-10-22 15:04:24 +02:00
parent 42b6da1ffe
commit 47fb9653b8
Signed by: p
GPG Key ID: A0420B94F92B9493
6 changed files with 36 additions and 137 deletions

View File

@ -1,9 +1,6 @@
project (logdiag C)
# The last version with Windows XP support is 3.13, we want to keep that # The last version with Windows XP support is 3.13, we want to keep that
cmake_minimum_required (VERSION 2.8.12) cmake_minimum_required (VERSION 3.9)
project (logdiag VERSION 0.2.0 LANGUAGES C)
# Default to 2.8.12 behaviour
cmake_policy (VERSION 2.8.12)
# Options # Options
option (OPTION_USE_VERA "Use vera++ for source code style checks" OFF) option (OPTION_USE_VERA "Use vera++ for source code style checks" OFF)
@ -11,14 +8,6 @@ option (OPTION_NOINSTALL "Only for developers; work without installing" OFF)
option (BUILD_TESTING "Build tests" OFF) option (BUILD_TESTING "Build tests" OFF)
# Project information # Project information
set (project_VERSION_MAJOR "0")
set (project_VERSION_MINOR "2")
set (project_VERSION_PATCH "0")
set (project_VERSION "${project_VERSION_MAJOR}")
set (project_VERSION "${project_VERSION}.${project_VERSION_MINOR}")
set (project_VERSION "${project_VERSION}.${project_VERSION_PATCH}")
set (project_URL "https://git.janouch.name/p/logdiag") set (project_URL "https://git.janouch.name/p/logdiag")
# For custom modules # For custom modules
@ -91,7 +80,6 @@ else (NOT WIN32)
# For whatever reason this now seems to be required # For whatever reason this now seems to be required
set (LUA_INCLUDE_DIR "${WIN32_DEPENDS_PATH}/include") set (LUA_INCLUDE_DIR "${WIN32_DEPENDS_PATH}/include")
# XXX: this seems to require CMake 3.0 ... include it in the project?
find_package (Lua REQUIRED) find_package (Lua REQUIRED)
if (LUA_VERSION_STRING VERSION_LESS "5.2") if (LUA_VERSION_STRING VERSION_LESS "5.2")
message (FATAL_ERROR "Lua 5.2 not found") message (FATAL_ERROR "Lua 5.2 not found")
@ -115,7 +103,7 @@ foreach (file ${project_PO_FILES})
list (APPEND project_TRANSLATIONS "${translation}") list (APPEND project_TRANSLATIONS "${translation}")
endforeach (file) endforeach (file)
# Documentation # Documentation--gtk-doc 1.25 is required
find_package (GtkDoc 1.25) find_package (GtkDoc 1.25)
set (project_DOC_DIR "${PROJECT_BINARY_DIR}/liblogdiag") set (project_DOC_DIR "${PROJECT_BINARY_DIR}/liblogdiag")
@ -251,9 +239,13 @@ if (BUILD_TESTING)
foreach (name ${logdiag_TESTS}) foreach (name ${logdiag_TESTS})
add_executable (test-${name} tests/${name}.c) add_executable (test-${name} tests/${name}.c)
target_link_libraries (test-${name} liblogdiag ${logdiag_LIBS}) target_link_libraries (test-${name} liblogdiag ${logdiag_LIBS})
add_test (NAME test-${name} COMMAND test-${name})
add_test (test-${name} test-${name}) list (APPEND logdiag_TEST_TARGETS test-${name})
endforeach (name) endforeach (name)
if (WIN32 AND NOT CMAKE_CROSSCOMPILING)
set_tests_properties (${logdiag_TEST_TARGETS}
PROPERTIES ENVIRONMENT "PATH=${WIN32_DEPENDS_PATH}/bin")
endif ()
endif (BUILD_TESTING) endif (BUILD_TESTING)
# Generate documentation # Generate documentation
@ -385,25 +377,20 @@ else (WIN32)
install (FILES LICENSE NEWS DESTINATION share/doc/${PROJECT_NAME}) install (FILES LICENSE NEWS DESTINATION share/doc/${PROJECT_NAME})
endif (WIN32) endif (WIN32)
install (FILES ${GSETTINGS_SCHEMAS} install (DIRECTORY share/gui share/library DESTINATION share/${PROJECT_NAME})
DESTINATION share/glib-2.0/schemas) install (FILES ${GSETTINGS_SCHEMAS} DESTINATION share/glib-2.0/schemas)
install (CODE " # DESTDIR is not in use on Windows install (CODE " # DESTDIR is not in use on Windows
if (WIN32 OR \"\$ENV{DESTDIR}\" STREQUAL \"\") if (WIN32 OR \"\$ENV{DESTDIR}\" STREQUAL \"\")
execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS_EXECUTABLE} execute_process (COMMAND \"${GLIB_COMPILE_SCHEMAS_EXECUTABLE}\"
\"\${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas\") \"\${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas\")
endif (WIN32 OR \"\$ENV{DESTDIR}\" STREQUAL \"\")") endif (WIN32 OR \"\$ENV{DESTDIR}\" STREQUAL \"\")")
install (DIRECTORY share/gui share/library
DESTINATION share/${PROJECT_NAME})
# CPack # CPack
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Schematic editor") set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Schematic editor")
set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch") set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch")
set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>") set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>")
set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set (CPACK_PACKAGE_VERSION_MAJOR ${project_VERSION_MAJOR}) set (CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set (CPACK_PACKAGE_VERSION_MINOR ${project_VERSION_MINOR})
set (CPACK_PACKAGE_VERSION_PATCH ${project_VERSION_PATCH})
if (WIN32) if (WIN32)
set (CPACK_GENERATOR "NSIS;ZIP") set (CPACK_GENERATOR "NSIS;ZIP")
@ -413,11 +400,13 @@ else (WIN32)
endif (WIN32) endif (WIN32)
set (CPACK_PACKAGE_FILE_NAME set (CPACK_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${project_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") "${PROJECT_NAME}-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
set (CPACK_PACKAGE_INSTALL_DIRECTORY set (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME} ${CPACK_PACKAGE_VERSION}")
"${PROJECT_NAME} ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
# XXX: It is still possible to install multiple copies, making commands collide.
set (CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set (CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${PROJECT_NAME}")
# FIXME: It is possible to install multiple copies. Everything screws up then.
set (CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/share\\\\header.bmp") set (CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/share\\\\header.bmp")
set (CPACK_NSIS_INSTALLED_ICON_NAME "logdiag.exe") set (CPACK_NSIS_INSTALLED_ICON_NAME "logdiag.exe")
set (CPACK_NSIS_CREATE_ICONS_EXTRA " set (CPACK_NSIS_CREATE_ICONS_EXTRA "
@ -451,7 +440,7 @@ set (CPACK_RPM_PACKAGE_URL "${project_URL}")
set (CPACK_SOURCE_GENERATOR "TGZ;ZIP") set (CPACK_SOURCE_GENERATOR "TGZ;ZIP")
set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user;/win32-depends;/liblogdiag/ld-marshal.[ch]") set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user;/win32-depends;/liblogdiag/ld-marshal.[ch]")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${project_VERSION}") set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
include (CPack) include (CPack)

View File

@ -15,7 +15,7 @@ a package with the latest development version from Archlinux's AUR.
Requirements Requirements
------------ ------------
Runtime dependencies: GTK+ >= 3.8, json-glib >= 0.10.4, lua >= 5.2 + Runtime dependencies: GTK+ >= 3.8, json-glib >= 0.10.4, lua >= 5.2 +
Build dependencies: CMake >= 2.8.12 Build dependencies: CMake >= 3.9
Build from source on Unix-like systems Build from source on Unix-like systems
-------------------------------------- --------------------------------------
@ -53,8 +53,11 @@ Build from source on Windows
---------------------------- ----------------------------
_Note that with the current method we're stuck with GTK+ 3.8.2._ _Note that with the current method we're stuck with GTK+ 3.8.2._
First install CMake >= 3.1 and MinGW. Add both to your system path. If you want First install CMake and MinGW. Add both to your system path. If you want
to build an installation package, also install NSIS. to build an installation package, also install NSIS. If you want to build within
a path containing spaces, fix your FindPkgConfig.cmake to say:
separate_arguments(_pkgconfig_invoke_result UNIX_COMMAND "${_pkgconfig_invoke_result}")
Run the following command in the directory with source files to automatically Run the following command in the directory with source files to automatically
fetch and setup all dependencies (contact me if the script becomes obsolete, fetch and setup all dependencies (contact me if the script becomes obsolete,
@ -63,6 +66,8 @@ releasing a new version in order to resolve compatibility issues):
> cmake -P Win32Depends.cmake > cmake -P Win32Depends.cmake
Note that Windows XP is no longer able to reliably download from HTTPS sources.
Reserve a directory for an out-of-source build: Reserve a directory for an out-of-source build:
> mkdir build > mkdir build

View File

@ -28,8 +28,12 @@ set (pkg_7za_urls "${pkg_7za_root}/7-Zip/9.20/7za920.zip")
set (pkg_7za_md5 "2fac454a90ae96021f4ffc607d4c00f8") set (pkg_7za_md5 "2fac454a90ae96021f4ffc607d4c00f8")
set (pkg_gtk_root "http://ftp.gnome.org/pub/gnome/binaries/win32") set (pkg_gtk_root "http://ftp.gnome.org/pub/gnome/binaries/win32")
set (pkg_gtk_urls "${pkg_gtk_root}/dependencies/gettext-tools-0.17.zip") set (pkg_gtk_urls
set (pkg_gtk_md5 "09baff956ebd1c391c7f71e9bd768edd") "${pkg_gtk_root}/dependencies/gettext-tools-0.17.zip"
"${pkg_gtk_root}/dependencies/gettext-runtime-0.17-1.zip")
set (pkg_gtk_md5
"09baff956ebd1c391c7f71e9bd768edd"
"110394b4b1e0a50cd440f1e8729d159c")
# https://sourceforge.net/projects/urlget/files # https://sourceforge.net/projects/urlget/files
# /GTK%2B%203%20binary%20for%20Windows/GTK%2B%203.16.6/ # /GTK%2B%203%20binary%20for%20Windows/GTK%2B%203.16.6/

View File

@ -1,99 +0,0 @@
# - 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.
#
# Additionally it provides the following macros:
# GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN )
# This will create a target "${PROJECT_NAME}_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.
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
# Copyright 2010-2011 Přemysl Eric Janouch
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of the Kitware nor the names of contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# 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 HOLDERS 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 (GETTEXT_MSGMERGE_EXECUTABLE msgmerge)
find_program (GETTEXT_MSGFMT_EXECUTABLE msgfmt)
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 (_potBasename ${_potFile} NAME_WE)
get_filename_component (_absPotFile ${_potFile} ABSOLUTE)
set (_addToAll)
if (${_firstPoFile} STREQUAL "ALL")
set (_addToAll "ALL")
set (_firstPoFile)
endif (${_firstPoFile} STREQUAL "ALL")
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)
# msgmerge versions older than 0.11 don't actually support --update
# and --backup, let's try to workaround that (tested on 0.10.40).
execute_process (COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} -V
OUTPUT_VARIABLE _msgmergeVersion)
string (REGEX MATCH "0[.][0-9]+" _msgmergeVersion ${_msgmergeVersion})
if ("${_msgmergeVersion}" MATCHES "[.]10|[.][0-9]")
set (_msgmergeParams --quiet -s
${_absFile} -o ${_absFile} ${_absPotFile})
else ("${_msgmergeVersion}" MATCHES "[.]10|[.][0-9]")
set (_msgmergeParams --quiet --update --backup=none -s
${_absFile} ${_absPotFile})
endif ("${_msgmergeVersion}" MATCHES "[.]10|[.][0-9]")
add_custom_command (
OUTPUT ${_gmoFile}
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} ${_msgmergeParams}
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 (_currentPoFile)
add_custom_target (${PROJECT_NAME}_translations ${_addToAll}
DEPENDS ${_gmoFiles})
endmacro (GETTEXT_CREATE_TRANSLATIONS)
include (FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (Gettext DEFAULT_MSG
GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE)

View File

@ -9,7 +9,7 @@
#define __CONFIG_H__ #define __CONFIG_H__
#define PROJECT_NAME "${PROJECT_NAME}" #define PROJECT_NAME "${PROJECT_NAME}"
#define PROJECT_VERSION "${project_VERSION}" #define PROJECT_VERSION "${PROJECT_VERSION}"
#define PROJECT_URL "${project_URL}" #define PROJECT_URL "${project_URL}"
#cmakedefine OPTION_NOINSTALL #cmakedefine OPTION_NOINSTALL

View File

@ -1,5 +1,5 @@
<schemalist> <schemalist>
<schema id="org.logdiag" path="/apps/logdiag/" gettext-domain="logdiag"> <schema id="org.logdiag" path="/org/logdiag/" gettext-domain="logdiag">
<key name="show-main-toolbar" type="b"> <key name="show-main-toolbar" type="b">
<default>true</default> <default>true</default>
<summary>Whether to show the main toolbar</summary> <summary>Whether to show the main toolbar</summary>