Changes: - Add GLAD dependency via vcpkg for proper OpenGL function loading - Force NVIDIA GPU usage with game-style exports (NvOptimusEnablement) - Create working console version (SecondVoice_Console.exe) - Add dual executable build (UI + Console versions) - Update to OpenGL 4.6 Core Profile with GLSL 460 - Add GPU detection and logging - Fix GLFW header conflicts with GLFW_INCLUDE_NONE Note: OpenGL shaders still failing to compile despite GLAD integration. Console version is fully functional for audio capture and translation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
149 lines
4.2 KiB
CMake
149 lines
4.2 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)
|
|
|
|
# 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()
|
|
|
|
# Find packages
|
|
find_package(portaudio CONFIG REQUIRED)
|
|
find_package(httplib CONFIG REQUIRED)
|
|
find_package(nlohmann_json CONFIG REQUIRED)
|
|
find_package(imgui CONFIG REQUIRED)
|
|
find_package(glfw3 CONFIG REQUIRED)
|
|
find_package(glad CONFIG REQUIRED)
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
# 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::imgui
|
|
${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::imgui
|
|
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)
|