Migrate project created with templates provided with WinCC OA 3.21.4 or older

Due to significant refactoring in WinCC OA 3.21.5, existing Backend projects require manual migration. This involves updating CMake library links, adding the MSVC runtime policy, adjusting subdirectory calls, and rebuilding after cleaning external libraries.

In WinCC OA 3.21.5 the template for Backend project was significantly refactored. It is necessary to migrate Backend projects to remain compatible with new WinCC OA release. Automatic migration procedure is not provided, because the affected files could contain adaptations introduced during Backend project development. What follows is a list of necessary project changes.

  1. Adapt
    target_link_libraries
    call in
    Lib/CMakeLists.txt
    change zeromq to libzmq - add libcppzmq - change protobuf to libprotobuf
    Example, before:
    target_link_libraries(${TARGET} 
      ${WCCOA_LIB_PREFIX}Basics${WCCOA_LIB_INFIX} 
      CommonBackend 
      ${SSL_LIB} 
      Importer 
      NgaProtobufFiles 
      CommonMultiplexer 
      DpeNameMapper 
      zeromq 
      protobuf )
    After:
    target_link_libraries(${TARGET} 
      ${WCCOA_LIB_PREFIX}Basics${WCCOA_LIB_INFIX} 
      CommonBackend
       ${SSL_LIB} 
      Importer 
      NgaProtobufFiles 
      CommonMultiplexer 
      DpeNameMapper 
      libzmq 
      libcppzmq 
      libprotobuf 
      )
  2. Adapt CMakeLists.txt file in the root of the project directory by adding this snippet just after cmake_minimum_required call at the beginning:
    if ( WIN32 ) 
      # MSVC runtime library flags are selected by an abstraction.
      cmake_policy(SET CMP0091 NEW) 
      set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL" CACHE STRING "" FORCE) ## on Windows always use the non-debug runtime libs (-MD)
    endif()
  3. Additionally, near the end of the file change add_subdirectory(ExternLibs) into
    add_subdirectory(${API_ROOT}/TemplateNextGenArchBackend/ExternLibs ${CMAKE_CURRENT_BINARY_DIR}/ExternLibs)
    The
    updateNextGenArchExternLibs.cmd 
    or
    updateNextGenArchExternLibs.sh
    script can be removed, it is no longer necessary. Updates to external dependencies are now managed by the cmake build process and will be available automatically after WinCC OA upgrade.
    The
    ExternLibs
    subdirectory together with its contents is no longer used by the project and can be removed.
  4. Remove the old `build` subdirectory and regenerate it:
    cd build
    cmake -G "Visual Studio 17 2022" -A "x64" -T "v143" -D CMAKE_BUILD_TYPE=RelWithDebInfo -D CMAKE_CONFIGURATION_TYPES=RelWithDebInfo ..

    or on Linux:

    cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo ..
  5. Now the project can be built:
    cmake --build . --config RelWithDebInfo