Skip to content

Commit e997249

Browse files
committed
Use gersemi to formate cmake files
1 parent c51d442 commit e997249

21 files changed

+494
-342
lines changed

asio/CMakeLists.txt

+89-60
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@ cmake_minimum_required(VERSION 3.28...3.31)
22

33
include(cmake/prelude.cmake)
44

5-
project(asio
6-
VERSION 1.34.0.1
7-
DESCRIPTION "Asio C++ Library"
8-
HOMEPAGE_URL "http://think-async.com/Asio/"
9-
LANGUAGES CXX
5+
project(
6+
asio
7+
VERSION 1.34.0.1
8+
DESCRIPTION "Asio C++ Library"
9+
HOMEPAGE_URL "http://think-async.com/Asio/"
10+
LANGUAGES CXX
1011
)
1112

1213
include(cmake/variables.cmake)
1314

1415
if(PROJECT_IS_TOP_LEVEL)
15-
include(CheckCXXSymbolExists)
16-
check_cxx_symbol_exists(snprintf cstdio ASIO_HAS_SNPRINTF)
17-
check_cxx_symbol_exists(sprintf_s cstdio ASIO_HAS_SECURE_RTL)
16+
include(CheckCXXSymbolExists)
17+
check_cxx_symbol_exists(snprintf cstdio ASIO_HAS_SNPRINTF)
18+
check_cxx_symbol_exists(sprintf_s cstdio ASIO_HAS_SECURE_RTL)
1819
endif()
1920

2021
set(CPPdefinitions ASIO_NO_DEPRECATED ASIO_DISABLE_BOOST_CONTEXT_FIBER)
2122
if(ASIO_HAS_SECURE_RTL)
22-
list(APPEND CPPdefinitions ASIO_HAS_SECURE_RTL)
23+
list(APPEND CPPdefinitions ASIO_HAS_SECURE_RTL)
2324
elseif(ASIO_HAS_SNPRINTF)
24-
list(APPEND CPPdefinitions ASIO_HAS_SNPRINTF)
25+
list(APPEND CPPdefinitions ASIO_HAS_SNPRINTF)
2526
endif()
2627

2728
option(ASIO_SEPARATE_COMPILATION "build asio lib too" ${PROJECT_IS_TOP_LEVEL})
@@ -34,82 +35,110 @@ find_package(OpenSSL REQUIRED)
3435

3536
# ---- Declare library ----
3637

37-
file(GLOB_RECURSE _asio_implementation "include/asio/*/*.hpp" "include/asio/*.ipp")
38+
file(
39+
GLOB_RECURSE _asio_implementation
40+
"include/asio/*/*.hpp"
41+
"include/asio/*.ipp"
42+
)
3843
list(FILTER _asio_implementation EXCLUDE REGEX [=[.*/experimental/.*]=])
3944

4045
# asio interface library
4146
add_library(asio_header INTERFACE)
4247
add_library(asio::asio_header ALIAS asio_header)
43-
target_sources(asio_header INTERFACE FILE_SET HEADERS BASE_DIRS include FILES ${_asio_implementation})
48+
target_sources(
49+
asio_header
50+
INTERFACE FILE_SET HEADERS BASE_DIRS include FILES ${_asio_implementation}
51+
)
4452
target_link_libraries(asio_header INTERFACE OpenSSL::SSL OpenSSL::Crypto)
4553

4654
target_compile_definitions(asio_header INTERFACE ${CPPdefinitions})
4755
target_compile_features(
48-
asio_header INTERFACE "$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>"
49-
"$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>"
56+
asio_header
57+
INTERFACE
58+
"$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>"
59+
"$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>"
5060
)
5161
target_link_libraries(asio_header INTERFACE Threads::Threads)
5262

5363
if(ASIO_SEPARATE_COMPILATION)
54-
set(_libasio_SOURCES src/asio.cpp)
55-
56-
if(OpenSSL_FOUND)
57-
list(APPEND _libasio_SOURCES src/asio_ssl.cpp)
58-
endif()
59-
60-
set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL})
61-
62-
file(GLOB_RECURSE _asio_headers "include/asio/*.hpp")
63-
list(FILTER _asio_headers EXCLUDE REGEX [=[.*/experimental/.*\.hpp]=])
64-
list(FILTER _asio_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=])
65-
66-
# FIXME: some header in include/asio/detail fails CMAKE_VERIFY_INTERFACE_HEADER_SETS!
67-
# NOTE: we need them installed, but we used them install with asio_header INTERFACE! CK
68-
set(_public_headers include/asio.hpp ${_asio_headers})
69-
list(FILTER _public_headers EXCLUDE REGEX [=[.*/detail/.*\.hpp]=])
70-
list(FILTER _public_headers EXCLUDE REGEX [=[.*/impl/.*\.hpp]=])
71-
list(FILTER _public_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=])
72-
# foreach(header in LISTS ${_public_headers})
73-
# message(INFO "${header}")
74-
# endforeach()
75-
76-
add_library(asio SHARED ${_libasio_SOURCES})
77-
add_library(asio::asio ALIAS asio)
78-
target_sources(asio PUBLIC FILE_SET public_headers TYPE HEADERS BASE_DIRS include FILES ${_public_headers})
79-
80-
target_compile_definitions(asio PUBLIC ASIO_SEPARATE_COMPILATION ${CPPdefinitions})
81-
target_link_libraries(asio PUBLIC Threads::Threads)
82-
target_compile_features(
83-
asio INTERFACE "$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>" "$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>"
84-
)
85-
86-
if(ASIO_WARNINGS_AS_ERRORS AND ASIO_DEVELOPER_MODE AND UNIX)
87-
target_compile_options(asio PUBLIC -Werror)
88-
endif()
89-
90-
if(OpenSSL_FOUND)
91-
target_link_libraries(asio PUBLIC OpenSSL::SSL OpenSSL::Crypto)
92-
endif()
64+
set(_libasio_SOURCES src/asio.cpp)
65+
66+
if(OpenSSL_FOUND)
67+
list(APPEND _libasio_SOURCES src/asio_ssl.cpp)
68+
endif()
69+
70+
set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL})
71+
72+
file(GLOB_RECURSE _asio_headers "include/asio/*.hpp")
73+
list(FILTER _asio_headers EXCLUDE REGEX [=[.*/experimental/.*\.hpp]=])
74+
list(FILTER _asio_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=])
75+
76+
# FIXME: some header in include/asio/detail fails CMAKE_VERIFY_INTERFACE_HEADER_SETS!
77+
# NOTE: we need them installed, but we used them install with asio_header INTERFACE! CK
78+
set(_public_headers include/asio.hpp ${_asio_headers})
79+
list(FILTER _public_headers EXCLUDE REGEX [=[.*/detail/.*\.hpp]=])
80+
list(FILTER _public_headers EXCLUDE REGEX [=[.*/impl/.*\.hpp]=])
81+
list(FILTER _public_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=])
82+
# foreach(header in LISTS ${_public_headers})
83+
# message(INFO "${header}")
84+
# endforeach()
85+
86+
add_library(asio SHARED ${_libasio_SOURCES})
87+
add_library(asio::asio ALIAS asio)
88+
target_sources(
89+
asio
90+
PUBLIC
91+
FILE_SET public_headers
92+
TYPE HEADERS
93+
BASE_DIRS include
94+
FILES ${_public_headers}
95+
)
96+
97+
target_compile_definitions(
98+
asio
99+
PUBLIC ASIO_SEPARATE_COMPILATION ${CPPdefinitions}
100+
)
101+
target_link_libraries(asio PUBLIC Threads::Threads)
102+
target_compile_features(
103+
asio
104+
INTERFACE
105+
"$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>"
106+
"$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>"
107+
)
108+
109+
if(ASIO_WARNINGS_AS_ERRORS AND ASIO_DEVELOPER_MODE AND UNIX)
110+
target_compile_options(asio PUBLIC -Werror)
111+
endif()
112+
113+
if(OpenSSL_FOUND)
114+
target_link_libraries(asio PUBLIC OpenSSL::SSL OpenSSL::Crypto)
115+
endif()
93116
endif()
94117

95118
add_subdirectory(src/examples)
96119

97120
# ---- Install rules ----
98121

99122
if(NOT CMAKE_SKIP_INSTALL_RULES)
100-
include(cmake/AddUninstallTarget.cmake)
101-
include(cmake/install-rules.cmake)
102-
configure_file(asio.pc.cmake asio.pc)
103-
install(FILES ${PROJECT_BINARY_DIR}/asio.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
104-
install(FILES module/asio.cppm DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/asio/module)
123+
include(cmake/AddUninstallTarget.cmake)
124+
include(cmake/install-rules.cmake)
125+
configure_file(asio.pc.cmake asio.pc)
126+
install(
127+
FILES ${PROJECT_BINARY_DIR}/asio.pc
128+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
129+
)
130+
install(
131+
FILES module/asio.cppm
132+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/asio/module
133+
)
105134
endif()
106135

107136
# ---- Developer mode ----
108137

109138
if(NOT ASIO_DEVELOPER_MODE)
110-
return()
139+
return()
111140
elseif(NOT PROJECT_IS_TOP_LEVEL)
112-
message(AUTHOR_WARNING "Developer mode is intended for developers of asio")
141+
message(AUTHOR_WARNING "Developer mode is intended for developers of asio")
113142
endif()
114143

115144
include(cmake/dev-mode.cmake)

asio/GNUmakefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ check:
1616
# ninja -C build/dev spell-check
1717
# ninja -C build/dev format-check
1818

19-
format:
20-
git ls-files ::*CMakeLists.txt ::*.cmake | xargs cmake-format -i
19+
format: .init
20+
git ls-files ::*CMakeLists.txt ::cmake/*.cmake | xargs gersemi -i
2121

2222
test:
2323
cmake --preset ci-${hostSystemName}

asio/cmake/AddUninstallTarget.cmake

+24-14
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,28 @@ If the ``uninstall`` target already exists, the module does nothing.
2929

3030
# AddUninstallTarget works only when included in the main CMakeLists.txt
3131
if(NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
32-
return()
32+
return()
3333
endif()
3434

3535
# The name of the target is uppercase in MSVC and Xcode (for coherence with the
3636
# other standard targets)
3737
if("${CMAKE_GENERATOR}" MATCHES "^(Visual Studio|Xcode)")
38-
set(_uninstall "UNINSTALL")
38+
set(_uninstall "UNINSTALL")
3939
else()
40-
set(_uninstall "uninstall")
40+
set(_uninstall "uninstall")
4141
endif()
4242

4343
# If target is already defined don't do anything
4444
if(TARGET ${_uninstall})
45-
return()
45+
return()
4646
endif()
4747

4848
set(_filename cmake_uninstall.cmake)
4949

50-
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_filename}"
51-
"if(NOT EXISTS \"${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt\")
50+
file(
51+
WRITE
52+
"${CMAKE_CURRENT_BINARY_DIR}/${_filename}"
53+
"if(NOT EXISTS \"${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt\")
5254
message(WARNING \"Cannot find install manifest: \\\"${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt\\\"\")
5355
return()
5456
endif()
@@ -76,17 +78,25 @@ endforeach(file)
7678

7779
set(_desc "Uninstall the project...")
7880
if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
79-
set(_comment COMMAND \$\(CMAKE_COMMAND\) -E cmake_echo_color --switch=$\(COLOR\) --cyan "${_desc}")
81+
set(_comment
82+
COMMAND
83+
\$\(CMAKE_COMMAND\)
84+
-E
85+
cmake_echo_color
86+
--switch=$\(COLOR\)
87+
--cyan
88+
"${_desc}"
89+
)
8090
else()
81-
set(_comment COMMENT "${_desc}")
91+
set(_comment COMMENT "${_desc}")
8292
endif()
8393
add_custom_target(
84-
${_uninstall}
85-
${_comment}
86-
COMMAND ${CMAKE_COMMAND} -P ${_filename}
87-
USES_TERMINAL
88-
BYPRODUCTS uninstall_byproduct
89-
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
94+
${_uninstall}
95+
${_comment}
96+
COMMAND ${CMAKE_COMMAND} -P ${_filename}
97+
USES_TERMINAL
98+
BYPRODUCTS uninstall_byproduct
99+
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
90100
)
91101
set_property(SOURCE uninstall_byproduct PROPERTY SYMBOLIC 1)
92102

asio/cmake/coverage.cmake

+29-11
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,40 @@
22

33
# We use variables separate from what CTest uses, because those have
44
# customization issues
5-
set(COVERAGE_TRACE_COMMAND lcov -c -q -o "${PROJECT_BINARY_DIR}/coverage.info" -d "${PROJECT_BINARY_DIR}" --include
6-
"${PROJECT_SOURCE_DIR}/*"
7-
CACHE STRING "; separated command to generate a trace for the 'coverage' target"
5+
set(COVERAGE_TRACE_COMMAND
6+
lcov
7+
-c
8+
-q
9+
-o
10+
"${PROJECT_BINARY_DIR}/coverage.info"
11+
-d
12+
"${PROJECT_BINARY_DIR}"
13+
--include
14+
"${PROJECT_SOURCE_DIR}/*"
15+
CACHE STRING
16+
"; separated command to generate a trace for the 'coverage' target"
817
)
918

10-
set(COVERAGE_HTML_COMMAND genhtml --legend -f -q "${PROJECT_BINARY_DIR}/coverage.info" -p "${PROJECT_SOURCE_DIR}" -o
11-
"${PROJECT_BINARY_DIR}/coverage_html"
12-
CACHE STRING "; separated command to generate an HTML report for the 'coverage' target"
19+
set(COVERAGE_HTML_COMMAND
20+
genhtml
21+
--legend
22+
-f
23+
-q
24+
"${PROJECT_BINARY_DIR}/coverage.info"
25+
-p
26+
"${PROJECT_SOURCE_DIR}"
27+
-o
28+
"${PROJECT_BINARY_DIR}/coverage_html"
29+
CACHE STRING
30+
"; separated command to generate an HTML report for the 'coverage' target"
1331
)
1432

1533
# ---- Coverage target ----
1634

1735
add_custom_target(
18-
coverage
19-
COMMAND ${COVERAGE_TRACE_COMMAND}
20-
COMMAND ${COVERAGE_HTML_COMMAND}
21-
COMMENT "Generating coverage report"
22-
VERBATIM
36+
coverage
37+
COMMAND ${COVERAGE_TRACE_COMMAND}
38+
COMMAND ${COVERAGE_HTML_COMMAND}
39+
COMMENT "Generating coverage report"
40+
VERBATIM
2341
)

asio/cmake/dev-mode.cmake

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ include(cmake/folders.cmake)
22

33
option(ASIO_BUILD_TESTING "Use ctest" ON)
44
if(ASIO_BUILD_TESTING)
5-
enable_testing()
5+
enable_testing()
66

7-
add_subdirectory(src/tests)
8-
add_subdirectory(module/tests)
7+
add_subdirectory(src/tests)
8+
add_subdirectory(module/tests)
99
endif()
1010

1111
option(ASIO_BUILD_MCSS_DOCS "Build documentation using Doxygen and m.css" OFF)
1212
if(ASIO_BUILD_MCSS_DOCS)
13-
include(cmake/docs.cmake)
13+
include(cmake/docs.cmake)
1414
endif()
1515

1616
option(ASIO_ENABLE_COVERAGE "Enable coverage support separate from CTest's" OFF)
1717
if(ASIO_ENABLE_COVERAGE)
18-
include(cmake/coverage.cmake)
18+
include(cmake/coverage.cmake)
1919
endif()
2020

2121
include(cmake/lint-targets.cmake)

0 commit comments

Comments
 (0)