allow RelWithDebInfo, improve FindClangTools

SetupCxxFlags.cmake does not list "RELWITHDEBINFO" in the final flag
setup, so cmake will error out if that build config is selected. It's
handy for quick debugging without switching your python build etc over
to "DEBUG".

FindClangTools.cmake could check the version of 'clang-format' (no
version suffix) to see if it satisfies a version requirement.

add note about clang tools path
This commit is contained in:
Benjamin Kietzman authored and Wes McKinney committed 2018-12-19 19:43:20 -06:00
1 parent 1a8c8f0b2a
commit 15526cf012
3 files changed
+32 -4

No files matched your search

+6
View File
@@ -428,6 +428,12 @@ You may find the required packages at http://releases.llvm.org/download.html
or use the Debian/Ubuntu APT repositories on https://apt.llvm.org/. On macOS
with [Homebrew][1] you can get it via `brew install llvm@6`.
Depending on how you installed clang-format, the build system may not be able
to find it. You can provide an explicit path to your LLVM installation (or the
root path for the clang tools) with the environment variable
`$CLANG_TOOLS_PATH` or by passing `-DClangTools_PATH=$PATH_TO_CLANG_TOOLS` when
invoking CMake.
## Checking for ABI and API stability
To build ABI compliance reports, you need to install the two tools
+25 -4
View File
@@ -20,7 +20,7 @@
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# ClangToolsBin_HOME -
# ClangTools_PATH -
# When set, this path is inspected instead of standard library binary locations
# to find clang-tidy and clang-format
#
@@ -75,10 +75,11 @@ if (CLANG_FORMAT_VERSION)
)
# If not found yet, search alternative locations
if (("${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND") AND APPLE)
if ("${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND")
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+" "\\1" CLANG_FORMAT_MAJOR_VERSION "${CLANG_FORMAT_VERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.([0-9]+)" "\\1" CLANG_FORMAT_MINOR_VERSION "${CLANG_FORMAT_VERSION}")
if (APPLE)
# Homebrew ships older LLVM versions in /usr/local/opt/llvm@version/
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+" "\\1" CLANG_FORMAT_MAJOR_VERSION "${CLANG_FORMAT_VERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.([0-9]+)" "\\1" CLANG_FORMAT_MINOR_VERSION "${CLANG_FORMAT_VERSION}")
if ("${CLANG_FORMAT_MINOR_VERSION}" STREQUAL "0")
find_program(CLANG_FORMAT_BIN
NAMES clang-format
@@ -102,7 +103,27 @@ if (CLANG_FORMAT_VERSION)
NO_DEFAULT_PATH
)
endif()
else()
# try searching for "clang-format" and check the version
find_program(CLANG_FORMAT_BIN
NAMES clang-format
PATHS
${ClangTools_PATH}
$ENV{CLANG_TOOLS_PATH}
/usr/local/bin /usr/bin
NO_DEFAULT_PATH
)
if (NOT ("${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND"))
execute_process(COMMAND ${CLANG_FORMAT_BIN} "-version"
OUTPUT_VARIABLE CLANG_FORMAT_FOUND_VERSION_MESSAGE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT ("${CLANG_FORMAT_FOUND_VERSION_MESSAGE}" MATCHES "^clang-format version ${CLANG_FORMAT_MAJOR_VERSION}\\.${CLANG_FORMAT_MINOR_VERSION}.*"))
set(CLANG_FORMAT_BIN "CLANG_FORMAT_BIN-NOTFOUND")
endif()
endif()
endif()
endif()
else()
find_program(CLANG_FORMAT_BIN
NAMES clang-format-4.0
+1
View File
@@ -365,6 +365,7 @@ message("Configured for ${CMAKE_BUILD_TYPE} build (set with cmake -DCMAKE_BUILD_
if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAGS_DEBUG}")
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RELWITHDEBINFO")
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "FASTDEBUG")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS_FASTDEBUG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAGS_FASTDEBUG}")