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.
3334# compile-public-headers
3435
3536if (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 ." )
4043else ()
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 )
0 commit comments