diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindQxt.cmake | 155 | ||||
-rw-r--r-- | cmake/GetGitRevisionDescription.cmake | 123 | ||||
-rw-r--r-- | cmake/GetGitRevisionDescription.cmake.in | 38 |
3 files changed, 161 insertions, 155 deletions
diff --git a/cmake/FindQxt.cmake b/cmake/FindQxt.cmake deleted file mode 100644 index 1ddfa0dd..00000000 --- a/cmake/FindQxt.cmake +++ /dev/null @@ -1,155 +0,0 @@ -############# -## basic FindQxt.cmake -## This is an *EXTREMELY BASIC* cmake find/config file for -## those times you have a cmake project and wish to use -## libQxt. -## -## It should be noted that at the time of writing, that -## I (mschnee) have an extremely limited understanding of the -## way Find*.cmake files work, but I have attempted to -## emulate what FindQt4.cmake and a few others do. -## -## To enable a specific component, set your QXT_USE_${modname}: -## SET(QXT_USE_QXTCORE TRUE) -## SET(QXT_USE_QXTGUI FALSE) -## Currently available components: -## QxtCore, QxtGui, QxtNetwork, QxtWeb, QxtSql -## Auto-including directories are enabled with INCLUDE_DIRECTORIES(), but -## can be accessed if necessary via ${QXT_INCLUDE_DIRS} -## -## To add the libraries to your build, TARGET_LINK_LIBRARIES(), such as... -## TARGET_LINK_LIBRARIES(YourTargetNameHere ${QXT_LIBRARIES}) -## ...or.. -## TARGET_LINK_LIBRARIES(YourTargetNameHere ${QT_LIBRARIES} ${QXT_LIBRARIES}) -################### TODO: -## The purpose of this cmake file is to find what components -## exist, regardless of how libQxt was build or configured, thus -## it should search/find all possible options. As I am not aware -## that any module requires anything special to be used, adding all -## modules to ${QXT_MODULES} below should be sufficient. -## Eventually, there should be version numbers, but -## I am still too unfamiliar with cmake to determine how to do -## version checks and comparisons. -## At the moment, this cmake returns a failure if you -## try to use a component that doesn't exist. I don't know how to -## set up warnings. -## It would be nice having a FindQxt.cmake and a UseQxt.cmake -## file like done for Qt - one to check for everything in advance - -############## - -###### setup -SET(QXT_MODULES QxtGui QxtWeb QxtZeroConf QxtNetwork QxtSql QxtBerkeley QxtCore) -SET(QXT_FOUND_MODULES) -FOREACH(mod ${QXT_MODULES}) - STRING(TOUPPER ${mod} U_MOD) - SET(QXT_${U_MOD}_INCLUDE_DIR NOTFOUND) - SET(QXT_${U_MOD}_LIB_DEBUG NOTFOUND) - SET(QXT_${U_MOD}_LIB_RELEASE NOTFOUND) - SET(QXT_FOUND_${U_MOD} FALSE) -ENDFOREACH(mod) -SET(QXT_QXTGUI_DEPENDSON QxtCore) -SET(QXT_QXTWEB_DEPENDSON QxtCore QxtNetwork) -SET(QXT_QXTZEROCONF_DEPENDSON QxtCore QxtNetwork) -SET(QXT_QXTNETWORK_DEPENDSON QxtCore) -SET(QXT_QXTQSQL_DEPENDSON QxtCore) -SET(QXT_QXTBERKELEY_DEPENDSON QxtCore) - -FOREACH(mod ${QXT_MODULES}) - STRING(TOUPPER ${mod} U_MOD) - IF(NOT ${U_MOD}_INCLUDE_DIR) - FIND_PATH(QXT_${U_MOD}_INCLUDE_DIR NAME ${mod} - PATH_SUFFIXES ${mod} include/${mod} - qxt/include/${mod} include/qxt/${mod} - Qxt/include/${mod} include/Qxt/${mod} - PATHS - ~/Library/Frameworks/ - /Library/Frameworks/ - /sw/ - /usr/local/ - /usr - /opt/local/ - /opt/csw - /opt - "C:/Program Files/libqxt/include" - "C:/Program Files (x86)/libqxt/include" - NO_DEFAULT_PATH - ) - FIND_LIBRARY(QXT_${U_MOD}_LIB_RELEASE NAME ${mod} - PATH_SUFFIXES Qxt/lib64 Qxt/lib lib64 lib lib/${CMAKE_LIBRARY_ARCHITECTURE} - PATHS - /sw - /usr/local - /usr - /opt/local - /opt/csw - /opt - "C:/Program Files/libqxt" - "C:/Program Files (x86)/libqxt" - NO_DEFAULT_PATH - ) - FIND_LIBRARY(QXT_${U_MOD}_LIB_DEBUG NAME ${mod}d - PATH_SUFFIXES Qxt/lib64 Qxt/lib lib64 lib lib/${CMAKE_LIBRARY_ARCHITECTURE} - PATHS - /sw - /usr/local - /usr - /opt/local - /opt/csw - /opt - "C:/Program Files/libqxt/" - "C:/Program Files (x86)/libqxt/" - NO_DEFAULT_PATH - ) - IF (QXT_${U_MOD}_LIB_RELEASE) - SET(QXT_FOUND_MODULES "${QXT_FOUND_MODULES} ${mod}") - ENDIF (QXT_${U_MOD}_LIB_RELEASE) - - IF (QXT_${U_MOD}_LIB_DEBUG) - SET(QXT_FOUND_MODULES "${QXT_FOUND_MODULES} ${mod}") - ENDIF (QXT_${U_MOD}_LIB_DEBUG) - ENDIF() -ENDFOREACH(mod) - -FOREACH(mod ${QXT_MODULES}) - STRING(TOUPPER ${mod} U_MOD) - IF(QXT_${U_MOD}_INCLUDE_DIR AND QXT_${U_MOD}_LIB_RELEASE) - SET(QXT_FOUND_${U_MOD} TRUE) - ENDIF(QXT_${U_MOD}_INCLUDE_DIR AND QXT_${U_MOD}_LIB_RELEASE) -ENDFOREACH(mod) - - -##### find and include -# To use a Qxt Library.... -# SET(QXT_FIND_COMPONENTS QxtCore, QxtGui) -# ...and this will do the rest -IF( QXT_FIND_COMPONENTS ) - FOREACH( component ${QXT_FIND_COMPONENTS} ) - STRING( TOUPPER ${component} _COMPONENT ) - SET(QXT_USE_${_COMPONENT}_COMPONENT TRUE) - ENDFOREACH( component ) -ENDIF( QXT_FIND_COMPONENTS ) - -SET(QXT_LIBRARIES "") -SET(QXT_INCLUDE_DIRS "") - -# like FindQt4.cmake, in order of dependence -FOREACH( module ${QXT_MODULES} ) - STRING(TOUPPER ${module} U_MOD) - IF(QXT_USE_${U_MOD} OR QXT_DEPENDS_${U_MOD}) - IF(QXT_FOUND_${U_MOD}) - STRING(REPLACE "QXT" "" qxt_module_def "${U_MOD}") - ADD_DEFINITIONS(-DQXT_${qxt_module_def}_LIB) - SET(QXT_INCLUDE_DIRS ${QXT_INCLUDE_DIRS} ${QXT_${U_MOD}_INCLUDE_DIR}) - INCLUDE_DIRECTORIES(${QXT_${U_MOD}_INCLUDE_DIR}) - SET(QXT_LIBRARIES ${QXT_LIBRARIES} ${QXT_${U_MOD}_LIB_RELEASE}) - ELSE(QXT_FOUND_${U_MOD}) - MESSAGE("Could not find Qxt Module ${module}") - RETURN() - ENDIF(QXT_FOUND_${U_MOD}) - FOREACH(dep QXT_${U_MOD}_DEPENDSON) - SET(QXT_DEPENDS_${dep} TRUE) - ENDFOREACH(dep) - ENDIF(QXT_USE_${U_MOD} OR QXT_DEPENDS_${U_MOD}) -ENDFOREACH(module) -MESSAGE(STATUS "Found Qxt Libraries:${QXT_FOUND_MODULES}") diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake new file mode 100644 index 00000000..e16d8c37 --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake @@ -0,0 +1,123 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe(<var> [<additional arguments to git describe> ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_get_exact_tag(<var> [<additional arguments to git describe> ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net> +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar) + set(GIT_PARENT_DIR "${CMAKE_SOURCE_DIR}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" + @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + ${hash} + ${ARGN} + WORKING_DIRECTORY + "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out ${ARGN}) + set(${_var} "${out}" PARENT_SCOPE) +endfunction() diff --git a/cmake/GetGitRevisionDescription.cmake.in b/cmake/GetGitRevisionDescription.cmake.in new file mode 100644 index 00000000..888ce13a --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake.in @@ -0,0 +1,38 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net> +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}") + configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + set(HEAD_HASH "${HEAD_REF}") + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() |