summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@intec.ugent.be>2016-02-11 19:36:19 +0100
committerDimitri Staessens <dimitri.staessens@intec.ugent.be>2016-02-11 19:36:19 +0100
commitd85f6700de4db56341c429c0f4b5a44b72c07bb5 (patch)
treecf977578c870a60f1a1fcff81d898df6488871cc /cmake
parentcedcaee9c0074380b627b61f0591d36b54c452f4 (diff)
parentf78310f4886bad7029cc039971159ab7a97e00af (diff)
downloadouroboros-d85f6700de4db56341c429c0f4b5a44b72c07bb5.tar.gz
ouroboros-d85f6700de4db56341c429c0f4b5a44b72c07bb5.zip
Merge branch 'be' of bitbucket.org:ouroboros-rina/ouroboros into be
Diffstat (limited to 'cmake')
-rw-r--r--cmake/CompilerUtils.cmake15
-rw-r--r--cmake/GitVersionGen.cmake43
-rw-r--r--cmake/MacroAddCompileFlags.cmake19
-rw-r--r--cmake/cmake_uninstall.cmake.in21
4 files changed, 98 insertions, 0 deletions
diff --git a/cmake/CompilerUtils.cmake b/cmake/CompilerUtils.cmake
new file mode 100644
index 00000000..99d9b662
--- /dev/null
+++ b/cmake/CompilerUtils.cmake
@@ -0,0 +1,15 @@
+include(CheckCXXCompilerFlag)
+
+function(test_and_set_cxx_compiler_flag_global _flag)
+
+ string(REGEX REPLACE "-" "_" _sflag ${_flag})
+ check_cxx_compiler_flag(${_flag} COMPILER_SUPPORTS_FLAG_${_sflag})
+
+ if(COMPILER_SUPPORTS_FLAG_${_sflag})
+ message(STATUS "Compiler supports flag ${_flag}, added globally")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}" PARENT_SCOPE)
+ else(${_retval})
+ message(STATUS "Compiler does not support flag ${_flag}, discarded")
+ endif()
+
+endfunction(test_and_set_cxx_compiler_flag_global)
diff --git a/cmake/GitVersionGen.cmake b/cmake/GitVersionGen.cmake
new file mode 100644
index 00000000..53ac166d
--- /dev/null
+++ b/cmake/GitVersionGen.cmake
@@ -0,0 +1,43 @@
+macro(GIT_VERSION_GEN)
+
+include(FindGit)
+if(NOT GIT_FOUND)
+ message(FATAL_ERROR "This is not a git repository")
+endif()
+
+find_program(SORT "sort")
+mark_as_advanced(SORT)
+if (${SORT} STREQUAL "")
+ message(FATAL_ERROR "Cannot find the sort executable")
+endif()
+
+find_program(TAIL "tail")
+mark_as_advanced(TAIL)
+if (${TAIL} STREQUAL "")
+ message(FATAL_ERROR "Cannot find the tail executable")
+endif()
+
+execute_process(
+ COMMAND ${GIT_EXECUTABLE} tag -l -n0
+ COMMAND ${SORT} -V
+ COMMAND ${TAIL} -n 1
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ OUTPUT_VARIABLE _git_tag
+ RESULT_VARIABLE _git_result
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(NOT ${_git_result} EQUAL 0)
+ message(FATAL_ERROR "Cannot fetch repository tag")
+endif()
+message(STATUS "Repository tag is: ${_git_tag}")
+
+string(REGEX REPLACE
+ "[^0-9]*([0-9]+)\\.[0-9]+.*" "\\1"
+ _version_major "${_git_tag}")
+string(REGEX REPLACE
+ "[^0-9]*[0-9]+\\.([0-9]+).*" "\\1"
+ _version_minor "${_git_tag}")
+
+set(PACKAGE_VERSION_MAJOR "${_version_major}")
+set(PACKAGE_VERSION_MINOR "${_version_minor}")
+
+endmacro(GIT_VERSION_GEN)
diff --git a/cmake/MacroAddCompileFlags.cmake b/cmake/MacroAddCompileFlags.cmake
new file mode 100644
index 00000000..41f3797c
--- /dev/null
+++ b/cmake/MacroAddCompileFlags.cmake
@@ -0,0 +1,19 @@
+# - MACRO_ADD_COMPILE_FLAGS(<_target> "flags...")
+
+# Copyright (c) 2006, Oswald Buddenhagen, <ossi@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+
+macro(MACRO_ADD_COMPILE_FLAGS _target _flg)
+
+ get_target_property(_flags ${_target} COMPILE_FLAGS)
+ if (_flags)
+ set(_flags "${_flags} ${_flg}")
+ else (_flags)
+ set(_flags "${_flg}")
+ endif (_flags)
+ set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "${_flags}")
+
+endmacro(MACRO_ADD_COMPILE_FLAGS)
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in
new file mode 100644
index 00000000..4c07dc7b
--- /dev/null
+++ b/cmake/cmake_uninstall.cmake.in
@@ -0,0 +1,21 @@
+if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
+ message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
+endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
+
+file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
+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(
+ "@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(NOT "${rm_retval}" STREQUAL 0)
+ else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+ endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+endforeach(file)