From 9969c36410b0cb5422406288e665f9861aab9d89 Mon Sep 17 00:00:00 2001 From: David Hale Date: Wed, 23 Sep 2026 13:50:28 -0700 Subject: [PATCH 1/2] moves the registration TU out of the core library into the final targets the shared library no longer forces a choice of interface. camerad and the python module each link exactly one registration. --- camerad/CMakeLists.txt | 7 ++++++- python/CMakeLists.txt | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/camerad/CMakeLists.txt b/camerad/CMakeLists.txt index aa72d47..88380c0 100644 --- a/camerad/CMakeLists.txt +++ b/camerad/CMakeLists.txt @@ -119,11 +119,15 @@ endif() # ---------------------------------------------------------------------------- # Camera Interface Base +# +# The registration translation unit, and any instrument sources, are +# deliberately not part of this library. They are compiled into the final +# targets below, so linking this library never forces a choice of interface +# and the final target alone determines which registration is linked. # ---------------------------------------------------------------------------- list (APPEND INTERFACE_SOURCES ${CAMERAD_DIR}/camera_interface.cpp ${CAMERAD_DIR}/image_process.cpp - ${INSTRUMENT_SOURCES} ) add_library(${INTERFACE_TARGET} ${INTERFACE_SOURCES}) target_link_libraries(${INTERFACE_TARGET} @@ -164,6 +168,7 @@ find_package(Threads) add_executable(camerad ${CAMERAD_DIR}/camerad.cpp ${CAMERAD_DIR}/camera_server.cpp + ${INSTRUMENT_SOURCES} ) # ---------------------------------------------------------------------------- diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 6d4e3a2..18efff1 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -29,6 +29,7 @@ find_package(pybind11 CONFIG REQUIRED) pybind11_add_module(camera_interface ${PROJECT_BASE_DIR}/python/camera_interface_module.cpp + ${INSTRUMENT_SOURCES} ) target_include_directories(camera_interface PRIVATE From 418366ddc6c54f8ac0f31806df2723704d2a3085 Mon Sep 17 00:00:00 2001 From: David Hale Date: Wed, 23 Sep 2026 16:53:44 -0700 Subject: [PATCH 2/2] builds the instrument implementation once, into an object library --- camerad/CMakeLists.txt | 28 ++++++++++++++++++++++------ python/CMakeLists.txt | 3 ++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/camerad/CMakeLists.txt b/camerad/CMakeLists.txt index 88380c0..681f56f 100644 --- a/camerad/CMakeLists.txt +++ b/camerad/CMakeLists.txt @@ -117,13 +117,16 @@ else() endif() endif() +# ---------------------------------------------------------------------------- +# Separate the registration TU from the instrument implementation so that +# the registration is compiled into the final target. +# ---------------------------------------------------------------------------- +set (INSTRUMENT_REGISTRATION ${INSTRUMENT_SOURCES}) +list (FILTER INSTRUMENT_REGISTRATION INCLUDE REGEX "_interface_factory\\.cpp$") +list (FILTER INSTRUMENT_SOURCES EXCLUDE REGEX "_interface_factory\\.cpp$") + # ---------------------------------------------------------------------------- # Camera Interface Base -# -# The registration translation unit, and any instrument sources, are -# deliberately not part of this library. They are compiled into the final -# targets below, so linking this library never forces a choice of interface -# and the final target alone determines which registration is linked. # ---------------------------------------------------------------------------- list (APPEND INTERFACE_SOURCES ${CAMERAD_DIR}/camera_interface.cpp @@ -136,6 +139,18 @@ target_link_libraries(${INTERFACE_TARGET} ) target_include_directories(${INTERFACE_TARGET} PUBLIC ${INTERFACE_INCLUDES}) +# ---------------------------------------------------------------------------- +# instrument implementation, if any. +# objects shared by the final targets, not depended on as a library +# ---------------------------------------------------------------------------- +if (INSTRUMENT_SOURCES) + add_library(instrument_obj OBJECT ${INSTRUMENT_SOURCES}) + target_link_libraries(instrument_obj ${INTERFACE_TARGET}) + set (INSTRUMENT_OBJECTS $) +else() + set (INSTRUMENT_OBJECTS "") +endif() + # ---------------------------------------------------------------------------- # External libraries, such as FITS, etc. # ---------------------------------------------------------------------------- @@ -168,7 +183,8 @@ find_package(Threads) add_executable(camerad ${CAMERAD_DIR}/camerad.cpp ${CAMERAD_DIR}/camera_server.cpp - ${INSTRUMENT_SOURCES} + ${INSTRUMENT_REGISTRATION} + ${INSTRUMENT_OBJECTS} ) # ---------------------------------------------------------------------------- diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 18efff1..eabac89 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -29,7 +29,8 @@ find_package(pybind11 CONFIG REQUIRED) pybind11_add_module(camera_interface ${PROJECT_BASE_DIR}/python/camera_interface_module.cpp - ${INSTRUMENT_SOURCES} + ${INSTRUMENT_REGISTRATION} + ${INSTRUMENT_OBJECTS} ) target_include_directories(camera_interface PRIVATE