Need more than one local source directory in ExternalProject

I have a project consisting of a CMake “external project” that creates a custom target for a Microchip PIC MCU. I would like to extend this project to build an additional custom target for a second MCU in the same family as the first. Each MCU would have its own configuration and driver files, but most of the task-level code would be shared between the two MCUs. Consequently, two external projects would be needed, each pulling in the shared code as well as the code specific to its corresponding MCU. I would like to keep all of the source code local: each external project would have its own source directory, and there would be a shared source directory. However, the ExternalProject_Add() function only accommodates a single local URL when specifying where source files are to be obtained from. Is there any way to overcome this limitation? Thanks.

Would this work?

set(common_source_dir "${CMAKE_CURRENT_BINARY_DIR}/src")
ExternalProject_add(common-src
  # Source args…
  SOURCE_DIR "${common_source_dir}/common"
  CONFIGURE_COMMAND ""
  BUILD_COMMAND ""
  INSTALL_COMMAND "")
ExternalProject_add(src-variant-1
  # Source args…
  SOURCE_DIR "${common_source_dir}/variant-1"
  CONFIGURE_COMMAND ""
  BUILD_COMMAND ""
  INSTALL_COMMAND "")
ExternalProject_add(build-variant-1
  DEPENDS common-src variant-1-src
  SOURCE_DIR "${common_source_dir}/common"
  CMAKE_ARGS
    -DVARIANT_DIR:PATH=${common_source_dir}/variant-1"
  …)

Ben, thanks for your rapid feedback and apologies for my delayed response. I incorporated your suggestions into my code and got closer to the desired outcome, but no cigar. Then I took a step back and realized that Microchip provides a Makefile generation tool that I could use instead of CMake. The resulting solution is actually quite elegant. The developer who previously worked on this project had used CMake exclusively, and I had assumed that simply extending his implementation would be the way to go. Again, thanks for your feedback and sorry for the trouble.