Skip to content

Unable to configure non-DLL build (/MT, not /MD) with CMake 3.17.3 and VS 2019 #912

@tomlogic

Description

@tomlogic

Disclaimer: Although I'm an experienced embedded C programmer, I'm relatively new to CMake, Visual Studio and building Windows libraries.

I'm trying to find a CMake configuration of yaml-cpp to get a 32-bit Visual Studio 2019 solution with the runtime library set to /MT and /MTd.

I'm using the following to configure my build, and even added some debug output to CMakeLists.txt to verify the MSVC_RUNTIME_LIBRARY setting:

$ cmake .. -AWin32 -DYAML_MSVC_SHARED_RT=OFF -DYAML_BUILD_SHARED_LIBS=OFF
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The CXX compiler identification is MSVC 19.26.28806.0
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x86/cl.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:OFF>:DLL>"
--
 Properties for TARGET yaml-cpp:
   yaml-cpp.MSVC_RUNTIME_LIBRARY = "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:OFF>:DLL>"

-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - not found
-- Found Threads: TRUE
-- The C compiler identification is MSVC 19.26.28806.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x86/cl.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PythonInterp: C:/msys64/mingw32/bin/python.exe (found version "3.8.3")
-- Configuring done
-- Generating done
-- Build files have been written to: [directory]

But when I open the solution in VS 2019 and check the Runtime Library setting, it's configured for Multi-threaded DLL.

Looking through CMakeLists.txt, it appears that an older version of CMake would manually add the -MT and -MTd compiler flags. I'm assuming that the point of target property MSVC_RUNTIME_LIBRARY is to simplify that.

Are there other flags I need to set? Additional information to aid in troubleshooting?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions