I tried with this example, but nothing happens:
cmake_minimum_required(VERSION 3.8)
project(cmake_simulator)
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION 21)
set(CMAKE_ANDROID_ARCH_ABI x86)
set(CMAKE_ANDROID_NDK /home/icarolima/Android/Sdk/ndk/21.3.6528147)
set(CMAKE_ANDROID_STL_TYPE gnustl_static)
set(CMAKE_TOOLCHAIN_FILE /home/icarolima/Android/Sdk/ndk/21.3.6528147/build/cmake/android.toolchain.cmake)
find_package(verilator HINTS $ENV{VERILATOR_ROOT} ${VERILATOR_ROOT})
if (NOT verilator_FOUND)
message(FATAL_ERROR "Verilator was not found. Either install it, or set the VERILATOR_ROOT environment variable")
endif()
# Create a new executable target that will contain all your sources
add_library(simulator SHARED simulator.cpp)
# Add the Verilated circuit to the target
verilate(simulator
INCLUDE_DIRS "."
SOURCES top.sv
VERILATOR_ARGS -Wno-CASEINCOMPLETE -Wno-WIDTH -Wno-COMBDLY -cc +1800-2012ext+sv)
For example, if I change the CMAKE_ANDROID_ARCH_ABI
to anything else, nothing happens. It is like CMake is ignoring the NDK part of the code.
But If I change the project to another location, different things happen:
cmake_minimum_required(VERSION 3.8)
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION 21)
set(CMAKE_ANDROID_ARCH_ABI x86)
set(CMAKE_ANDROID_NDK /home/icarolima/Android/Sdk/ndk/21.3.6528147)
set(CMAKE_ANDROID_STL_TYPE gnustl_static)
project(cmake_simulator)
set(CMAKE_TOOLCHAIN_FILE /home/icarolima/Android/Sdk/ndk/21.3.6528147/build/cmake/android.toolchain.cmake)
find_package(verilator HINTS $ENV{VERILATOR_ROOT} ${VERILATOR_ROOT})
if (NOT verilator_FOUND)
message(FATAL_ERROR "Verilator was not found. Either install it, or set the VERILATOR_ROOT environment variable")
endif()
# Create a new executable target that will contain all your sources
add_library(simulator SHARED simulator.cpp)
# Add the Verilated circuit to the target
verilate(simulator
INCLUDE_DIRS "."
SOURCES top.sv
VERILATOR_ARGS -Wno-CASEINCOMPLETE -Wno-WIDTH -Wno-COMBDLY -cc +1800-2012ext+sv)
The error:
CMake Error at /home/icarolima/Android/Sdk/cmake/3.10.2.4988404/share/cmake-3.10/Modules/Platform/Android/Determine-Compiler-NDK.cmake:97 (message):
Android: No toolchain for ABI 'x86' found in the NDK:
/home/icarolima/Android/Sdk/ndk/21.3.6528147
I have no experience with CMake, I think that the problem is the order of the things. Can anyone help me?
So, just to clarify, the way I solved it can be seen here: Dockerfile, and here: sandbox_template.
Thanks for the answers @squareskittles!