How CEDA cmake config supports multiple platforms

Typically the Windows CEDA SDK is installed under C:\Program Files\Ceda.

Platforms

The Windows CEDA SDK installer supports cross platform development, allowing for the following target platforms:

For each platform there are four variants for relwithdebinfo/debug and shared/static.

Registration of Ceda in the CMake System Package Registry

The cmake package name for the CEDA SDK is Ceda.

For example, you might use the following find_package cmake command in your CMakeLists.txt file to find the Ceda package:

    find_package(Ceda CONFIG REQUIRED)

The installer registers the CEDA SDK in the cmake System Package Registry, by writing the install location (such as C:\Program Files\Ceda) under

HKEY_LOCAL_MACHINE\SOFTWARE\Kitware\CMake\Packages\Ceda

The upshot is that cmake will automatically find the CEDA headers and library files, when you are building CEDA based applications.

More specifically, cmake will find the platform independent CedaConfig.cmake typically located in C:\Program Files\Ceda\cmake.

How CEDA cmake config supports multiple platforms

CMake doesn't provide specialised support for having a CedaConfig.cmake file which allows for multiple target platforms. This is because the "default" CedaConfigVersion.cmake created by the write_basic_package_version_file macro only pays attention to CMAKE_SIZEOF_VOID_P. The solution is to have a platform independent CedaConfig.cmake which includes a particular platform dependent one, depending on the values of the following CMake variables:

    CMAKE_SYSTEM_NAME
    CMAKE_SYSTEM_PROCESSOR
    CMAKE_SYSTEM_VERSION
    CMAKE_SIZEOF_VOID_P
    BUILD_SHARED_LIBS

CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_PROCESSOR, CMAKE_SYSTEM_VERSION and CMAKE_SIZEOF_VOID_P are used to select the target platform or architecture. Currently CMAKE_SYSTEM_VERSION is not checked for any of the supported platforms, but may be needed if there are ABI [] changes when the target platform version changes.

BUILD_SHARED_LIBS is used to select between shared/static variants.

The platform independent CedaConfig.cmake typically has path C:\Program Files\Ceda\cmake\CedaConfig.cmake.


# File: CedaConfig.cmake
# Location: cmake/
#
# This is platform-independent script.
#
# Redirect configuration to the platform-specific script <system>/<cpu>/lib/CedaConfig.cmake.

# Calculate platform name. E.g. Windows-x86, Windows-x64, Android-aarch64
# The platform name is determined by the values of CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_PROCESSOR and CMAKE_SIZEOF_VOID_P
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
    if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64")
        if (${CMAKE_SIZEOF_VOID_P} EQUAL "8")
            set(PLATFORM "Windows-x64")
        else()
            # If CMAKE_SIZEOF_VOID_P disagrees with CMAKE_SYSTEM_PROCESSOR then go by CMAKE_SIZEOF_VOID_P
            set(PLATFORM "Windows-x86")
        endif()
    elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86")
        set(PLATFORM "Windows-x86")
    else()
        set(PLATFORM ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
    endif()
else()
    set(PLATFORM ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
endif()

set(LIBTYPE "")
if (NOT BUILD_SHARED_LIBS)
    set(LIBTYPE "-static")
endif()

include(${CMAKE_CURRENT_LIST_DIR}/../${PLATFORM}${LIBTYPE}/cmake/CedaConfig.cmake)

This will include a platform dependent CedaConfig.cmake with one of the following paths:

Examples of platform dependent cmake files for the CEDA SDK

C:\Program Files\Ceda\Windows-x64\cmake
├── CedaCommon.cmake
├── CedaConfig.cmake
├── CedaConfigVersion.cmake
├── CedaTargets-debug.cmake
├── CedaTargets-relwithdebinfo.cmake
├── CedaTargets.cmake
├── ConfigureFile.cmake
├── CreateAndInstallWheel.cmake
├── GlobJniFiles.cmake
└── GlobRecurseFileCopy.cmake