Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/cmake/FindRTI.cmake
T
torstenandCopilot 850d10d8de Qt6 migration verification: RTI 7.7 Pro integration and path fixes
Major changes:
- Merged branches: feature/arcgis300-symbology-migration, feature/lts-viewer-validation-testing-phase, bugfix/fix-warning-issue
- Integrated RTI 7.7 Pro commercial library with proper CMake configuration
- Fixed all hardcoded /workspace paths to use /repo (Docker mount point)
- Added DOCKER_MOUNT_ROOT parameter to new_docker_build.sh for configurable mount points
- Fixed RPATH configuration for proper runtime library loading

Technical fixes:
- cmake/FindRTI.cmake: Set CMP0111 policy unconditionally, fixed IMPORTED_LOCATION property setting outside target creation block, added debug logging
- CMakeLists.txt: Added CMP0111 before find_package(RTI), updated path detection for /repo, configured RPATH
- Lts/DDS/CMakeLists.txt: Reordered DdsUnitTests before DdsUnitTestsPlaceholder to fix test executable naming
- ArcGIS symbology: Removed deprecated m_sssResult and m_esriSwatchTaskUuid members (ArcGIS 300 API changes)

Build verification:
- 10 CPU build: 100% success (error fixing phase)
- 1 CPU build: 100% success (final validation)
- CTest: 675 tests run, 97% pass rate (654/675 passed)
- RTI DDS integration test: PASSED

Known issues:
- 21 tests failed (mostly 'Not Run' for missing smoke test executables)
- Timeout issues in bld_bsm_test and taboc_serialtest (connection refused errors)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-04 09:04:01 +00:00

412 lines
16 KiB
CMake
Executable File

SET(_rti_gcc_arch "")
# Suppress CMP0153 warning: EXEC_PROGRAM is deprecated
if(POLICY CMP0153)
cmake_policy(SET CMP0153 OLD)
endif()
# Set policy for imported target location requirements - must be set before any imported targets are created
if(POLICY CMP0111)
cmake_policy(SET CMP0111 NEW)
endif()
# Check if RTI_DIR is not set OR is empty (cached empty string from previous failed detection)
IF(NOT RTI_DIR OR RTI_DIR STREQUAL "")
# First check RTI_INSTALL_DIR CMake variable (set by parent CMakeLists.txt)
IF(RTI_INSTALL_DIR AND EXISTS "${RTI_INSTALL_DIR}")
SET(_RTI_DIR "${RTI_INSTALL_DIR}")
ELSE()
SET(_arch "unknown")
IF(WIN32)
SET(_RTI_DIR $ENV{DDS_PATH})
IF(NOT _RTI_DIR)
GET_FILENAME_COMPONENT(_rti_root_path "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Real-Time Innovations\\RTI Connext DDS Pro 5.2.3;Location]" ABSOLUTE)
SET(_RTI_DIR "${_rti_root_path}")
ENDIF()
IF(MSVC_VERSION EQUAL 1900)
SET(_rti_msvc_ver "VS2015")
ELSEIF(MSVC_VERSION GREATER_EQUAL 1910)
SET(_rti_msvc_ver "VS2017")
ENDIF()
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(_rti_msvc_ver "x64Win64${_rti_msvc_ver}")
ELSE()
SET(_rti_msvc_ver "i86Win32${_rti_msvc_ver}")
ENDIF()
IF(NOT ${_rti_root_path})
SET(_RTI_DIR $ENV{KDEROOT})
FILE(TO_CMAKE_PATH "${_RTI_DIR}" _RTI_DIR)
IF(NOT EXISTS "${_RTI_DIR}" OR NOT IS_DIRECTORY "${_RTI_DIR}")
SET(_RTI_DIR $ENV{WORKSPACE})
FILE(TO_CMAKE_PATH "${_RTI_DIR}" _RTI_DIR)
ENDIF()
IF(NOT EXISTS "${_RTI_DIR}" OR NOT IS_DIRECTORY "${_RTI_DIR}")
SET(_RTI_DIR ${EXTERNAL_LIBRARY_DIR})
FILE(TO_CMAKE_PATH "${_RTI_DIR}" _RTI_DIR)
ENDIF()
ENDIF()
SET(_arch "${_rti_msvc_ver}")
ELSE(WIN32)
SET(_RTI_DIR $ENV{DDS_PATH})
IF(NOT _RTI_DIR)
# Try local external directory first (check multiple levels for different repo structures)
# Check container path first (${DOCKER_MOUNT_ROOT}/external, default /repo), then host-relative paths
IF(EXISTS "${CMAKE_SOURCE_DIR}/external/rti_connext_dds-7.7.0")
SET(_RTI_DIR "${CMAKE_SOURCE_DIR}/external/rti_connext_dds-7.7.0")
ELSEIF(EXISTS "${CMAKE_SOURCE_DIR}/../external/rti_connext_dds-7.7.0")
SET(_RTI_DIR "${CMAKE_SOURCE_DIR}/../external/rti_connext_dds-7.7.0")
ELSEIF(EXISTS "${CMAKE_SOURCE_DIR}/../../../external/rti_connext_dds-7.7.0")
SET(_RTI_DIR "${CMAKE_SOURCE_DIR}/../../../external/rti_connext_dds-7.7.0")
ELSE()
SET(_RTI_DIR "/opt/RTI")
ENDIF()
ENDIF()
IF(NOT EXISTS "${_RTI_DIR}" OR NOT IS_DIRECTORY "${_RTI_DIR}")
MESSAGE(WARNING "RTI directory ${_RTI_DIR} not found; continuing without RTI. Set DDS_PATH to RTI installation to enable RTI features.")
# mark as not available
set(_RTI_DIR_NOT_FOUND TRUE)
set(_RTI_DIR "")
ENDIF()
SET(_rti_gcc_arch "x64Linux3gcc4.8.2")
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
IF(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0.0)
# Prefer newer gcc-based RTI builds; try a sequence then fall back to any x64Linux4gcc* dir found under RTI lib
# RTI 7.7 Pro uses resource/app/lib structure instead of lib/
IF(EXISTS "${_RTI_DIR}/resource/app/lib")
SET(_rti_lib_dir "${_RTI_DIR}/resource/app/lib")
ELSE()
SET(_rti_lib_dir "${_RTI_DIR}/lib")
ENDIF()
SET(_preferred_archs "x64Linux4gcc8.5.0;x64Linux4gcc7.3.0;x64Linux3gcc5.4.0")
SET(_found_arch "")
foreach(_cand IN LISTS _preferred_archs)
if(EXISTS "${_rti_lib_dir}/${_cand}")
SET(_found_arch "${_cand}")
break()
endif()
endforeach()
if(_found_arch STREQUAL "")
# fallback: pick any x64Linux* directory under lib
file(GLOB _rti_arch_dirs RELATIVE "${_rti_lib_dir}" "${_rti_lib_dir}/x64Linux*")
list(LENGTH _rti_arch_dirs _rti_arch_dirs_len)
if(_rti_arch_dirs_len GREATER 0)
list(GET _rti_arch_dirs 0 _found_arch)
endif()
endif()
if(NOT _found_arch STREQUAL "")
SET(_rti_gcc_arch "${_found_arch}")
else()
# final fallbacks
SET(_rti_gcc_arch "x64Linux4gcc7.3.0")
endif()
ENDIF()
ENDIF()
SET(_arch "${_rti_gcc_arch}")
ENDIF()
ENDIF()
SET(RTI_DIR "${_RTI_DIR}" CACHE STRING "RTI base path" FORCE)
MESSAGE(STATUS "Trying to use RTI from ${RTI_DIR} with arch ${_arch}")
ELSE()
# RTI_DIR was provided externally - auto-detect architecture
SET(_rti_gcc_arch "x64Linux3gcc4.8.2")
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
IF(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0.0)
# Prefer newer gcc-based RTI builds; try a sequence then fall back to any x64Linux4gcc* dir found under RTI lib
# RTI 7.7 Pro uses resource/app/lib structure instead of lib/
IF(EXISTS "${RTI_DIR}/resource/app/lib")
SET(_rti_lib_dir "${RTI_DIR}/resource/app/lib")
ELSE()
SET(_rti_lib_dir "${RTI_DIR}/lib")
ENDIF()
SET(_preferred_archs "x64Linux4gcc8.5.0;x64Linux4gcc7.3.0;x64Linux3gcc5.4.0")
SET(_found_arch "")
foreach(_cand IN LISTS _preferred_archs)
if(EXISTS "${_rti_lib_dir}/${_cand}")
SET(_found_arch "${_cand}")
break()
endif()
endforeach()
if(_found_arch STREQUAL "")
# fallback: pick any x64Linux* directory under lib
file(GLOB _rti_arch_dirs RELATIVE "${_rti_lib_dir}" "${_rti_lib_dir}/x64Linux*")
list(LENGTH _rti_arch_dirs _rti_arch_dirs_len)
if(_rti_arch_dirs_len GREATER 0)
list(GET _rti_arch_dirs 0 _found_arch)
endif()
endif()
if(NOT _found_arch STREQUAL "")
SET(_rti_gcc_arch "${_found_arch}")
else()
# final fallbacks
SET(_rti_gcc_arch "x64Linux4gcc7.3.0")
endif()
ENDIF()
ENDIF()
MESSAGE(STATUS "Using externally provided RTI from ${RTI_DIR} with arch ${_rti_gcc_arch}")
ENDIF()
IF(WIN32)
SET(_rti_include_hint "${RTI_DIR}/include/")
SET(_rti_library_hint "${RTI_DIR}/lib/${_rti_msvc_ver}/")
ELSE()
SET(_rti_include_hint "${RTI_DIR}/include/")
SET(_rti_library_hint "${RTI_DIR}/lib/")
ENDIF()
IF(NOT RTI_INCLUDE_DIR)
if(DEFINED _RTI_DIR_NOT_FOUND AND _RTI_DIR STREQUAL "")
# RTI directory was not found earlier; skip searching for includes and create empty placeholder
message(WARNING "Skipping RTI include search because RTI installation was not found")
set(RTI_INCLUDE_DIR "")
set(RTI_INCLUDE_DIRS "" CACHE STRING "RTI include directories" FORCE)
# Create placeholder INTERFACE targets for all RTI libraries when RTI is not installed
# These allow configuration to succeed but will cause link errors if actually used
SET(_RTI_LIBS nddscore nddsc nddscpp2 rtiroutingservice)
FOREACH(_lib ${_RTI_LIBS})
SET(_tgt_name RTI::${_lib})
IF(NOT TARGET ${_tgt_name})
ADD_LIBRARY(${_tgt_name} INTERFACE IMPORTED)
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "")
# Set dummy library variables to satisfy Ninja dependency tracking
SET(RTI_${_lib}_LIBRARY "" CACHE STRING "RTI ${_lib} library (placeholder)" FORCE)
SET(RTI_${_lib}_LIBRARY_RELEASE "" CACHE STRING "RTI ${_lib} library release (placeholder)" FORCE)
SET(RTI_${_lib}_LIBRARY_DEBUG "" CACHE STRING "RTI ${_lib} library debug (placeholder)" FORCE)
ENDIF()
ENDFOREACH()
SET(RTI_LIBRARIES "" CACHE STRING "All rti libraries (placeholder)" FORCE)
SET(RTI_FOUND FALSE CACHE BOOL "RTI not found" FORCE)
# Force BUILD_RTI to OFF when RTI is not actually installed
SET(BUILD_RTI OFF CACHE BOOL "Build with RTI support" FORCE)
MESSAGE(WARNING "RTI not found - disabling BUILD_RTI. Set DDS_PATH to RTI installation to enable RTI features.")
return()
else()
# Use PATHS instead of HINTS for more reliable path resolution
FIND_PATH(RTI_INCLUDE_DIR ndds/ndds_cpp.h PATHS ${_rti_include_hint} NO_DEFAULT_PATH)
IF(RTI_INCLUDE_DIR)
SET(RTI_INCLUDE_DIRS "${RTI_INCLUDE_DIR}" "${RTI_INCLUDE_DIR}/ndds" "${RTI_INCLUDE_DIR}/ndds/hpp" CACHE STRING "RTI include directories" FORCE)
MARK_AS_ADVANCED(RTI_INCLUDE_DIRS)
ELSE()
MESSAGE(FATAL "Could not find RTI include directory at ${_rti_include_hint}")
ENDIF()
endif()
ENDIF()
IF(NOT RTI_DDSGEN_EXECUTABLE)
# RTI 7.7 Pro uses resource/app/bin structure
IF(EXISTS "${RTI_DIR}/resource/app/bin/${_rti_gcc_arch}")
FIND_PROGRAM(RTI_DDSGEN_EXECUTABLE NAMES rtiddsgen rtiddsgen2 rtiddsgen.bat
HINTS ${RTI_DIR}/resource/app/bin/${_rti_gcc_arch} ${RTI_DIR}/bin)
ELSE()
FIND_PROGRAM(RTI_DDSGEN_EXECUTABLE NAMES rtiddsgen rtiddsgen.bat
HINTS ${RTI_DIR}/scripts ${RTI_DIR}/bin)
ENDIF()
ENDIF()
IF(NOT RTI_VERSION_MAJOR)
EXEC_PROGRAM(${RTI_DDSGEN_EXECUTABLE} ARGS -version OUTPUT_VARIABLE _dds_version_output)
STRING(REGEX REPLACE ".* ([0-9]\\.[0-9]\\.[0-9]).*" "\\1" _dds_version_output ${_dds_version_output})
SET(_rti_version_major 5)
IF(_dds_version_output VERSION_GREATER 2.9.9)
SET(_rti_version_major 6)
ENDIF()
SET(RTI_VERSION_MAJOR ${_rti_version_major} CACHE STRING "RTI version" FORCE)
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
# Set policy for imported target library requirements
if(POLICY CMP0111)
cmake_policy(SET CMP0111 NEW)
endif()
SET(_RTI_LIBS nddscore nddsc nddscpp2 rtiroutingservice)
SET(_libs "")
SET(_lib_vars "")
# Build list of library search paths including arch-specific subdirs
# RTI 7.7 Pro uses resource/app/lib structure instead of lib/
IF(EXISTS "${RTI_DIR}/resource/app/lib")
SET(_rti_lib_base "${RTI_DIR}/resource/app/lib")
ELSE()
SET(_rti_lib_base "${RTI_DIR}/lib")
ENDIF()
set(_rti_lib_search_paths "${_rti_lib_base}" "${_rti_lib_base}/${_rti_gcc_arch}")
# Also scan for any arch subdirs under lib/
file(GLOB _rti_arch_dirs "${_rti_lib_base}/*")
foreach(_arch_dir IN LISTS _rti_arch_dirs)
if(IS_DIRECTORY "${_arch_dir}")
list(APPEND _rti_lib_search_paths "${_arch_dir}")
endif()
endforeach()
FOREACH(_lib ${_RTI_LIBS})
SET(_libname "RTI_${_lib}_LIBRARY")
SET(_libname_release "RTI_${_lib}_LIBRARY_RELEASE")
SET(_libname_debug "RTI_${_lib}_LIBRARY_DEBUG")
# Build explicit search paths for this library
# RTI 7.7 Pro uses resource/app/lib structure instead of lib/
IF(EXISTS "${RTI_DIR}/resource/app/lib")
SET(_rti_lib_base "${RTI_DIR}/resource/app/lib")
ELSE()
SET(_rti_lib_base "${RTI_DIR}/lib")
ENDIF()
set(_lib_search_paths
"${_rti_lib_base}/${_rti_gcc_arch}"
"${_rti_lib_base}"
)
MESSAGE(STATUS "Finding RTI library '${_lib}': searching in ${_lib_search_paths}")
MESSAGE(STATUS " _rti_lib_base=${_rti_lib_base}, _rti_gcc_arch=${_rti_gcc_arch}")
# Find release library (no suffix)
FIND_LIBRARY(${_libname_release}
NAMES ${_lib}
PATHS ${_lib_search_paths}
NO_DEFAULT_PATH)
MESSAGE(STATUS " Result: ${_libname_release}=${${_libname_release}}")
# Find debug library (d suffix on Linux)
FIND_LIBRARY(${_libname_debug}
NAMES ${_lib}d
PATHS ${_lib_search_paths}
NO_DEFAULT_PATH)
# Use temporary variables to avoid double-dereference issues in IF conditions
SET(_release_path "${${_libname_release}}")
SET(_debug_path "${${_libname_debug}}")
# Set combined library variable - use simple SET without CACHE to avoid conflicts
IF(_release_path AND NOT _release_path MATCHES "NOTFOUND")
SET(${_libname} "${_release_path}")
ELSEIF(_debug_path AND NOT _debug_path MATCHES "NOTFOUND")
SET(${_libname} "${_debug_path}")
ENDIF()
SET(_tgt_name RTI::${_lib})
# Check if libraries are found BEFORE creating the target
SET(_release_found FALSE)
SET(_debug_found FALSE)
IF(_release_path AND NOT _release_path MATCHES "NOTFOUND")
SET(_release_found TRUE)
ENDIF()
IF(_debug_path AND NOT _debug_path MATCHES "NOTFOUND")
SET(_debug_found TRUE)
ENDIF()
MESSAGE(STATUS "DEBUG ${_lib}: _release_path=${_release_path}, _release_found=${_release_found}, _debug_found=${_debug_found}")
# Only create target if at least one library is found
IF(NOT _release_found AND NOT _debug_found)
MESSAGE(WARNING "RTI library ${_lib} not found in ${RTI_DIR}")
SET(${_libname} "" CACHE STRING "RTI ${_lib} library (not found)" FORCE)
CONTINUE()
ENDIF()
IF(NOT TARGET ${_tgt_name})
ADD_LIBRARY(${_tgt_name} UNKNOWN IMPORTED)
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${RTI_INCLUDE_DIRS}")
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${RTI_INCLUDE_DIRS}")
IF(UNIX)
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY INTERFACE_COMPILE_DEFINITIONS "RTI_UNIX;RTI_LINUX;RTI_64BIT" )
ENDIF()
IF(WIN32)
IF("${_lib}" STREQUAL "rtiroutingservice")
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY INTERFACE_COMPILE_DEFINITIONS "RTI_WIN32;RTI_routingservice_DLL_VARIABLE" )
ELSE()
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY INTERFACE_COMPILE_DEFINITIONS "RTI_WIN32;NDDS_DLL_VARIABLE" )
ENDIF()
ENDIF()
ENDIF()
# Set library locations - use release for both configs if debug not found
# Use pre-computed _release_path and _debug_path variables to avoid double-dereference issues
# IMPORTANT: This must be outside the TARGET creation block to handle multiple find_package calls
IF(_release_found AND _debug_found)
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG RelWithDebInfo)
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY IMPORTED_LOCATION_RELEASE "${_release_path}")
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY IMPORTED_LOCATION_DEBUG "${_debug_path}")
# Set default IMPORTED_LOCATION for non-configured builds
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY IMPORTED_LOCATION "${_release_path}")
# Set RelWithDebInfo to use release library
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY IMPORTED_LOCATION_RelWithDebInfo "${_release_path}")
ELSEIF(_release_found)
# Only release library found - don't list DEBUG in configurations
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY IMPORTED_CONFIGURATIONS RELEASE RelWithDebInfo)
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY IMPORTED_LOCATION_RELEASE "${_release_path}")
# Set default IMPORTED_LOCATION for non-configured builds
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY IMPORTED_LOCATION "${_release_path}")
# Set RelWithDebInfo to use release library
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY IMPORTED_LOCATION_RelWithDebInfo "${_release_path}")
ELSEIF(_debug_found)
# Only debug library found - don't list RELEASE in configurations
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY IMPORTED_CONFIGURATIONS DEBUG RelWithDebInfo)
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY IMPORTED_LOCATION_DEBUG "${_debug_path}")
# Set default IMPORTED_LOCATION for non-configured builds
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY IMPORTED_LOCATION "${_debug_path}")
# Set RelWithDebInfo to use debug library
SET_PROPERTY(TARGET ${_tgt_name} PROPERTY IMPORTED_LOCATION_RelWithDebInfo "${_debug_path}")
ENDIF()
# Use the combined library variable value
SET(_lib_path "${${_libname}}")
IF(_lib_path)
LIST(APPEND _libs "${_lib_path}")
ENDIF()
# rtiroutingservice is optional - only add required libs to _lib_vars for FIND_PACKAGE_HANDLE_STANDARD_ARGS
IF(NOT "${_lib}" STREQUAL "rtiroutingservice")
LIST(APPEND _lib_vars "${_libname}")
ENDIF()
ENDFOREACH()
IF(TARGET RTI::nddscore AND UNIX)
SET_PROPERTY(TARGET RTI::nddscore PROPERTY INTERFACE_LINK_LIBRARIES "dl" )
ENDIF()
SET(RTI_LIBRARIES ${_libs} CACHE STRING "All rti libraries" FORCE)
MARK_AS_ADVANCED(RTI_LIBRARIES)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(RTI DEFAULT_MSG RTI_DIR RTI_INCLUDE_DIR RTI_DDSGEN_EXECUTABLE ${_lib_vars})
# Explicitly set RTI_FOUND to TRUE when all required components are found
# This ensures CMakeLists.txt fallback code doesn't create placeholder targets
IF(RTI_DIR AND RTI_INCLUDE_DIR AND RTI_DDSGEN_EXECUTABLE AND RTI_LIBRARIES)
SET(RTI_FOUND TRUE CACHE BOOL "RTI found" FORCE)
MESSAGE(STATUS "RTI Connext DDS found: ${RTI_DIR} (libraries: ${RTI_LIBRARIES})")
ENDIF()