47 lines
1.2 KiB
CMake
47 lines
1.2 KiB
CMake
# 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})
|
|
target_include_directories(${PROJECT_NAME} PUBLIC include
|
|
PRIVATE private_include)
|
|
|
|
set(cflags_np
|
|
-ffunction-sections
|
|
-fdata-sections
|
|
-pedantic
|
|
-Wall
|
|
-std=c99
|
|
)
|
|
|
|
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})
|
|
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)
|
|
add_subdirectory(test)
|