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

Added cmake toolchain arm support. #350

Merged
merged 4 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Added cmake toolchain arm support.
  • Loading branch information
nmoinvaz committed May 29, 2019
commit d3254400eb83c16972739ea6efb1a09fccfa9608
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ else()
endif()
message(STATUS "Architecture: ${ARCH}")

if(CMAKE_TOOLCHAIN_FILE)
message(STATUS "Using cmake toolchain: ${CMAKE_TOOLCHAIN_FILE}")
endif()

option (WITH_GZFILEOP "Compile with support for gzFile related functions" OFF)
option (ZLIB_COMPAT "Compile with zlib compatible API" OFF)
if (ZLIB_COMPAT)
Expand Down Expand Up @@ -807,7 +811,7 @@ if (ZLIB_ENABLE_TESTS)
enable_testing()
add_executable(example test/example.c)
target_link_libraries(example zlib)
add_test(example example${CMAKE_EXECUTABLE_SUFFIX})
add_test(NAME example COMMAND example${CMAKE_EXECUTABLE_SUFFIX})

add_executable(minigzip test/minigzip.c)
target_link_libraries(minigzip zlib)
Expand All @@ -816,7 +820,7 @@ if (ZLIB_ENABLE_TESTS)
add_executable(example64 test/example.c)
target_link_libraries(example64 zlib)
set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
add_test(example64 example64${CMAKE_EXECUTABLE_SUFFIX})
add_test(NAME example64 COMMAND example64${CMAKE_EXECUTABLE_SUFFIX})

add_executable(minigzip64 test/minigzip.c)
target_link_libraries(minigzip64 zlib)
Expand Down
27 changes: 27 additions & 0 deletions test/cmake/toolchain-aarch64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_SYSTEM_VERSION 1)

message(STATUS "Using cross-compile toolchain: ${CROSS_COMPILE_TOOLCHAIN}")

set(CMAKE_C_COMPILER_TARGET "aarch64-linux-gnu")
set(CMAKE_CXX_COMPILER_TARGET "aarch64-linux-gnu")

set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_CROSSCOMPILING_EMULATOR qemu-aarch64 -L /usr/${CMAKE_C_COMPILER_TARGET}/)

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

find_program(C_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-gcc)
if(NOT C_COMPILER_FULL_PATH)
message(FATAL_ERROR "Cross-compiler ${CMAKE_C_COMPILER_TARGET}-gcc not found")
endif ()
set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH})
find_program(CXX_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-g++)
nmoinvaz marked this conversation as resolved.
Show resolved Hide resolved
if(CXX_COMPILER_FULL_PATH)
set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH})
endif()


nmoinvaz marked this conversation as resolved.
Show resolved Hide resolved
23 changes: 23 additions & 0 deletions test/cmake/toolchain-arm.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_SYSTEM_VERSION 1)

message(STATUS "Using cross-compile toolchain: ${CMAKE_C_COMPILER_TARGET}")

set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_CROSSCOMPILING_EMULATOR qemu-arm -L /usr/${CMAKE_C_COMPILER_TARGET}/)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

find_program(C_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-gcc)
if(NOT C_COMPILER_FULL_PATH)
message(FATAL_ERROR "Cross-compiler ${CMAKE_C_COMPILER_TARGET}-gcc not found")
endif ()
set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH})
find_program(CXX_COMPILER_FULL_PATH ${CMAKE_C_COMPILER_TARGET}-g++)
if(CXX_COMPILER_FULL_PATH)
set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH})
endif()
nmoinvaz marked this conversation as resolved.
Show resolved Hide resolved