This repository has been archived on 2023-11-05. You can view files and clone it, but cannot push or open issues or pull requests.
wrt/CMakeLists.txt
2023-02-06 21:03:06 +08:00

47 lines
1.1 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}=.")
add_definitions(-DWRT_DEBUG=4)
# 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)