Skip to content

Commit 75cf04a

Browse files
committed
build: add option for external mpgen binary
This is useful for cross builds. Note that the internal binary is still built, but it can be skipped by building the multiprocess target directly.
1 parent 07c917f commit 75cf04a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ if(Libmultiprocess_ENABLE_CLANG_TIDY)
2222
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}")
2323
endif()
2424

25+
set(EXTERNAL_MPGEN "" CACHE STRING "Use the supplied mpgen binary rather than the one built internally")
26+
2527
include("cmake/compat_config.cmake")
2628
include("cmake/pthread_checks.cmake")
2729
include(GNUInstallDirs)

cmake/TargetCapnpSources.cmake

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,23 @@ function(target_capnp_sources target include_prefix)
6060
"IMPORT_PATHS" # multi_value_keywords
6161
)
6262

63-
if(NOT TARGET Libmultiprocess::mpgen)
64-
message(FATAL_ERROR "Target 'Libmultiprocess::mpgen' does not exist.")
63+
set(MPGEN_BINARY "")
64+
if(EXTERNAL_MPGEN)
65+
set(MPGEN_BINARY "${EXTERNAL_MPGEN}")
66+
if(NOT EXISTS "${MPGEN_BINARY}")
67+
message(FATAL_ERROR "EXTERNAL_MPGEN: \"${MPGEN_BINARY}\" does not exist.")
68+
endif()
69+
elseif(TARGET Libmultiprocess::multiprocess)
70+
set(MPGEN_BINARY $<TARGET_FILE:Libmultiprocess::mpgen>)
71+
else()
72+
message(FATAL_ERROR "No usable mpgen. Set EXTERNAL_MPGEN or enable the internal target.")
6573
endif()
6674

6775
set(generated_headers "")
6876
foreach(capnp_file IN LISTS TCS_UNPARSED_ARGUMENTS)
6977
add_custom_command(
7078
OUTPUT ${capnp_file}.c++ ${capnp_file}.h ${capnp_file}.proxy-client.c++ ${capnp_file}.proxy-types.h ${capnp_file}.proxy-server.c++ ${capnp_file}.proxy-types.c++ ${capnp_file}.proxy.h
71-
COMMAND Libmultiprocess::mpgen ${CMAKE_CURRENT_SOURCE_DIR} ${include_prefix} ${CMAKE_CURRENT_SOURCE_DIR}/${capnp_file} ${TCS_IMPORT_PATHS} ${MP_INCLUDE_DIR}
79+
COMMAND ${MPGEN_BINARY} ${CMAKE_CURRENT_SOURCE_DIR} ${include_prefix} ${CMAKE_CURRENT_SOURCE_DIR}/${capnp_file} ${TCS_IMPORT_PATHS} ${MP_INCLUDE_DIR}
7280
DEPENDS ${capnp_file}
7381
VERBATIM
7482
)

0 commit comments

Comments
 (0)