[BUG] MSVC 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'
#1,655 创建于 2023年8月23日
描述
Describe the bug A clear and concise description of what the bug is.
I have download and compile and test Google BenchMark success on My Linux, My Mac. but On My Windows PC , I get an error when other project link the benchmark!
I know this is because the benchmark project is a lib generated by MD, but the test project regards it as MT, so the link is wrong.
I am forced to manually modify the benchmark attribute to MT then build and then manually copy it to the installation directory . it can work well.
I have tried the code below adding to CMakeLists.txt, it don't work!
if (MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")
endif
or adding MT to the build script, but it has no effect!
cmake -E chdir "build" cmake -DCMAKE_CXX_FLAGS_RELEASE=/MT -DCMAKE_CXX_FLAGS=/MT -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release ../
System Which OS, compiler, and compiler version are you using:
- OS: windows 11,22H2,22621.2134
- Compiler and version: Microsoft Visual Studio Professional 2022 (64-bit) - Current Version 17.6.5
To reproduce Steps to reproduce the behavior: install.bat
git clone https://github.com/google/benchmark.git
cd benchmark
cmake -E make_directory "build"
cmake -E chdir "build" cmake -DCMAKE_CXX_FLAGS_RELEASE=/MT -DCMAKE_CXX_FLAGS=/MT -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release ../
cmake --build "build" --config Release --target install
then other project use the google bench
CMakeLists.txt
find_package(benchmark REQUIRED)
target_link_libraries(main PUBLIC benchmark::benchmark)
target_link_libraries(main PUBLIC benchmark::benchmark_main)
Expected behavior A clear and concise description of what you expected to happen. How Can fix the google benchmark MD to MT auto
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.