From 10e5847fa852bc03f160cb11e4c9d22db64b23d9 Mon Sep 17 00:00:00 2001 From: James Choi Date: Tue, 11 Apr 2023 15:27:11 -0400 Subject: [PATCH] Add support for QNX 7.1 build Signed-off-by: James Choi --- CMakeLists.txt | 5 +++ build_qnx/Makefile | 8 +++++ build_qnx/common.mk | 57 +++++++++++++++++++++++++++++++ build_qnx/nto/Makefile | 8 +++++ build_qnx/nto/aarch64/Makefile | 8 +++++ build_qnx/nto/aarch64/le/Makefile | 5 +++ build_qnx/nto/x86_64/Makefile | 8 +++++ build_qnx/nto/x86_64/o/Makefile | 5 +++ build_qnx/qnx.nto.toolchain.cmake | 34 ++++++++++++++++++ tests/CMakeLists.txt | 4 +++ 10 files changed, 142 insertions(+) create mode 100644 build_qnx/Makefile create mode 100644 build_qnx/common.mk create mode 100644 build_qnx/nto/Makefile create mode 100644 build_qnx/nto/aarch64/Makefile create mode 100644 build_qnx/nto/aarch64/le/Makefile create mode 100644 build_qnx/nto/x86_64/Makefile create mode 100644 build_qnx/nto/x86_64/o/Makefile create mode 100644 build_qnx/qnx.nto.toolchain.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f30ba679..9940da15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1468,6 +1468,11 @@ endforeach() if(BUILD_SHARED) target_link_libraries(libzmq ${CMAKE_THREAD_LIBS_INIT}) + + if(QNX) + target_link_libraries(libzmq -lsocket) + endif() + if(GNUTLS_FOUND) target_link_libraries(libzmq ${GNUTLS_LIBRARIES}) target_include_directories(libzmq PRIVATE "${GNUTLS_INCLUDE_DIR}") diff --git a/build_qnx/Makefile b/build_qnx/Makefile new file mode 100644 index 00000000..1f254004 --- /dev/null +++ b/build_qnx/Makefile @@ -0,0 +1,8 @@ +LIST=OS +ifndef QRECURSE +QRECURSE=recurse.mk +ifdef QCONFIG +QRDIR=$(dir $(QCONFIG)) +endif +endif +include $(QRDIR)$(QRECURSE) diff --git a/build_qnx/common.mk b/build_qnx/common.mk new file mode 100644 index 00000000..4e5df41f --- /dev/null +++ b/build_qnx/common.mk @@ -0,0 +1,57 @@ +ifndef QCONFIG +QCONFIG=qconfig.mk +endif +include $(QCONFIG) + +NAME=libzmq + +#$(INSTALL_ROOT_$(OS)) is pointing to $QNX_TARGET +#by default, unless it was manually re-routed to +#a staging area by setting both INSTALL_ROOT_nto +#and USE_INSTALL_ROOT +LIBZMQ_INSTALL_ROOT ?= $(INSTALL_ROOT_$(OS)) + +LIBZMQ_VERSION = .4.3.4 + +#choose Release or Debug +CMAKE_BUILD_TYPE ?= Release + +#override 'all' target to bypass the default QNX build system +ALL_DEPENDENCIES = libzmq_all +.PHONY: libzmq_all install check clean + +CFLAGS += $(FLAGS) +LDFLAGS += -Wl,--build-id=md5 + +include $(MKFILES_ROOT)/qtargets.mk + +LIBZMQ_DIR = $(PROJECT_ROOT)/../ + +CMAKE_ARGS = -DCMAKE_TOOLCHAIN_FILE=$(PROJECT_ROOT)/qnx.nto.toolchain.cmake \ + -DCMAKE_INSTALL_PREFIX=$(LIBZMQ_INSTALL_ROOT)/${CPUVARDIR}/usr \ + -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \ + -DEXTRA_CMAKE_C_FLAGS="$(CFLAGS)" \ + -DEXTRA_CMAKE_CXX_FLAGS="$(CFLAGS)" \ + -DEXTRA_CMAKE_ASM_FLAGS="$(FLAGS)" \ + -DEXTRA_CMAKE_LINKER_FLAGS="$(LDFLAGS)" \ + -DCMAKE_INSTALL_INCLUDEDIR=$(LIBZMQ_INSTALL_ROOT)/usr/include \ + -DCMAKE_INSTALL_LIBDIR=$(LIBZMQ_INSTALL_ROOT)/$(CPUVARDIR)/usr/lib \ + -DCMAKE_INSTALL_BINDIR=$(LIBZMQ_INSTALL_ROOT)/$(CPUVARDIR)/usr/bin \ + -DCPUVARDIR=$(CPUVARDIR) + +MAKE_ARGS ?= -j $(firstword $(JLEVEL) 1) + +ifndef NO_TARGET_OVERRIDE +libzmq_all: + @mkdir -p build + @cd build && cmake $(CMAKE_ARGS) $(LIBZMQ_DIR) + @cd build && make VERBOSE=1 all $(MAKE_ARGS) + +install check: libzmq_all + @cd build && make VERBOSE=1 install + +clean iclean spotless: + rm -rf build + +uninstall: +endif diff --git a/build_qnx/nto/Makefile b/build_qnx/nto/Makefile new file mode 100644 index 00000000..0cc5eae2 --- /dev/null +++ b/build_qnx/nto/Makefile @@ -0,0 +1,8 @@ +LIST=CPU +ifndef QRECURSE +QRECURSE=recurse.mk +ifdef QCONFIG +QRDIR=$(dir $(QCONFIG)) +endif +endif +include $(QRDIR)$(QRECURSE) diff --git a/build_qnx/nto/aarch64/Makefile b/build_qnx/nto/aarch64/Makefile new file mode 100644 index 00000000..0e22650c --- /dev/null +++ b/build_qnx/nto/aarch64/Makefile @@ -0,0 +1,8 @@ +LIST=VARIANT +ifndef QRECURSE +QRECURSE=recurse.mk +ifdef QCONFIG +QRDIR=$(dir $(QCONFIG)) +endif +endif +include $(QRDIR)$(QRECURSE) diff --git a/build_qnx/nto/aarch64/le/Makefile b/build_qnx/nto/aarch64/le/Makefile new file mode 100644 index 00000000..df9c574f --- /dev/null +++ b/build_qnx/nto/aarch64/le/Makefile @@ -0,0 +1,5 @@ +include ../../../common.mk + +CMAKE_ARGS += -DCMAKE_SYSTEM_PROCESSOR=aarch64 +FLAGS += $(VFLAG_le) $(CCVFLAG_le) +LDFLAGS += $(VFLAG_le) $(LDVFLAG_le) diff --git a/build_qnx/nto/x86_64/Makefile b/build_qnx/nto/x86_64/Makefile new file mode 100644 index 00000000..0e22650c --- /dev/null +++ b/build_qnx/nto/x86_64/Makefile @@ -0,0 +1,8 @@ +LIST=VARIANT +ifndef QRECURSE +QRECURSE=recurse.mk +ifdef QCONFIG +QRDIR=$(dir $(QCONFIG)) +endif +endif +include $(QRDIR)$(QRECURSE) diff --git a/build_qnx/nto/x86_64/o/Makefile b/build_qnx/nto/x86_64/o/Makefile new file mode 100644 index 00000000..ee74a170 --- /dev/null +++ b/build_qnx/nto/x86_64/o/Makefile @@ -0,0 +1,5 @@ +include ../../../common.mk + +CMAKE_ARGS += -DCMAKE_SYSTEM_PROCESSOR=x86_64 +FLAGS += $(VFLAG_o) $(CCVFLAG_o) +LDFLAGS += $(VFLAG_o) $(LDVFLAG_o) diff --git a/build_qnx/qnx.nto.toolchain.cmake b/build_qnx/qnx.nto.toolchain.cmake new file mode 100644 index 00000000..05cc7c78 --- /dev/null +++ b/build_qnx/qnx.nto.toolchain.cmake @@ -0,0 +1,34 @@ +if("$ENV{QNX_HOST}" STREQUAL "") + message(FATAL_ERROR "QNX_HOST environment variable not found. Please set the variable to your host's build tools") +endif() +if("$ENV{QNX_TARGET}" STREQUAL "") + message(FATAL_ERROR "QNX_TARGET environment variable not found. Please set the variable to the qnx target location") +endif() + +if(CMAKE_HOST_WIN32) + set(HOST_EXECUTABLE_SUFFIX ".exe") + #convert windows paths to cmake paths + file(TO_CMAKE_PATH "$ENV{QNX_HOST}" QNX_HOST) + file(TO_CMAKE_PATH "$ENV{QNX_TARGET}" QNX_TARGET) +else() + set(QNX_HOST "$ENV{QNX_HOST}") + set(QNX_TARGET "$ENV{QNX_TARGET}") +endif() + +message(STATUS "using QNX_HOST ${QNX_HOST}") +message(STATUS "using QNX_TARGET ${QNX_TARGET}") + +set(QNX TRUE) +set(CMAKE_SYSTEM_NAME QNX) +set(CMAKE_C_COMPILER ${QNX_HOST}/usr/bin/qcc) +set(CMAKE_CXX_COMPILER ${QNX_HOST}/usr/bin/qcc) +set(CMAKE_ASM_COMPILER ${QNX_HOST}/usr/bin/qcc) +set(CMAKE_AR "${QNX_HOST}/usr/bin/nto${CMAKE_SYSTEM_PROCESSOR}-ar${HOST_EXECUTABLE_SUFFIX}" CACHE PATH "archiver") +set(CMAKE_RANLIB "${QNX_HOST}/usr/bin/nto${CMAKE_SYSTEM_PROCESSOR}-ranlib${HOST_EXECUTABLE_SUFFIX}" CACHE PATH "ranlib") + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Vgcc_nto${CMAKE_SYSTEM_PROCESSOR} ${EXTRA_CMAKE_C_FLAGS}" CACHE STRING "c_flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Vgcc_nto${CMAKE_SYSTEM_PROCESSOR} -std=gnu++11 ${EXTRA_CMAKE_CXX_FLAGS}" CACHE STRING "cxx_flags") +set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Vgcc_nto${CMAKE_SYSTEM_PROCESSOR} ${EXTRA_CMAKE_ASM_FLAGS}" CACHE STRING "asm_flags") + +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EXTRA_CMAKE_LINKER_FLAGS}" CACHE STRING "exe_linker_flags") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${EXTRA_CMAKE_LINKER_FLAGS}" CACHE STRING "so_linker_flags") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 54cdf24a..c57d198d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -306,6 +306,10 @@ foreach(test ${tests}) set_tests_properties(${test} PROPERTIES TIMEOUT 10) set_tests_properties(${test} PROPERTIES SKIP_RETURN_CODE 77) + + if(QNX) + install(TARGETS ${test} RUNTIME DESTINATION bin/) + endif() endforeach() # override timeout for these tests