Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ag-ohlberger
dune-community
dune-xt
Commits
64c7f447
Unverified
Commit
64c7f447
authored
8 years ago
by
René Fritze
Browse files
Options
Downloads
Patches
Plain Diff
[WIP,cmake] rewire clang format discovery
parent
58048183
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmake/modules/DuneXtCommonMacros.cmake
+18
-18
18 additions, 18 deletions
cmake/modules/DuneXtCommonMacros.cmake
cmake/modules/FindClangFormat.cmake
+29
-0
29 additions, 0 deletions
cmake/modules/FindClangFormat.cmake
with
47 additions
and
18 deletions
cmake/modules/DuneXtCommonMacros.cmake
+
18
−
18
View file @
64c7f447
...
...
@@ -46,25 +46,25 @@ macro(add_analyze)
endif
(
EXISTS
${
ANALYZER
}
)
endmacro
(
add_analyze
)
find_package
(
ClangFormat 3.7
)
macro
(
add_format
)
find_program
(
FORMAT NAMES clang-format clang-format-3.4 clang-format-3.5 clang-format-3.6 clang-format-3.7 clang-format-3.8 clang-format-3.9
)
if
(
EXISTS
${
FORMAT
}
)
message
(
STATUS
"adding format target"
)
if
(
NOT TARGET format
)
add_custom_target
(
format SOURCES
${
ARGN
}
)
endif
(
NOT TARGET format
)
foreach
(
_file
${
ARGN
}
)
string
(
REPLACE
"/"
"_"
fn
${
_file
}
)
if
(
NOT EXISTS
${
_file
}
)
# 'fix' relative source defs
set
(
_file
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
_file
}
)
endif
(
NOT EXISTS
${
_file
}
)
add_custom_target
(
"format_
${
fn
}
"
${
FORMAT
}
-i -style=file
${
_file
}
)
add_dependencies
(
format
"format_
${
fn
}
"
)
endforeach
(
_file
)
else
()
message
(
WARNING
"not adding format target because clang-format is missing"
)
endif
(
EXISTS
${
FORMAT
}
)
if
(
CLANG_FORMAT_FOUND
)
message
(
STATUS
"adding format target"
)
if
(
NOT TARGET format
)
add_custom_target
(
format SOURCES
${
ARGN
}
)
endif
(
NOT TARGET format
)
foreach
(
_file
${
ARGN
}
)
string
(
REPLACE
"/"
"_"
fn
${
_file
}
)
if
(
NOT EXISTS
${
_file
}
)
# 'fix' relative source defs
set
(
_file
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
_file
}
)
endif
(
NOT EXISTS
${
_file
}
)
add_custom_target
(
"format_
${
fn
}
"
${
CLANG_FORMAT_BINARY
}
-i -style=file
${
_file
}
)
add_dependencies
(
format
"format_
${
fn
}
"
)
endforeach
(
_file
)
else
()
message
(
WARNING
"not adding format target because clang-format is missing"
)
endif
(
CLANG_FORMAT_FOUND
)
endmacro
(
add_format
)
macro
(
add_forced_doxygen_target
)
...
...
This diff is collapsed.
Click to expand it.
cmake/modules/FindClangFormat.cmake
0 → 100644
+
29
−
0
View file @
64c7f447
# Use this module by invoking find_package with the form::
#
# find_package(ClangFormat
# [version] # Minimum version e.g. 3.7
# )
#
# optionally pass the minimal version you require like so find_package(ClangFormat 3.7)
# this module set CLANG_FORMAT_EXECUTABLE, CLANG_FORMAT_VERSION
# and CLANG_FORMAT_FOUND accordingly
#
set
(
CLANG_FORMAT_FOUND 0
)
find_program
(
format_binary NAMES clang-format clang-format-3.6 clang-format-3.7 clang-format-3.8 clang-format-3.9 clang-format-4.0
)
if
(
EXISTS
${
format_binary
}
)
execute_process
(
COMMAND
${
format_binary
}
-version OUTPUT_VARIABLE clang_out
)
message
(
"clang verison out"
${
clang_out
}
)
string
(
REGEX REPLACE
".*clang-format version ([0-9]+
\\
.[0-9]+).*"
"
\\
1"
CLANG_FORMAT_VERSION
${
clang_out
}
)
set
(
CLANG_FORMAT_FOUND 1
)
set
(
CLANG_FORMAT_EXECUTABLE
${
format_binary
}
)
if
(
optional argument passed
)
check match with CLANG_FORMAT_VERSION
if
(
not matched
)
message
(
INFO
"Requested clang-format >= arg_passed, found
${
CLANG_FORMAT_VERSION
}
"
set
(
CLANG_FORMAT_FOUND 0
)
endif
()
endif
()
#message("clang-format executable: ${CLANG_FORMAT_EXECUTABLE}")
#message("clang-format version: ${CLANG_FORMAT_VERSION}")
endif
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment