Skip to content

Commit e43ecbf

Browse files
author
Terry Cojean
committed
Add editorconfig support. Fix CMake indent issues.
1 parent 617fb36 commit e43ecbf

File tree

13 files changed

+230
-207
lines changed

13 files changed

+230
-207
lines changed

.editorconfig

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# More info: https://editorconfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Use space and 4 indentation style everywhere.
7+
# Also add a newline at the end of every file.
8+
[*]
9+
charset = utf-8
10+
end_of_line = lf
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
indent_style = space
14+
indent_size = 4
15+
16+
# YAML files use 2 space indentation for now.
17+
[*.{yml,md}]
18+
indent_style = space
19+
indent_size = 2
20+
21+
# Makefiles require tabs
22+
[Makefile]
23+
indent_style = tab

CMakeLists.txt

+11-11
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ if(GINKGO_BUILD_TESTS AND (GINKGO_BUILD_CUDA OR GINKGO_BUILD_OMP OR GINKGO_BUILD
7171
endif()
7272

7373
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
74-
message(STATUS "Setting build type to 'Release' as none was specified.")
75-
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
74+
message(STATUS "Setting build type to 'Release' as none was specified.")
75+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
7676
endif()
7777

7878
if(BUILD_SHARED_LIBS)
@@ -100,11 +100,11 @@ if(GINKGO_BUILD_TESTS)
100100
endif()
101101

102102
if(GINKGO_WITH_CLANG_TIDY)
103-
find_program(GINKGO_CLANG_TIDY_PATH clang-tidy)
103+
find_program(GINKGO_CLANG_TIDY_PATH clang-tidy)
104104
endif()
105105

106106
if(GINKGO_WITH_IWYU)
107-
find_program(GINKGO_IWYU_PATH iwyu)
107+
find_program(GINKGO_IWYU_PATH iwyu)
108108
endif()
109109

110110
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
@@ -227,13 +227,13 @@ if(NOT "${BASH}" STREQUAL "BASH-NOTFOUND" AND GINKGO_DEVEL_TOOLS)
227227
endif()
228228
unset(GIT CACHE)
229229
add_custom_target(format_header_all
230-
COMMAND echo "format header on all code files except build/examples/third_party/ginkgo.hpp"
231-
COMMAND bash -c "find * -type f | \
230+
COMMAND echo "format header on all code files except build/examples/third_party/ginkgo.hpp"
231+
COMMAND bash -c "find * -type f | \
232232
grep -Ev 'build|examples|third_party|ginkgo.hpp' | \
233233
grep -E '(\.hip)?\.(cu|hpp|cuh|cpp)$' | \
234234
xargs -r -n1 ${Ginkgo_SOURCE_DIR}/dev_tools/scripts/format_header.sh"
235-
WORKING_DIRECTORY ${Ginkgo_SOURCE_DIR}
236-
VERBATIM)
235+
WORKING_DIRECTORY ${Ginkgo_SOURCE_DIR}
236+
VERBATIM)
237237
endif()
238238
unset(BASH CACHE)
239239

@@ -270,9 +270,9 @@ else()
270270
endif()
271271
add_custom_target(test_install
272272
COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -H${Ginkgo_SOURCE_DIR}/test_install
273-
-B${Ginkgo_BINARY_DIR}/test_install
274-
-DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}/${GINKGO_INSTALL_CONFIG_DIR}
275-
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
273+
-B${Ginkgo_BINARY_DIR}/test_install
274+
-DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}/${GINKGO_INSTALL_CONFIG_DIR}
275+
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
276276
# `--config cfg` is ignored by single-configuration generator.
277277
# `$<CONFIG>` is always be the same as `CMAKE_BUILD_TYPE` in single-configuration generator.
278278
COMMAND ${CMAKE_COMMAND} --build ${Ginkgo_BINARY_DIR}/test_install --config $<CONFIG>

benchmark/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ if (NOT CMAKE_BUILD_TYPE STREQUAL "Release")
55
endif()
66

77
if (GINKGO_BUILD_CUDA AND GINKGO_BUILD_HIP AND GINKGO_HIP_PLATFORM MATCHES "hcc")
8-
message(FATAL_ERROR "Building the benchmarks for both HIP AMD and CUDA "
9-
"at the same time is currently not supported. "
10-
"Disable the benchmark build using `-DGINKGO_BUILD_BENCHMARKS=OFF` "
11-
"or use `export HIP_PLATFORM=nvcc` in your build environment instead.")
8+
message(FATAL_ERROR "Building the benchmarks for both HIP AMD and CUDA "
9+
"at the same time is currently not supported. "
10+
"Disable the benchmark build using `-DGINKGO_BUILD_BENCHMARKS=OFF` "
11+
"or use `export HIP_PLATFORM=nvcc` in your build environment instead.")
1212
endif()
1313

1414
function(ginkgo_benchmark_cusp_linops name)

cmake/create_test.cmake

+35-35
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
function(ginkgo_create_test test_name)
22
file(RELATIVE_PATH REL_BINARY_DIR
3-
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
3+
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
44
string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_name}")
55
add_executable(${TEST_TARGET_NAME} ${test_name}.cpp)
66
target_include_directories("${TEST_TARGET_NAME}"
77
PRIVATE
8-
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
8+
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
99
)
1010
set_target_properties(${TEST_TARGET_NAME} PROPERTIES
1111
OUTPUT_NAME ${test_name})
@@ -17,34 +17,34 @@ function(ginkgo_create_test test_name)
1717
endfunction(ginkgo_create_test)
1818

1919
function(ginkgo_create_thread_test test_name)
20-
set(THREADS_PREFER_PTHREAD_FLAG ON)
21-
find_package(Threads REQUIRED)
22-
file(RELATIVE_PATH REL_BINARY_DIR
23-
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
24-
string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_name}")
25-
add_executable(${TEST_TARGET_NAME} ${test_name}.cpp)
26-
target_include_directories("${TEST_TARGET_NAME}"
27-
PRIVATE
28-
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
29-
)
30-
set_target_properties(${TEST_TARGET_NAME} PROPERTIES
31-
OUTPUT_NAME ${test_name})
32-
if (GINKGO_CHECK_CIRCULAR_DEPS)
33-
target_link_libraries(${TEST_TARGET_NAME} PRIVATE "${GINKGO_CIRCULAR_DEPS_FLAGS}")
34-
endif()
35-
target_link_libraries(${TEST_TARGET_NAME} PRIVATE ginkgo GTest::Main GTest::GTest Threads::Threads ${ARGN})
36-
add_test(NAME ${REL_BINARY_DIR}/${test_name} COMMAND ${TEST_TARGET_NAME})
20+
set(THREADS_PREFER_PTHREAD_FLAG ON)
21+
find_package(Threads REQUIRED)
22+
file(RELATIVE_PATH REL_BINARY_DIR
23+
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
24+
string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_name}")
25+
add_executable(${TEST_TARGET_NAME} ${test_name}.cpp)
26+
target_include_directories("${TEST_TARGET_NAME}"
27+
PRIVATE
28+
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
29+
)
30+
set_target_properties(${TEST_TARGET_NAME} PROPERTIES
31+
OUTPUT_NAME ${test_name})
32+
if (GINKGO_CHECK_CIRCULAR_DEPS)
33+
target_link_libraries(${TEST_TARGET_NAME} PRIVATE "${GINKGO_CIRCULAR_DEPS_FLAGS}")
34+
endif()
35+
target_link_libraries(${TEST_TARGET_NAME} PRIVATE ginkgo GTest::Main GTest::GTest Threads::Threads ${ARGN})
36+
add_test(NAME ${REL_BINARY_DIR}/${test_name} COMMAND ${TEST_TARGET_NAME})
3737
endfunction(ginkgo_create_thread_test)
3838

3939
function(ginkgo_create_test_cpp_cuda_header test_name)
4040
file(RELATIVE_PATH REL_BINARY_DIR
41-
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
41+
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
4242
string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_name}")
4343
add_executable(${TEST_TARGET_NAME} ${test_name}.cpp)
4444
target_include_directories("${TEST_TARGET_NAME}"
4545
PRIVATE
46-
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
47-
"${CUDA_INCLUDE_DIRS}"
46+
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
47+
"${CUDA_INCLUDE_DIRS}"
4848
)
4949
set_target_properties(${TEST_TARGET_NAME} PROPERTIES
5050
OUTPUT_NAME ${test_name})
@@ -57,12 +57,12 @@ endfunction(ginkgo_create_test_cpp_cuda_header)
5757

5858
function(ginkgo_create_cuda_test test_name)
5959
file(RELATIVE_PATH REL_BINARY_DIR
60-
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
60+
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
6161
string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_name}")
6262
add_executable(${TEST_TARGET_NAME} ${test_name}.cu)
6363
target_include_directories("${TEST_TARGET_NAME}"
6464
PRIVATE
65-
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
65+
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
6666
)
6767
set_target_properties(${TEST_TARGET_NAME} PROPERTIES
6868
OUTPUT_NAME ${test_name})
@@ -77,7 +77,7 @@ endfunction(ginkgo_create_cuda_test)
7777
function(ginkgo_create_hip_test_special_linkage test_name)
7878
# use gcc to compile but use hip to link
7979
file(RELATIVE_PATH REL_BINARY_DIR
80-
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
80+
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
8181
string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_name}")
8282
add_executable(${TEST_TARGET_NAME} ${test_name}.cpp)
8383
# Fix the missing metadata when building static library.
@@ -86,7 +86,7 @@ function(ginkgo_create_hip_test_special_linkage test_name)
8686
endif()
8787
target_include_directories("${TEST_TARGET_NAME}"
8888
PRIVATE
89-
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
89+
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
9090
)
9191
set_target_properties(${TEST_TARGET_NAME} PROPERTIES
9292
OUTPUT_NAME ${test_name})
@@ -99,7 +99,7 @@ endfunction(ginkgo_create_hip_test_special_linkage)
9999

100100
function(ginkgo_create_hip_test test_name)
101101
file(RELATIVE_PATH REL_BINARY_DIR
102-
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
102+
${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
103103
string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_name}")
104104

105105
set_source_files_properties(${test_name}.hip.cpp PROPERTIES HIP_SOURCE_PROPERTY_FORMAT TRUE)
@@ -113,14 +113,14 @@ function(ginkgo_create_hip_test test_name)
113113

114114
target_include_directories("${TEST_TARGET_NAME}"
115115
PRIVATE
116-
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
117-
# Only `math` requires it so far, but it's much easier
118-
# to put these this way.
119-
${GINKGO_HIP_THRUST_PATH}
120-
# Only `exception_helpers` requires thess so far, but it's much easier
121-
# to put these this way.
122-
${HIPBLAS_INCLUDE_DIRS}
123-
${HIPSPARSE_INCLUDE_DIRS}
116+
"$<BUILD_INTERFACE:${Ginkgo_BINARY_DIR}>"
117+
# Only `math` requires it so far, but it's much easier
118+
# to put these this way.
119+
${GINKGO_HIP_THRUST_PATH}
120+
# Only `exception_helpers` requires thess so far, but it's much easier
121+
# to put these this way.
122+
${HIPBLAS_INCLUDE_DIRS}
123+
${HIPSPARSE_INCLUDE_DIRS}
124124
)
125125
set_target_properties(${TEST_TARGET_NAME} PROPERTIES
126126
OUTPUT_NAME ${test_name})

doc/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ option(GINKGO_DOC_GENERATE_PDF "Generate PDF documentation" OFF)
66
option(GINKGO_DOC_GENERATE_DEV "Generate internal documentation" OFF)
77
option(GINKGO_DOC_GENERATE_EXAMPLES "Generate example documentation" ON)
88
if(GINKGO_DOC_GENERATE_EXAMPLES)
9-
add_subdirectory(examples)
9+
add_subdirectory(examples)
1010
endif()
1111

1212
if (GINKGO_DOC_GENERATE_PDF)

doc/examples/CMakeLists.txt

+63-63
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
11
# Collect all of the directory names for the examples programs
22
FILE(GLOB _ginkgo_examples
3-
${CMAKE_SOURCE_DIR}/examples/*
4-
)
3+
${CMAKE_SOURCE_DIR}/examples/*
4+
)
55
LIST(REMOVE_ITEM _ginkgo_examples "${CMAKE_SOURCE_DIR}/examples/CMakeLists.txt")
66

77
ADD_CUSTOM_TARGET(examples)
88

99
file(GLOB _ginkgo_examples_tooltip
10-
${CMAKE_SOURCE_DIR}/examples/*/doc/tooltip
11-
)
10+
${CMAKE_SOURCE_DIR}/examples/*/doc/tooltip
11+
)
1212

1313
file(GLOB _ginkgo_examples_kind
14-
${CMAKE_SOURCE_DIR}/examples/*/doc/kind
15-
)
14+
${CMAKE_SOURCE_DIR}/examples/*/doc/kind
15+
)
1616
file(GLOB _ginkgo_examples_buildson
17-
${CMAKE_SOURCE_DIR}/examples/*/doc/builds-on
18-
)
17+
${CMAKE_SOURCE_DIR}/examples/*/doc/builds-on
18+
)
1919

2020
ADD_CUSTOM_COMMAND(
21-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/examples.hpp
22-
COMMAND ${PERL_EXECUTABLE}
23-
ARGS
24-
${CMAKE_SOURCE_DIR}/doc/scripts/examples.pl
25-
${CMAKE_CURRENT_SOURCE_DIR}/examples.hpp.in
26-
${_ginkgo_examples}
27-
> ${CMAKE_CURRENT_BINARY_DIR}/examples.hpp
28-
DEPENDS
29-
${CMAKE_SOURCE_DIR}/doc/scripts/examples.pl
30-
${CMAKE_CURRENT_SOURCE_DIR}/examples.hpp.in
31-
${_ginkgo_examples_tooltip}
32-
${_ginkgo_examples_kind}
33-
${_ginkgo_examples_buildson}
34-
)
21+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/examples.hpp
22+
COMMAND ${PERL_EXECUTABLE}
23+
ARGS
24+
${CMAKE_SOURCE_DIR}/doc/scripts/examples.pl
25+
${CMAKE_CURRENT_SOURCE_DIR}/examples.hpp.in
26+
${_ginkgo_examples}
27+
> ${CMAKE_CURRENT_BINARY_DIR}/examples.hpp
28+
DEPENDS
29+
${CMAKE_SOURCE_DIR}/doc/scripts/examples.pl
30+
${CMAKE_CURRENT_SOURCE_DIR}/examples.hpp.in
31+
${_ginkgo_examples_tooltip}
32+
${_ginkgo_examples_kind}
33+
${_ginkgo_examples_buildson}
34+
)
3535
ADD_CUSTOM_TARGET(build_examples_hpp
36-
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/examples.hpp
37-
COMMENT
38-
"Building examples.hpp")
36+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/examples.hpp
37+
COMMENT
38+
"Building examples.hpp")
3939
ADD_DEPENDENCIES(examples build_examples_hpp)
4040

4141
#
4242
# Prepare the examples for documentation generation
4343
#
4444

4545
FOREACH(example ${_ginkgo_examples})
46-
GET_FILENAME_COMPONENT(example "${example}" NAME)
46+
GET_FILENAME_COMPONENT(example "${example}" NAME)
4747

48-
ADD_CUSTOM_COMMAND(
49-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${example}.cpp
50-
COMMAND ${PERL_EXECUTABLE}
51-
ARGS
52-
${CMAKE_SOURCE_DIR}/doc/scripts/program2plain
53-
< ${CMAKE_SOURCE_DIR}/examples/${example}/${example}.cpp
54-
> ${CMAKE_CURRENT_BINARY_DIR}/${example}.cpp
55-
DEPENDS
56-
${CMAKE_SOURCE_DIR}/doc/scripts/program2plain
57-
${CMAKE_SOURCE_DIR}/examples/${example}/${example}.cpp
58-
VERBATIM
59-
)
48+
ADD_CUSTOM_COMMAND(
49+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${example}.cpp
50+
COMMAND ${PERL_EXECUTABLE}
51+
ARGS
52+
${CMAKE_SOURCE_DIR}/doc/scripts/program2plain
53+
< ${CMAKE_SOURCE_DIR}/examples/${example}/${example}.cpp
54+
> ${CMAKE_CURRENT_BINARY_DIR}/${example}.cpp
55+
DEPENDS
56+
${CMAKE_SOURCE_DIR}/doc/scripts/program2plain
57+
${CMAKE_SOURCE_DIR}/examples/${example}/${example}.cpp
58+
VERBATIM
59+
)
6060

61-
ADD_CUSTOM_COMMAND(
62-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${example}.hpp
63-
COMMAND ${PERL_EXECUTABLE}
64-
ARGS
65-
${CMAKE_SOURCE_DIR}/doc/scripts/make_example.pl
66-
${example} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
67-
> ${CMAKE_CURRENT_BINARY_DIR}/${example}.hpp
68-
WORKING_DIRECTORY
69-
${CMAKE_CURRENT_BINARY_DIR}
70-
DEPENDS
71-
${CMAKE_SOURCE_DIR}/doc/scripts/make_example.pl
72-
${CMAKE_SOURCE_DIR}/doc/scripts/intro2toc
73-
${CMAKE_SOURCE_DIR}/doc/scripts/create_anchors
74-
${CMAKE_SOURCE_DIR}/doc/scripts/program2doxygen
75-
${CMAKE_SOURCE_DIR}/examples/${example}/${example}.cpp
76-
${CMAKE_SOURCE_DIR}/examples/${example}/doc/intro.dox
77-
${CMAKE_SOURCE_DIR}/examples/${example}/doc/results.dox
78-
)
61+
ADD_CUSTOM_COMMAND(
62+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${example}.hpp
63+
COMMAND ${PERL_EXECUTABLE}
64+
ARGS
65+
${CMAKE_SOURCE_DIR}/doc/scripts/make_example.pl
66+
${example} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
67+
> ${CMAKE_CURRENT_BINARY_DIR}/${example}.hpp
68+
WORKING_DIRECTORY
69+
${CMAKE_CURRENT_BINARY_DIR}
70+
DEPENDS
71+
${CMAKE_SOURCE_DIR}/doc/scripts/make_example.pl
72+
${CMAKE_SOURCE_DIR}/doc/scripts/intro2toc
73+
${CMAKE_SOURCE_DIR}/doc/scripts/create_anchors
74+
${CMAKE_SOURCE_DIR}/doc/scripts/program2doxygen
75+
${CMAKE_SOURCE_DIR}/examples/${example}/${example}.cpp
76+
${CMAKE_SOURCE_DIR}/examples/${example}/doc/intro.dox
77+
${CMAKE_SOURCE_DIR}/examples/${example}/doc/results.dox
78+
)
7979

80-
ADD_CUSTOM_TARGET(examples_${example}
81-
DEPENDS
82-
${CMAKE_CURRENT_BINARY_DIR}/${example}.hpp
83-
${CMAKE_CURRENT_BINARY_DIR}/${example}.cpp
84-
COMMENT
80+
ADD_CUSTOM_TARGET(examples_${example}
81+
DEPENDS
82+
${CMAKE_CURRENT_BINARY_DIR}/${example}.hpp
83+
${CMAKE_CURRENT_BINARY_DIR}/${example}.cpp
84+
COMMENT
8585
"Building doxygen input file for examples program <${example}>"
86-
)
87-
ADD_DEPENDENCIES(examples examples_${example})
86+
)
87+
ADD_DEPENDENCIES(examples examples_${example})
8888
ENDFOREACH()

0 commit comments

Comments
 (0)