Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross Compilation with CMake #189

Open
iloveangpao opened this issue Feb 16, 2024 · 0 comments
Open

Cross Compilation with CMake #189

iloveangpao opened this issue Feb 16, 2024 · 0 comments

Comments

@iloveangpao
Copy link

iloveangpao commented Feb 16, 2024

I am facing some issues with cross compiling my project using libserial as a dependency. I have a toolchain file:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

# Specify the cross compiler locations
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)

That I am passing to my cmake command. I include libserial using fetchcontent:

FetchContent_Declare(
    libserial
    GIT_REPOSITORY https://github.com/crayzeewulf/libserial.git
    GIT_TAG        origin/master # or a specific tag/commit
    CMAKE_ARGS     -DCMAKE_TOOLCHAIN_FILE=aarch64-linux-gnu.cmake
)
FetchContent_MakeAvailable(libserial)
set(LIBSERIAL_LIBRARIES libserial_static)
include_directories(${libserial_SOURCE_DIR}/src/libserial/ ${libserial_SOURCE_DIR}/src/)

But gtest is compiled differently from my project:

set(CMAKE_HOST_SYSTEM "Linux-5.15.133.1-microsoft-standard-WSL2")
set(CMAKE_HOST_SYSTEM_NAME "Linux")
set(CMAKE_HOST_SYSTEM_VERSION "5.15.133.1-microsoft-standard-WSL2")
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")



set(CMAKE_SYSTEM "Linux-5.15.133.1-microsoft-standard-WSL2")
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION "5.15.133.1-microsoft-standard-WSL2")
set(CMAKE_SYSTEM_PROCESSOR "x86_64")

set(CMAKE_CROSSCOMPILING "FALSE")
set(CMAKE_HOST_SYSTEM "Linux-5.15.133.1-microsoft-standard-WSL2")
set(CMAKE_HOST_SYSTEM_NAME "Linux")
set(CMAKE_HOST_SYSTEM_VERSION "5.15.133.1-microsoft-standard-WSL2")
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")

include("/src/aarch64-linux-gnu.cmake")

set(CMAKE_SYSTEM "Linux")
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION "")
set(CMAKE_SYSTEM_PROCESSOR "aarch64")

set(CMAKE_CROSSCOMPILING "TRUE")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant