mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-10 22:05:06 +00:00
cmake: Use shared submodule for Clang integration
This commit is contained in:
parent
5956a6f7a9
commit
cbb6c4f785
4 changed files with 7 additions and 82 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "cmake/clang"]
|
||||
path = cmake/clang
|
||||
url = https://github.com/Xaymar/cmake-clang.git
|
|
@ -65,11 +65,11 @@ set(PROJECT_COPYRIGHT_YEARS "2018 - 2020")
|
|||
################################################################################
|
||||
|
||||
# Search Path
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/clang" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
# CMake Modules
|
||||
include("util")
|
||||
include("ClangToolkit")
|
||||
include("Clang")
|
||||
|
||||
# Detect Build Type
|
||||
if("${CMAKE_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
|
||||
|
@ -528,6 +528,7 @@ add_library(${PROJECT_NAME} MODULE
|
|||
clang_format(
|
||||
TARGETS ${PROJECT_NAME}
|
||||
DEPENDENCY
|
||||
VERSION 9.0.0
|
||||
)
|
||||
|
||||
# Include Directories
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
set(CLANG_PATH "" CACHE PATH "Path to Clang Toolset (if not in environment)")
|
||||
|
||||
function(clang_format)
|
||||
cmake_parse_arguments(
|
||||
PARSE_ARGV 0
|
||||
_CLANG_FORMAT
|
||||
"DEPENDENCY;GLOBAL"
|
||||
"REGEX"
|
||||
"TARGETS"
|
||||
)
|
||||
|
||||
find_program(CLANG_FORMAT_BIN
|
||||
"clang-format"
|
||||
HINTS
|
||||
${CLANG_PATH}
|
||||
PATHS
|
||||
/bin
|
||||
/sbin
|
||||
/usr/bin
|
||||
/usr/local/bin
|
||||
PATH_SUFFIXES
|
||||
bin
|
||||
bin64
|
||||
bin32
|
||||
)
|
||||
if(NOT CLANG_FORMAT_BIN)
|
||||
message(WARNING "Clang: Could not find clang-format at path '${CLANG_FORMAT_BIN}'. Disabling clang-format...")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT _CLANG_FORMAT_FILTER)
|
||||
set(_CLANG_FORMAT_FILTER "\.(h|hpp|c|cpp)$")
|
||||
endif()
|
||||
|
||||
foreach(_target ${_CLANG_FORMAT_TARGETS})
|
||||
# get_target_property(target_name ${_target} NAME)
|
||||
|
||||
get_target_property(target_sources_rel ${_target} SOURCES)
|
||||
set(target_sources "")
|
||||
foreach(source_relative ${target_sources_rel})
|
||||
get_filename_component(source_absolute ${source_relative} ABSOLUTE)
|
||||
list(APPEND target_sources ${source_absolute})
|
||||
endforeach()
|
||||
list(FILTER target_sources INCLUDE REGEX "${_CLANG_FORMAT_FILTER}")
|
||||
unset(target_sources_rel)
|
||||
|
||||
get_target_property(target_source_dir_rel ${_target} SOURCE_DIR)
|
||||
get_filename_component(target_source_dir ${target_source_dir_rel} ABSOLUTE)
|
||||
unset(target_source_dir_rel)
|
||||
|
||||
add_custom_target(${_target}_CLANG-FORMAT
|
||||
COMMAND
|
||||
${CLANG_FORMAT_BIN}
|
||||
-style=file
|
||||
-i
|
||||
${target_sources}
|
||||
COMMENT
|
||||
"clang-format: Formatting ${_target}..."
|
||||
WORKING_DIRECTORY
|
||||
${target_source_dir_rel}
|
||||
)
|
||||
|
||||
if(_CLANG_FORMAT_DEPENDENCY)
|
||||
add_dependencies(${_target} ${_target}_CLANG-FORMAT)
|
||||
endif()
|
||||
|
||||
if(_CLANG_FORMAT_GLOBAL)
|
||||
if(TARGET CLANG-FORMAT)
|
||||
add_dependencies(CLANG-FORMAT ${_target}_CLANG-FORMAT)
|
||||
else()
|
||||
add_custom_target(CLANG-FORMAT
|
||||
DEPENDS
|
||||
${_target}_CLANG-FORMAT
|
||||
COMMENT
|
||||
"clang-format: Formatting..."
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
1
cmake/clang
Submodule
1
cmake/clang
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 9166c8a575a2a6bf4c029cfefc84d4bbe62befc5
|
Loading…
Reference in a new issue