initial commit
This commit is contained in:
commit
efcd3e1892
106 changed files with 27000 additions and 0 deletions
151
cmake/GetGitRevisionDescription.cmake
Normal file
151
cmake/GetGitRevisionDescription.cmake
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
# - 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(get_git_is_dirty _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
diff-index --name-only HEAD --
|
||||
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()
|
||||
|
||||
if (NOT "${out}" STREQUAL "")
|
||||
set(IS_DIRTY "dirty")
|
||||
else()
|
||||
set(IS_DIRTY "")
|
||||
endif()
|
||||
set(${_var} "${IS_DIRTY}" 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_tag _var)
|
||||
git_describe(out --tags ${ARGN})
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
38
cmake/GetGitRevisionDescription.cmake.in
Normal file
38
cmake/GetGitRevisionDescription.cmake.in
Normal file
|
|
@ -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()
|
||||
12
cmake/MacPlistMacros.cmake
Normal file
12
cmake/MacPlistMacros.cmake
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Mac Plist Macros
|
||||
|
||||
FUNCTION (GET_VERSION_PLIST PLISTFILE OUTVAR)
|
||||
SET (PVERSION "")
|
||||
IF (EXISTS ${PLISTFILE})
|
||||
FILE (READ "${PLISTFILE}" info_plist)
|
||||
STRING (REGEX REPLACE "\n" "" info_plist "${info_plist}")
|
||||
STRING (REGEX MATCH "<key>CFBundleShortVersionString</key>[ \t]*<string>([0-9\\.]*)</string>" PLISTVERSION "${info_plist}")
|
||||
STRING (REGEX REPLACE "<key>CFBundleShortVersionString</key>[ \t]*<string>([0-9\\.]*)</string>" "\\1" PVERSION "${PLISTVERSION}")
|
||||
ENDIF (EXISTS ${PLISTFILE})
|
||||
SET (${OUTVAR} ${PVERSION} PARENT_SCOPE)
|
||||
ENDFUNCTION (GET_VERSION_PLIST)
|
||||
133
cmake/cpplint.cmake
Normal file
133
cmake/cpplint.cmake
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
#
|
||||
# CMake module to C++ static analysis against
|
||||
# Google C++ Style Guide (https://google.github.io/styleguide/cppguide.html)
|
||||
#
|
||||
# For more detials please follow links:
|
||||
#
|
||||
# - https://github.com/google/styleguide
|
||||
# - https://pypi.python.org/pypi/cpplint
|
||||
# - https://github.com/theandrewdavis/cpplint
|
||||
#
|
||||
# Copyright (c) 2016 Piotr L. Figlarek
|
||||
#
|
||||
# Usage
|
||||
# -----
|
||||
# Include this module via CMake include(...) command and then add each source directory
|
||||
# via introduced by this module cpplint_add_subdirectory(...) function. Added directory
|
||||
# will be recursivelly scanned and all available files will be checked.
|
||||
#
|
||||
# Example
|
||||
# -------
|
||||
# # include CMake module
|
||||
# include(cmake/cpplint.cmake)
|
||||
#
|
||||
# # add all source code directories
|
||||
# cpplint_add_subdirectory(core)
|
||||
# cpplint_add_subdirectory(modules/c-bind)
|
||||
#
|
||||
# License (MIT)
|
||||
# -------------
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
|
||||
# select files extensions to check
|
||||
option(CPPLINT_TEST_C_FILES "Check *.c files" ON)
|
||||
option(CPPLINT_TEST_H_FILES "Check *.h files" ON)
|
||||
option(CPPLINT_TEST_CPP_FILES "Check *.cpp files" ON)
|
||||
option(CPPLINT_TEST_HPP_FILES "Check *.hpp files" ON)
|
||||
option(CPPLINT_TEST_TPP_FILES "Check *.tpp files" ON)
|
||||
|
||||
# target to run cpplint.py for all configured sources
|
||||
set(CPPLINT_TARGET lint CACHE STRING "Name of C++ style checker target")
|
||||
|
||||
# project root directory
|
||||
set(CPPLINT_PROJECT_ROOT "${PROJECT_SOURCE_DIR}" CACHE STRING "Project ROOT directory")
|
||||
|
||||
|
||||
# find cpplint.py script
|
||||
if(CPPLINT)
|
||||
message(STATUS "cpplint parser: ${CPPLINT}")
|
||||
else()
|
||||
message(FATAL_ERROR "cpplint script: NOT FOUND! "
|
||||
"Please set the CPPLINT variable.")
|
||||
endif()
|
||||
|
||||
|
||||
# common target to concatenate all cpplint.py targets
|
||||
add_custom_target(${CPPLINT_TARGET} ALL)
|
||||
|
||||
|
||||
# use cpplint.py to check source code files inside DIR directory
|
||||
function(cpplint_add_subdirectory DIR)
|
||||
# create relative path to the directory
|
||||
set(ABSOLUTE_DIR ${CMAKE_CURRENT_LIST_DIR}/${DIR})
|
||||
|
||||
# add *.c files
|
||||
if(CPPLINT_TEST_C_FILES)
|
||||
set(EXTENSIONS ${EXTENSIONS}c,)
|
||||
set(FILES_TO_CHECK ${FILES_TO_CHECK} ${ABSOLUTE_DIR}/*.c)
|
||||
endif()
|
||||
|
||||
# add *.h files
|
||||
if(CPPLINT_TEST_H_FILES)
|
||||
set(EXTENSIONS ${EXTENSIONS}h,)
|
||||
set(FILES_TO_CHECK ${FILES_TO_CHECK} ${ABSOLUTE_DIR}/*.h)
|
||||
endif()
|
||||
|
||||
# add *.cpp files
|
||||
if(CPPLINT_TEST_CPP_FILES)
|
||||
set(EXTENSIONS ${EXTENSIONS}cpp,)
|
||||
set(FILES_TO_CHECK ${FILES_TO_CHECK} ${ABSOLUTE_DIR}/*.cpp)
|
||||
endif()
|
||||
|
||||
# add *.hpp files
|
||||
if(CPPLINT_TEST_HPP_FILES)
|
||||
set(EXTENSIONS ${EXTENSIONS}hpp,)
|
||||
set(FILES_TO_CHECK ${FILES_TO_CHECK} ${ABSOLUTE_DIR}/*.hpp)
|
||||
endif()
|
||||
|
||||
# add *.tpp files
|
||||
if(CPPLINT_TEST_TPP_FILES)
|
||||
set(EXTENSIONS ${EXTENSIONS}tpp,)
|
||||
set(FILES_TO_CHECK ${FILES_TO_CHECK} ${ABSOLUTE_DIR}/*.tpp)
|
||||
endif()
|
||||
|
||||
# find all source files inside project
|
||||
file(GLOB_RECURSE LIST_OF_FILES ${FILES_TO_CHECK})
|
||||
|
||||
# create valid target name for this check
|
||||
string(REGEX REPLACE "/" "." TEST_NAME ${DIR})
|
||||
set(TARGET_NAME ${CPPLINT_TARGET}.${TEST_NAME})
|
||||
|
||||
# perform cpplint check
|
||||
add_custom_target(${TARGET_NAME}
|
||||
COMMAND ${CPPLINT} "--extensions=${EXTENSIONS}"
|
||||
"--root=${CPPLINT_PROJECT_ROOT}"
|
||||
"--quiet"
|
||||
${LIST_OF_FILES}
|
||||
DEPENDS ${LIST_OF_FILES}
|
||||
COMMENT "cpplint: Checking source code style"
|
||||
)
|
||||
|
||||
# run this target when root cpplint.py test is triggered
|
||||
add_dependencies(${CPPLINT_TARGET} ${TARGET_NAME})
|
||||
|
||||
# add this test to CTest
|
||||
add_test(${TARGET_NAME} ${CMAKE_MAKE_PROGRAM} ${TARGET_NAME})
|
||||
endfunction()
|
||||
Loading…
Add table
Add a link
Reference in a new issue