diff --git a/cmake/Modules/Generate.cmake b/cmake/Modules/Generate.cmake index cacf2c2bb1..6a54baf631 100644 --- a/cmake/Modules/Generate.cmake +++ b/cmake/Modules/Generate.cmake @@ -17,11 +17,27 @@ function(IDLC_GENERATE) cmake_parse_arguments( IDLC "${options}" "${one_value_keywords}" "${multi_value_keywords}" "" ${ARGN}) - set(_idlc_shared_lib "$") - set(_idlc_depends CycloneDDS::libidlc) + if (TARGET CycloneDDS::libidlc) + set(_idlc_backend "$") + 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} @@ -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() @@ -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 @@ -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) diff --git a/ports/qnx/qnx-common.cmake b/ports/qnx/qnx-common.cmake new file mode 100644 index 0000000000..eec1a8aab3 --- /dev/null +++ b/ports/qnx/qnx-common.cmake @@ -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) + diff --git a/ports/qnx/qnx-sdp710-aarch64le.cmake b/ports/qnx/qnx-sdp710-aarch64le.cmake new file mode 100644 index 0000000000..1313ee3f2f --- /dev/null +++ b/ports/qnx/qnx-sdp710-aarch64le.cmake @@ -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") diff --git a/ports/qnx/qnx-sdp710-x86_64.cmake b/ports/qnx/qnx-sdp710-x86_64.cmake new file mode 100644 index 0000000000..75e139c161 --- /dev/null +++ b/ports/qnx/qnx-sdp710-x86_64.cmake @@ -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") diff --git a/src/ddsrt/CMakeLists.txt b/src/ddsrt/CMakeLists.txt index d5c7863654..0fe47b8ce1 100644 --- a/src/ddsrt/CMakeLists.txt +++ b/src/ddsrt/CMakeLists.txt @@ -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()