PROBLÈME RÉSOLU: Les shaders ImGui compilent maintenant avec succès!
Changements majeurs:
- Remplacé vcpkg ImGui par FetchContent (compilation from source)
- Créé wrapper GLAD pour ImGui (imgui_opengl3_glad.cpp)
- Ajout de makeContextCurrent() pour gérer le contexte OpenGL multi-thread
- Release du contexte dans initialize(), puis rendu current dans uiThread()
Root Cause Analysis:
1. Rendering s'exécute dans uiThread() (thread séparé)
2. Contexte OpenGL créé dans thread principal n'était pas accessible
3. glCreateShader retournait 0 avec GL_INVALID_OPERATION (erreur 1282)
4. Solution: Transfer du contexte OpenGL du thread principal vers uiThread
Debugging profond:
- Ajout de logs debug dans ImGui pour tracer glCreateShader
- Découvert que handle=0 indiquait échec de création (pas compilation)
- Identifié erreur WGL \"ressource en cours d'utilisation\" = contexte locked
Fichiers modifiés:
- vcpkg.json: Supprimé imgui
- CMakeLists.txt: FetchContent pour ImGui + imgui_backends library
- src/imgui_opengl3_glad.cpp: Nouveau wrapper GLAD
- src/ui/TranslationUI.{h,cpp}: Ajout makeContextCurrent()
- src/core/Pipeline.cpp: Appel makeContextCurrent() dans uiThread()
- build/.../imgui_impl_opengl3.cpp: Debug logs (temporaire)
Résultat: UI fonctionne! NVIDIA RTX 4060 GPU, OpenGL 3.3.0, shaders compilent
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
179 lines
5.1 KiB
CMake
179 lines
5.1 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(SecondVoice VERSION 0.1.0 LANGUAGES CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
# FetchContent for downloading ImGui from source
|
|
include(FetchContent)
|
|
|
|
# Force static linking for MinGW
|
|
if(MINGW)
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
|
|
endif()
|
|
|
|
# Fetch ImGui from GitHub (like WarFactory does!)
|
|
FetchContent_Declare(
|
|
imgui
|
|
GIT_REPOSITORY https://github.com/ocornut/imgui.git
|
|
GIT_TAG v1.90.1
|
|
)
|
|
|
|
FetchContent_MakeAvailable(imgui)
|
|
|
|
# Create ImGui library with OpenGL/GLFW backends
|
|
add_library(imgui_backends
|
|
${imgui_SOURCE_DIR}/imgui.cpp
|
|
${imgui_SOURCE_DIR}/imgui_demo.cpp
|
|
${imgui_SOURCE_DIR}/imgui_draw.cpp
|
|
${imgui_SOURCE_DIR}/imgui_tables.cpp
|
|
${imgui_SOURCE_DIR}/imgui_widgets.cpp
|
|
${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/imgui_opengl3_glad.cpp # Our wrapper with GLAD
|
|
)
|
|
|
|
target_include_directories(imgui_backends PUBLIC
|
|
${imgui_SOURCE_DIR}
|
|
${imgui_SOURCE_DIR}/backends
|
|
)
|
|
|
|
# Find packages (no more vcpkg imgui!)
|
|
find_package(portaudio CONFIG REQUIRED)
|
|
find_package(httplib CONFIG REQUIRED)
|
|
find_package(nlohmann_json CONFIG REQUIRED)
|
|
find_package(glfw3 CONFIG REQUIRED)
|
|
find_package(glad CONFIG REQUIRED)
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
# Link imgui_backends with glfw and OpenGL
|
|
target_link_libraries(imgui_backends PUBLIC glfw OpenGL::GL glad::glad)
|
|
|
|
# Source files for UI version
|
|
set(SOURCES_UI
|
|
src/main.cpp
|
|
# Audio module
|
|
src/audio/AudioCapture.cpp
|
|
src/audio/AudioBuffer.cpp
|
|
# API clients
|
|
src/api/WhisperClient.cpp
|
|
src/api/ClaudeClient.cpp
|
|
# UI
|
|
src/ui/TranslationUI.cpp
|
|
# Utils
|
|
src/utils/Config.cpp
|
|
# Core
|
|
src/core/Pipeline.cpp
|
|
)
|
|
|
|
# Source files for Console version (NO UI, NO Pipeline)
|
|
set(SOURCES_CONSOLE
|
|
src/main_console.cpp
|
|
# Audio module
|
|
src/audio/AudioCapture.cpp
|
|
src/audio/AudioBuffer.cpp
|
|
# API clients
|
|
src/api/WhisperClient.cpp
|
|
src/api/ClaudeClient.cpp
|
|
# Utils
|
|
src/utils/Config.cpp
|
|
# Core - WAIT, Pipeline uses UI!
|
|
# src/core/Pipeline.cpp
|
|
)
|
|
|
|
# UI Executable
|
|
add_executable(${PROJECT_NAME} ${SOURCES_UI})
|
|
|
|
# Console Executable (NO UI)
|
|
add_executable(${PROJECT_NAME}_Console ${SOURCES_CONSOLE})
|
|
|
|
# Include directories
|
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
)
|
|
target_include_directories(${PROJECT_NAME}_Console PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
)
|
|
|
|
# Link libraries
|
|
if(MINGW AND NOT BUILD_SHARED_LIBS)
|
|
# Static linking for MinGW - need to add Windows system libs for portaudio
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE
|
|
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-mingw-static/lib/libportaudio.a
|
|
httplib::httplib
|
|
nlohmann_json::nlohmann_json
|
|
imgui_backends
|
|
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-mingw-static/lib/libglfw3.a
|
|
glad::glad
|
|
OpenGL::GL
|
|
# Windows system libraries for portaudio
|
|
winmm
|
|
setupapi
|
|
)
|
|
# Console version - NO UI libs
|
|
target_link_libraries(${PROJECT_NAME}_Console PRIVATE
|
|
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-mingw-static/lib/libportaudio.a
|
|
httplib::httplib
|
|
nlohmann_json::nlohmann_json
|
|
# Windows system libraries for portaudio
|
|
winmm
|
|
setupapi
|
|
)
|
|
else()
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE
|
|
portaudio
|
|
httplib::httplib
|
|
nlohmann_json::nlohmann_json
|
|
imgui_backends
|
|
glfw
|
|
glad::glad
|
|
OpenGL::GL
|
|
)
|
|
# Console version - NO UI libs
|
|
target_link_libraries(${PROJECT_NAME}_Console PRIVATE
|
|
portaudio
|
|
httplib::httplib
|
|
nlohmann_json::nlohmann_json
|
|
)
|
|
endif()
|
|
|
|
# Compiler options
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
|
target_compile_options(${PROJECT_NAME} PRIVATE
|
|
-Wall
|
|
-Wextra
|
|
-Wpedantic
|
|
)
|
|
target_compile_options(${PROJECT_NAME}_Console PRIVATE
|
|
-Wall
|
|
-Wextra
|
|
-Wpedantic
|
|
)
|
|
|
|
# MinGW: cpp-httplib's GetAddrInfoExCancel is not available
|
|
# Don't treat warnings as errors for MinGW due to httplib incompatibilities
|
|
if(NOT MINGW)
|
|
target_compile_options(${PROJECT_NAME} PRIVATE -Werror)
|
|
target_compile_options(${PROJECT_NAME}_Console PRIVATE -Werror)
|
|
else()
|
|
# Force console subsystem on Windows (not GUI subsystem)
|
|
target_link_options(${PROJECT_NAME} PRIVATE -mconsole)
|
|
target_link_options(${PROJECT_NAME}_Console PRIVATE -mconsole)
|
|
|
|
# FORCE GPU exports using .def file (like games do!)
|
|
target_link_options(${PROJECT_NAME} PRIVATE
|
|
-Wl,--export-all-symbols
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/gpu_exports.def
|
|
)
|
|
endif()
|
|
endif()
|
|
|
|
# Copy config files to build directory
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.json
|
|
${CMAKE_CURRENT_BINARY_DIR}/config.json COPYONLY)
|
|
|
|
# Install target
|
|
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
|
install(FILES config.json DESTINATION bin)
|