mirror of
https://github.com/altlinux/admc.git
synced 2025-01-18 02:04:36 +03:00
Add 'clangformat' target to CMake
... to simplify use of clang-format for formatting the sources, using ClangFormat.cmake module from https://github.com/zemasoft/clangformat-cmake .
This commit is contained in:
parent
e359cdfa1f
commit
0a60e0f422
@ -47,6 +47,7 @@ set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
|
|||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
include(ClangFormat)
|
||||||
|
|
||||||
option(ADMC_BUILD_DEB "Build the deb package of ADMC." OFF)
|
option(ADMC_BUILD_DEB "Build the deb package of ADMC." OFF)
|
||||||
|
|
||||||
|
@ -19,6 +19,13 @@ $ make -j12
|
|||||||
|
|
||||||
If the build fails, check build output for missing dependencies.
|
If the build fails, check build output for missing dependencies.
|
||||||
|
|
||||||
|
You can also format the sources by building `clangformat`
|
||||||
|
target after `cmake` is run, for example:
|
||||||
|
|
||||||
|
```
|
||||||
|
make -C build clangformat
|
||||||
|
```
|
||||||
|
|
||||||
# Usage:
|
# Usage:
|
||||||
|
|
||||||
This app requires a working Active Directory domain and for the client machine to be connected and logged into the domain. You can find articles about these topics on [ALTLinux wiki](https://www.altlinux.org/%D0%94%D0%BE%D0%BC%D0%B5%D0%BD).
|
This app requires a working Active Directory domain and for the client machine to be connected and logged into the domain. You can find articles about these topics on [ALTLinux wiki](https://www.altlinux.org/%D0%94%D0%BE%D0%BC%D0%B5%D0%BD).
|
||||||
|
52
cmake/ClangFormat.cmake
Normal file
52
cmake/ClangFormat.cmake
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# Copyright Tomas Zeman 2019-2020.
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
function(prefix_clangformat_setup prefix)
|
||||||
|
if(NOT CLANGFORMAT_EXECUTABLE)
|
||||||
|
set(CLANGFORMAT_EXECUTABLE clang-format)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT EXISTS ${CLANGFORMAT_EXECUTABLE})
|
||||||
|
find_program(clangformat_executable_tmp ${CLANGFORMAT_EXECUTABLE})
|
||||||
|
if(clangformat_executable_tmp)
|
||||||
|
set(CLANGFORMAT_EXECUTABLE ${clangformat_executable_tmp})
|
||||||
|
unset(clangformat_executable_tmp)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "ClangFormat: ${CLANGFORMAT_EXECUTABLE} not found! Aborting")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(clangformat_source ${ARGN})
|
||||||
|
get_filename_component(clangformat_source ${clangformat_source} ABSOLUTE)
|
||||||
|
list(APPEND clangformat_sources ${clangformat_source})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_custom_target(${prefix}_clangformat
|
||||||
|
COMMAND
|
||||||
|
${CLANGFORMAT_EXECUTABLE}
|
||||||
|
-style=file
|
||||||
|
-i
|
||||||
|
${clangformat_sources}
|
||||||
|
WORKING_DIRECTORY
|
||||||
|
${CMAKE_SOURCE_DIR}
|
||||||
|
COMMENT
|
||||||
|
"Formatting ${prefix} with ${CLANGFORMAT_EXECUTABLE} ..."
|
||||||
|
)
|
||||||
|
|
||||||
|
if(TARGET clangformat)
|
||||||
|
add_dependencies(clangformat ${prefix}_clangformat)
|
||||||
|
else()
|
||||||
|
add_custom_target(clangformat DEPENDS ${prefix}_clangformat)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(clangformat_setup)
|
||||||
|
prefix_clangformat_setup(${PROJECT_NAME} ${ARGN})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(target_clangformat_setup target)
|
||||||
|
get_target_property(target_sources ${target} SOURCES)
|
||||||
|
prefix_clangformat_setup(${target} ${target_sources})
|
||||||
|
endfunction()
|
@ -22,7 +22,7 @@ configure_file("adldap_config.h.in" "adldap_config.h")
|
|||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
|
|
||||||
add_library(adldap SHARED
|
set(ADLDAP_SOURCES
|
||||||
ad_interface.cpp
|
ad_interface.cpp
|
||||||
ad_config.cpp
|
ad_config.cpp
|
||||||
ad_utils.cpp
|
ad_utils.cpp
|
||||||
@ -31,7 +31,11 @@ add_library(adldap SHARED
|
|||||||
ad_filter.cpp
|
ad_filter.cpp
|
||||||
ad_security.cpp
|
ad_security.cpp
|
||||||
gplink.cpp
|
gplink.cpp
|
||||||
|
)
|
||||||
|
prefix_clangformat_setup(adldap ${ADLDAP_SOURCES})
|
||||||
|
|
||||||
|
|
||||||
|
set(ADLDAP_SAMBA_SOURCES
|
||||||
samba/gp_manage.c
|
samba/gp_manage.c
|
||||||
samba/ndr_security.c
|
samba/ndr_security.c
|
||||||
samba/dom_sid.c
|
samba/dom_sid.c
|
||||||
@ -39,7 +43,12 @@ add_library(adldap SHARED
|
|||||||
samba/ndr_misc.c
|
samba/ndr_misc.c
|
||||||
samba/libsmb_xattr.c
|
samba/libsmb_xattr.c
|
||||||
samba/security_descriptor.c
|
samba/security_descriptor.c
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
add_library(adldap SHARED
|
||||||
|
${ADLDAP_SOURCES}
|
||||||
|
${ADLDAP_SAMBA_SOURCES}
|
||||||
adldap.qrc
|
adldap.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -192,6 +192,7 @@ add_executable(admc
|
|||||||
main.cpp
|
main.cpp
|
||||||
${ADMC_SOURCES}
|
${ADMC_SOURCES}
|
||||||
)
|
)
|
||||||
|
target_clangformat_setup(admc)
|
||||||
|
|
||||||
# NOTE: build admc as library to streamline building tests.
|
# NOTE: build admc as library to streamline building tests.
|
||||||
# Tests just link to this lib and use all of admc's code.
|
# Tests just link to this lib and use all of admc's code.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user