aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2019-12-17 23:52:05 +0100
committerMarvin W <git@larma.de>2019-12-18 00:51:49 +0100
commitbd45fdf1e16e7d4ff49e1472ee30f269867f531e (patch)
tree4e9766553fa0dbb48eebe77ab9a4f0a9ad8d2627 /CMakeLists.txt
parenta4a795af333d6bcf378e11df456a858af2fa4603 (diff)
downloaddino-bd45fdf1e16e7d4ff49e1472ee30f269867f531e.tar.gz
dino-bd45fdf1e16e7d4ff49e1472ee30f269867f531e.zip
Add version and adjust some cmake
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt125
1 files changed, 83 insertions, 42 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9e007ad3..9a074e0f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,33 +1,73 @@
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)
-if(DISABLED_PLUGINS)
- list(REMOVE_ITEM PLUGINS ${DISABLED_PLUGINS})
-endif(DISABLED_PLUGINS)
-if(ENABLED_PLUGINS)
- list(APPEND PLUGINS ${ENABLED_PLUGINS})
-endif(ENABLED_PLUGINS)
+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)
+ 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)
+ 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)
- if(NOT ${what})
+ if (NOT ${what})
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()
- message(STATUS "${desc}: ${${what}}")
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")
@@ -52,22 +92,22 @@ include(CheckCSourceCompiles)
macro(AddCFlagIfSupported flag)
string(REGEX REPLACE "[^a-z^A-Z^_^0-9]+" "_" flag_name ${flag})
check_c_compiler_flag(${flag} COMPILER_SUPPORTS${flag_name})
- if(${COMPILER_SUPPORTS${flag_name}})
+ if (${COMPILER_SUPPORTS${flag_name}})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
- endif()
+ endif ()
endmacro()
macro(AddValaCFlagIfSupported flag)
string(REGEX REPLACE "[^a-z^A-Z^_^0-9]+" "_" flag_name ${flag})
check_c_compiler_flag(${flag} COMPILER_SUPPORTS${flag_name})
- if(${COMPILER_SUPPORTS${flag_name}})
+ if (${COMPILER_SUPPORTS${flag_name}})
set(VALA_CFLAGS "${VALA_CFLAGS} ${flag}")
- endif()
+ endif ()
endmacro()
-if("Ninja" STREQUAL ${CMAKE_GENERATOR})
- AddCFlagIfSupported(-fdiagnostics-color COMPILER_SUPPORTS_fdiagnistics-color)
-endif()
+if ("Ninja" STREQUAL ${CMAKE_GENERATOR})
+ AddCFlagIfSupported(-fdiagnostics-color COMPILER_SUPPORTS_fdiagnistics-color)
+endif ()
AddCFlagIfSupported(-Wall)
AddCFlagIfSupported(-Werror=format-security)
@@ -82,36 +122,37 @@ AddValaCFlagIfSupported(-Wno-unused-function)
AddValaCFlagIfSupported(-Wno-unused-label)
try_compile(__WITHOUT_FILE_OFFSET_BITS_64 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/LargeFileOffsets.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
-if(NOT __WITHOUT_FILE_OFFSET_BITS_64)
+if (NOT __WITHOUT_FILE_OFFSET_BITS_64)
try_compile(__WITH_FILE_OFFSET_BITS_64 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/LargeFileOffsets.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64)
- if(__WITH_FILE_OFFSET_BITS_64)
+ if (__WITH_FILE_OFFSET_BITS_64)
AddCFlagIfSupported(-D_FILE_OFFSET_BITS=64)
AddValaCFlagIfSupported(-D_FILE_OFFSET_BITS=64)
message(STATUS "Enabled large file support using _FILE_OFFSET_BITS=64")
- else(__WITH_FILE_OFFSET_BITS_64)
+ else (__WITH_FILE_OFFSET_BITS_64)
message(STATUS "Large file support not available")
- endif(__WITH_FILE_OFFSET_BITS_64)
+ endif (__WITH_FILE_OFFSET_BITS_64)
unset(__WITH_FILE_OFFSET_BITS_64)
-endif(NOT __WITHOUT_FILE_OFFSET_BITS_64)
+endif (NOT __WITHOUT_FILE_OFFSET_BITS_64)
unset(__WITHOUT_FILE_OFFSET_BITS_64)
-if($ENV{USE_CCACHE})
+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($ENV{USE_CCACHE})
+ endif (CCACHE_BIN)
+endif ($ENV{USE_CCACHE})
-if(NOT NO_DEBUG)
+if (NOT NO_DEBUG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
set(CMAKE_VALA_FLAGS "${CMAKE_VALA_FLAGS} -g")
-endif(NOT NO_DEBUG)
+endif (NOT NO_DEBUG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
@@ -119,15 +160,15 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(GTK3_GLOBAL_VERSION 3.22)
set(GLib_GLOBAL_VERSION 2.38)
-if(NOT VALA_EXECUTABLE)
+if (NOT VALA_EXECUTABLE)
unset(VALA_EXECUTABLE CACHE)
-endif()
+endif ()
find_package(Vala 0.34 REQUIRED)
-if(VALA_VERSION VERSION_GREATER "0.34.90" AND VALA_VERSION VERSION_LESS "0.36.1" OR # Due to a bug on 0.36.0 (and pre-releases), we need to disable FAST_VAPI
- VALA_VERSION VERSION_EQUAL "0.44.10" OR VALA_VERSION VERSION_EQUAL "0.46.4" OR VALA_VERSION VERSION_EQUAL "0.47.1") # See Dino issue #646
+if (VALA_VERSION VERSION_GREATER "0.34.90" AND VALA_VERSION VERSION_LESS "0.36.1" OR # Due to a bug on 0.36.0 (and pre-releases), we need to disable FAST_VAPI
+ VALA_VERSION VERSION_EQUAL "0.44.10" OR VALA_VERSION VERSION_EQUAL "0.46.4" OR VALA_VERSION VERSION_EQUAL "0.47.1") # See Dino issue #646
set(DISABLE_FAST_VAPI yes)
-endif()
+endif ()
include(${VALA_USE_FILE})
include(MultiFind)