cmake_minimum_required(VERSION 3.22.1)
project(xdl)

file(GLOB XDL_SRC *.c)
add_library(xdl SHARED ${XDL_SRC})
target_compile_features(xdl PUBLIC c_std_17)
target_compile_options(xdl PUBLIC -std=c17 -Weverything -Werror)
target_include_directories(xdl PUBLIC include .)
#target_link_libraries(xdl log)

if(USEASAN)
    target_compile_options(xdl PUBLIC -fsanitize=address -fno-omit-frame-pointer)
    target_link_options(xdl PUBLIC -fsanitize=address)
else()
    target_compile_options(xdl PUBLIC -Os -ffunction-sections -fdata-sections)
    target_link_options(xdl PUBLIC -Os -Wl,--exclude-libs,ALL -Wl,--gc-sections -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/xdl.map.txt)
endif()

if((${ANDROID_ABI} STREQUAL "arm64-v8a") OR (${ANDROID_ABI} STREQUAL "x86_64"))
    target_link_options(xdl PUBLIC "-Wl,-z,max-page-size=16384")
endif()
