Skip to content

Commit 470fc51

Browse files
committed
Merge #230: cmake: add ONLY_CAPNP target_capnp_sources option
81c6526 cmake: add ONLY_CAPNP target_capnp_sources option (Ryan Ofsky) Pull request description: Make `target_capnp_sources` function take `ONLY_CAPNP` option to only add cap'n proto-generated files to the target library and not add libmultiprocess-generated ones. This is needed in bitcoin/bitcoin#10102 to support building with ENABLE_IPC=ON and ENABLE_WALLET=OFF because libmultiprocess-generated wallet files `wallet.capnp.proxy*.c++` can't be built without causing link errors, while the `wallet.capnp.c++` file is still necessary to build because it is referenced by `init.capnp` and `node.capnp` there. ACKs for top commit: hebasto: ACK 81c6526, I have reviewed the code and it looks OK. Tree-SHA512: f85da2e480da00b374be4fde9abebf152f49f493b7fd33c2c1f1ae24fc3cdf6db9e242b160edd84f3be42b3daafbd9be989c8c76c71063f65236f96c381e5186
2 parents 2d8886f + 81c6526 commit 470fc51

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

cmake/TargetCapnpSources.cmake

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Example:
5555
function(target_capnp_sources target include_prefix)
5656
cmake_parse_arguments(PARSE_ARGV 2
5757
"TCS" # prefix
58-
"" # options
58+
"ONLY_CAPNP" # options
5959
"" # one_value_keywords
6060
"IMPORT_PATHS" # multi_value_keywords
6161
)
@@ -85,11 +85,14 @@ function(target_capnp_sources target include_prefix)
8585
set_source_files_properties(${capnp_file}.c++ PROPERTIES SKIP_LINTING TRUE) # Ignored before cmake 3.27
8686
target_sources(${target} PRIVATE
8787
${CMAKE_CURRENT_BINARY_DIR}/${capnp_file}.c++
88-
${CMAKE_CURRENT_BINARY_DIR}/${capnp_file}.proxy-client.c++
89-
${CMAKE_CURRENT_BINARY_DIR}/${capnp_file}.proxy-server.c++
90-
${CMAKE_CURRENT_BINARY_DIR}/${capnp_file}.proxy-types.c++
9188
)
92-
89+
if(NOT TCS_ONLY_CAPNP)
90+
target_sources(${target} PRIVATE
91+
${CMAKE_CURRENT_BINARY_DIR}/${capnp_file}.proxy-client.c++
92+
${CMAKE_CURRENT_BINARY_DIR}/${capnp_file}.proxy-server.c++
93+
${CMAKE_CURRENT_BINARY_DIR}/${capnp_file}.proxy-types.c++
94+
)
95+
endif()
9396
list(APPEND generated_headers ${capnp_file}.h)
9497
endforeach()
9598

@@ -111,5 +114,7 @@ function(target_capnp_sources target include_prefix)
111114
# dependencies explicitly because while cmake detect dependencies of non
112115
# generated files on generated headers, it does not reliably detect
113116
# dependencies of generated headers on other generated headers.
114-
add_custom_target("${target}_headers" DEPENDS ${generated_headers})
117+
if(NOT TARGET "${target}_headers")
118+
add_custom_target("${target}_headers" DEPENDS ${generated_headers})
119+
endif()
115120
endfunction()

0 commit comments

Comments
 (0)