diff --git a/test/cmocka/CMakeLists.txt b/test/cmocka/CMakeLists.txt index 24e27988f..b260c1411 100644 --- a/test/cmocka/CMakeLists.txt +++ b/test/cmocka/CMakeLists.txt @@ -15,7 +15,7 @@ else() PREFIX "${PROJECT_BINARY_DIR}/cmocka_git" BINARY_DIR ${cmocka_binary_directory} CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmocka-xtensa-xt-toolchain.cmake -DWITH_SHARED_LIB=OFF -DWITH_STATIC_LIB=ON -DWITH_EXAMPLES=OFF diff --git a/test/cmocka/cmocka-xtensa-xt-toolchain.cmake b/test/cmocka/cmocka-xtensa-xt-toolchain.cmake new file mode 100644 index 000000000..6d7271757 --- /dev/null +++ b/test/cmocka/cmocka-xtensa-xt-toolchain.cmake @@ -0,0 +1,28 @@ +message(STATUS "Preparing Xtensa toolchain") + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_VERSION 1) + +set(CMAKE_ASM_COMPILER_FORCED 1) +set(CMAKE_C_COMPILER_FORCED 1) + +set(CMAKE_ASM_COMPILER_ID GNU) +set(CMAKE_C_COMPILER_ID GNU) + +set(CROSS_COMPILE "xt-") + +set(CMAKE_C_COMPILER ${CROSS_COMPILE}xcc) + +set(CMAKE_LD ${CROSS_COMPILE}ld CACHE STRING "") +set(CMAKE_AR ${CROSS_COMPILE}ar CACHE STRING "") +set(CMAKE_OBJCOPY ${CROSS_COMPILE}objcopy) +set(CMAKE_OBJDUMP ${CROSS_COMPILE}objdump) + +set(CMAKE_FIND_ROOT_PATH ".") +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# Cmocka is written in C99, but for some reason it sets this flag, only on Posix +# We set up it here, because our system is Generic +add_definitions("-std=gnu99")