Skip to content
Snippets Groups Projects
Commit f4aafa45 authored by demiralp's avatar demiralp
Browse files

Add cppcheck cmake utilities.

parent c9d772cc
No related branches found
No related tags found
1 merge request!52Feature/#9 cppcheck support
...@@ -38,6 +38,7 @@ conan_or_find_package(cpplint REQUIRED) ...@@ -38,6 +38,7 @@ conan_or_find_package(cpplint REQUIRED)
include(cpplint) include(cpplint)
conan_or_find_package(cppcheck REQUIRED) conan_or_find_package(cppcheck REQUIRED)
include(cppcheck)
include(GenerateExportHeader) include(GenerateExportHeader)
......
#-------------------------------------------------------------------------------
# Project Phoenix
#
# Copyright (c) 2017 RWTH Aachen University, Germany,
# Virtual Reality & Immersive Visualisation Group.
#-------------------------------------------------------------------------------
# License
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not 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
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-------------------------------------------------------------------------------
if(TARGET CONAN_PKG::cppcheck)
if(CONAN_BIN_DIRS_CPPCHECK_RELEASE)
set(CPPCHECK_DIR ${CONAN_BIN_DIRS_CPPCHECK_RELEASE})
elseif(CONAN_BIN_DIRS_CPPCHECK)
set(CPPCHECK_DIR ${CONAN_BIN_DIRS_CPPCHECK})
endif()
# TODO: Validate that .exes are detected.
if(EXISTS "${CPPCHECK_DIR}/cppcheck")
set(CPPCHECK_COMMAND "${CPPCHECK_DIR}/cppcheck")
endif()
else()
# TODO: Validate that .exes are detected.
find_file(CPPCHECK_COMMAND cppcheck PATHS $ENV{PATH} $ENV{CPPCHECK_DIR})
endif()
if(NOT CPPCHECK_COMMAND)
message(SEND_ERROR
" ERROR: Could not find cppcheck.
Having cppcheck is a mandatory requirement.
CMake will not generate the project without it.
Add its location to the environments variables PATH or CPPCHECK_DIR.")
endif()
function(ADD_TEST_CPPCHECK)
set(options)
set(oneValueArgs NAME)
set(multiValueArgs)
cmake_parse_arguments(ARGS
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
add_test(NAME ${ARGS_NAME}
COMMAND ${CPPCHECK_COMMAND} ${ARGS_UNPARSED_ARGUMENTS})
set_tests_properties(${ARGS_NAME} PROPERTIES TIMEOUT 10.0)
endfunction()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment