Skip to content

Commit

Permalink
Squashed 'cmake/' changes from 0875d124..ad436ee7
Browse files Browse the repository at this point in the history
ad436ee7 Add creator's update windows SDK to search directories.
6c3c6b0a Merge branch 'nickbroon-improve-cppcheck'
58843aef CppcheckTargets: update credits
66fe49e8 CppcheckTargets: fix indents
7638eb54 Rename convenience target back to all_cppcheck from cppcheck.
35e68230 Update requirement info for CppcheckTargets
065ecf13 Merge branch 'improve-cppcheck' of https://github.com/nickbroon/cmake-modules into nickbroon-improve-cppcheck
98e28d2f Merge pull request #44 from AlessandroMenti/boost-test-targets-check-fix
82e5a292 Merge pull request #45 from noma/master
deca4d3d Added git_local_changes() to GetGitRevisionDescription.cmake
08987b54 Update to stash map config to make it actually properly push and pop
c330929f New module: stash map config.
8a18a1b4 Add new InstallDebugSymbols module.
30573d30 Small JsonCpp cleanup.
2ef829da Fix "no target to set property" error in FindJsonCpp
997754e2 Fix wrong check in BoostTestTargets.cmake
41e16511 libusb1 enhancements from VRPN
7ef3955d Fixes to FindWindowsSDK so it doesn't return TRUE as the first element of every directory list.
a4974827 Fix indentation and accidentally-left-in debug messages in FindDirectShow
b43b5e27 Bug fix in backported FindGit.
7c8c7925 Add a greatly enhanced FindGLEW (for CMake 2.8.12+), based on the upstream.
ec0c486f Add the Windows 10 1607 "Anniversary Update" SDK version to the WindowsSDK list.
7dc51986 Fix building against jsoncpp when the build types don't exactly match.
1932f85b Return to more conservative default settings.
b1d2d88b cppcheck will check C as well as C++
a4561deb Improvements on cppcheck

git-subtree-dir: cmake
git-subtree-split: ad436ee7be33ca291a59866a173b777b0e2d81ce
  • Loading branch information
rpavlik committed Aug 7, 2017
1 parent 2680388 commit 8546db8
Show file tree
Hide file tree
Showing 12 changed files with 439 additions and 56 deletions.
2 changes: 1 addition & 1 deletion BoostTestTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function(add_boost_test _name)
endforeach()

if(NOT _boostTestTargetsNagged${_name} STREQUAL "${includeType}")
if("includeType" STREQUAL "CONFIGURED")
if("${includeType}" STREQUAL "CONFIGURED")
message(STATUS
"Test '${_name}' uses the CMake-configurable form of the boost test framework - congrats! (Including File: ${includeFileLoc})")
elseif("${includeType}" STREQUAL "INCLUDED")
Expand Down
44 changes: 27 additions & 17 deletions CppcheckTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
# Requires these CMake modules:
# Findcppcheck
#
# Requires CMake 2.6 or newer (uses the 'function' command)
# Requires CMake 2.8 or newer (uses VERSION_LESS)
#
# Original Author:
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Copyright Anthony Pesch 2014
# Copyright Stefan Eilemann 2014
# Copyright Nicholas Brown 2015
# Copyright Ryan Pavlik 2017
# 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)
Expand All @@ -30,16 +34,24 @@ if(NOT CPPCHECK_FOUND)
find_package(cppcheck QUIET)
endif()

if(CPPCHECK_FOUND)
if(NOT TARGET all_cppcheck)
add_custom_target(all_cppcheck)
set_target_properties(all_cppcheck PROPERTIES EXCLUDE_FROM_ALL TRUE)
endif()
if(NOT CPPCHECK_FOUND)
add_custom_target(all_cppcheck
COMMENT "cppcheck executable not found")
set_target_properties(all_cppcheck PROPERTIES EXCLUDE_FROM_ALL TRUE)
elseif(CPPCHECK_VERSION VERSION_LESS 1.53.0)
add_custom_target(all_cppcheck
COMMENT "Need at least cppcheck 1.53, found ${CPPCHECK_VERSION}")
set_target_properties(all_cppcheck PROPERTIES EXCLUDE_FROM_ALL TRUE)
set(CPPCHECK_FOUND)
endif()

if(NOT TARGET all_cppcheck)
add_custom_target(all_cppcheck)
endif()

function(add_cppcheck_sources _targetname)
if(CPPCHECK_FOUND)
set(_cppcheck_args)
set(_cppcheck_args -I ${CMAKE_SOURCE_DIR} ${CPPCHECK_EXTRA_ARGS})
set(_input ${ARGN})
list(FIND _input UNUSED_FUNCTIONS _unused_func)
if("${_unused_func}" GREATER "-1")
Expand Down Expand Up @@ -79,7 +91,7 @@ function(add_cppcheck_sources _targetname)
if(_cppcheck_loc)
# This file has a source file property, carry on.
get_source_file_property(_cppcheck_lang "${_source}" LANGUAGE)
if("${_cppcheck_lang}" MATCHES "CXX")
if(("${_cppcheck_lang}" STREQUAL "C") OR ("${_cppcheck_lang}" STREQUAL "CXX"))
list(APPEND _files "${_cppcheck_loc}")
endif()
else()
Expand Down Expand Up @@ -119,9 +131,7 @@ function(add_cppcheck_sources _targetname)
FAIL_REGULAR_EXPRESSION
"${CPPCHECK_FAIL_REGULAR_EXPRESSION}")

add_custom_command(TARGET
all_cppcheck
PRE_BUILD
add_custom_target(${_targetname}_cppcheck
COMMAND
${CPPCHECK_EXECUTABLE}
${CPPCHECK_QUIET_ARG}
Expand All @@ -133,6 +143,7 @@ function(add_cppcheck_sources _targetname)
COMMENT
"${_targetname}_cppcheck: Running cppcheck on target ${_targetname}..."
VERBATIM)
add_dependencies(cppcheck ${_targetname}_cppcheck)
endif()
endfunction()

Expand All @@ -142,7 +153,7 @@ function(add_cppcheck _name)
"add_cppcheck given a target name that does not exist: '${_name}' !")
endif()
if(CPPCHECK_FOUND)
set(_cppcheck_args)
set(_cppcheck_args -I ${CMAKE_SOURCE_DIR} ${CPPCHECK_EXTRA_ARGS})

list(FIND ARGN UNUSED_FUNCTIONS _unused_func)
if("${_unused_func}" GREATER "-1")
Expand Down Expand Up @@ -183,7 +194,7 @@ function(add_cppcheck _name)
foreach(_source ${_cppcheck_sources})
get_source_file_property(_cppcheck_lang "${_source}" LANGUAGE)
get_source_file_property(_cppcheck_loc "${_source}" LOCATION)
if("${_cppcheck_lang}" MATCHES "CXX")
if(("${_cppcheck_lang}" STREQUAL "C") OR ("${_cppcheck_lang}" STREQUAL "CXX"))
list(APPEND _files "${_cppcheck_loc}")
endif()
endforeach()
Expand Down Expand Up @@ -211,9 +222,7 @@ function(add_cppcheck _name)
FAIL_REGULAR_EXPRESSION
"${CPPCHECK_FAIL_REGULAR_EXPRESSION}")

add_custom_command(TARGET
all_cppcheck
PRE_BUILD
add_custom_target(${_name}_cppcheck
COMMAND
${CPPCHECK_EXECUTABLE}
${CPPCHECK_QUIET_ARG}
Expand All @@ -226,6 +235,7 @@ function(add_cppcheck _name)
COMMENT
"${_name}_cppcheck: Running cppcheck on target ${_name}..."
VERBATIM)
add_dependencies(all_cppcheck ${_name}_cppcheck)
endif()

endfunction()
18 changes: 9 additions & 9 deletions FindDirectShow.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ _directshow_check_current_qedit()
# Compose a list of possible directories that might hold a qedit.h file.
set(DIRECTSHOW_QEDIT_SEARCH)
if(WINDOWSSDK_FOUND AND NOT DIRECTSHOW_QEDIT_INCLUDE_DIR)
foreach(_sdk ${WINDOWSSDK_DIRS})
foreach(_sdk ${WINDOWSSDK_DIRS})
windowssdk_build_lookup("${_sdk}" _build)
if(_build AND ("${_build}" VERSION_LESS 6.2))
get_windowssdk_include_dirs("${_sdk}" _dirs)
if(_dirs)
list(APPEND DIRECTSHOW_QEDIT_SEARCH ${_dirs})
endif()
get_windowssdk_include_dirs("${_sdk}" _dirs)
if(_dirs)
list(APPEND DIRECTSHOW_QEDIT_SEARCH ${_dirs})
endif()
endif()
endforeach()
endforeach()
endif()

# This one we can grab from another SDK version.
Expand Down Expand Up @@ -149,14 +149,14 @@ endif()

set(DIRECTSHOW_STRMIIDS_SEARCH)
if(WINDOWSSDK_FOUND AND NOT DIRECTSHOW_STRMIIDS_LIBRARY)
foreach(_sdk ${WINDOWSSDK_DIRS})
foreach(_sdk ${WINDOWSSDK_DIRS})
get_windowssdk_library_dirs("${_sdk}" _dirs)
message(STATUS "- ${_dirs}")
if(_dirs)
list(APPEND DIRECTSHOW_STRMIIDS_SEARCH ${_dirs})
endif()
endforeach()
endforeach()
endif()

find_library(DIRECTSHOW_STRMIIDS_LIBRARY
NAMES
strmiids
Expand Down
132 changes: 132 additions & 0 deletions FindGLEW.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#.rst:
# FindGLEW
# --------
#
# Find the OpenGL Extension Wrangler Library (GLEW)
#
# IMPORTED Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines the :prop_tgt:`IMPORTED` target ``GLEW::GLEW``,
# if GLEW has been found.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module defines the following variables:
#
# ::
#
# GLEW_INCLUDE_DIRS - include directories for GLEW
# GLEW_LIBRARIES - libraries to link against GLEW
# GLEW_FOUND - true if GLEW has been found and can be used

#=============================================================================
# Copyright 2012 Benjamin Eikel
# Copyright 2016 Ryan Pavlik
#
# Distributed under the OSI-approved BSD License (the "License");
# see below.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the names of Kitware, Inc., the Insight Software Consortium,
# nor the names of their contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================

find_path(GLEW_INCLUDE_DIR GL/glew.h)
if(WIN32)
# TODO how to make this exclude arm?
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(GLEW_ARCH Win32)
else()
set(GLEW_ARCH x64)
endif()
set(GLEW_EXTRA_SUFFIXES lib/Release/${GLEW_ARCH} bin/Release/${GLEW_ARCH})
endif()

if(WIN32 AND GLEW_INCLUDE_DIR)
get_filename_component(GLEW_LIB_ROOT_CANDIDATE "${GLEW_INCLUDE_DIR}/.." ABSOLUTE)
endif()

find_library(GLEW_LIBRARY
NAMES GLEW glew32 glew glew32s
PATH_SUFFIXES lib64 ${GLEW_EXTRA_SUFFIXES}
HINTS "${GLEW_LIB_ROOT_CANDIDATE}")

if(WIN32 AND GLEW_LIBRARY AND NOT GLEW_LIBRARY MATCHES ".*s.lib")
get_filename_component(GLEW_LIB_DIR "${GLEW_LIBRARY}" DIRECTORY)
get_filename_component(GLEW_BIN_ROOT_CANDIDATE1 "${GLEW_LIB_DIR}/.." ABSOLUTE)
get_filename_component(GLEW_BIN_ROOT_CANDIDATE2 "${GLEW_LIB_DIR}/../../.." ABSOLUTE)
find_file(GLEW_RUNTIME_LIBRARY
NAMES glew32.dll
PATH_SUFFIXES bin ${GLEW_EXTRA_SUFFIXES}
HINTS
"${GLEW_BIN_ROOT_CANDIDATE1}"
"${GLEW_BIN_ROOT_CANDIDATE2}")
endif()

set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR})
set(GLEW_LIBRARIES ${GLEW_LIBRARY})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLEW
REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY)

if(GLEW_FOUND AND NOT TARGET GLEW::GLEW)
if(WIN32 AND GLEW_LIBRARY MATCHES ".*s.lib")
# Windows, known static library.
add_library(GLEW::GLEW STATIC IMPORTED)
set_target_properties(GLEW::GLEW PROPERTIES
IMPORTED_LOCATION "${GLEW_LIBRARY}"
PROPERTY INTERFACE_COMPILE_DEFINITIONS GLEW_STATIC)

elseif(WIN32 AND GLEW_RUNTIME_LIBRARY)
# Windows, known dynamic library and we have both pieces
# TODO might be different for mingw
add_library(GLEW::GLEW SHARED IMPORTED)
set_target_properties(GLEW::GLEW PROPERTIES
IMPORTED_LOCATION "${GLEW_RUNTIME_LIBRARY}"
IMPORTED_IMPLIB "${GLEW_LIBRARY}")
else()

# Anything else - previous behavior.
add_library(GLEW::GLEW UNKNOWN IMPORTED)
set_target_properties(GLEW::GLEW PROPERTIES
IMPORTED_LOCATION "${GLEW_LIBRARY}")
endif()

set_target_properties(GLEW::GLEW PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}")

endif()

mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY GLEW_RUNTIME_LIBRARY)
24 changes: 22 additions & 2 deletions FindJsonCpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ macro(_jsoncpp_check_for_real_jsoncpplib)
set(__jsoncpp_have_jsoncpplib FALSE)
if(TARGET jsoncpp_lib)
get_property(__jsoncpp_lib_type TARGET jsoncpp_lib PROPERTY TYPE)
#message(STATUS "__jsoncpp_lib_type ${__jsoncpp_lib_type}")
# We make interface libraries. If an actual config module made it, it would be an imported library.
if(NOT __jsoncpp_lib_type STREQUAL "INTERFACE_LIBRARY")
#message("have jsoncpp_lib and we didn't invent it ourselves")
set(__jsoncpp_have_jsoncpplib TRUE)
endif()
endif()
#message(STATUS "__jsoncpp_have_jsoncpplib ${__jsoncpp_have_jsoncpplib}")
endmacro()

include(FindPackageHandleStandardArgs)
# Ensure that if this is TRUE later, it's because we set it.
set(JSONCPP_FOUND FALSE)
set(__jsoncpp_have_jsoncpplib FALSE)

# See if we find a CMake config file - there is no harm in calling this more than once,
# and we need to call it at least once every CMake invocation to create the original
Expand All @@ -71,14 +71,34 @@ if(jsoncpp_FOUND)

# part of the string to indicate if we found a real jsoncpp_lib (and what kind)
_jsoncpp_check_for_real_jsoncpplib()

macro(_jsoncpp_apply_map_config target)
if(MSVC)
# Can't do this - different runtimes, incompatible ABI, etc.
set(_jsoncpp_debug_fallback)
else()
set(_jsoncpp_debug_fallback DEBUG)
#osvr_stash_map_config(DEBUG DEBUG RELWITHDEBINFO RELEASE MINSIZEREL NONE)
endif()
# Appending, just in case using project or upstream fixes this.
set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_RELEASE RELEASE RELWITHDEBINFO MINSIZEREL NONE ${_jsoncpp_debug_fallback})
set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELWITHDEBINFO RELEASE MINSIZEREL NONE ${_jsoncpp_debug_fallback})
set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_MINSIZEREL MINSIZEREL RELEASE RELWITHDEBINFO NONE ${_jsoncpp_debug_fallback})
set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_NONE RELEASE RELWITHDEBINFO MINSIZEREL ${_jsoncpp_debug_fallback})
if(NOT MSVC)
set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_DEBUG DEBUG RELWITHDEBINFO RELEASE MINSIZEREL NONE)
endif()
endmacro()
if(__jsoncpp_have_jsoncpplib)
list(APPEND __jsoncpp_info_string "[${__jsoncpp_lib_type}]")
_jsoncpp_apply_map_config(jsoncpp_lib)
else()
list(APPEND __jsoncpp_info_string "[]")
endif()
# part of the string to indicate if we found jsoncpp_lib_static
if(TARGET jsoncpp_lib_static)
list(APPEND __jsoncpp_info_string "[T]")
_jsoncpp_apply_map_config(jsoncpp_lib_static)
else()
list(APPEND __jsoncpp_info_string "[]")
endif()
Expand Down
8 changes: 6 additions & 2 deletions FindLibusb1.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ if(WIN32)
program_files_fallback_glob(_dirs "LibUSB-Win32")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
if(MSVC)
set(_lib_suffixes lib/msvc_x64)
set(_lib_suffixes lib/msvc_x64 MS64/static)
endif()
else()
if(MSVC)
set(_lib_suffixes lib/msvc)
set(_lib_suffixes lib/msvc MS32/static)
elseif(COMPILER_IS_GNUCXX)
set(_lib_suffixes lib/gcc)
endif()
Expand All @@ -62,16 +62,20 @@ find_path(LIBUSB1_INCLUDE_DIR
HINTS
"${LIBUSB1_ROOT_DIR}"
PATH_SUFFIXES
include/libusb-1.0
include
libusb-1.0)

find_library(LIBUSB1_LIBRARY
NAMES
libusb-1.0
usb-1.0
PATHS
${PC_LIBUSB1_LIBRARY_DIRS}
${PC_LIBUSB1_LIBDIR}
${_dirs}
HINTS
"${LIBUSB1_ROOT_DIR}"
PATH_SUFFIXES
${_lib_suffixes})

Expand Down
Loading

0 comments on commit 8546db8

Please sign in to comment.