SET(TARGET_NAME aktualizr-c)
SET(SOURCES libaktualizr-c.cc)

add_library(${TARGET_NAME} SHARED ${SOURCES})
target_include_directories(${TARGET_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(${TARGET_NAME} PRIVATE aktualizr_static_lib ${AKTUALIZR_EXTERNAL_LIBS})

aktualizr_source_file_checks(${SOURCES})

add_subdirectory(test)

SET(SOURCES libaktualizr-c.cc)

add_library(aktualizr-c SHARED ${SOURCES}
    $<TARGET_OBJECTS:asn1>
    $<TARGET_OBJECTS:asn1_lib>
    $<TARGET_OBJECTS:bootloader>
    $<TARGET_OBJECTS:bootstrap>
    $<TARGET_OBJECTS:campaign>
    $<TARGET_OBJECTS:config>
    $<TARGET_OBJECTS:crypto>
    $<TARGET_OBJECTS:http>
    $<TARGET_OBJECTS:jsoncpp>
    $<TARGET_OBJECTS:package_manager>
    $<TARGET_OBJECTS:primary>
    $<TARGET_OBJECTS:utilities>
    $<TARGET_OBJECTS:logging>
    $<TARGET_OBJECTS:storage>
    $<TARGET_OBJECTS:uptane>)
if (BUILD_ISOTP)
    target_sources(aktualizr-c PRIVATE $<TARGET_OBJECTS:isotp_conn>)
endif (BUILD_ISOTP)

target_include_directories(aktualizr-c PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(aktualizr-c PRIVATE ${AKTUALIZR_EXTERNAL_LIBS})

aktualizr_source_file_checks(${SOURCES})

add_subdirectory(test)

Fix libaktualizr-c after pluggable pacman changes
Fix libaktualizr-c after pluggable pacman changes

Unfortunately, I did not find a better solution than repeating the
objects here.

Linking with aktualizr_static_lib does not work as initialization
symbols are not taken into the .so.

I also tried:

```
add_library(aktualizr_objects $<TARGET_OBJECTS:asn1> ...)
add_library(aktualizr-c SHARED $<TARGET_OBJECTS:aktualizr_objects>)
```

But CMake does not seem to support that, unfortunately.

Signed-off-by: Laurent Bonnans <0909bc0a3d1b0c91d8e00372b9633e8e9ea958de@here.com>
