cmake_minimum_required(VERSION 3.30)
project(prototype1 C)

#include_directories(${CMAKE_SOURCE_DIR})
set(CMAKE_C_FLAGS "-Wno-unused-parameter \
 -Wall -Wextra -Werror=implicit-function-declaration -Werror=return-type \
 --std=c99 -g -ggdb -O0")

execute_process(
        COMMAND pkg-config --cflags libpipewire-0.3
        OUTPUT_VARIABLE LIBPIPEWIRE_CFLAGS
        OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
        COMMAND pkg-config --libs libpipewire-0.3
        OUTPUT_VARIABLE LIBPIPEWIRE_LIBS
        OUTPUT_STRIP_TRAILING_WHITESPACE
)

#add_compile_options("-I/nix/store/2hm4rjvywd00p417y43i9rzx8v793qi0-pipewire-1.4.5-dev/include/pipewire-0.3 -I/nix/store/2hm4rjvywd00p417y43i9rzx8v793qi0-pipewire-1.4.5-dev/include/spa-0.2")

#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
# -I /nix/store/2hm4rjvywd00p417y43i9rzx8v793qi0-pipewire-1.4.5-dev/include/pipewire-0.3 \
#    -I /nix/store/2hm4rjvywd00p417y43i9rzx8v793qi0-pipewire-1.4.5-dev/include/spa-0.2 ")

add_compile_definitions(_POSIX_C_SOURCE=200112L)
add_compile_definitions(_GNU_SOURCE)
add_compile_options(-fno-trapping-math)

add_executable(codegen_l1 src/l1/anne/codegen.c)
target_compile_definitions(codegen_l1
    PRIVATE PROTOTYPE1_L1_CODEGEN_BOOTSTRAP_USE_CHICKEN_VECU8)

#add_executable(0_test src/l1_4/tests/t0.c)
#add_executable(1_test src/l1_4/tests/t1.c)
add_executable(3_test src/l1_4/tests/t3.c)
target_link_libraries(3_test -lm)
#
#add_executable(l1_4_t2 src/l1_4/tests/t2.c)

add_executable(codegen_l1_5 src/l1_5/anne/codegen.c)

#add_executable(1_render_test src/l2/tests/r1/r1.c gen/l_wl_protocols/xdg-shell-private.c)
#target_link_libraries(1_render_test -lwayland-client -lrt -lm -lxkbcommon)
#
#add_executable(2a_render_test src/l2/tests/r2/r2a.c gen/l_wl_protocols/xdg-shell-private.c)
#target_link_libraries(2a_render_test ${LIBPIPEWIRE_LIBS} -lwayland-client -lrt -lm -lxkbcommon)
#
#add_executable(3_render_test src/l2/tests/r3/r3.c gen/l_wl_protocols/xdg-shell-private.c)
#target_link_libraries(3_render_test -lwayland-client -lm -lvulkan -lxkbcommon)

#add_executable(l2t0_2 src/l2/tests/data_structures/t0_2.c)  // todo: I will get back
#add_executable(l2t0 src/l2/tests/data_structures/t0.c)
#add_executable(l2t0_3 src/l2/tests/data_structures/t0_3.c)
#add_executable(l2t2 src/l2/tests/data_structures/t2.c)

#add_executable(l2t0 src/l2/tests/data_structures/t0.c)
#add_executable(l2t1 src/l2/tests/data_structures/t1.c)

add_executable(l2_tex_gen src/l2/anne/codegen.c)
target_link_libraries(l2_tex_gen -lm -lpng)

add_executable(l2_r4 src/l3/r4/r4.c gen/l_wl_protocols/xdg-shell-private.c)
target_link_libraries(l2_r4 -lvulkan -lwayland-client -lm -lxkbcommon -lpng -lfreetype)
