cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

SDK Reference Part 9

No ratings

 

 

Step 13: C - Support Other Platforms

 

If you are using a platform that is different than the options provided in the CMake configurations or in the C SDK configurations, you can add your own computer type.

 

CMake has its own custom toolchain support that enables you to add your computer to the CMake configurations.

 

  1. Go to the CMake Toolchain.

    NOTE: The C SDK provides a CMakeList.txt file that contains the setup instructions for the C SDK. Make changes only if you have verified the configurations and compiler information.

  2. Create a CMakeList.txt file based on your OS inside the folder in which you would like to setup your application.
  3. Modify the Platform Configuration section of the CMakeList.txt file to add your personal computer architecture if it is not already listed.
  4. Ensure your configurations are in your application's CMakeList.txt file.

 

An example of the Platform Configuration section is shown below.

if (PLATFORM)
    if (${PLATFORM} MATCHES "linux-arm")
        set(OS "linux")
        set(ARCHITECTURE "arm")
        set(CMAKE_C_COMPILER ${CMAKE_CURRENT_SOURCE_DIR}/../TOOLS/gcc-linux-arm-cross/bin/arm-angstrom-linux-gnueabi-gcc)
        set(CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../TOOLS/gcc-linux-arm-cross ${CMAKE_CURRENT_SOURCE_DIR}/../TOOLS/gcc-linux-arm-cross/arm-angstrom-linux-gnueabi)
        # Set LD_LIBRARY_PATH
        set(Env{LD_LIBRARY_PATH} "${CMAKE_FIND_ROOT_PATH}/lib/gcc")
else ()
    if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
        set(OS "linux")
        if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
            set(ARCHITECTURE "x86_64")
            set(PLATFORM "linux-x86-64")
        elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_32" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i[36]86")
            set(ARCHITECTURE "x86_32")
            set(PLATFORM "linux-x86-32")
        elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv5tejl")
            set(ARCHITECTURE "arm")
            set(PLATFORM "linux-arm")
        elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv[67]l")
            set(ARCHITECTURE "arm-hwfpu")
            set(PLATFORM "linux-arm-hwfpu")
        else () # default to linux-x86_64
            set(ARCHITECTURE "x86_64")
            set(PLATFORM "linux-x86-64")
        endif()
endif ()

 

An example of how to work with your OS in your application's CMakeList.txt file is shown below:

add_executable (SteamSensor src/main.c src/SteamThing.c)
target_link_libraries (SteamSensor LINK_PUBLIC twCSdk)

if (${OS} MATCHES "windows")
    add_custom_command(TARGET SteamSensor POST_BUILD
            COMMAND cmake -E copy_if_different "${CMAKE_BINARY_DIR}/$<CONFIGURATION>/twCSdk.dll" "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/twCSdk.dll"
            COMMENT "Copying C SDK dll to example directory.")
    if (${TLS_LIB} MATCHES "openssl")
        # Copy over openssl dll files
        add_custom_command(TARGET SteamSensor POST_BUILD
                COMMAND cmake -E copy_if_different "${OPENSSL_SSLEAY_BIN_PATH}" "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/ssleay32.dll"
                COMMENT "Copying ssleay dll to example directory.")
        add_custom_command(TARGET SteamSensor POST_BUILD
                COMMAND cmake -E copy_if_different "${OPENSSL_LIBEAY_BIN_PATH}" "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/libeay32.dll"
                COMMENT "Copying ssleay dll to example directory.")
    endif ()
endif ()

if (${OS} MATCHES "linux")
    if (${TLS_LIB} MATCHES "openssl")
        # Copy over openssl libraries.
        add_custom_command(TARGET SteamSensor POST_BUILD
                COMMAND cmake -E copy_if_different "${OPENSSL_LIB_DIR}/libcrypto.so.1.0.0" "${CMAKE_CURRENT_BINARY_DIR}"
                COMMAND cmake -E copy_if_different "${OPENSSL_LIB_DIR}/libssl.so.1.0.0" "${CMAKE_CURRENT_BINARY_DIR}"
                COMMENT "Copying openssl to test directory.")
    endif ()
endif ()

if (${OS} MATCHES "macos")
    if (${TLS_LIB} MATCHES "openssl")
        # Copy over openssl libraries.
        add_custom_command(TARGET SteamSensor POST_BUILD
                COMMAND cmake -E copy_if_different "${OPENSSL_LIB_DIR}/libcrypto.1.0.0.dylib" "${CMAKE_CURRENT_BINARY_DIR}"
                COMMAND cmake -E copy_if_different "${OPENSSL_LIB_DIR}/libssl.1.0.0.dylib" "${CMAKE_CURRENT_BINARY_DIR}"
                COMMENT "Copying openssl to test directory.")
    endif ()
endif()
 
 

Step 14: Next Steps

 

Congratulations! You've successfully completed the SDK Reference Guide.

 

This guide is designed to be used as a reference when developing your application with one of the ThingWorx SDKs.

 

Learn More

 

We recommend the following resources to continue your learning experience:

 

CapabilityGuide
BuildDesign Your Data Model

 

Additional Resources

 

If you have questions, issues, or need additional information, refer to:

ResourceLink 
CommunityDeveloper Community Forum 
SupportC SDK Help CenterJava SDK Help Center
Version history
Last update:
‎Nov 08, 2022 03:31 PM
Updated by:
Labels (2)
Contributors