116 lines
2.1 KiB
CMake
116 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 3.18)
|
|
project(unshell C ASM)
|
|
|
|
include(GenerateG3A)
|
|
include(Fxconv)
|
|
find_package(Gint 2.6.0 REQUIRED)
|
|
|
|
include_directories(include)
|
|
include_directories(wren/include)
|
|
|
|
# source files
|
|
set(SOURCES
|
|
src/main.c
|
|
src/term.c
|
|
src/ui.c
|
|
src/battery.c
|
|
src/syscalls.S
|
|
src/job.c
|
|
src/wren_utils.c
|
|
src/utf8.c
|
|
src/vfs/vfs.c
|
|
)
|
|
set(SOURCES_WREN
|
|
wren/src/wren_compiler.c
|
|
wren/src/wren_core.c
|
|
wren/src/wren_debug.c
|
|
wren/src/wren_primitive.c
|
|
wren/src/wren_utils.c
|
|
wren/src/wren_value.c
|
|
wren/src/wren_vm.c
|
|
wren/src/wren_opt_meta.c
|
|
wren/src/wren_opt_random.c
|
|
)
|
|
set(SOURCES_PRINTF
|
|
src/printf.c
|
|
)
|
|
|
|
set(ASSETS
|
|
assets/example.png
|
|
assets/uf5x7
|
|
)
|
|
|
|
# Compile flags
|
|
set(FLAGS
|
|
# C standard, other values: c89, c99
|
|
-std=c11
|
|
|
|
# general warnings
|
|
-Wall -Wextra -pedantic
|
|
|
|
# enable this flag to stop compilation on warnings
|
|
#-Werror
|
|
|
|
# specific warnings
|
|
# variable shadowing
|
|
-Wshadow
|
|
# switch/case safety
|
|
-Wswitch-default -Wswitch-enum
|
|
# unreachable code, bad 99% of the time
|
|
-Wunreachable-code
|
|
# prototypes warnings
|
|
-Wstrict-prototypes -Wmissing-prototypes
|
|
# function declaration
|
|
-Werror-implicit-function-declaration
|
|
|
|
# optimisation level
|
|
# -Os: like -O2 without space-expensive optimizations
|
|
# -O2: good speed/size tradeoff
|
|
# -O3: gotta go fast
|
|
-Os
|
|
|
|
-m4a-nofpu
|
|
-flto -ffat-lto-objects
|
|
|
|
-fstack-protector
|
|
)
|
|
|
|
set(FLAGS_WREN
|
|
-std=c11
|
|
-Os
|
|
-m4a-nofpu
|
|
-flto -ffat-lto-objects
|
|
)
|
|
set(FLAGS_PRINTF
|
|
-std=c11
|
|
-Ofast
|
|
-m4a-nofpu
|
|
-flto -ffat-lto-objects
|
|
)
|
|
|
|
set(CMAKE_ASM_FLAGS "-x assembler-with-cpp")
|
|
add_link_options(
|
|
-flto
|
|
-Wl,--print-memory-usage
|
|
)
|
|
|
|
add_library(Printf ${SOURCES_PRINTF})
|
|
target_compile_options(Printf PRIVATE ${FLAGS_PRINTF})
|
|
|
|
add_library(Wren ${SOURCES_WREN})
|
|
target_compile_options(Wren PRIVATE ${FLAGS_WREN})
|
|
target_link_libraries(Wren Printf Gint::Gint)
|
|
|
|
fxconv_declare_assets(${ASSETS} WITH_METADATA)
|
|
add_executable(Main ${SOURCES} ${ASSETS})
|
|
target_compile_options(Main PRIVATE ${FLAGS})
|
|
|
|
target_link_libraries(Main Printf Wren Gint::Gint)
|
|
|
|
generate_g3a(
|
|
TARGET Main
|
|
OUTPUT "${PROJECT_NAME}.g3a"
|
|
NAME "${PROJECT_NAME}"
|
|
ICONS assets/icon-uns.png assets/icon-sel.png
|
|
)
|