Skip to content

Commit c91c153

Browse files
arcolightdzabotlin
andauthored
IGNITE-28454 C++3.0: Reduce generated files names and paths (#7929)
Co-authored-by: dzabotlin <dzabotlin@gridgain.com>
1 parent bceab69 commit c91c153

11 files changed

Lines changed: 94 additions & 22 deletions

File tree

modules/platforms/cpp/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ include(CPack)
159159
message(STATUS "IGNITE_INCLUDEDIR=${IGNITE_INCLUDEDIR}")
160160
include(ignite_install_headers)
161161
include(ignite_check_headers)
162+
include(ignite_collect_public_headers)
162163

163164
# Turn on DLL export directives.
164165
add_definitions(-DIGNITE_IMPL)
@@ -203,6 +204,11 @@ endif()
203204

204205
include(ignite_test)
205206

207+
# Accumulated list of all installed public headers (relative to the include
208+
# root, e.g. "ignite/common/big_integer.h"). Each module appends its own
209+
# headers below; ignite_compile_headers.cmake reads this list.
210+
set(IGNITE3_ALL_PUBLIC_HEADERS "")
211+
206212
# Add common libraries along with their unit tests if any.
207213
add_subdirectory(ignite/common)
208214
add_subdirectory(ignite/tuple)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# ignite_collect_public_headers(<MODULE> <HEADERS_VAR>)
19+
#
20+
# Registers public headers for compile-time checking.
21+
#
22+
# Arguments:
23+
# <MODULE> The module name (e.g. "common", "tuple", "client").
24+
# <HEADERS_VAR> Name of a variable containing the list of headers as paths
25+
# relative to the module source directory
26+
# (e.g. "big_integer.h", "compute/compute.h").
27+
#
28+
# Appends "ignite/<MODULE>/<header>" to the IGNITE3_ALL_PUBLIC_HEADERS list
29+
# and propagates the updated list to the parent scope.
30+
#
31+
# Implemented as a macro (not a function) so that PARENT_SCOPE resolves to
32+
# the scope above the calling subdirectory — i.e. the top-level CMakeLists.txt
33+
# — rather than only one level above the call site.
34+
macro(ignite_collect_public_headers MODULE HEADERS_VAR)
35+
foreach(H IN LISTS ${HEADERS_VAR})
36+
list(APPEND IGNITE3_ALL_PUBLIC_HEADERS "ignite/${MODULE}/${H}")
37+
endforeach()
38+
set(IGNITE3_ALL_PUBLIC_HEADERS "${IGNITE3_ALL_PUBLIC_HEADERS}" PARENT_SCOPE)
39+
endmacro()

modules/platforms/cpp/cmake/ignite_compile_headers.cmake

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
# limitations under the License.
1616
#
1717

18-
# Compile-time check for public headers (always enabled when ENABLE_CLIENT=ON).
18+
# Compile-time check for all public headers (always enabled when ENABLE_CLIENT=ON).
1919
#
20-
# For every public header of ignite3-client, compiles a minimal .cpp that
21-
# includes ONLY that header against the INSTALLED package. This catches:
20+
# For every public header registered via ignite_collect_public_headers(), compiles
21+
# a minimal .cpp that includes ONLY that header against the INSTALLED package.
22+
# This catches:
2223
# 1. Headers missing their own #include dependencies.
2324
# 2. Public headers that #include internal (non-installed) headers.
2425
# 3. Headers missing from the installed package.
@@ -33,19 +34,21 @@
3334
# compile-public-headers
3435

3536
if (NOT ENABLE_CLIENT)
37+
# The sub-project links against the installed ignite::client target, so
38+
# the check requires the client to be built even for common/tuple headers.
3639
message(STATUS "compile-public-headers: ENABLE_CLIENT=OFF, skipping.")
37-
elseif (NOT IGNITE3_CLIENT_PUBLIC_HEADERS)
38-
message(WARNING "compile-public-headers: IGNITE3_CLIENT_PUBLIC_HEADERS is empty. "
39-
"Check ignite/client/CMakeLists.txt.")
40+
elseif (NOT IGNITE3_ALL_PUBLIC_HEADERS)
41+
message(WARNING "compile-public-headers: IGNITE3_ALL_PUBLIC_HEADERS is empty. "
42+
"Check ignite_collect_public_headers() calls in module CMakeLists.txt files.")
4043
else()
41-
set(CPH_DIR "${CMAKE_BINARY_DIR}/compile-public-headers")
44+
set(CPH_DIR "${CMAKE_BINARY_DIR}/cph")
4245

4346
# Write the list of public headers to a cmake file that the
4447
# sub-project will include. This avoids command-line quoting
4548
# issues when passing a list with semicolons.
4649
set(CPH_LIST_FILE "${CPH_DIR}/headers_list.cmake")
4750
set(CPH_LIST_CONTENT "set(IGNITE_PUBLIC_HEADERS\n")
48-
foreach(H IN LISTS IGNITE3_CLIENT_PUBLIC_HEADERS)
51+
foreach(H IN LISTS IGNITE3_ALL_PUBLIC_HEADERS)
4952
string(APPEND CPH_LIST_CONTENT " \"${H}\"\n")
5053
endforeach()
5154
string(APPEND CPH_LIST_CONTENT ")\n")
@@ -65,8 +68,17 @@ else()
6568
list(APPEND CPH_GENERATOR_ARGS -A "${CMAKE_GENERATOR_PLATFORM}")
6669
endif()
6770

68-
# Use add_custom_command so the check is skipped when ignite3-client has
69-
# not been rebuilt since the last successful run (stamp file is up-to-date).
71+
# Build the list of absolute source paths for all public headers so that
72+
# the stamp is invalidated whenever any header file is edited, not only
73+
# when the ignite3-client target is rebuilt (which may not recompile a
74+
# header-only change in common/tuple that is not included by any TU).
75+
set(CPH_HEADER_SOURCES)
76+
foreach(H IN LISTS IGNITE3_ALL_PUBLIC_HEADERS)
77+
list(APPEND CPH_HEADER_SOURCES "${CMAKE_SOURCE_DIR}/${H}")
78+
endforeach()
79+
80+
# Use add_custom_command so the check is skipped when neither
81+
# ignite3-client nor any public header has changed since the last run.
7082
add_custom_command(
7183
OUTPUT "${CPH_STAMP}"
7284
# Install the already-built client to a temp prefix.
@@ -88,7 +100,7 @@ else()
88100
"-B${CPH_SUB_BIN}"
89101
COMMAND ${CMAKE_COMMAND} --build "${CPH_SUB_BIN}"
90102
COMMAND ${CMAKE_COMMAND} -E touch "${CPH_STAMP}"
91-
DEPENDS ignite3-client
103+
DEPENDS ignite3-client ${CPH_HEADER_SOURCES}
92104
COMMENT "compile-public-headers: compiling each public header against installed package"
93105
VERBATIM
94106
)

modules/platforms/cpp/ignite/client/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ set(PRIVATE_HEADERS
115115

116116
ignite_check_headers(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${PUBLIC_HEADERS} PRIVATE ${PRIVATE_HEADERS})
117117

118-
# Expose the public header list to the parent scope for cmake/abi_check.cmake.
119-
set(IGNITE3_CLIENT_PUBLIC_HEADERS "${PUBLIC_HEADERS}" PARENT_SCOPE)
118+
ignite_collect_public_headers(client PUBLIC_HEADERS)
120119

121120
add_library(${TARGET}-obj OBJECT ${SOURCES})
122121
target_include_directories(${TARGET}-obj PUBLIC ${IGNITE_CMAKE_TOP_DIR})

modules/platforms/cpp/ignite/common/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ set(PRIVATE_HEADERS
5555

5656
ignite_check_headers(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${PUBLIC_HEADERS} PRIVATE ${PRIVATE_HEADERS})
5757

58+
ignite_collect_public_headers(common PUBLIC_HEADERS)
59+
5860
set(SOURCES
5961
big_decimal.cpp
6062
big_integer.cpp
@@ -65,7 +67,7 @@ set(SOURCES
6567
uuid.cpp
6668
detail/hash_calculator.cpp
6769
detail/hash_utils.cpp
68-
detail/murmur3_hash.cpp
70+
detail/murmur3_hash.cpp
6971
)
7072

7173
add_library(${TARGET} STATIC ${SOURCES})

modules/platforms/cpp/ignite/common/detail/bytes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#pragma once
1919

20-
#include "detail/config.h"
20+
#include "config.h"
2121

2222
#include <cstddef>
2323
#include <cstdint>

modules/platforms/cpp/ignite/network/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ set(PRIVATE_HEADERS
6060

6161
ignite_check_headers(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${PUBLIC_HEADERS} PRIVATE ${PRIVATE_HEADERS})
6262

63+
ignite_collect_public_headers(network PUBLIC_HEADERS)
64+
6365
find_package(OpenSSL)
6466
if (EXISTS ${OPENSSL_INCLUDE_DIR})
6567
message(STATUS "OPENSSL_INCLUDE_DIR: " ${OPENSSL_INCLUDE_DIR})

modules/platforms/cpp/ignite/odbc/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ set(PRIVATE_HEADERS
5858

5959
ignite_check_headers(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${PUBLIC_HEADERS} PRIVATE ${PRIVATE_HEADERS})
6060

61+
ignite_collect_public_headers(odbc PUBLIC_HEADERS)
62+
6163
include(find_odbc)
6264
find_package(ODBC REQUIRED)
6365

modules/platforms/cpp/ignite/protocol/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ set(PRIVATE_HEADERS
3737

3838
ignite_check_headers(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${PUBLIC_HEADERS} PRIVATE ${PRIVATE_HEADERS})
3939

40+
ignite_collect_public_headers(protocol PUBLIC_HEADERS)
41+
4042
set(SOURCES
4143
sql/column_meta.cpp sql/column_meta.h
4244
bitset_span.h

modules/platforms/cpp/ignite/tuple/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ set(PRIVATE_HEADERS)
3232

3333
ignite_check_headers(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${PUBLIC_HEADERS} PRIVATE ${PRIVATE_HEADERS})
3434

35+
ignite_collect_public_headers(tuple PUBLIC_HEADERS)
36+
3537
add_library(${TARGET} STATIC ${SOURCES})
3638

3739
target_link_libraries(${TARGET} ignite-common)

0 commit comments

Comments
 (0)