Can I make two separate library packages in one CMakelIsts.txt file?

OK I think I have a solution. I used the COMPONENTS to have two separate packages made. I separated out and created two libraries each with shard and static:

set(QW_WEATHER_DEVICES_LIB weatherdevices)

add_library(${QW_WEATHER_DEVICES_LIB} SHARED
  anemometer_adafruit.cpp
)

# Also make a static library for dev package
add_library(${QW_WEATHER_DEVICES_LIB}_static STATIC
  anemometer_adafruit.cpp
)

set(QW_ECOWITT_LN90LP_DEVICE_LIB ecowittln90lp)

add_library(${QW_ECOWITT_LN90LP_DEVICE_LIB} SHARED
  ecowitt_ln90lp.cpp
)

# Also make a static library for dev package
add_library(${QW_ECOWITT_LN90LP_DEVICE_LIB}_static STATIC
  ecowitt_ln90lp.cpp
)


Then made different install rules with different components:

install( FILES
    include/anemometer_adafruit.h
  DESTINATION include/qw/devices
  COMPONENT weatherdevices_dev
)
# Install static library for dev package
install(
  TARGETS ${QW_WEATHER_DEVICES_LIB}_static
  DESTINATION lib/qw/devices/lib${QW_WEATHER_DEVICES_LIB}.a
  COMPONENT weatherdevices_dev
)
# Install shared library for runtime package
install(
  TARGETS ${QW_WEATHER_DEVICES_LIB}
  DESTINATION lib/qw/devices/lib
  COMPONENT weatherdevices_runtime
  )

install( FILES
    include/ecowitt_ln90lp.h
  DESTINATION include/qw/devices
  COMPONENT ecowittln90lp_dev
)
# Install static library for dev package
install(
  TARGETS ${QW_WEATHER_DEVICES_LIB}_static
  DESTINATION lib/qw/devices/lib${QW_WEATHER_DEVICES_LIB}.a
  COMPONENT ecowittln90lp_dev
)
# Install shared library for runtime package
install(
  TARGETS ${QW_WEATHER_DEVICES_LIB}
  DESTINATION lib/qw/devices/lib
  COMPONENT ecowittln90lp_runtime
  )

I then added these components to the ALL COMPONENTS value in my cpack_debian.cmake file:

set(CPACK_COMPONENTS_ALL
  runtime
  weatherdevices_runtime
  ecowittln90lp_runtime
  dev
  weatherdevices_dev
  ecowittln90lp_dev
)

I then got a different deb package for each one.

[cpack] CPack: Create package
[cpack] CPack: - package: /home/chrisk/Projects/src/qwunits/build/arm64-debug/libqwunits-dev_0.1.1-2_arm64.deb generated.
[cpack] CPack: - package: /home/chrisk/Projects/src/qwunits/build/arm64-debug/qwlibs-0.1.1-Linux-ecowittln90lp_dev.deb generated.
[cpack] CPack: - package: /home/chrisk/Projects/src/qwunits/build/arm64-debug/qwlibs-0.1.1-Linux-ecowittln90lp_runtime.deb generated.
[cpack] CPack: - package: /home/chrisk/Projects/src/qwunits/build/arm64-debug/libqwunits_0.1.1-2_arm64.deb generated.
[cpack] CPack: - package: /home/chrisk/Projects/src/qwunits/build/arm64-debug/qwlibs-0.1.1-Linux-weatherdevices_dev.deb generated.
[cpack] CPack: - package: /home/chrisk/Projects/src/qwunits/build/arm64-debug/qwlibs-0.1.1-Linux-weatherdevices_runtime.deb generated.

It seemed to have the expected files in them.

I’ll have to think if I like that better than giving each one their own directory and leave the COMPONENT for each as runtime and dev like all my other libraries.

Also, one thing I noticed is in order to add both a static and a shared library. In order for them to exist together I had to use a different name. so I appended “_static” to the static library definition. I ended up with a _static.a and a .a file. I would like to figure out how to only end up with a <library.a file. But, that is a different question.

Thanks

Chris