加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMakeLists.txt 3.15 KB
一键复制 编辑 原始数据 按行查看 历史
Chris Lalancette 提交于 2021-12-17 13:24 . Update to uncrustify 0.72 (#27)
cmake_minimum_required(VERSION 3.10)
project(uncrustify_vendor)
option(FORCE_BUILD_VENDOR_PKG
"Build uncrustify from source, even if system-installed package is available"
OFF)
find_package(ament_cmake REQUIRED)
macro(build_uncrustify)
set(extra_cmake_args)
if(DEFINED CMAKE_BUILD_TYPE)
list(APPEND extra_cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
endif()
if(DEFINED CMAKE_TOOLCHAIN_FILE)
list(APPEND extra_cmake_args "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
if(ANDROID)
if(DEFINED ANDROID_ABI)
list(APPEND extra_cmake_args "-DANDROID_ABI=${ANDROID_ABI}")
endif()
if(DEFINED ANDROID_CPP_FEATURES)
list(APPEND extra_cmake_args "-DANDROID_CPP_FEATURES=${ANDROID_CPP_FEATURES}")
endif()
if(DEFINED ANDROID_FUNCTION_LEVEL_LINKING)
list(APPEND extra_cmake_args "-DANDROID_FUNCTION_LEVEL_LINKING=${ANDROID_FUNCTION_LEVEL_LINKING}")
endif()
if(DEFINED ANDROID_NATIVE_API_LEVEL)
list(APPEND extra_cmake_args "-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL}")
endif()
if(DEFINED ANDROID_NDK)
list(APPEND extra_cmake_args "-DANDROID_NDK=${ANDROID_NDK}")
endif()
if(DEFINED ANDROID_STL)
list(APPEND extra_cmake_args "-DANDROID_STL=${ANDROID_STL}")
endif()
if(DEFINED ANDROID_TOOLCHAIN_NAME)
list(APPEND extra_cmake_args "-DANDROID_TOOLCHAIN_NAME=${ANDROID_TOOLCHAIN_NAME}")
endif()
endif()
endif()
include(ExternalProject)
# Get uncrustify 0.72.0
ExternalProject_Add(uncrustify-0.72.0
GIT_REPOSITORY https://github.com/uncrustify/uncrustify.git
GIT_TAG uncrustify-0.72.0
GIT_CONFIG advice.detachedHead=false
# Suppress git update due to https://gitlab.kitware.com/cmake/cmake/-/issues/16419
# See https://github.com/ament/uncrustify_vendor/pull/22 for details
UPDATE_COMMAND ""
TIMEOUT 600
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_install
${extra_cmake_args}
-Wno-dev
PATCH_COMMAND
${CMAKE_COMMAND} -E chdir <SOURCE_DIR> git apply -p1 --ignore-space-change --whitespace=nowarn ${CMAKE_CURRENT_SOURCE_DIR}/install-patch.diff
)
# The external project will install to the build folder, but we'll install that on make install.
install(
DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_install/
DESTINATION
${CMAKE_INSTALL_PREFIX}
USE_SOURCE_PERMISSIONS
)
endmacro()
execute_process(
COMMAND uncrustify --version
RESULT_VARIABLE res
OUTPUT_VARIABLE out
ERROR_VARIABLE err
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
set(need_local_build FALSE)
if(NOT res EQUAL 0)
set(need_local_build TRUE)
else()
# Before 0.65 uncrustify used a different versioning scheme so the regex won't match
string(REGEX REPLACE "^Uncrustify-(.*)_f$" "\\1" version_prefix_match "${out}")
if(version_prefix_match STREQUAL "" OR version_prefix_match VERSION_LESS 0.72)
set(need_local_build TRUE)
endif()
endif()
if(FORCE_BUILD_VENDOR_PKG OR need_local_build)
build_uncrustify()
endif()
# this ensures that the package has an environment hook setting the PATH
ament_package()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化