Skip to content

Commit

Permalink
start adding toolchain for cross-compiling for FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
qrkourier committed Mar 28, 2024
1 parent 6e2f145 commit e91acb3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"VCPKG_TARGET_TRIPLET": "x64-freebsd",
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/toolchains/FreeBSD-x64.cmake"
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/toolchains/FreeBSD-x86_64.cmake"
}
},
{
Expand Down
18 changes: 0 additions & 18 deletions toolchains/FreeBSD-x64.cmake

This file was deleted.

33 changes: 33 additions & 0 deletions toolchains/FreeBSD-x86_64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Toolchain file for building for FreeBSD from Linux

# Set the system name to reflect the target environment
set(CMAKE_SYSTEM_NAME FreeBSD)

# Specify the target architecture
set(CMAKE_SYSTEM_PROCESSOR x86_64)

# Specify the cross-compiler locations. These paths might need to be adjusted
# based on where the cross-compilers are installed on your system.
set(CMAKE_C_COMPILER /usr/bin/clang)
set(CMAKE_CXX_COMPILER /usr/bin/clang++)

# You might need to specify the sysroot if you have a FreeBSD sysroot available on your Linux machine.
# This is especially necessary for finding the target system's libraries and headers.
# set(CMAKE_SYSROOT /path/to/freebsd-sysroot)

# Ensure that the compiler can find includes and link against libraries for the target environment
# This might include specifying the path to the target's libc and other essential libraries.
# Example:
# set(CMAKE_FIND_ROOT_PATH /path/to/freebsd-sysroot)

# Tell CMake to look for programs in the native build host first.
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# For libraries and headers, since we are cross-compiling, we don't want to use the host's libraries/headers.
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# Optionally, you can set compiler flags specific to your project's needs or to optimize for the target architecture
# set(CMAKE_C_FLAGS "-target x86_64-unknown-freebsd11 --sysroot=${CMAKE_SYSROOT}" CACHE STRING "")
# set(CMAKE_CXX_FLAGS "-target x86_64-unknown-freebsd11 --sysroot=${CMAKE_SYSROOT}" CACHE STRING "")

0 comments on commit e91acb3

Please sign in to comment.