diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-09-07 00:04:38 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-10-05 08:17:21 +0200 |
| commit | 144b7fe1415ff97497fa4ea3b95e8dd6b95d069e (patch) | |
| tree | 68391f6ec2dba2879ca8255ee25ce39ebaa7d4ad /CMakeLists.txt | |
First commit1st
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) |
