function(gnet_add_source_group src_path src_files)
  foreach(files ${src_files})
    get_filename_component(dir_parent "${files}" PATH)
    file(RELATIVE_PATH dir_parent ${src_path} ${dir_parent})
    string(REPLACE "/" "\\" src_files_group "${dir_parent}")
    set(src_files_group "${src_files_group}")
    source_group("${src_files_group}" FILES "${files}")
  endforeach()
endfunction()

function(gnet_add_library target_name src_path)
  file(GLOB_RECURSE src_files "${src_path}/*.cpp")
  gnet_add_source_group(${src_path} "${src_files}")
  add_library(${target_name} "${src_files}")
  target_precompile_headers(${target_name} PUBLIC "${CMAKE_SOURCE_DIR}/gnet/include/pch.hpp")
  target_include_directories(${target_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
endfunction()

function(gnet_add_executable target_name src_path)
  file(GLOB_RECURSE src_files "${src_path}/*.*")
  gnet_add_source_group(${src_path} "${src_files}")
  add_executable(${target_name} ${src_files})
  target_precompile_headers(${target_name} INTERFACE "${CMAKE_SOURCE_DIR}/gnet/include/pch.hpp")
endfunction()
