Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ if(Libmultiprocess_ENABLE_CLANG_TIDY)
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}")
endif()

set(EXTERNAL_MPGEN "" CACHE STRING "Use the supplied mpgen binary rather than the one built internally")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The value of EXTERNAL_MPGEN must be a full path to satisfy the if(EXIST...) condition. Why not make this more explicit by using the FILEPATH type and mentioning in the help string?

  2. As a user-facing cache variable, it should have a library-specific prefix, like this one:https://github.com/chaincodelabs/libmultiprocess/blob/1e06ff07cdeadc78b2c022750f7b5cbc88d56b1d/CMakeLists.txt#L18

  3. style nit: A full stop at the end of the help string?


include("cmake/compat_config.cmake")
include("cmake/pthread_checks.cmake")
include(GNUInstallDirs)
Expand Down
14 changes: 11 additions & 3 deletions cmake/TargetCapnpSources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,23 @@ function(target_capnp_sources target include_prefix)
"IMPORT_PATHS" # multi_value_keywords
)

if(NOT TARGET Libmultiprocess::mpgen)
message(FATAL_ERROR "Target 'Libmultiprocess::mpgen' does not exist.")
set(MPGEN_BINARY "")
if(EXTERNAL_MPGEN)
set(MPGEN_BINARY "${EXTERNAL_MPGEN}")
if(NOT EXISTS "${MPGEN_BINARY}")
message(FATAL_ERROR "EXTERNAL_MPGEN: \"${MPGEN_BINARY}\" does not exist.")
endif()
elseif(TARGET Libmultiprocess::multiprocess)
set(MPGEN_BINARY $<TARGET_FILE:Libmultiprocess::mpgen>)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fairly certain that a generation expression isn't necessary here:

Suggested change
set(MPGEN_BINARY $<TARGET_FILE:Libmultiprocess::mpgen>)
set(MPGEN_BINARY Libmultiprocess::mpgen)

else()
message(FATAL_ERROR "No usable mpgen. Set EXTERNAL_MPGEN or enable the internal target.")
endif()

set(generated_headers "")
foreach(capnp_file IN LISTS TCS_UNPARSED_ARGUMENTS)
add_custom_command(
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
COMMAND Libmultiprocess::mpgen ${CMAKE_CURRENT_SOURCE_DIR} ${include_prefix} ${CMAKE_CURRENT_SOURCE_DIR}/${capnp_file} ${TCS_IMPORT_PATHS} ${MP_INCLUDE_DIR}
COMMAND ${MPGEN_BINARY} ${CMAKE_CURRENT_SOURCE_DIR} ${include_prefix} ${CMAKE_CURRENT_SOURCE_DIR}/${capnp_file} ${TCS_IMPORT_PATHS} ${MP_INCLUDE_DIR}
DEPENDS ${capnp_file}
VERBATIM
)
Expand Down