Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windows static library build parameter in CMakeLists.txt #1182

Merged
merged 3 commits into from
Feb 17, 2025

Conversation

MiyamuraMiyako
Copy link
Contributor

Use cmake parameter set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") to build windows static library.

Copy link
Member

@COM8 COM8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MiyamuraMiyako thanks for submitting this PR!

Could you please explain a bit why this is needed? I'm not so deep into msvc stuff.

Also please add a bit of inline comments what your code does and why it is needed.

@MiyamuraMiyako
Copy link
Contributor Author

MiyamuraMiyako commented Feb 16, 2025

@COM8 The current Cmake configuration (-DBUILD_SHARED_LIBS=OFF) cannot compile a pure static library for Windows normally. By my test, need to add the configuration: set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"). I think the message I output in cmake has explained the purpose of this modification.

if (MSVC)
    if (BUILD_SHARED_LIBS)
        message(STATUS "Build windows dynamic libs.")
    else()
        # Add this to build windows pure static library.
        set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
        message(STATUS "Build windows static libs.")
    endif()
endif()

@MiyamuraMiyako MiyamuraMiyako requested a review from COM8 February 16, 2025 16:21
@COM8
Copy link
Member

COM8 commented Feb 16, 2025

Thanks! From what I can see, you have not yet pushed the comment to your CMake code. You just removed some Compiler definitions.

@MiyamuraMiyako
Copy link
Contributor Author

@COM8 Ok, I add this comment to CMakeLists.txt

@COM8 COM8 added this to the CPR 1.11.x milestone Feb 17, 2025
@COM8 COM8 merged commit bc4f169 into libcpr:master Feb 17, 2025
37 of 39 checks passed
COM8 added a commit that referenced this pull request Feb 17, 2025
Fix windows static library build parameter in CMakeLists.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants