nshell/CMakeLists.txt

116 lines
2.1 KiB
CMake
Raw Permalink Normal View History

2021-08-31 15:52:53 +02:00
cmake_minimum_required(VERSION 3.18)
2021-09-02 19:02:54 +02:00
project(unshell C ASM)
2021-08-31 15:52:53 +02:00
include(GenerateG3A)
include(Fxconv)
2021-09-10 21:43:40 +02:00
find_package(Gint 2.6.0 REQUIRED)
2021-08-31 15:52:53 +02:00
include_directories(include)
2021-09-09 23:43:50 +02:00
include_directories(wren/include)
2021-08-31 15:52:53 +02:00
# source files
set(SOURCES
src/main.c
2021-10-02 16:43:39 +02:00
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
2021-09-10 21:43:19 +02:00
)
set(SOURCES_WREN
2021-10-02 16:43:39 +02:00
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
2021-08-31 15:52:53 +02:00
)
2021-09-12 20:34:21 +02:00
set(SOURCES_PRINTF
2021-10-02 16:43:39 +02:00
src/printf.c
2021-09-12 20:34:21 +02:00
)
2021-09-10 21:43:19 +02:00
2021-08-31 15:52:53 +02:00
set(ASSETS
2021-10-04 19:56:12 +02:00
assets/example.png
assets/uf5x7
2021-08-31 15:52:53 +02:00
)
# 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
2021-10-02 16:43:39 +02:00
-m4a-nofpu
-flto -ffat-lto-objects
-fstack-protector
2021-08-31 15:52:53 +02:00
)
2021-10-02 16:43:39 +02:00
2021-09-10 21:43:19 +02:00
set(FLAGS_WREN
2021-10-02 16:43:39 +02:00
-std=c11
-Os
-m4a-nofpu
-flto -ffat-lto-objects
2021-09-12 20:34:21 +02:00
)
set(FLAGS_PRINTF
2021-10-02 16:43:39 +02:00
-std=c11
-Ofast
-m4a-nofpu
-flto -ffat-lto-objects
2021-09-10 21:43:19 +02:00
)
2021-08-31 15:52:53 +02:00
2021-09-10 21:43:19 +02:00
set(CMAKE_ASM_FLAGS "-x assembler-with-cpp")
2021-09-12 22:05:09 +02:00
add_link_options(
2021-10-02 16:43:39 +02:00
-flto
-Wl,--print-memory-usage
2021-09-12 22:05:09 +02:00
)
2021-09-12 20:34:21 +02:00
add_library(Printf ${SOURCES_PRINTF})
target_compile_options(Printf PRIVATE ${FLAGS_PRINTF})
2021-09-02 19:02:54 +02:00
2021-09-10 21:43:19 +02:00
add_library(Wren ${SOURCES_WREN})
target_compile_options(Wren PRIVATE ${FLAGS_WREN})
2021-09-12 20:34:21 +02:00
target_link_libraries(Wren Printf Gint::Gint)
2021-08-31 15:52:53 +02:00
2021-10-04 19:56:12 +02:00
fxconv_declare_assets(${ASSETS} WITH_METADATA)
add_executable(Main ${SOURCES} ${ASSETS})
2021-08-31 15:52:53 +02:00
target_compile_options(Main PRIVATE ${FLAGS})
2021-09-10 21:43:19 +02:00
2021-09-12 20:34:21 +02:00
target_link_libraries(Main Printf Wren Gint::Gint)
2021-08-31 15:52:53 +02:00
2021-10-04 19:56:12 +02:00
generate_g3a(
TARGET Main
OUTPUT "${PROJECT_NAME}.g3a"
NAME "${PROJECT_NAME}"
ICONS assets/icon-uns.png assets/icon-sel.png
)