Add version and adjust some cmake
This commit is contained in:
parent
a4a795af33
commit
bd45fdf1e1
|
@ -1,21 +1,58 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
project(Dino LANGUAGES C)
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
||||
include(ComputeVersion)
|
||||
if (NOT VERSION_FOUND)
|
||||
project(Dino LANGUAGES C)
|
||||
elseif (VERSION_IS_RELEASE)
|
||||
project(Dino VERSION ${VERSION_FULL} LANGUAGES C)
|
||||
else ()
|
||||
project(Dino LANGUAGES C)
|
||||
set(PROJECT_VERSION ${VERSION_FULL})
|
||||
endif ()
|
||||
|
||||
# Prepare Plugins
|
||||
set(PLUGINS omemo;openpgp;http-files)
|
||||
set(DEFAULT_PLUGINS omemo;openpgp;http-files)
|
||||
foreach (plugin ${DEFAULT_PLUGINS})
|
||||
if ("$CACHE{DINO_PLUGIN_ENABLED_${plugin}}" STREQUAL "")
|
||||
if (NOT DEFINED DINO_PLUGIN_ENABLED_${plugin}})
|
||||
set(DINO_PLUGIN_ENABLED_${plugin} "yes" CACHE BOOL "Enable plugin ${plugin}")
|
||||
else ()
|
||||
set(DINO_PLUGIN_ENABLED_${plugin} "${DINO_PLUGIN_ENABLED_${plugin}}" CACHE BOOL "Enable plugin ${plugin}" FORCE)
|
||||
endif ()
|
||||
if (DINO_PLUGIN_ENABLED_${plugin})
|
||||
message(STATUS "Enabled plugin: ${plugin}")
|
||||
else ()
|
||||
message(STATUS "Disabled plugin: ${plugin}")
|
||||
endif ()
|
||||
endif ()
|
||||
endforeach (plugin)
|
||||
|
||||
if (DISABLED_PLUGINS)
|
||||
list(REMOVE_ITEM PLUGINS ${DISABLED_PLUGINS})
|
||||
foreach(plugin ${DISABLED_PLUGINS})
|
||||
set(DINO_PLUGIN_ENABLED_${plugin} "no" CACHE BOOL "Enable plugin ${plugin}" FORCE)
|
||||
message(STATUS "Disabled plugin: ${plugin}")
|
||||
endforeach(plugin)
|
||||
endif (DISABLED_PLUGINS)
|
||||
|
||||
if (ENABLED_PLUGINS)
|
||||
list(APPEND PLUGINS ${ENABLED_PLUGINS})
|
||||
foreach(plugin ${ENABLED_PLUGINS})
|
||||
set(DINO_PLUGIN_ENABLED_${plugin} "yes" CACHE BOOL "Enable plugin ${plugin}" FORCE)
|
||||
message(STATUS "Enabled plugin: ${plugin}")
|
||||
endforeach(plugin)
|
||||
endif (ENABLED_PLUGINS)
|
||||
list(REMOVE_DUPLICATES PLUGINS)
|
||||
|
||||
foreach(plugin ${PLUGINS})
|
||||
message(STATUS "Building plugin: ${plugin}")
|
||||
set(PLUGIN_ENABLED_${plugin} "yes")
|
||||
endforeach(plugin)
|
||||
set(PLUGINS "")
|
||||
get_cmake_property(all_variables VARIABLES)
|
||||
foreach (variable_name ${all_variables})
|
||||
if (variable_name MATCHES "^DINO_PLUGIN_ENABLED_(.+)$" AND ${variable_name})
|
||||
list(APPEND PLUGINS ${CMAKE_MATCH_1})
|
||||
endif()
|
||||
endforeach ()
|
||||
list(SORT PLUGINS)
|
||||
list(JOIN PLUGINS ", " PLUGINS_TEXT)
|
||||
|
||||
message(STATUS "Configuring Dino ${PROJECT_VERSION} with plugins: ${PLUGINS_TEXT}")
|
||||
|
||||
# Prepare instal paths
|
||||
macro(set_path what val desc)
|
||||
|
@ -23,11 +60,14 @@ macro(set_path what val desc)
|
|||
unset(${what} CACHE)
|
||||
set(${what} ${val})
|
||||
endif ()
|
||||
if (NOT "${${what}}" STREQUAL "${_${what}_SET}")
|
||||
message(STATUS "${desc}: ${${what}}")
|
||||
set(_${what}_SET ${${what}} CACHE INTERNAL ${desc})
|
||||
endif()
|
||||
endmacro(set_path)
|
||||
|
||||
string(REGEX REPLACE "^liblib" "lib" LIBDIR_NAME "lib${LIB_SUFFIX}")
|
||||
message(STATUS "Installation directory for architecture-independent files: ${CMAKE_INSTALL_PREFIX}")
|
||||
set_path(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" "Installation directory for architecture-independent files")
|
||||
set_path(EXEC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" "Installation directory for architecture-dependent files")
|
||||
set_path(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share" "Installation directory for read-only architecture-independent data")
|
||||
|
||||
|
@ -98,14 +138,15 @@ unset(__WITHOUT_FILE_OFFSET_BITS_64)
|
|||
|
||||
if ($ENV{USE_CCACHE})
|
||||
# Configure CCache if available
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
if(CCACHE_FOUND)
|
||||
find_program(CCACHE_BIN ccache)
|
||||
mark_as_advanced(CCACHE_BIN)
|
||||
if (CCACHE_BIN)
|
||||
message(STATUS "Using ccache")
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||
else(CCACHE_FOUND)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_BIN})
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_BIN})
|
||||
else (CCACHE_BIN)
|
||||
message(STATUS "USE_CCACHE was set but ccache was not found")
|
||||
endif(CCACHE_FOUND)
|
||||
endif (CCACHE_BIN)
|
||||
endif ($ENV{USE_CCACHE})
|
||||
|
||||
if (NOT NO_DEBUG)
|
||||
|
|
104
cmake/ComputeVersion.cmake
Normal file
104
cmake/ComputeVersion.cmake
Normal file
|
@ -0,0 +1,104 @@
|
|||
include(CMakeParseArguments)
|
||||
|
||||
function(_compute_version_from_file)
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/VERSION)
|
||||
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/VERSION)
|
||||
set(VERSION_FOUND 0 PARENT_SCOPE)
|
||||
return()
|
||||
endif ()
|
||||
file(STRINGS ${CMAKE_SOURCE_DIR}/VERSION VERSION_FILE)
|
||||
string(REPLACE " " ";" VERSION_FILE "${VERSION_FILE}")
|
||||
cmake_parse_arguments(VERSION_FILE "" "RELEASE;PRERELEASE" "" ${VERSION_FILE})
|
||||
if (DEFINED VERSION_FILE_RELEASE)
|
||||
string(STRIP "${VERSION_FILE_RELEASE}" VERSION_FILE_RELEASE)
|
||||
set(VERSION_IS_RELEASE 1 PARENT_SCOPE)
|
||||
set(VERSION_FULL "${VERSION_FILE_RELEASE}" PARENT_SCOPE)
|
||||
set(VERSION_FOUND 1 PARENT_SCOPE)
|
||||
elseif (DEFINED VERSION_FILE_PRERELEASE)
|
||||
string(STRIP "${VERSION_FILE_PRERELEASE}" VERSION_FILE_PRERELEASE)
|
||||
set(VERSION_IS_RELEASE 0 PARENT_SCOPE)
|
||||
set(VERSION_FULL "${VERSION_FILE_PRERELEASE}" PARENT_SCOPE)
|
||||
set(VERSION_FOUND 1 PARENT_SCOPE)
|
||||
else ()
|
||||
set(VERSION_FOUND 0 PARENT_SCOPE)
|
||||
endif ()
|
||||
endfunction(_compute_version_from_file)
|
||||
|
||||
function(_compute_version_from_git)
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/.git)
|
||||
if (NOT GIT_EXECUTABLE)
|
||||
find_package(Git QUIET)
|
||||
if (NOT GIT_FOUND)
|
||||
return()
|
||||
endif ()
|
||||
endif (NOT GIT_EXECUTABLE)
|
||||
|
||||
# Git tag
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" describe --tags --abbrev=0
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE git_result
|
||||
OUTPUT_VARIABLE git_tag
|
||||
ERROR_VARIABLE git_error
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if (NOT git_result EQUAL 0)
|
||||
return()
|
||||
endif (NOT git_result EQUAL 0)
|
||||
|
||||
if (git_tag MATCHES "^v?([0-9]+[.]?[0-9]*[.]?[0-9]*)(-[.0-9A-Za-z-]+)?([+][.0-9A-Za-z-]+)?$")
|
||||
set(VERSION_LAST_RELEASE "${CMAKE_MATCH_1}")
|
||||
else ()
|
||||
return()
|
||||
endif ()
|
||||
|
||||
# Git describe
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" describe --tags
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE git_result
|
||||
OUTPUT_VARIABLE git_describe
|
||||
ERROR_VARIABLE git_error
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if (NOT git_result EQUAL 0)
|
||||
return()
|
||||
endif (NOT git_result EQUAL 0)
|
||||
|
||||
if ("${git_tag}" STREQUAL "${git_describe}")
|
||||
set(VERSION_IS_RELEASE 1)
|
||||
else ()
|
||||
set(VERSION_IS_RELEASE 0)
|
||||
if (git_describe MATCHES "g([0-9a-f]+)$")
|
||||
set(VERSION_COMMIT_HASH "${CMAKE_MATCH_1}")
|
||||
endif ()
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" show --format=%cd --date=format:%Y%m%d -s
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE git_result
|
||||
OUTPUT_VARIABLE git_time
|
||||
ERROR_VARIABLE git_error
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if (NOT git_result EQUAL 0)
|
||||
return()
|
||||
endif (NOT git_result EQUAL 0)
|
||||
set(VERSION_COMMIT_DATE "${git_time}")
|
||||
endif ()
|
||||
if (NOT VERSION_IS_RELEASE)
|
||||
set(VERSION_SUFFIX ".git${VERSION_COMMIT_DATE}.${VERSION_COMMIT_HASH}")
|
||||
else (NOT VERSION_IS_RELEASE)
|
||||
set(VERSION_SUFFIX "")
|
||||
endif (NOT VERSION_IS_RELEASE)
|
||||
set(VERSION_IS_RELEASE ${VERSION_IS_RELEASE} PARENT_SCOPE)
|
||||
set(VERSION_FULL "${VERSION_LAST_RELEASE}${VERSION_SUFFIX}" PARENT_SCOPE)
|
||||
set(VERSION_FOUND 1 PARENT_SCOPE)
|
||||
endfunction(_compute_version_from_git)
|
||||
|
||||
_compute_version_from_file()
|
||||
if (NOT VERSION_FOUND)
|
||||
_compute_version_from_git()
|
||||
endif (NOT VERSION_FOUND)
|
|
@ -27,6 +27,9 @@ endif()
|
|||
|
||||
if (GDK3_FOUND)
|
||||
find_file(GDK3_WITH_X11 "gdk/gdkx.h" HINTS ${GDK3_INCLUDE_DIRS})
|
||||
if (GDK3_WITH_X11)
|
||||
set(GDK3_WITH_X11 yes CACHE INTERNAL "Does GDK3 support X11")
|
||||
endif (GDK3_WITH_X11)
|
||||
endif ()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
|
|
@ -193,6 +193,9 @@ function(vala_precompile output)
|
|||
endif(ARGS_GENERATE_HEADER)
|
||||
|
||||
string(REPLACE " " ";" VALAC_FLAGS ${CMAKE_VALA_FLAGS})
|
||||
if (VALA_VERSION VERSION_GREATER "0.38")
|
||||
set(VALAC_COLORS "--color=always")
|
||||
endif ()
|
||||
|
||||
if(ARGS_FAST_VAPI)
|
||||
foreach(src ${ARGS_SOURCES} ${ARGS_UNPARSED_ARGUMENTS})
|
||||
|
@ -211,6 +214,7 @@ function(vala_precompile output)
|
|||
COMMAND
|
||||
${VALA_EXECUTABLE}
|
||||
ARGS
|
||||
${VALAC_COLORS}
|
||||
--fast-vapi ${fast_vapi_file}
|
||||
${vala_define_opts}
|
||||
${ARGS_OPTIONS}
|
||||
|
@ -246,6 +250,7 @@ function(vala_precompile output)
|
|||
COMMAND
|
||||
${VALA_EXECUTABLE}
|
||||
ARGS
|
||||
${VALAC_COLORS}
|
||||
"-C"
|
||||
"-d" ${dir}
|
||||
${vala_pkg_opts}
|
||||
|
@ -271,6 +276,7 @@ function(vala_precompile output)
|
|||
COMMAND
|
||||
${VALA_EXECUTABLE}
|
||||
ARGS
|
||||
${VALAC_COLORS}
|
||||
-C -q --disable-warnings
|
||||
${header_arguments}
|
||||
${vapi_arguments}
|
||||
|
@ -306,6 +312,7 @@ function(vala_precompile output)
|
|||
COMMAND
|
||||
${VALA_EXECUTABLE}
|
||||
ARGS
|
||||
${VALAC_COLORS}
|
||||
-C
|
||||
${header_arguments}
|
||||
${vapi_arguments}
|
||||
|
|
20
configure
vendored
20
configure
vendored
|
@ -191,9 +191,16 @@ if ! [ -x "$ninja_bin" ]; then
|
|||
ninja_bin="$(which ninja 2>/dev/null)"
|
||||
fi
|
||||
if [ -x "$ninja_bin" ]; then
|
||||
ninja_version=$($ninja_bin --version 2>/dev/null)
|
||||
ninja_version=`$ninja_bin --version 2>/dev/null`
|
||||
if [ $? -eq 0 ]; then
|
||||
if [ -d build ]; then
|
||||
last_ninja_version=`cat build/.ninja_version 2>/dev/null`
|
||||
else
|
||||
last_ninja_version=0
|
||||
fi
|
||||
if [ "$ninja_version" != "$last_ninja_version" ]; then
|
||||
echo "-- Found Ninja: $ninja_bin (found version \"$ninja_version\")"
|
||||
fi
|
||||
cmake_type="Ninja"
|
||||
exec_bin="$ninja_bin"
|
||||
exec_command="$exec_bin"
|
||||
|
@ -219,14 +226,12 @@ if ! [ -x "$exec_bin" ]; then
|
|||
fi
|
||||
|
||||
|
||||
if [ -f ./build ]
|
||||
then
|
||||
if [ -f ./build ]; then
|
||||
echo "-!- ./build file exists. ./configure can't continue"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ -d build ]
|
||||
then
|
||||
if [ -d build ]; then
|
||||
last_type=`cat build/.cmake_type`
|
||||
if [ "$cmake_type" != "$last_type" ]
|
||||
then
|
||||
|
@ -241,6 +246,7 @@ mkdir -p build
|
|||
cd build
|
||||
|
||||
echo "$cmake_type" > .cmake_type
|
||||
echo "$ninja_version" > .ninja_version
|
||||
cmake -G "$cmake_type" \
|
||||
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
|
||||
-DENABLED_PLUGINS="$ENABLED_PLUGINS" \
|
||||
|
@ -256,10 +262,10 @@ cmake -G "$cmake_type" \
|
|||
-DBIN_INSTALL_DIR="$BINDIR" \
|
||||
-DINCLUDE_INSTALL_DIR="$INCLUDEDIR" \
|
||||
-DLIB_INSTALL_DIR="$LIBDIR" \
|
||||
-Wno-dev \
|
||||
.. || exit 9
|
||||
|
||||
if [ "$cmake_type" = "Ninja" ]
|
||||
then
|
||||
if [ "$cmake_type" = "Ninja" ]; then
|
||||
cat << EOF > Makefile
|
||||
default:
|
||||
@sh -c "$exec_command"
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
using Dino.Entities;
|
||||
|
||||
public interface Dino.Application : GLib.Application {
|
||||
namespace Dino {
|
||||
extern const string VERSION;
|
||||
|
||||
public interface Application : GLib.Application {
|
||||
|
||||
public abstract Database db { get; set; }
|
||||
public abstract Dino.Entities.Settings settings { get; set; }
|
||||
|
@ -127,3 +130,4 @@ public interface Dino.Application : GLib.Application {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -169,7 +169,7 @@ OPTIONS
|
|||
${MAIN_EXTRA_OPTIONS}
|
||||
)
|
||||
|
||||
add_definitions(${VALA_CFLAGS} -DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\" -DLOCALE_INSTALL_DIR=\"${LOCALE_INSTALL_DIR}\")
|
||||
add_definitions(${VALA_CFLAGS} -DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\" -DLOCALE_INSTALL_DIR=\"${LOCALE_INSTALL_DIR}\" -DDINO_VERSION=\"${PROJECT_VERSION}\")
|
||||
add_executable(dino ${MAIN_VALA_C} ${MAIN_GRESOURCES_TARGET} src/emojichooser.c)
|
||||
add_dependencies(dino ${GETTEXT_PACKAGE}-translations)
|
||||
target_include_directories(dino PRIVATE src)
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
<attribute name="action">app.open_shortcuts</attribute>
|
||||
<attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="action">app.about</attribute>
|
||||
<attribute name="label" translatable="yes">About Dino</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
</interface>
|
||||
|
|
|
@ -80,6 +80,10 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
|
|||
settings_action.activate.connect(show_settings_window);
|
||||
add_action(settings_action);
|
||||
|
||||
SimpleAction about_action = new SimpleAction("about", null);
|
||||
about_action.activate.connect(show_about_window);
|
||||
add_action(about_action);
|
||||
|
||||
SimpleAction quit_action = new SimpleAction("quit", null);
|
||||
quit_action.activate.connect(quit);
|
||||
add_action(quit_action);
|
||||
|
@ -169,6 +173,18 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
|
|||
dialog.present();
|
||||
}
|
||||
|
||||
private void show_about_window() {
|
||||
show_about_dialog(get_active_window(),
|
||||
logo_icon_name: "im.dino.Dino",
|
||||
program_name: "Dino",
|
||||
version: Dino.VERSION.strip().length == 0 ? null : Dino.VERSION,
|
||||
comments: "Dino. Communicating happiness.",
|
||||
website: "https://dino.im/",
|
||||
website_label: "dino.im",
|
||||
copyright: "Copyright © 2016-2019 - Dino Team",
|
||||
license_type: License.GPL_3_0);
|
||||
}
|
||||
|
||||
private void show_join_muc_dialog(Account? account, Jid jid) {
|
||||
Dialog dialog = new Dialog.with_buttons(_("Join Channel"), window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.USE_HEADER_BAR, _("Join"), ResponseType.OK, _("Cancel"), ResponseType.CANCEL);
|
||||
dialog.modal = true;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
if(PLUGIN_ENABLED_http-files)
|
||||
if(DINO_PLUGIN_ENABLED_http-files)
|
||||
add_subdirectory(http-files)
|
||||
endif(PLUGIN_ENABLED_http-files)
|
||||
endif(DINO_PLUGIN_ENABLED_http-files)
|
||||
|
||||
if(PLUGIN_ENABLED_openpgp)
|
||||
if(DINO_PLUGIN_ENABLED_openpgp)
|
||||
add_subdirectory(gpgme-vala)
|
||||
add_subdirectory(openpgp)
|
||||
endif(PLUGIN_ENABLED_openpgp)
|
||||
endif(DINO_PLUGIN_ENABLED_openpgp)
|
||||
|
||||
if(PLUGIN_ENABLED_omemo)
|
||||
if(DINO_PLUGIN_ENABLED_omemo)
|
||||
add_subdirectory(crypto-vala)
|
||||
add_subdirectory(omemo)
|
||||
add_subdirectory(signal-protocol)
|
||||
endif(PLUGIN_ENABLED_omemo)
|
||||
endif(DINO_PLUGIN_ENABLED_omemo)
|
||||
|
||||
if(PLUGIN_ENABLED_notification-sound)
|
||||
if(DINO_PLUGIN_ENABLED_notification-sound)
|
||||
add_subdirectory(notification-sound)
|
||||
endif(PLUGIN_ENABLED_notification-sound)
|
||||
endif(DINO_PLUGIN_ENABLED_notification-sound)
|
||||
|
|
|
@ -18,8 +18,6 @@ endif()
|
|||
|
||||
vala_precompile(ENGINE_VALA_C
|
||||
SOURCES
|
||||
"src/glib_fixes.vapi"
|
||||
|
||||
"src/core/namespace_state.vala"
|
||||
"src/core/stanza_attribute.vala"
|
||||
"src/core/stanza_node.vala"
|
||||
|
@ -101,6 +99,8 @@ GENERATE_VAPI
|
|||
xmpp-vala
|
||||
GENERATE_HEADER
|
||||
xmpp-vala
|
||||
CUSTOM_VAPIS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/glib_fixes.vapi"
|
||||
DEFINITIONS
|
||||
${ENGINE_DEFINITIONS}
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue