From d9032ef3199a86c14bd4263f8750d682341b6696 Mon Sep 17 00:00:00 2001 From: Denis Biryukov Date: Thu, 24 Oct 2024 11:17:47 +0200 Subject: [PATCH 1/2] add sample toolchains and fix library names --- .cargo/config.toml | 3 +++ CMakeLists.txt | 12 ++++++++++-- TC-armv7-unknown-linux-gnueabihf.cmake | 5 +++++ TC-x86_64-pc-windows-gnu.cmake | 5 +++++ TC-x86_64-unknown-linux-gnu.cmake | 5 +++++ install/CMakeLists.txt | 5 ++++- install/cpack_project_config.cmake | 8 -------- 7 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 TC-armv7-unknown-linux-gnueabihf.cmake create mode 100644 TC-x86_64-pc-windows-gnu.cmake create mode 100644 TC-x86_64-unknown-linux-gnu.cmake diff --git a/.cargo/config.toml b/.cargo/config.toml index 5adae5e04..153e58df2 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -3,3 +3,6 @@ rustflags = "-Ctarget-feature=-crt-static" [target.aarch64-unknown-linux-musl] rustflags = "-Ctarget-feature=-crt-static" + +[target.armv7-unknown-linux-gnueabihf] +linker = "armv7-linux-gnueabihf-gcc" \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 592e291e9..656b31c38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,9 +175,17 @@ set_lib(dylibsd dylibd ${CMAKE_SHARED_LIBRARY_PREFIX}zenohcd${CMAKE_SHARED_LIBRA set_lib(staticlibsr staticlibr ${CMAKE_STATIC_LIBRARY_PREFIX}zenohc${CMAKE_STATIC_LIBRARY_SUFFIX}) set_lib(staticlibsd staticlibd ${CMAKE_STATIC_LIBRARY_PREFIX}zenohcd${CMAKE_STATIC_LIBRARY_SUFFIX}) if(WIN32) - set_lib(dylibsr implibr ${CMAKE_IMPORT_LIBRARY_PREFIX}zenohc${CMAKE_SHARED_LIBRARY_SUFFIX}${CMAKE_IMPORT_LIBRARY_SUFFIX}) - set_lib(dylibsd implibd ${CMAKE_IMPORT_LIBRARY_PREFIX}zenohcd${CMAKE_SHARED_LIBRARY_SUFFIX}${CMAKE_IMPORT_LIBRARY_SUFFIX}) + if (MINGW) + set_lib(dylibsr dylibr zenohc${CMAKE_SHARED_LIBRARY_SUFFIX}) + set_lib(dylibsd dylibd zenohcd${CMAKE_SHARED_LIBRARY_SUFFIX}) + set_lib(dylibsr implibr ${CMAKE_STATIC_LIBRARY_PREFIX}zenohc${CMAKE_IMPORT_LIBRARY_SUFFIX}) + set_lib(dylibsd implibd ${CMAKE_STATIC_LIBRARY_PREFIX}zenohcd${CMAKE_IMPORT_LIBRARY_SUFFIX}) + elseif(MSVC) + set_lib(dylibsr implibr ${CMAKE_STATIC_LIBRARY_PREFIX}zenohc${CMAKE_SHARED_LIBRARY_SUFFIX}${CMAKE_IMPORT_LIBRARY_SUFFIX}) + set_lib(dylibsd implibd ${CMAKE_STATIC_LIBRARY_PREFIX}zenohcd${CMAKE_SHARED_LIBRARY_SUFFIX}${CMAKE_IMPORT_LIBRARY_SUFFIX}) + endif() endif() + list(APPEND libsr ${dylibsr}) list(APPEND libsr ${staticlibsr}) list(APPEND libsd ${dylibsd}) diff --git a/TC-armv7-unknown-linux-gnueabihf.cmake b/TC-armv7-unknown-linux-gnueabihf.cmake new file mode 100644 index 000000000..846a53d6a --- /dev/null +++ b/TC-armv7-unknown-linux-gnueabihf.cmake @@ -0,0 +1,5 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR armv7) +set(ZENOHC_CUSTOM_TARGET armv7-unknown-linux-gnueabihf) +set(CMAKE_C_COMPILER armv7-linux-gnueabihf-gcc) +set(CMAKE_CXX_COMPILER armv7-linux-gnueabihf-g++) \ No newline at end of file diff --git a/TC-x86_64-pc-windows-gnu.cmake b/TC-x86_64-pc-windows-gnu.cmake new file mode 100644 index 000000000..bd8d38787 --- /dev/null +++ b/TC-x86_64-pc-windows-gnu.cmake @@ -0,0 +1,5 @@ +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR x86_64) +set(ZENOHC_CUSTOM_TARGET x86_64-pc-windows-gnu) +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER_TARGET x86_64-w64-mingw32-g++) \ No newline at end of file diff --git a/TC-x86_64-unknown-linux-gnu.cmake b/TC-x86_64-unknown-linux-gnu.cmake new file mode 100644 index 000000000..523c95d6d --- /dev/null +++ b/TC-x86_64-unknown-linux-gnu.cmake @@ -0,0 +1,5 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR x86_64) +set(ZENOHC_CUSTOM_TARGET x86_64-unknown-linux-gnu) +set(CMAKE_C_COMPILER x86_64-unknown-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER x86_64-unknown-linux-gnu-g++) \ No newline at end of file diff --git a/install/CMakeLists.txt b/install/CMakeLists.txt index 3b9e64d98..96c4ca48a 100644 --- a/install/CMakeLists.txt +++ b/install/CMakeLists.txt @@ -92,6 +92,7 @@ install_zenohc_lib("Debug" "DEBUG" zenohc) # # Configure CPack # +set(CPACK_BUILD_CONFIG ${CMAKE_BUILD_TYPE}) set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/packages") set(CPACK_PACKAGE_CHECKSUM MD5) set(CPACK_PACKAGE_VENDOR "The Eclipse Foundation") @@ -123,7 +124,9 @@ if(NOT CPACK_PACKAGE_VERSION) endif() endif() -set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") + +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}) set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cpack_project_config.cmake") include(CPack) diff --git a/install/cpack_project_config.cmake b/install/cpack_project_config.cmake index f6425b117..51c220aab 100644 --- a/install/cpack_project_config.cmake +++ b/install/cpack_project_config.cmake @@ -1,15 +1,7 @@ if(CPACK_GENERATOR MATCHES "DEB") # DEB package - if(NOT DEBARCH) - execute_process( - COMMAND dpkg --print-architecture - OUTPUT_VARIABLE DEBARCH - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - endif() message(STATUS "Configure DEB packaging for Linux ${DEBARCH}") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "ZettaScale Zenoh Team, ") - set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DEBARCH}) set(CPACK_DEB_COMPONENT_INSTALL ON) set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) set(CPACK_DEBIAN_LIB_PACKAGE_NAME lib${CPACK_PACKAGE_NAME}) From 3669fe86f3d680fddd242b7d68d055349dfd89bd Mon Sep 17 00:00:00 2001 From: Diogo Mendes Matsubara Date: Thu, 24 Oct 2024 12:26:40 +0200 Subject: [PATCH 2/2] fix: Add cmake toolchain files for all targets --- .cargo/config.toml | 2 +- .github/workflows/release.yml | 2 +- TC-aarch64-apple-darwin.cmake | 3 +++ TC-aarch64-unknown-linux-gnu.cmake | 5 +++++ TC-aarch64-unknown-linux-musl.cmake | 5 +++++ TC-arm-unknown-linux-gnueabi.cmake | 5 +++++ TC-arm-unknown-linux-gnueabihf.cmake | 5 +++++ TC-x86_64-apple-darwin.cmake | 3 +++ TC-x86_64-pc-windows-msvc.cmake | 3 +++ TC-x86_64-unknown-linux-gnu.cmake | 4 ++-- TC-x86_64-unknown-linux-musl.cmake | 5 +++++ 11 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 TC-aarch64-apple-darwin.cmake create mode 100644 TC-aarch64-unknown-linux-gnu.cmake create mode 100644 TC-aarch64-unknown-linux-musl.cmake create mode 100644 TC-arm-unknown-linux-gnueabi.cmake create mode 100644 TC-arm-unknown-linux-gnueabihf.cmake create mode 100644 TC-x86_64-apple-darwin.cmake create mode 100644 TC-x86_64-pc-windows-msvc.cmake create mode 100644 TC-x86_64-unknown-linux-musl.cmake diff --git a/.cargo/config.toml b/.cargo/config.toml index 001748b73..f4067361a 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -12,7 +12,7 @@ linker = "arm-linux-gnueabihf-gcc" linker = "arm-linux-gnueabi-gcc" [target.arm7-unknown-linux-gnueabihf] -linker = "arm-linux-gnueabihf-gcc" +linker = "armv7-linux-gnueabihf-gcc" [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1fdc6d5da..77910283c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -133,7 +133,7 @@ jobs: export PATH=$(PWD)/aarch64-linux-musl-cross/bin/:$PATH fi mkdir -p build && cd build - cmake .. -DZENOHC_CUSTOM_TARGET=${{ matrix.build.target }} -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DZENOHC_BUILD_WITH_UNSTABLE_API=ON -DZENOHC_BUILD_WITH_SHARED_MEMORY=ON + cmake .. -DZENOHC_CUSTOM_TARGET=${{ matrix.build.target }} -DCMAKE_TOOLCHAIN_FILE=../${{ matrix.build.target }}.cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DZENOHC_BUILD_WITH_UNSTABLE_API=ON -DZENOHC_BUILD_WITH_SHARED_MEMORY=ON cmake --build . --config Release cpack -C Release -G ZIP diff --git a/TC-aarch64-apple-darwin.cmake b/TC-aarch64-apple-darwin.cmake new file mode 100644 index 000000000..be899bf0c --- /dev/null +++ b/TC-aarch64-apple-darwin.cmake @@ -0,0 +1,3 @@ +set(CMAKE_SYSTEM_NAME Darwin) +set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(ZENOHC_CUSTOM_TARGET aarch64-apple-darwin) \ No newline at end of file diff --git a/TC-aarch64-unknown-linux-gnu.cmake b/TC-aarch64-unknown-linux-gnu.cmake new file mode 100644 index 000000000..8e058bf3b --- /dev/null +++ b/TC-aarch64-unknown-linux-gnu.cmake @@ -0,0 +1,5 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(ZENOHC_CUSTOM_TARGET aarch64-unknown-linux-gnu) +set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER_TARGET aarch64-linux-gnu-g++) \ No newline at end of file diff --git a/TC-aarch64-unknown-linux-musl.cmake b/TC-aarch64-unknown-linux-musl.cmake new file mode 100644 index 000000000..5d96fa928 --- /dev/null +++ b/TC-aarch64-unknown-linux-musl.cmake @@ -0,0 +1,5 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(ZENOHC_CUSTOM_TARGET aarch64-unknown-linux-musl) +set(CMAKE_C_COMPILER aarch64-linux-musl-gcc) +set(CMAKE_CXX_COMPILER_TARGET aarch64-linux-musl-g++) \ No newline at end of file diff --git a/TC-arm-unknown-linux-gnueabi.cmake b/TC-arm-unknown-linux-gnueabi.cmake new file mode 100644 index 000000000..dbb3400a9 --- /dev/null +++ b/TC-arm-unknown-linux-gnueabi.cmake @@ -0,0 +1,5 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) +set(ZENOHC_CUSTOM_TARGET arm-unknown-linux-gnueabi) +set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc) +set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++) \ No newline at end of file diff --git a/TC-arm-unknown-linux-gnueabihf.cmake b/TC-arm-unknown-linux-gnueabihf.cmake new file mode 100644 index 000000000..5355cc692 --- /dev/null +++ b/TC-arm-unknown-linux-gnueabihf.cmake @@ -0,0 +1,5 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR armhf) +set(ZENOHC_CUSTOM_TARGET arm-unknown-linux-gnueabihf) +set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) +set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) \ No newline at end of file diff --git a/TC-x86_64-apple-darwin.cmake b/TC-x86_64-apple-darwin.cmake new file mode 100644 index 000000000..647d1520b --- /dev/null +++ b/TC-x86_64-apple-darwin.cmake @@ -0,0 +1,3 @@ +set(CMAKE_SYSTEM_NAME Darwin) +set(CMAKE_SYSTEM_PROCESSOR x86_64) +set(ZENOHC_CUSTOM_TARGET x86_64-apple-darwin) \ No newline at end of file diff --git a/TC-x86_64-pc-windows-msvc.cmake b/TC-x86_64-pc-windows-msvc.cmake new file mode 100644 index 000000000..2a0ec0d39 --- /dev/null +++ b/TC-x86_64-pc-windows-msvc.cmake @@ -0,0 +1,3 @@ +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR x86_64) +set(ZENOHC_CUSTOM_TARGET x86_64-pc-windows-msvc) diff --git a/TC-x86_64-unknown-linux-gnu.cmake b/TC-x86_64-unknown-linux-gnu.cmake index 523c95d6d..3ffc6f991 100644 --- a/TC-x86_64-unknown-linux-gnu.cmake +++ b/TC-x86_64-unknown-linux-gnu.cmake @@ -1,5 +1,5 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR x86_64) set(ZENOHC_CUSTOM_TARGET x86_64-unknown-linux-gnu) -set(CMAKE_C_COMPILER x86_64-unknown-linux-gnu-gcc) -set(CMAKE_CXX_COMPILER x86_64-unknown-linux-gnu-g++) \ No newline at end of file +set(CMAKE_C_COMPILER x86_64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER x86_64-linux-gnu-g++) \ No newline at end of file diff --git a/TC-x86_64-unknown-linux-musl.cmake b/TC-x86_64-unknown-linux-musl.cmake new file mode 100644 index 000000000..851cf5b1e --- /dev/null +++ b/TC-x86_64-unknown-linux-musl.cmake @@ -0,0 +1,5 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR x86_64) +set(ZENOHC_CUSTOM_TARGET x86_64-unknown-linux-musl) +set(CMAKE_C_COMPILER x86_64-linux-musl-gcc) +set(CMAKE_CXX_COMPILER_TARGET x86_64-linux-musl-g++) \ No newline at end of file