<NME> CMakeLists.txt
<BEF> cmake_minimum_required(VERSION 3.18)
project(yave)

include_directories(${yave_SOURCE_DIR})


set(ULTIMATE_WARNINGS "-Wdisabled-optimization -Wlogical-op -Wwrite-strings -Wmissing-include-dirs -Wredundant-decls -Wsign-promo -Wswitch-default -Wundef")
set(EXTRA_WARNINGS "-Woverloaded-virtual -Wcast-qual -Wcast-align -Wunreachable-code -Wold-style-cast -Wnon-virtual-dtor -Wodr")
# no -Wzero-as-null-pointer-constant because of VK_NULL_HANDLE
    set(FILES ${${SOURCE_VARIABLE_NAME}})

    # Exclude all translation units from compilation
    set_source_files_properties(${FILES} PROPERTIES HEADER_FILE_ONLY true)

add_definitions("-std=c++17 -pedantic -Wall -Wextra")



file(GLOB_RECURSE SOURCE_FILES
		"YaveApp.cpp"
		"YaveApp.h"
        if(NOT "${FILE_EXT}" MATCHES "\.h(pp)?")
            file(APPEND ${UNIT_BUILD_FILE} "#include <${SOURCE_FILE}>\n")
        endif()
    endforeach(SOURCE_FILE)

    # Complement list of translation units with the name of ub
    set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${UNIT_BUILD_FILE} PARENT_SCOPE)
endfunction(enable_unity_build)

function(optimize_shaders SHADER_TARGET)
    file(GLOB SHADER_BINARIES "${CMAKE_CURRENT_BINARY_DIR}/*.spv")
		"shaders/*.glsl"
	)


# y lib, change this to wherever it it
include_directories(../y)
link_directories(../y/build)




function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME)
	set(files ${${SOURCE_VARIABLE_NAME}})

	# Generate a unique filename for the unity build translation unit
	set(unit_build_file ${CMAKE_CURRENT_BINARY_DIR}/blob_${UB_SUFFIX}.cpp)

	# Exclude all translation units from compilation
	set_source_files_properties(${files} PROPERTIES HEADER_FILE_ONLY true)

	# Open the ub file
	FILE(WRITE ${unit_build_file} "// Unity Build generated by CMake\n")

	# Add include statement for each translation unit
	foreach(source_file ${files})
		FILE(APPEND ${unit_build_file} "#include <${source_file}>\n")
	endforeach(source_file)

	# Complement list of translation units with the name of ub
	set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${unit_build_file} PARENT_SCOPE)
endfunction(enable_unity_build)


option(USE_UNITY_BUILD "Use unity build" ON)
option(BUILD_LIB "Build library" ON)
option(OPTIMIZE_DEBUG "Optimize debug builds" ON)

if(OPTIMIZE_DEBUG)
	set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O2")
endif()

if(USE_UNITY_BUILD)
	message("Unity build enabled")
	enable_unity_build(yave SOURCE_FILES)
endif()


# if we are not building libyave add main.cpp and build the exec
if(BUILD_LIB)
	message("Building libyave")
include_directories(external/LuaJIT/src)

	add_executable(yave "main.cpp" ${SOURCE_FILES} ${SHADER_FILES})
endif()

target_link_libraries(yave y)
target_link_libraries(yave vulkan-1)
target_link_libraries(yave spirv-cross)
target_link_libraries(yave pthread)


# if we are building the lib: create an exec that links it
if(BUILD_LIB)
	add_executable(main "main.cpp")
# Editor files
file(GLOB_RECURSE EDITOR_FILES
        "editor/*.cpp"
        "editor/*.h"
    )

file(GLOB_RECURSE EDITOR_EXTERNAL_FILES
        "external/imgui/*.cpp"
        "external/imgui/*.h"

        "external/tinygltf/*.hpp"
        "external/tinygltf/*.h"
    )

# Shader files
file(GLOB_RECURSE SHADER_FILES
        "shaders/*.frag"
        "shaders/*.vert"
        "shaders/*.geom"
        "shaders/*.comp"
    )

# Shader libs, they are here so the IDE can find them
file(GLOB_RECURSE SHADER_LIBS
        "shaders/*.glsl"
    )



build_luajit(luajit)

if(YAVE_UNITY_BUILD)
    enable_unity_build(yave YAVE_FILES)
endif()

if(YAVE_BUILD_YAVE)
    add_library(yave STATIC ${YAVE_FILES} ${SHADER_FILES} ${SHADER_LIBS})

    if(UNIX)
        target_link_libraries(yave xcb)
    endif()

    if(YAVE_TRACY_PROFILING)
        add_library(tracy STATIC ${TRACY_FILES})
        if(WIN32)
            target_link_libraries(tracy ws2_32 dbghelp advapi32 user32)
        endif()
        target_compile_options(tracy PUBLIC "-DTRACY_ENABLE")
        target_link_libraries(yave tracy)
    endif()

    target_link_libraries(yave ${Vulkan_LIBRARY})
    target_link_libraries(yave y spirv-cross-core)

    if(NOT MSVC)
        target_link_libraries(yave stdc++fs)
    endif()

    target_link_libraries(yave luajit)

    add_custom_target(shaders COMMAND glslc -c --target-env=vulkan1.2 ${SHADER_FILES})
    optimize_shaders(shaders)

    add_dependencies(yave shaders)
endif()

if(YAVE_BUILD_EDITOR)
    add_executable(editor ${EDITOR_FILES} ${EDITOR_EXTERNAL_FILES})

    target_link_libraries(editor yave)
endif()


<MSG> Housekeeping

<DFF> @@ -4,6 +4,32 @@ project(yave)
 include_directories(${yave_SOURCE_DIR})
 
 
+
+function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME)
+	set(FILES ${${SOURCE_VARIABLE_NAME}})
+
+	# Exclude all translation units from compilation
+	set_source_files_properties(${FILES} PROPERTIES HEADER_FILE_ONLY true)
+
+	# Generate a unique filename for the unity build translation unit
+	set(UNIT_BUILD_FILE ${CMAKE_CURRENT_BINARY_DIR}/blob_${UB_SUFFIX}.cpp)
+	file(WRITE ${UNIT_BUILD_FILE} "// Unity Build generated by CMake\n")
+
+	# Add include statement for each translation unit
+	foreach(SOURCE_FILE ${FILES})
+		get_filename_component(FILE_EXT "${SOURCE_FILE}" EXT)
+		if(NOT "${FILE_EXT}" MATCHES "\.h(pp)?")
+			file(APPEND ${UNIT_BUILD_FILE} "#include <${SOURCE_FILE}>\n")
+		endif()
+	endforeach(SOURCE_FILE)
+
+	# Complement list of translation units with the name of ub
+	set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${UNIT_BUILD_FILE} PARENT_SCOPE)
+endfunction(enable_unity_build)
+
+
+
+
 set(ULTIMATE_WARNINGS "-Wdisabled-optimization -Wlogical-op -Wwrite-strings -Wmissing-include-dirs -Wredundant-decls -Wsign-promo -Wswitch-default -Wundef")
 set(EXTRA_WARNINGS "-Woverloaded-virtual -Wcast-qual -Wcast-align -Wunreachable-code -Wold-style-cast -Wnon-virtual-dtor -Wodr")
 # no -Wzero-as-null-pointer-constant because of VK_NULL_HANDLE
@@ -15,7 +41,7 @@ add_definitions("${ULTIMATE_WARNINGS}")
 add_definitions("-std=c++17 -pedantic -Wall -Wextra")
 
 
-
+# main files
 file(GLOB_RECURSE SOURCE_FILES
 		"YaveApp.cpp"
 		"YaveApp.h"
@@ -33,50 +59,32 @@ file(GLOB_RECURSE SHADER_FILES
 		"shaders/*.glsl"
 	)
 
-
 # y lib, change this to wherever it it
 include_directories(../y)
 link_directories(../y/build)
 
 
 
-
-function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME)
-	set(files ${${SOURCE_VARIABLE_NAME}})
-
-	# Generate a unique filename for the unity build translation unit
-	set(unit_build_file ${CMAKE_CURRENT_BINARY_DIR}/blob_${UB_SUFFIX}.cpp)
-
-	# Exclude all translation units from compilation
-	set_source_files_properties(${files} PROPERTIES HEADER_FILE_ONLY true)
-
-	# Open the ub file
-	FILE(WRITE ${unit_build_file} "// Unity Build generated by CMake\n")
-
-	# Add include statement for each translation unit
-	foreach(source_file ${files})
-		FILE(APPEND ${unit_build_file} "#include <${source_file}>\n")
-	endforeach(source_file)
-
-	# Complement list of translation units with the name of ub
-	set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${unit_build_file} PARENT_SCOPE)
-endfunction(enable_unity_build)
-
-
 option(USE_UNITY_BUILD "Use unity build" ON)
-option(BUILD_LIB "Build library" ON)
+option(BUILD_LIB "Build library" OFF)
 option(OPTIMIZE_DEBUG "Optimize debug builds" ON)
+# option(USE_IMGUI "Use Imgui" ON)
 
 if(OPTIMIZE_DEBUG)
 	set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O2")
 endif()
 
+# if(USE_IMGUI)
+# 	file(GLOB_RECURSE IMGUI_FILES "external/imgui/*.cpp" "external/imgui/*.h")
+# 	set(SOURCE_FILES ${SOURCE_FILES} ${IMGUI_FILES})
+# 	add_definitions(-DYAVE_IMGUI)
+# endif()
+
 if(USE_UNITY_BUILD)
 	message("Unity build enabled")
 	enable_unity_build(yave SOURCE_FILES)
 endif()
 
-
 # if we are not building libyave add main.cpp and build the exec
 if(BUILD_LIB)
 	message("Building libyave")
@@ -85,12 +93,15 @@ else()
 	add_executable(yave "main.cpp" ${SOURCE_FILES} ${SHADER_FILES})
 endif()
 
+
+
+
+
 target_link_libraries(yave y)
 target_link_libraries(yave vulkan-1)
 target_link_libraries(yave spirv-cross)
 target_link_libraries(yave pthread)
 
-
 # if we are building the lib: create an exec that links it
 if(BUILD_LIB)
 	add_executable(main "main.cpp")

Housekeeping