ggerganov / whisper.cpp

Port of OpenAI's Whisper model in C/C++
MIT License
35.38k stars 3.61k forks source link

MSVC static runtime library #2109

Open pierreguillot opened 6 months ago

pierreguillot commented 6 months ago

It would be great to be able to define the MSVC runtime library via CMAKE_MSVC_RUNTIME_LIBRARY (or the MSVC_RUNTIME_LIBRARY property). However, this feature has only been included in CMake 3.15. Would it be possible to set this version as the minimum? Or set the minimum version to 3.5 only if it is not yet defined?

if(NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION)
  cmake_minimum_required(VERSION 3.5)
endif()

P.S. I can create a PR if necessary.

thewh1teagle commented 2 months ago

I spent hours debugging why it doesn't respect setting static msvc linking.

I tried with set(MSVC_RUNTIME_LIBRARY, "MultiThreaded") or set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")

Eventually the only way worked:

if (MSVC)
    set(CompilerFlags
            CMAKE_CXX_FLAGS
            CMAKE_CXX_FLAGS_DEBUG
            CMAKE_CXX_FLAGS_RELEASE
            )
    foreach(CompilerFlag ${CompilerFlags})
    string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
    endforeach()
endif()
altunenes commented 2 months ago

Any hope of this? same issue on Windows. :(