Skip to content

Commit

Permalink
Add support for QNX SDP 7.1
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Masselink <patrick.masselink@zettascale.tech>
  • Loading branch information
PatrickM-ZS authored and eboasson committed Feb 5, 2024
1 parent 1c9bc19 commit 2cfdc1b
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 13 deletions.
37 changes: 25 additions & 12 deletions cmake/Modules/Generate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,27 @@ function(IDLC_GENERATE)
cmake_parse_arguments(
IDLC "${options}" "${one_value_keywords}" "${multi_value_keywords}" "" ${ARGN})

set(_idlc_shared_lib "$<TARGET_FILE:CycloneDDS::libidlc>")
set(_idlc_depends CycloneDDS::libidlc)
if (TARGET CycloneDDS::libidlc)
set(_idlc_backend "$<TARGET_FILE:CycloneDDS::libidlc>")
if (NOT DEFINED _idlc_generate_skipreport)
message(STATUS "Building internal IDLC backend")
set(_idlc_generate_skipreport 1 CACHE INTERNAL "")
endif()
set(_idlc_depends CycloneDDS::libidlc)
else()
find_library(_idlc_backend "cycloneddsidlc" NO_CMAKE_FIND_ROOT_PATH)
if (_idlc_backend)
if (NOT DEFINED _idlc_generate_skipreport)
message(STATUS "Using external IDLC backend: ${_idlc_backend}")
set(_idlc_generate_skipreport 1 CACHE INTERNAL "")
endif()
else()
message(FATAL_ERROR "Unable to find IDLC C-backend library: cycloneddsidlc")
endif()
endif()

set(gen_args
BACKEND ${_idlc_shared_lib}
BACKEND ${_idlc_backend}
${IDLC_UNPARSED_ARGUMENTS}
TARGET ${IDLC_TARGET}
BASE_DIR ${IDLC_BASE_DIR}
Expand All @@ -32,12 +48,15 @@ function(IDLC_GENERATE)
OUTPUT_DIR ${IDLC_OUTPUT_DIR}
DEFAULT_EXTENSIBILITY ${IDLC_DEFAULT_EXTENSIBILITY}
DEPENDS ${_idlc_depends})

if(${IDLC_NO_TYPE_INFO})
list(APPEND gen_args NO_TYPE_INFO)
endif()

if(${IDLC_WERROR})
list(APPEND gen_args WERROR)
endif()

idlc_generate_generic(${gen_args})
endfunction()

Expand All @@ -49,15 +68,7 @@ function(IDLC_GENERATE_GENERIC)
IDLC "${options}" "${one_value_keywords}" "${multi_value_keywords}" "" ${ARGN})

# find idlc binary
if(CMAKE_CROSSCOMPILING OR NOT BUILD_IDLC)
find_program(_idlc_executable idlc NO_CMAKE_FIND_ROOT_PATH REQUIRED)

if(_idlc_executable)
set(_idlc_depends "")
else()
message(FATAL_ERROR "Cannot find idlc executable")
endif()
else()
if(BUILD_IDLC)
if (CMAKE_PROJECT_NAME STREQUAL "CycloneDDS")
# By using the internal target when building CycloneDDS itself, prevent using an external idlc
# This prevents a problem when an installed cyclone is on your prefix path when building cyclone again
Expand All @@ -67,6 +78,8 @@ function(IDLC_GENERATE_GENERIC)
set(_idlc_executable CycloneDDS::idlc)
set(_idlc_depends CycloneDDS::idlc)
endif()
else()
find_program(_idlc_executable "idlc" NO_CMAKE_FIND_ROOT_PATH REQUIRED)
endif()

if(NOT IDLC_TARGET AND NOT IDLC_FILES)
Expand Down
25 changes: 25 additions & 0 deletions ports/qnx/qnx-common.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
set(CMAKE_SYSTEM_NAME QNX)
set(CMAKE_SYSTEM_VERSION ${QNX_VERSION})
set(CMAKE_SYSTEM_PROCESSOR ${QNX_PROCESSOR})

set(CMAKE_C_COMPILER qcc)
set(CMAKE_CXX_COMPILER q++)

set(CMAKE_C_COMPILER_TARGET ${QNX_TOOLCHAIN_ARCH})
set(CMAKE_CXX_COMPILER_TARGET ${QNX_TOOLCHAIN_ARCH})

if(NOT DEFINED ENV{QNX_HOST} OR NOT DEFINED ENV{QNX_TARGET})
message(FATAL_ERROR "Environment variable(s) QNX_HOST and/or QNX_TARGET not set! Set the QNX SDP environment by running e.g. 'source qnxsdp-env.sh'")
endif()

set(CMAKE_FIND_ROOT_PATH $ENV{QNX_TARGET};$ENV{QNX_TARGET}/${CMAKE_SYSTEM_PROCESSOR})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

add_compile_options("-D_QNX_SOURCE=1")

# Default features which are not supported by QNX and need to be disabled
set(ENABLE_SOURCE_SPECIFIC_MULTICAST 0)

5 changes: 5 additions & 0 deletions ports/qnx/qnx-sdp710-aarch64le.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(QNX_VERSION 7.1.0)
set(QNX_PROCESSOR aarch64le)
set(QNX_TOOLCHAIN_ARCH gcc_ntoaarch64le)

include("${CMAKE_CURRENT_LIST_DIR}/qnx-common.cmake")
5 changes: 5 additions & 0 deletions ports/qnx/qnx-sdp710-x86_64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(QNX_VERSION 7.1.0)
set(QNX_PROCESSOR x86_64)
set(QNX_TOOLCHAIN_ARCH gcc_ntox86_64)

include("${CMAKE_CURRENT_LIST_DIR}/qnx-common.cmake")
2 changes: 1 addition & 1 deletion src/ddsrt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ else()
if(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
target_link_libraries(ddsrt INTERFACE socket nsl)
elseif(CMAKE_SYSTEM_NAME MATCHES QNX)
target_link_libraries(ddsrt INTERFACE socket)
target_link_libraries(ddsrt INTERFACE socket m)
endif()
endif()
endif()
Expand Down

0 comments on commit 2cfdc1b

Please sign in to comment.