diff options
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9c9d97b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,47 @@ +# nanowasm, a tiny WebAssembly/Wasm interpreter +# Copyright (C) 2023-2024 Xavier Del Campo Romero +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +cmake_minimum_required(VERSION 3.19) +project(nanowasm C) +option(NW_LOG "Enables logging to stderr" ON) +add_library(${PROJECT_NAME}) +add_subdirectory(test) +target_include_directories(${PROJECT_NAME} PUBLIC include + PRIVATE private_include) + +set(cflags_np + -ffunction-sections + -fdata-sections + -pedantic + -Wall +) + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(cflags_np ${cflags_np} -Og) +elseif(CMAKE_BUILD_TYPE STREQUAL "Release") + set(cflags_np ${cflags_np} -Os) +endif() + +include(CheckCompilerFlag) + +foreach(f ${cflags_np}) + string(REPLACE "-" "_" var supported_${f}) + check_compiler_flag(C ${f} ${var}) + + if(${var}) + target_compile_options(${PROJECT_NAME} PRIVATE ${f}) + target_compile_options(test PRIVATE ${f}) + endif() +endforeach() + +if(NW_LOG) + target_compile_definitions(${PROJECT_NAME} PRIVATE ENABLE_LOG) +endif() + +set_target_properties(${PROJECT_NAME} PROPERTIES C_STANDARD 99 C_EXTENSIONS OFF) +add_subdirectory(src) +target_compile_options(${PROJECT_NAME} PRIVATE -g) |
