chore(cmake): format

Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
This commit is contained in:
Leonardo Di Donato 2020-01-17 16:42:18 +01:00 committed by Leo Di Donato
parent 77d23d2cc6
commit 47c88d05b2
8 changed files with 270 additions and 316 deletions

View File

@ -15,7 +15,9 @@ set(CPACK_DEBIAN_PACKAGE_SECTION "utils")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://www.falco.org") set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://www.falco.org")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "dkms (>= 2.1.0.0), libyaml-0-2") set(CPACK_DEBIAN_PACKAGE_DEPENDS "dkms (>= 2.1.0.0), libyaml-0-2")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_BINARY_DIR}/scripts/debian/postinst;${CMAKE_BINARY_DIR}/scripts/debian/prerm;${PROJECT_SOURCE_DIR}/scripts/debian/postrm;${PROJECT_SOURCE_DIR}/cmake/cpack/debian/conffiles") set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
"${CMAKE_BINARY_DIR}/scripts/debian/postinst;${CMAKE_BINARY_DIR}/scripts/debian/prerm;${PROJECT_SOURCE_DIR}/scripts/debian/postrm;${PROJECT_SOURCE_DIR}/cmake/cpack/debian/conffiles"
)
set(CPACK_RPM_PACKAGE_LICENSE "Apache v2.0") set(CPACK_RPM_PACKAGE_LICENSE "Apache v2.0")
set(CPACK_RPM_PACKAGE_URL "https://www.falco.org") set(CPACK_RPM_PACKAGE_URL "https://www.falco.org")
@ -23,7 +25,16 @@ set(CPACK_RPM_PACKAGE_REQUIRES "dkms, gcc, make, kernel-devel, perl")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_SOURCE_DIR}/scripts/rpm/postinstall") set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_SOURCE_DIR}/scripts/rpm/postinstall")
set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_SOURCE_DIR}/scripts/rpm/preuninstall") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_SOURCE_DIR}/scripts/rpm/preuninstall")
set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${PROJECT_SOURCE_DIR}/scripts/rpm/postuninstall") set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${PROJECT_SOURCE_DIR}/scripts/rpm/postuninstall")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/src /usr/share/man /usr/share/man/man8 /etc /usr /usr/bin /usr/share /etc/rc.d /etc/rc.d/init.d) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
/usr/src
/usr/share/man
/usr/share/man/man8
/etc
/usr
/usr/bin
/usr/share
/etc/rc.d
/etc/rc.d/init.d)
set(CPACK_RPM_PACKAGE_RELOCATABLE "OFF") set(CPACK_RPM_PACKAGE_RELOCATABLE "OFF")
include(CPack) include(CPack)

View File

@ -1,5 +1,5 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying # Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or
# file Copyright.txt or https://cmake.org/licensing for details. # https://cmake.org/licensing for details.
#[=======================================================================[.rst: #[=======================================================================[.rst:
Catch Catch
@ -92,15 +92,10 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
#]=======================================================================] #]=======================================================================]
#------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
function(catch_discover_tests TARGET) function(catch_discover_tests TARGET)
cmake_parse_arguments( cmake_parse_arguments("" "" "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST" "TEST_SPEC;EXTRA_ARGS;PROPERTIES"
"" ${ARGN})
""
"TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST"
"TEST_SPEC;EXTRA_ARGS;PROPERTIES"
${ARGN}
)
if(NOT _WORKING_DIRECTORY) if(NOT _WORKING_DIRECTORY)
set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
@ -109,67 +104,56 @@ function(catch_discover_tests TARGET)
set(_TEST_LIST ${TARGET}_TESTS) set(_TEST_LIST ${TARGET}_TESTS)
endif() endif()
## Generate a unique name based on the extra arguments # Generate a unique name based on the extra arguments
string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS}") string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS}")
string(SUBSTRING ${args_hash} 0 7 args_hash) string(SUBSTRING ${args_hash} 0 7 args_hash)
# Define rule to generate test list for aforementioned test executable # Define rule to generate test list for aforementioned test executable
set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake") set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake")
set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake") set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake")
get_property(crosscompiling_emulator get_property(
crosscompiling_emulator
TARGET ${TARGET} TARGET ${TARGET}
PROPERTY CROSSCOMPILING_EMULATOR PROPERTY CROSSCOMPILING_EMULATOR)
)
add_custom_command( add_custom_command(
TARGET ${TARGET} POST_BUILD TARGET ${TARGET}
POST_BUILD
BYPRODUCTS "${ctest_tests_file}" BYPRODUCTS "${ctest_tests_file}"
COMMAND "${CMAKE_COMMAND}" COMMAND
-D "TEST_TARGET=${TARGET}" "${CMAKE_COMMAND}" -D "TEST_TARGET=${TARGET}" -D "TEST_EXECUTABLE=$<TARGET_FILE:${TARGET}>" -D
-D "TEST_EXECUTABLE=$<TARGET_FILE:${TARGET}>" "TEST_EXECUTOR=${crosscompiling_emulator}" -D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}" -D
-D "TEST_EXECUTOR=${crosscompiling_emulator}" "TEST_SPEC=${_TEST_SPEC}" -D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}" -D "TEST_PROPERTIES=${_PROPERTIES}" -D
-D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}" "TEST_PREFIX=${_TEST_PREFIX}" -D "TEST_SUFFIX=${_TEST_SUFFIX}" -D "TEST_LIST=${_TEST_LIST}" -D
-D "TEST_SPEC=${_TEST_SPEC}" "CTEST_FILE=${ctest_tests_file}" -P "${_CATCH_DISCOVER_TESTS_SCRIPT}"
-D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}" VERBATIM)
-D "TEST_PROPERTIES=${_PROPERTIES}"
-D "TEST_PREFIX=${_TEST_PREFIX}"
-D "TEST_SUFFIX=${_TEST_SUFFIX}"
-D "TEST_LIST=${_TEST_LIST}"
-D "CTEST_FILE=${ctest_tests_file}"
-P "${_CATCH_DISCOVER_TESTS_SCRIPT}"
VERBATIM
)
file(WRITE "${ctest_include_file}" file(
"if(EXISTS \"${ctest_tests_file}\")\n" WRITE "${ctest_include_file}"
" include(\"${ctest_tests_file}\")\n" "if(EXISTS \"${ctest_tests_file}\")\n" " include(\"${ctest_tests_file}\")\n" "else()\n"
"else()\n" " add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n" "endif()\n")
" add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n"
"endif()\n"
)
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0")
# Add discovered tests to directory TEST_INCLUDE_FILES # Add discovered tests to directory TEST_INCLUDE_FILES
set_property(DIRECTORY set_property(
APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}" DIRECTORY
) APPEND
PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}")
else() else()
# Add discovered tests as directory TEST_INCLUDE_FILE if possible # Add discovered tests as directory TEST_INCLUDE_FILE if possible
get_property(test_include_file_set DIRECTORY PROPERTY TEST_INCLUDE_FILE SET) get_property(
if (NOT ${test_include_file_set}) test_include_file_set
set_property(DIRECTORY DIRECTORY
PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}" PROPERTY TEST_INCLUDE_FILE
) SET)
if(NOT ${test_include_file_set})
set_property(DIRECTORY PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}")
else() else()
message(FATAL_ERROR message(FATAL_ERROR "Cannot set more than one TEST_INCLUDE_FILE")
"Cannot set more than one TEST_INCLUDE_FILE"
)
endif() endif()
endif() endif()
endfunction() endfunction()
############################################################################### # ######################################################################################################################
set(_CATCH_DISCOVER_TESTS_SCRIPT set(_CATCH_DISCOVER_TESTS_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/CatchAddTests.cmake)
${CMAKE_CURRENT_LIST_DIR}/CatchAddTests.cmake
)

View File

@ -1,5 +1,5 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying # Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or
# file Copyright.txt or https://cmake.org/licensing for details. # https://cmake.org/licensing for details.
set(prefix "${TEST_PREFIX}") set(prefix "${TEST_PREFIX}")
set(suffix "${TEST_SUFFIX}") set(suffix "${TEST_SUFFIX}")
@ -19,31 +19,25 @@ function(add_command NAME)
set(_args "${_args} ${_arg}") set(_args "${_args} ${_arg}")
endif() endif()
endforeach() endforeach()
set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE) set(script
"${script}${NAME}(${_args})\n"
PARENT_SCOPE)
endfunction() endfunction()
# Run test executable to get list of available tests # Run test executable to get list of available tests
if(NOT EXISTS "${TEST_EXECUTABLE}") if(NOT EXISTS "${TEST_EXECUTABLE}")
message(FATAL_ERROR message(FATAL_ERROR "Specified test executable '${TEST_EXECUTABLE}' does not exist")
"Specified test executable '${TEST_EXECUTABLE}' does not exist"
)
endif() endif()
execute_process( execute_process(
COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-test-names-only COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-test-names-only
OUTPUT_VARIABLE output OUTPUT_VARIABLE output
RESULT_VARIABLE result RESULT_VARIABLE result)
)
# Catch --list-test-names-only reports the number of tests, so 0 is... surprising # Catch --list-test-names-only reports the number of tests, so 0 is... surprising
if(${result} EQUAL 0) if(${result} EQUAL 0)
message(WARNING message(WARNING "Test executable '${TEST_EXECUTABLE}' contains no tests!\n")
"Test executable '${TEST_EXECUTABLE}' contains no tests!\n"
)
elseif(${result} LESS 0) elseif(${result} LESS 0)
message(FATAL_ERROR message(FATAL_ERROR "Error running test executable '${TEST_EXECUTABLE}':\n" " Result: ${result}\n"
"Error running test executable '${TEST_EXECUTABLE}':\n" " Output: ${output}\n")
" Result: ${result}\n"
" Output: ${output}\n"
)
endif() endif()
string(REPLACE "\n" ";" output "${output}") string(REPLACE "\n" ";" output "${output}")
@ -54,24 +48,13 @@ foreach(line ${output})
# use escape commas to handle properly test cases with commans inside the name # use escape commas to handle properly test cases with commans inside the name
string(REPLACE "," "\\," test_name ${test}) string(REPLACE "," "\\," test_name ${test})
# ...and add to script # ...and add to script
add_command(add_test add_command(add_test "${prefix}${test}${suffix}" ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" "${test_name}" ${extra_args})
"${prefix}${test}${suffix}" add_command(set_tests_properties "${prefix}${test}${suffix}" PROPERTIES WORKING_DIRECTORY "${TEST_WORKING_DIR}"
${TEST_EXECUTOR} ${properties})
"${TEST_EXECUTABLE}"
"${test_name}"
${extra_args}
)
add_command(set_tests_properties
"${prefix}${test}${suffix}"
PROPERTIES
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
${properties}
)
list(APPEND tests "${prefix}${test}${suffix}") list(APPEND tests "${prefix}${test}${suffix}")
endforeach() endforeach()
# Create a list of all discovered tests, which users may use to e.g. set # Create a list of all discovered tests, which users may use to e.g. set properties on the tests
# properties on the tests
add_command(set ${TEST_LIST} ${tests}) add_command(set ${TEST_LIST} ${tests})
# Write CTest script # Write CTest script

View File

@ -1,29 +1,25 @@
# #
# Copyright (C) 2019 The Falco Authors. # Copyright (C) 2019 The Falco Authors.
# #
# # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# Licensed under the Apache License, Version 2.0 (the "License"); you may not # the License. You may obtain a copy of the License at
# use this file except in compliance with the License. You may obtain a copy of
# the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # specific language governing permissions and limitations under the License.
# License for the specific language governing permissions and limitations under
# the License.
# #
# Tests coverage # Tests coverage
option(FALCO_COVERAGE "Build test suite with coverage information" OFF) option(FALCO_COVERAGE "Build test suite with coverage information" OFF)
if(FALCO_COVERAGE) if(FALCO_COVERAGE)
if (NOT (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))) if(NOT (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")))
message(FATAL_ERROR "FALCO_COVERAGE requires GCC or Clang.") message(FATAL_ERROR "FALCO_COVERAGE requires GCC or Clang.")
endif() endif()
message(STATUS "Building with coverage information") message(STATUS "Building with coverage information")
add_compile_options(-g --coverage) add_compile_options(-g --coverage)
set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS}")
endif() endif()

View File

@ -1,28 +1,21 @@
# #
# Copyright (C) 2019 The Falco Authors. # Copyright (C) 2019 The Falco Authors.
# #
# # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# Licensed under the Apache License, Version 2.0 (the "License"); you may not # the License. You may obtain a copy of the License at
# use this file except in compliance with the License. You may obtain a copy of
# the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # specific language governing permissions and limitations under the License.
# License for the specific language governing permissions and limitations under
# the License.
# #
include(ExternalProject) include(ExternalProject)
set(CATCH2_INCLUDE ${CMAKE_BINARY_DIR}/catch2-prefix/include) set(CATCH2_INCLUDE ${CMAKE_BINARY_DIR}/catch2-prefix/include)
set(CATCH_EXTERNAL_URL set(CATCH_EXTERNAL_URL URL https://github.com/catchorg/catch2/archive/v2.9.1.tar.gz URL_HASH
URL MD5=4980778888fed635bf191d8a86f9f89c)
https://github.com/catchorg/catch2/archive/v2.9.1.tar.gz
URL_HASH
MD5=4980778888fed635bf191d8a86f9f89c)
ExternalProject_Add( ExternalProject_Add(
catch2 catch2
@ -30,9 +23,5 @@ ExternalProject_Add(
${CATCH_EXTERNAL_URL} ${CATCH_EXTERNAL_URL}
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/catch2-prefix/src/catch2/single_include/catch2/catch.hpp
${CMAKE_COMMAND} ${CATCH2_INCLUDE}/catch.hpp)
-E
copy
${CMAKE_BINARY_DIR}/catch2-prefix/src/catch2/single_include/catch2/catch.hpp
${CATCH2_INCLUDE}/catch.hpp)

View File

@ -1,28 +1,21 @@
# #
# Copyright (C) 2019 The Falco Authors. # Copyright (C) 2019 The Falco Authors.
# #
# # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# Licensed under the Apache License, Version 2.0 (the "License"); you may not # the License. You may obtain a copy of the License at
# use this file except in compliance with the License. You may obtain a copy of
# the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # specific language governing permissions and limitations under the License.
# License for the specific language governing permissions and limitations under
# the License.
# #
include(ExternalProject) include(ExternalProject)
set(FAKEIT_INCLUDE ${CMAKE_BINARY_DIR}/fakeit-prefix/include) set(FAKEIT_INCLUDE ${CMAKE_BINARY_DIR}/fakeit-prefix/include)
set(FAKEIT_EXTERNAL_URL set(FAKEIT_EXTERNAL_URL URL https://github.com/eranpeer/fakeit/archive/2.0.5.tar.gz URL_HASH
URL MD5=d3d21b909cebaea5b780af5500bf384e)
https://github.com/eranpeer/fakeit/archive/2.0.5.tar.gz
URL_HASH
MD5=d3d21b909cebaea5b780af5500bf384e)
ExternalProject_Add( ExternalProject_Add(
fakeit-external fakeit-external
@ -31,8 +24,5 @@ ExternalProject_Add(
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND INSTALL_COMMAND
${CMAKE_COMMAND} ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/fakeit-prefix/src/fakeit-external/single_header/catch/fakeit.hpp
-E
copy
${CMAKE_BINARY_DIR}/fakeit-prefix/src/fakeit-external/single_header/catch/fakeit.hpp
${FAKEIT_INCLUDE}/fakeit.hpp) ${FAKEIT_INCLUDE}/fakeit.hpp)

View File

@ -1,168 +1,168 @@
# - Returns a version string from Git # * Returns a version string from Git
# #
# These functions force a re-configure on each git commit so that you can # These functions force a re-configure on each git commit so that you can trust the values of the variables in your
# trust the values of the variables in your build system. # build system.
# #
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...]) # get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
# #
# Returns the refspec and sha hash of the current head revision # Returns the refspec and sha hash of the current head revision
# #
# git_describe(<var> [<additional arguments to git describe> ...]) # git_describe(<var> [<additional arguments to git describe> ...])
# #
# Returns the results of git describe on the source tree, and adjusting # Returns the results of git describe on the source tree, and adjusting the output so that it tests false if an error
# the output so that it tests false if an error occurs. # occurs.
# #
# git_get_exact_tag(<var> [<additional arguments to git describe> ...]) # git_get_exact_tag(<var> [<additional arguments to git describe> ...])
# #
# Returns the results of git describe --exact-match on the source tree, # Returns the results of git describe --exact-match on the source tree, and adjusting the output so that it tests false
# and adjusting the output so that it tests false if there was no exact # if there was no exact matching tag.
# matching tag.
# #
# git_local_changes(<var>) # git_local_changes(<var>)
# #
# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. # Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. Uses the return code of "git diff-index --quiet
# Uses the return code of "git diff-index --quiet HEAD --". # HEAD --". Does not regard untracked files.
# Does not regard untracked files.
# #
# Requires CMake 2.6 or newer (uses the 'function' command) # Requires CMake 2.6 or newer (uses the 'function' command)
# #
# Original Author: # Original Author: 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net> http://academic.cleardefinition.com
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC # Iowa State University HCI Graduate Program/VRAC
# #
# Copyright Iowa State University 2009-2010. # Copyright Iowa State University 2009-2010. Distributed under the Boost Software License, Version 1.0. (See
# Distributed under the Boost Software License, Version 1.0. # accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(__get_git_revision_description) if(__get_git_revision_description)
return() return()
endif() endif()
set(__get_git_revision_description YES) set(__get_git_revision_description YES)
# We must run the following at "include" time, not at function call time, # We must run the following at "include" time, not at function call time, to find the path to this module rather than
# to find the path to this module rather than the path to a calling list file # the path to a calling list file
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
function(get_git_head_revision _refspecvar _hashvar) function(get_git_head_revision _refspecvar _hashvar)
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(GIT_DIR "${GIT_PARENT_DIR}/.git") set(GIT_DIR "${GIT_PARENT_DIR}/.git")
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
# We have reached the root directory, we are not in git # We have reached the root directory, we are not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) set(${_refspecvar}
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) "GITDIR-NOTFOUND"
return() PARENT_SCOPE)
endif() set(${_hashvar}
set(GIT_DIR "${GIT_PARENT_DIR}/.git") "GITDIR-NOTFOUND"
endwhile() PARENT_SCOPE)
# check if this is a submodule return()
if(NOT IS_DIRECTORY ${GIT_DIR}) endif()
file(READ ${GIT_DIR} submodule) set(GIT_DIR "${GIT_PARENT_DIR}/.git")
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) endwhile()
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) # check if this is a submodule
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) if(NOT IS_DIRECTORY ${GIT_DIR})
endif() file(READ ${GIT_DIR} submodule)
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
if(NOT EXISTS "${GIT_DATA}") get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
file(MAKE_DIRECTORY "${GIT_DATA}") get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
endif() endif()
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") if(NOT EXISTS "${GIT_DIR}/HEAD")
return() return()
endif() endif()
set(HEAD_FILE "${GIT_DATA}/HEAD") set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" "${GIT_DATA}/grabRef.cmake" @ONLY)
"${GIT_DATA}/grabRef.cmake" include("${GIT_DATA}/grabRef.cmake")
@ONLY)
include("${GIT_DATA}/grabRef.cmake")
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) set(${_refspecvar}
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) "${HEAD_REF}"
PARENT_SCOPE)
set(${_hashvar}
"${HEAD_HASH}"
PARENT_SCOPE)
endfunction() endfunction()
function(git_describe _var) function(git_describe _var)
if(NOT GIT_FOUND) if(NOT GIT_FOUND)
find_package(Git QUIET) find_package(Git QUIET)
endif() endif()
get_git_head_revision(refspec hash) get_git_head_revision(refspec hash)
if(NOT GIT_FOUND) if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) set(${_var}
return() "GIT-NOTFOUND"
endif() PARENT_SCOPE)
if(NOT hash) return()
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) endif()
return() if(NOT hash)
endif() set(${_var}
"HEAD-HASH-NOTFOUND"
PARENT_SCOPE)
return()
endif()
# TODO sanitize # TODO sanitize if((${ARGN}" MATCHES "&&") OR (ARGN MATCHES "||") OR (ARGN MATCHES "\\;")) message("Please report the
#if((${ARGN}" MATCHES "&&") OR # following error to the project!") message(FATAL_ERROR "Looks like someone's doing something nefarious with
# (ARGN MATCHES "||") OR # git_describe! Passed arguments ${ARGN}") endif()
# (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}") # message(STATUS "Arguments to execute_process: ${ARGN}")
execute_process(COMMAND execute_process(
"${GIT_EXECUTABLE}" COMMAND "${GIT_EXECUTABLE}" describe ${hash} ${ARGN}
describe WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
${hash} RESULT_VARIABLE res
${ARGN} OUTPUT_VARIABLE out
WORKING_DIRECTORY ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
"${CMAKE_CURRENT_SOURCE_DIR}" if(NOT res EQUAL 0)
RESULT_VARIABLE set(out "${out}-${res}-NOTFOUND")
res endif()
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) set(${_var}
"${out}"
PARENT_SCOPE)
endfunction() endfunction()
function(git_get_exact_tag _var) function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN}) git_describe(out --exact-match ${ARGN})
set(${_var} "${out}" PARENT_SCOPE) set(${_var}
"${out}"
PARENT_SCOPE)
endfunction() endfunction()
function(git_local_changes _var) function(git_local_changes _var)
if(NOT GIT_FOUND) if(NOT GIT_FOUND)
find_package(Git QUIET) find_package(Git QUIET)
endif() endif()
get_git_head_revision(refspec hash) get_git_head_revision(refspec hash)
if(NOT GIT_FOUND) if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) set(${_var}
return() "GIT-NOTFOUND"
endif() PARENT_SCOPE)
if(NOT hash) return()
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) endif()
return() if(NOT hash)
endif() set(${_var}
"HEAD-HASH-NOTFOUND"
PARENT_SCOPE)
return()
endif()
execute_process(COMMAND execute_process(
"${GIT_EXECUTABLE}" COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD --
diff-index --quiet HEAD -- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
WORKING_DIRECTORY RESULT_VARIABLE res
"${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE out
RESULT_VARIABLE ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
res if(res EQUAL 0)
OUTPUT_VARIABLE set(${_var}
out "CLEAN"
ERROR_QUIET PARENT_SCOPE)
OUTPUT_STRIP_TRAILING_WHITESPACE) else()
if(res EQUAL 0) set(${_var}
set(${_var} "CLEAN" PARENT_SCOPE) "DIRTY"
else() PARENT_SCOPE)
set(${_var} "DIRTY" PARENT_SCOPE) endif()
endif() endfunction()
endfunction()

View File

@ -21,52 +21,53 @@ else()
set(CURL_SSL_OPTION "--with-ssl") set(CURL_SSL_OPTION "--with-ssl")
message(STATUS "Using bundled curl in '${CURL_BUNDLE_DIR}'") message(STATUS "Using bundled curl in '${CURL_BUNDLE_DIR}'")
ExternalProject_Add(
ExternalProject_Add(curl curl
# START CHANGE for CVE-2017-8816, CVE-2017-8817, CVE-2017-8818, CVE-2018-1000007 # START CHANGE for CVE-2017-8816, CVE-2017-8817, CVE-2017-8818, CVE-2018-1000007
URL "https://s3.amazonaws.com/download.draios.com/dependencies/curl-7.61.0.tar.bz2" URL "https://s3.amazonaws.com/download.draios.com/dependencies/curl-7.61.0.tar.bz2"
URL_MD5 "31d0a9f48dc796a7db351898a1e5058a" URL_MD5 "31d0a9f48dc796a7db351898a1e5058a"
# END CHANGE for CVE-2017-8816, CVE-2017-8817, CVE-2017-8818, CVE-2018-1000007 # END CHANGE for CVE-2017-8816, CVE-2017-8817, CVE-2017-8818, CVE-2018-1000007
CONFIGURE_COMMAND ./configure CONFIGURE_COMMAND
${CURL_SSL_OPTION} ./configure
--disable-shared ${CURL_SSL_OPTION}
--enable-optimize --disable-shared
--disable-curldebug --enable-optimize
--disable-rt --disable-curldebug
--enable-http --disable-rt
--disable-ftp --enable-http
--disable-file --disable-ftp
--disable-ldap --disable-file
--disable-ldaps --disable-ldap
--disable-rtsp --disable-ldaps
--disable-telnet --disable-rtsp
--disable-tftp --disable-telnet
--disable-pop3 --disable-tftp
--disable-imap --disable-pop3
--disable-smb --disable-imap
--disable-smtp --disable-smb
--disable-gopher --disable-smtp
--disable-sspi --disable-gopher
--disable-ntlm-wb --disable-sspi
--disable-tls-srp --disable-ntlm-wb
--without-winssl --disable-tls-srp
--without-darwinssl --without-winssl
--without-polarssl --without-darwinssl
--without-cyassl --without-polarssl
--without-nss --without-cyassl
--without-axtls --without-nss
--without-ca-path --without-axtls
--without-ca-bundle --without-ca-path
--without-libmetalink --without-ca-bundle
--without-librtmp --without-libmetalink
--without-winidn --without-librtmp
--without-libidn2 --without-winidn
--without-libpsl --without-libidn2
--without-nghttp2 --without-libpsl
--without-libssh2 --without-nghttp2
--disable-threaded-resolver --without-libssh2
--without-brotli --disable-threaded-resolver
BUILD_COMMAND ${CMD_MAKE} --without-brotli
BUILD_IN_SOURCE 1 BUILD_COMMAND ${CMD_MAKE}
INSTALL_COMMAND "") BUILD_IN_SOURCE 1
INSTALL_COMMAND "")
endif() endif()