aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/ComputeVersion.cmake104
-rw-r--r--cmake/FindGDK3.cmake7
-rw-r--r--cmake/UseVala.cmake7
3 files changed, 116 insertions, 2 deletions
diff --git a/cmake/ComputeVersion.cmake b/cmake/ComputeVersion.cmake
new file mode 100644
index 00000000..3a962671
--- /dev/null
+++ b/cmake/ComputeVersion.cmake
@@ -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) \ No newline at end of file
diff --git a/cmake/FindGDK3.cmake b/cmake/FindGDK3.cmake
index f90868e1..fcbfa13c 100644
--- a/cmake/FindGDK3.cmake
+++ b/cmake/FindGDK3.cmake
@@ -25,9 +25,12 @@ if(GDK3_FOUND AND NOT GDK3_VERSION)
endif()
endif()
-if(GDK3_FOUND)
+if (GDK3_FOUND)
find_file(GDK3_WITH_X11 "gdk/gdkx.h" HINTS ${GDK3_INCLUDE_DIRS})
-endif()
+ if (GDK3_WITH_X11)
+ set(GDK3_WITH_X11 yes CACHE INTERNAL "Does GDK3 support X11")
+ endif (GDK3_WITH_X11)
+endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GDK3
diff --git a/cmake/UseVala.cmake b/cmake/UseVala.cmake
index 822ac005..b08b8a19 100644
--- a/cmake/UseVala.cmake
+++ b/cmake/UseVala.cmake
@@ -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}