<commit_before>include(CMakeParseArguments)

set(LUG_SHADERS_DIR "shaders")
set(PROJECT_SHADERS_ROOT "shaders")

# shaders
macro(add_shader shader)
    # Select where to copy the resource
    if(LUG_OS_ANDROID)
        set(new_path ${ANDROID_PROJECT_SHADERS}/${shader})
    else()
        set(new_path ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_SHADERS_ROOT}/${shader}.spv)
    endif()

    set(old_path ${LUG_RESOURCES_DIR}/${LUG_SHADERS_DIR}/${shader})
    get_filename_component(new_path_directory ${new_path} DIRECTORY)

    if(LUG_OS_ANDROID)
        # Just copy to the good place, Android will compile the shader for us
        add_custom_command(
            OUTPUT ${new_path}
            DEPENDS ${old_path}
            COMMAND ${CMAKE_COMMAND} -E make_directory ${new_path_directory}
            COMMAND ${CMAKE_COMMAND} -E copy ${old_path} ${new_path}

            COMMENT "Copying shader ${old_path} to ${new_path}"
        )
    else()
        # Compile the shader
        add_custom_command(
            OUTPUT ${new_path}
            DEPENDS ${old_path}
            COMMAND ${CMAKE_COMMAND} -E make_directory ${new_path_directory}
            COMMAND glslangValidator -V ${old_path} -o ${new_path}

            COMMENT "Compiling shader ${old_path} to ${new_path}"
        )
    endif()

    list(APPEND SHADERS_DEPENDS ${new_path})
endmacro()

macro(add_shaders target)
    lug_set_option(BUILD_SHADERS TRUE BOOL "Compile shaders")

    if(BUILD_SHADERS)
        foreach(shader ${ARGN})
            add_shader(${shader})
        endforeach(shader)
    endif()

    set(target_shaders "shaders-${target}")

    add_custom_target(${target_shaders} DEPENDS ${SHADERS_DEPENDS})
    add_dependencies(${target} ${target_shaders})
endmacro()

# resources
macro(add_resource target_resources directory resource)
    # Select where to copy the resource
    if(LUG_OS_ANDROID)
        set(new_path ${ANDROID_PROJECT_ASSETS}/${resource})
    else()
        set(new_path ${CMAKE_CURRENT_BINARY_DIR}/${resource})
    endif()

    set(old_path ${directory}/${resource})
    get_filename_component(new_path_directory ${new_path} DIRECTORY)

    # Custom command to create the directory and copy the resource
    add_custom_command(
        OUTPUT ${new_path}
        DEPENDS ${old_path}
        COMMAND ${CMAKE_COMMAND} -E make_directory ${new_path_directory}
        COMMAND ${CMAKE_COMMAND} -E copy ${old_path} ${new_path}

        COMMENT "Copying ${old_path} to ${new_path}"
    )

    list(APPEND ${target_resources}_DEPENDS ${new_path})
endmacro()

macro(add_resources target target_resources directory)
    # Copy all resources
    foreach(resource ${ARGN})
        add_resource(${target_resources} ${directory} ${resource})
    endforeach(resource)

    # Link new resources files to the target
    add_custom_target(${target_resources} DEPENDS ${${target_resources}_DEPENDS})
    add_dependencies(${target} ${target_resources})
endmacro()

# macro to add a sample
macro(lug_add_sample target)
    # parse the arguments
    cmake_parse_arguments(THIS "" "" "SOURCES;DEPENDS;SHADERS;LUG_RESOURCES;OTHER_RESOURCES" ${ARGN})

    # find vulkan
    find_package(Vulkan)

    if (NOT VULKAN_INCLUDE_DIR)
        if (NOT EXISTS "${CMAKE_SOURCE_DIR}/../../thirdparty/vulkan")
            message(FATAL_ERROR "Can't find vulkan, call `git submodule update --recursive`")
        endif()

        set(VULKAN_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/../../thirdparty/vulkan/include)
        message(STATUS "Found Vulkan: ${VULKAN_INCLUDE_DIR}")
    endif()

    include_directories(${VULKAN_INCLUDE_DIR})

    # find fmt
    find_package(Fmt)

    if (NOT FMT_INCLUDE_DIR)
        if (NOT EXISTS "${CMAKE_SOURCE_DIR}/../../thirdparty/fmt")
            message(FATAL_ERROR "Can't find fmt, call `git submodule update --recursive`")
        endif()

        set(FMT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/../../thirdparty/fmt/include)
        message(STATUS "Found Fmt: ${FMT_INCLUDE_DIR}")
    endif()

    include_directories(${FMT_INCLUDE_DIR})

    # find Lugdunum
    find_package(LUG REQUIRED ${THIS_DEPENDS})<commit_msg>Fix the find of thirdparty with the complete CMakeLists.txt<commit_after>include(CMakeParseArguments)

set(LUG_SHADERS_DIR "shaders")
set(PROJECT_SHADERS_ROOT "shaders")

# shaders
macro(add_shader shader)
    # Select where to copy the resource
    if(LUG_OS_ANDROID)
        set(new_path ${ANDROID_PROJECT_SHADERS}/${shader})
    else()
        set(new_path ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_SHADERS_ROOT}/${shader}.spv)
    endif()

    set(old_path ${LUG_RESOURCES_DIR}/${LUG_SHADERS_DIR}/${shader})
    get_filename_component(new_path_directory ${new_path} DIRECTORY)

    if(LUG_OS_ANDROID)
        # Just copy to the good place, Android will compile the shader for us
        add_custom_command(
            OUTPUT ${new_path}
            DEPENDS ${old_path}
            COMMAND ${CMAKE_COMMAND} -E make_directory ${new_path_directory}
            COMMAND ${CMAKE_COMMAND} -E copy ${old_path} ${new_path}

            COMMENT "Copying shader ${old_path} to ${new_path}"
        )
    else()
        # Compile the shader
        add_custom_command(
            OUTPUT ${new_path}
            DEPENDS ${old_path}
            COMMAND ${CMAKE_COMMAND} -E make_directory ${new_path_directory}
            COMMAND glslangValidator -V ${old_path} -o ${new_path}

            COMMENT "Compiling shader ${old_path} to ${new_path}"
        )
    endif()

    list(APPEND SHADERS_DEPENDS ${new_path})
endmacro()

macro(add_shaders target)
    lug_set_option(BUILD_SHADERS TRUE BOOL "Compile shaders")

    if(BUILD_SHADERS)
        foreach(shader ${ARGN})
            add_shader(${shader})
        endforeach(shader)
    endif()

    set(target_shaders "shaders-${target}")

    add_custom_target(${target_shaders} DEPENDS ${SHADERS_DEPENDS})
    add_dependencies(${target} ${target_shaders})
endmacro()

# resources
macro(add_resource target_resources directory resource)
    # Select where to copy the resource
    if(LUG_OS_ANDROID)
        set(new_path ${ANDROID_PROJECT_ASSETS}/${resource})
    else()
        set(new_path ${CMAKE_CURRENT_BINARY_DIR}/${resource})
    endif()

    set(old_path ${directory}/${resource})
    get_filename_component(new_path_directory ${new_path} DIRECTORY)

    # Custom command to create the directory and copy the resource
    add_custom_command(
        OUTPUT ${new_path}
        DEPENDS ${old_path}
        COMMAND ${CMAKE_COMMAND} -E make_directory ${new_path_directory}
        COMMAND ${CMAKE_COMMAND} -E copy ${old_path} ${new_path}

        COMMENT "Copying ${old_path} to ${new_path}"
    )

    list(APPEND ${target_resources}_DEPENDS ${new_path})
endmacro()

macro(add_resources target target_resources directory)
    # Copy all resources
    foreach(resource ${ARGN})
        add_resource(${target_resources} ${directory} ${resource})
    endforeach(resource)

    # Link new resources files to the target
    add_custom_target(${target_resources} DEPENDS ${${target_resources}_DEPENDS})
    add_dependencies(${target} ${target_resources})
endmacro()

# macro to add a sample
macro(lug_add_sample target)
    # parse the arguments
    cmake_parse_arguments(THIS "" "" "SOURCES;DEPENDS;SHADERS;LUG_RESOURCES;OTHER_RESOURCES" ${ARGN})

    # find vulkan
    find_package(Vulkan)

    if (NOT VULKAN_INCLUDE_DIR)
        if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/vulkan")
            message(FATAL_ERROR "Can't find vulkan, call `git submodule update --recursive`")
        endif()

        set(VULKAN_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/vulkan/include)
        message(STATUS "Found Vulkan: ${VULKAN_INCLUDE_DIR}")
    endif()

    include_directories(${VULKAN_INCLUDE_DIR})

    # find fmt
    find_package(Fmt)

    if (NOT FMT_INCLUDE_DIR)
        if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/fmt")
            message(FATAL_ERROR "Can't find fmt, call `git submodule update --recursive`")
        endif()

        set(FMT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/fmt/include)
        message(STATUS "Found Fmt: ${FMT_INCLUDE_DIR}")
    endif()

    include_directories(${FMT_INCLUDE_DIR})

    # find Lugdunum
    find_package(LUG REQUIRED ${THIS_DEPENDS})
{'fraction_non_alphanumeric': 0.11310960888459681, 'fraction_numerical': 0.0, 'mean_word_length': 3.4735421166306697, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '618187', 'n_tokens_mistral': 2871, 'n_tokens_neox': 2693, 'n_words': 551}