Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="speedgoat-linux-toolchain.cmake" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="x64-speedgoat-linux-static.cmake" type="File"/>
22 changes: 17 additions & 5 deletions toolbox/+vcpkg/buildVcpkgDeps.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function buildVcpkgDeps(manifestFolder, vpckgArguments, options)
%% Figure out target triplet

% Initialize variables
qnxSdpBat = '';
targetEnvRootBat = '';

% Figure out target triplet if required
if options.buildHostOnly
Expand All @@ -41,16 +41,28 @@ function buildVcpkgDeps(manifestFolder, vpckgArguments, options)
targetTriplet = vcpkg.getTargetTriplet;

if contains(targetTriplet, 'qnx', 'IgnoreCase', true)
% Using QNX with Siumink Real-Time Target Support Package
% Using QNX with Simulink Real-Time Target Support Package
slrealtime.qnxSetupFcn;
qnxSpRoot = getenv('SLREALTIME_QNX_SP_ROOT');
qnxVersion = getenv('SLREALTIME_QNX_VERSION');

if ispc
qnxSdpBat = ['&& ',fullfile(qnxSpRoot,qnxVersion,'qnxsdp-env.bat')];
targetEnvRootBat = ['&& ',fullfile(qnxSpRoot,qnxVersion,'qnxsdp-env.bat')];
elseif isunix
% Sourcing the .sh file for qcc compilation.
qnxSdpBat = ['&& ',append('source ',fullfile(qnxSpRoot,qnxVersion,'qnxsdp-env.sh'))];
targetEnvRootBat = ['&& ',append('source ',fullfile(qnxSpRoot,qnxVersion,'qnxsdp-env.sh'))];
end
elseif contains(targetTriplet, 'x64-speedgoat-linux', 'IgnoreCase', true)
% Yocto cc specific implementation
x64CCRoot = getenv('X64CC_ROOT');
if isempty(x64CCRoot)
%Error x64 cc root path not defined.
error(message('slrealtime:utils:x64CCRootNotSet'));
end
if ispc
targetEnvRootBat = ['&& ',fullfile(x64CCRoot,'toolchain','x64cc-setup-env.bat')];
else
error('Current host OS is still not supported.');
end
end

Expand All @@ -67,7 +79,7 @@ function buildVcpkgDeps(manifestFolder, vpckgArguments, options)

% Build up vcpkg full command
vcpkgCmd = ['cd ', manifestFolder, ' ',...
qnxSdpBat,...
targetEnvRootBat,...
' && vcpkg install ',targetTriplet,' --host-triplet ', vcpkg.getHostTriplet,...
' --overlay-triplets "', fullfile(vcpkg.getToolboxRoot,'overlay-triplets'), '" ', strjoin(vpckgArguments,' ')];

Expand Down
5 changes: 4 additions & 1 deletion toolbox/+vcpkg/getTargetTriplet.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
elseif isMATLABReleaseOlderThan('R2020b')
triplet = 'x86-windows-static';
else
error('Target triplet is not supported for MATLAB R2026a and later yet. Use buildHostOnly.');
% MATLAB R2026a or later
if exist('speedgoat','file')
triplet = 'x64-speedgoat-linux-static';
end
end

end
3 changes: 1 addition & 2 deletions toolbox/overlay-triplets/qnx-toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if(NOT DEFINED ENV{QNX_HOST} OR NOT DEFINED ENV{QNX_TARGET})
message(FATAL_ERROR "QNX environment not found. Please 'source qnxsdp-env.sh' first.")
endif()

# Allow caller to choose architecture; default to aarch64
# Allow caller to choose architecture; default to x86_64
set(CMAKE_SYSTEM_PROCESSOR "x86_64" CACHE STRING "QNX target arch (aarch64|armv7|x86_64)")

# Map arch → qcc variant string and sysroot suffix
Expand Down Expand Up @@ -43,7 +43,6 @@ set(CMAKE_CXX_COMPILER_TARGET ${QNX_QCC_VARIANT})
set(CMAKE_SYSROOT "$ENV{QNX_TARGET}/${QNX_SYSROOT_SUFFIX}")

# Make sure CMake finds things in the QNX sysroot first
set(CMAKE_FIND_ROOT_PATH "$ENV{QNX_TARGET}")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
Expand Down
35 changes: 35 additions & 0 deletions toolbox/overlay-triplets/speedgoat-linux-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# speedgoat-linux-toolchain.cmake

# Require a modern-enough CMake
cmake_minimum_required(VERSION 3.20)

# Tell CMake we target Linux
set(CMAKE_SYSTEM_NAME Linux)

# Allow caller to choose architecture; default to x86_64
set(CMAKE_SYSTEM_PROCESSOR "x86_64" CACHE STRING "Speedgoat Linux target arch (aarch64|x86_64)")

# Compilers
set(CMAKE_C_COMPILER ${CMAKE_SYSTEM_PROCESSOR}-speedgoat-linux-gcc)
set(CMAKE_CXX_COMPILER ${CMAKE_SYSTEM_PROCESSOR}-speedgoat-linux-g++)

# Sysroot
set(CMAKE_SYSROOT "$ENV{SDKTARGETSYSROOT}")

# Optimize for target architecture
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
add_compile_options(-march=core2)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
add_compile_options(-march=armv8-a+crc)
else()
message(FATAL_ERROR "Unsupported processor architecture='${CMAKE_SYSTEM_PROCESSOR}'. Use aarch64|x86_64.")
endif()

# Make sure CMake finds things in the sysroot first
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)

# Set fPIC flag
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
16 changes: 16 additions & 0 deletions toolbox/overlay-triplets/x64-speedgoat-linux-static.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)

# Linkage preferences
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static) # common for embedded

# Pass environment variables
set(VCPKG_ENV_PASSTHROUGH SDKTARGETSYSROOT;PATH)

# Absolute path to the chainloaded toolchain
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE
"${CMAKE_CURRENT_LIST_DIR}/speedgoat-linux-toolchain.cmake")

# Disable debug builds
set(VCPKG_BUILD_TYPE release)