55 lines
1.4 KiB
CMake
55 lines
1.4 KiB
CMake
cmake_minimum_required(VERSION 3.24)
|
|
project(wrt)
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmacro-prefix-map=${CMAKE_SOURCE_DIR}=.")
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
add_definitions(-DWRT_DEBUG=4)
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fsanitize=address,undefined -fno-sanitize=alignment")
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined -fno-sanitize=alignment")
|
|
else ()
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
|
|
endif ()
|
|
|
|
|
|
# math
|
|
find_library(M_LIBRARY m)
|
|
|
|
# libffi
|
|
include(FindPkgConfig)
|
|
pkg_check_modules(FFI REQUIRED IMPORTED_TARGET libffi)
|
|
|
|
# google test
|
|
# tests
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
googletest
|
|
URL https://github.com/google/googletest/archive/refs/tags/v1.13.0.zip
|
|
)
|
|
FetchContent_MakeAvailable(googletest)
|
|
|
|
# wamr
|
|
include(wasm.conf)
|
|
include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
|
|
add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
|
|
|
|
# wrt
|
|
add_library(wrt wrt/wrt.c wrt/dl.c)
|
|
target_include_directories(wrt PRIVATE .)
|
|
target_link_libraries(wrt vmlib PkgConfig::FFI ${M_LIBRARY})
|
|
|
|
# main
|
|
add_executable(main main.c)
|
|
target_include_directories(main PRIVATE .)
|
|
target_link_libraries(main wrt)
|
|
|
|
# test
|
|
enable_testing()
|
|
add_executable(test_all tests/dl.cpp)
|
|
target_include_directories(test_all PRIVATE .)
|
|
target_link_libraries(test_all GTest::gtest_main wrt)
|
|
include(GoogleTest)
|
|
gtest_discover_tests(test_all)
|