MyCompany/CMakeLists.txt

project(Pizza VERSION 2.0.0 LANGUAGES CXX)

find_package(Ceda REQUIRED)

cedaSetSourceRoot("${CMAKE_CURRENT_SOURCE_DIR}/..")

cedaTarget(XCPP NAMESPACE MyCompany PROJPATH MyCompany/DateTime)
target_link_libraries(DateTime 
    PUBLIC Ceda::cxUtils 
           Ceda::cxObject 
           Ceda::cxPersistStore)

cedaTarget(XCPP NAMESPACE MyCompany PROJPATH MyCompany/Shapes)
target_link_libraries(Shapes 
    PUBLIC Ceda::cxUtils 
           Ceda::cxObject 
           Ceda::cxPersistStore)

cedaTarget(XCPP NAMESPACE MyCompany PROJPATH MyCompany/Pizza)
target_link_libraries(Pizza 
    PUBLIC Ceda::cxUtils 
           Ceda::cxObject 
           Ceda::cxPersistStore
           MyCompany::DateTime
           MyCompany::Shapes)

message("--------------- Adding sub directory ConsoleTest")
add_subdirectory(ConsoleTest)

if (BUILD_SHARED_LIBS AND NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Android"))
    message("--------------- Adding sub directory python")
    add_subdirectory(python)
endif()

set(PIZZA_TARGETS DateTime Shapes Pizza)

if (BUILD_SHARED_LIBS)
    if (CEDA_LIBFFI_WORKS)
        cedaAddJni(pypizza pizza_jni PizzaJni ${CMAKE_CURRENT_SOURCE_DIR}/Java/generate_pizza_jni_wrappers.py "MyCompany::DateTime;MyCompany::Shapes;MyCompany::Pizza")
        list(APPEND PIZZA_TARGETS pizza_jni)
    endif()

    message("--------------- Adding sub directory Java")
    add_subdirectory(Java)
endif()

if (BUILD_SHARED_LIBS AND ${CMAKE_SYSTEM_NAME} STREQUAL "Android")
    set(AndroidLibs ${CMAKE_SOURCE_DIR}/MyCompany/CedaAndroidExample/app/libs)
    file(MAKE_DIRECTORY ${AndroidLibs})

    set(AndroidJniLibs ${CMAKE_SOURCE_DIR}/MyCompany/CedaAndroidExample/app/src/main/jniLibs/arm64-v8a)
    file(MAKE_DIRECTORY ${AndroidJniLibs})

    foreach(tgt DateTime Shapes Pizza pizza_jni)
        add_custom_command(
            TARGET ${tgt}
            POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${tgt}> ${AndroidJniLibs})
    endforeach()

    get_target_property(pizzaJarFile PizzaJni JAR_FILE)

    add_custom_command(
        TARGET PizzaJni
        POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy ${pizzaJarFile} ${AndroidLibs})

    file(GLOB CEDA_LIBS ${Ceda_LIB}/*.so)
    message("CEDA_LIBS = ${CEDA_LIBS}")
    file(COPY ${CEDA_LIBS} DESTINATION ${AndroidJniLibs})

    file(GLOB CEDA_JARS ${Ceda_BIN}/*.jar)
    message("CEDA_JARS = ${CEDA_JARS}")
    file(COPY ${CEDA_JARS} DESTINATION ${AndroidLibs})
endif()

###################################################################################################
# Installation instructions

cedaSetInstallDefaults()

include(GNUInstallDirs)

if (TARGET PizzaJni)
    install_jar(PizzaJni ${CMAKE_INSTALL_BINDIR})
endif()

install(TARGETS ${PIZZA_TARGETS}
    EXPORT pizza-targets
    CONFIGURATIONS "${CMAKE_BUILD_TYPE}"
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
	RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(DIRECTORY "${CMAKE_BINARY_DIR}/ceda-include/" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(DIRECTORY "${CMAKE_BINARY_DIR}/ceda-export/" DESTINATION ${CMAKE_INSTALL_EXPORTDIR})

install(EXPORT pizza-targets
  FILE
    PizzaTargets.cmake
  NAMESPACE
    MyCompany::
  DESTINATION
    ${INSTALL_CONFIGDIR}
)

include(CMakePackageConfigHelpers)

set(CVF_VERSION "${PROJECT_VERSION}")
configure_file(
    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PizzaConfigVersion.cmake.in 
    ${CMAKE_CURRENT_BINARY_DIR}/PizzaConfigVersion.cmake
    @ONLY)

#write_basic_package_version_file(
#    ${CMAKE_CURRENT_BINARY_DIR}/PizzaConfigVersion.cmake
#    VERSION ${PROJECT_VERSION}
#    COMPATIBILITY SameMajorVersion
#)

configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/PizzaConfig.cmake.in
    ${CMAKE_CURRENT_BINARY_DIR}/PizzaConfig.cmake
    INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)

install(FILES
    ${CMAKE_CURRENT_BINARY_DIR}/PizzaConfig.cmake
    ${CMAKE_CURRENT_BINARY_DIR}/PizzaConfigVersion.cmake
    DESTINATION ${INSTALL_CONFIGDIR}
)