MP_INCLUDE_DIR in the target_capnp_sources function, removing the need to manually propagate it across directories for both this project and downstream projects.
MP_INCLUDE_DIR to global property
#168
MP_INCLUDE_DIR in the target_capnp_sources function, removing the need to manually propagate it across directories for both this project and downstream projects.
29@@ -30,16 +30,14 @@ include("cmake/compat_config.cmake")
30 include("cmake/pthread_checks.cmake")
31 include(GNUInstallDirs)
32
33-# Set convenience variables for subdirectories.
34-set(MP_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
35+# Set a convenience global property.
In commit “Switch MP_INCLUDE_DIR to global property” (b55383072016479f462fb019f90896f35a642450)
New comment seems to be dropping information about why a global variable or property is useful. Would suggest keeping more of original comment and changing “Set a convenience global property” to something like “Set MP_INCLUDE_DIR as a global property so target_capnp_sources function can use it, and its callers don’t need to specify the include directory manually to avoid “error: Import failed: /mp/proxy.capnp” failures from capnproto. IMO, it’s important for build systems to have comments like this explaining why they do things otherwise it’s too easy to guess incorrectly what code was trying to do and break things when making changes.
29@@ -30,16 +30,14 @@ include("cmake/compat_config.cmake")
30 include("cmake/pthread_checks.cmake")
31 include(GNUInstallDirs)
32
33-# Set convenience variables for subdirectories.
34-set(MP_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
35+# Set a convenience global property.
36+set_property(GLOBAL PROPERTY LIBMULTIPROCESS_MP_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
In commit “Switch MP_INCLUDE_DIR to global property” (b55383072016479f462fb019f90896f35a642450)
LIBMULTIPROCESS_MP prefix is redundant, would suggest calling the property just MP_INCLUDE_DIR or LIBMULTIPROCESS_INCLUDE_DIR, and I’d slightly prefer shorter MP_INCLUDE_DIR since this project has used “mp” prefix for namespacing since beginning, calling its c++ namespace mp::, installing C++ and capnproto include files in include/mp/, and naming the code generator mpgen. But either prefix would be ok.
This change automates handling of `MP_INCLUDE_DIR` in the
`target_capnp_sources` function, removing the need to manually propagate
it across directories for both this project and downstream projects.
Thank you for your review! Your feedback has been addressed.