Commit f6125622 authored by Graeme Gott's avatar Graeme Gott
Browse files

Clean up fetching version string

parent ffb80f58
cmake_minimum_required(VERSION 3.16)
# SPDX-FileCopyrightText: 2013-2022 Graeme Gott <graeme@gottcode.org>
#
# SPDX-License-Identifier: GPL-2.0-or-later
project(whiskermenu)
cmake_minimum_required(VERSION 3.16)
# version number
set(whiskermenu_version_major "2")
set(whiskermenu_version_minor "7")
set(whiskermenu_version_micro "0")
set(whiskermenu_version_tag "git")
set(whiskermenu_version "${whiskermenu_version_major}.${whiskermenu_version_minor}.${whiskermenu_version_micro}")
if(${whiskermenu_version_tag} MATCHES "git")
if(NOT DEFINED whiskermenu_version_build)
execute_process(COMMAND git describe
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE whiskermenu_version_build)
string(REGEX REPLACE "^.*-g" "" whiskermenu_version_build "${whiskermenu_version_build}")
string(REGEX REPLACE "\n" "" whiskermenu_version_build "${whiskermenu_version_build}")
endif()
set(whiskermenu_version "${whiskermenu_version}.${whiskermenu_version_tag}-${whiskermenu_version_build}")
endif()
project(whiskermenu VERSION 2.7.0)
# options
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_TOLOWER)
......
# SPDX-FileCopyrightText: 2022 Graeme Gott <graeme@gottcode.org>
#
# SPDX-License-Identifier: GPL-2.0-or-later
function(add_version_compile_definition versionstr_file versionstr_def)
# Use project's VERSION by default
set(versionstr ${PROJECT_VERSION})
find_package(Git QUIET)
if(Git_FOUND)
# Find git repository
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --absolute-git-dir
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE git_dir_result
OUTPUT_VARIABLE git_dir
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (git_dir_result EQUAL 0)
# Find version number from git
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --match "v*"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE versionstr
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REGEX REPLACE "^v" "" versionstr "${versionstr}")
# Rerun CMake when git repository changes
if (EXISTS ${git_dir}/logs/HEAD)
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS ${git_dir}/logs/HEAD
)
endif()
endif()
endif()
# Pass version as compile definition to file
set_property(
SOURCE ${versionstr_file}
APPEND
PROPERTY COMPILE_DEFINITIONS ${versionstr_def}="${versionstr}"
)
endfunction()
......@@ -11,11 +11,11 @@ string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
execute_process(
"@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()
......
# SPDX-FileCopyrightText: 2013 Graeme Gott <graeme@gottcode.org>
#
# SPDX-License-Identifier: GPL-2.0-or-later
set(INSTALL_ICONDIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor)
install(FILES hi16-app-whiskermenu.png
......
# SPDX-FileCopyrightText: 2013-2022 Graeme Gott <graeme@gottcode.org>
#
# SPDX-License-Identifier: GPL-2.0-or-later
include(../cmake/AddVersionCompileDefinition.cmake)
add_version_compile_definition(plugin.cpp PACKAGE_VERSION)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED IMPORTED_TARGET gtk+-3.0>=3.22)
pkg_check_modules(exo REQUIRED IMPORTED_TARGET exo-2>=0.12)
......@@ -52,7 +59,6 @@ target_compile_definitions(whiskermenu PRIVATE
GETTEXT_PACKAGE="xfce4-whiskermenu-plugin"
PACKAGE_LOCALE_DIR="${CMAKE_INSTALL_FULL_LOCALEDIR}"
PACKAGE_NAME="xfce4-whiskermenu-plugin"
PACKAGE_VERSION="${whiskermenu_version}"
BINDIR="${CMAKE_INSTALL_FULL_BINDIR}"
DATADIR="${CMAKE_INSTALL_FULL_DATADIR}"
SETTINGS_MENUFILE="${CMAKE_INSTALL_FULL_SYSCONFDIR}/xdg/menus/xfce-settings-manager.menu"
......
# SPDX-FileCopyrightText: 2013-2020 Graeme Gott <graeme@gottcode.org>
#
# SPDX-License-Identifier: GPL-2.0-or-later
find_package(Gettext 0.19.1 REQUIRED)
# Generate translations
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment