diff --git a/camerad/CMakeLists.txt b/camerad/CMakeLists.txt index aa72d47..681f56f 100644 --- a/camerad/CMakeLists.txt +++ b/camerad/CMakeLists.txt @@ -117,13 +117,20 @@ 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 # ---------------------------------------------------------------------------- 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} @@ -132,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. # ---------------------------------------------------------------------------- @@ -164,6 +183,8 @@ find_package(Threads) add_executable(camerad ${CAMERAD_DIR}/camerad.cpp ${CAMERAD_DIR}/camera_server.cpp + ${INSTRUMENT_REGISTRATION} + ${INSTRUMENT_OBJECTS} ) # ---------------------------------------------------------------------------- diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 6d4e3a2..eabac89 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -29,6 +29,8 @@ find_package(pybind11 CONFIG REQUIRED) pybind11_add_module(camera_interface ${PROJECT_BASE_DIR}/python/camera_interface_module.cpp + ${INSTRUMENT_REGISTRATION} + ${INSTRUMENT_OBJECTS} ) target_include_directories(camera_interface PRIVATE