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

SQLITECPP_USE_STATIC_RUNTIME doesn't work on CMake 3.25 #417

Closed
ghuser404 opened this issue Apr 19, 2023 · 3 comments
Closed

SQLITECPP_USE_STATIC_RUNTIME doesn't work on CMake 3.25 #417

ghuser404 opened this issue Apr 19, 2023 · 3 comments
Assignees
Labels

Comments

@ghuser404
Copy link

Setting SQLITECPP_USE_STATIC_RUNTIME to ON, the generated MSVC project files still use /MD flag.

To solve this, CMAKE_MSVC_RUNTIME_LIBRARY should be set.

Here is how glfw solves this:

if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
    if (CMAKE_VERSION VERSION_LESS 3.15)
        foreach (flag CMAKE_C_FLAGS
                      CMAKE_C_FLAGS_DEBUG
                      CMAKE_C_FLAGS_RELEASE
                      CMAKE_C_FLAGS_MINSIZEREL
                      CMAKE_C_FLAGS_RELWITHDEBINFO)

            if (flag MATCHES "/MD")
                string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
            endif()
            if (flag MATCHES "/MDd")
                string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
            endif()

        endforeach()
    else()
        set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
    endif()
endif()
@SRombauts
Copy link
Owner

Hey @ghuser404, thanks for reporting, looks promising!
If you can propose a change, I'd be happy to review it.

SRombauts added a commit that referenced this issue Aug 18, 2023
- Replace the set() of "/MT" to REPLACE "/MD" "/MT" inspired from Zlib
licensed glfw https://github.com/glfw/glfw/blob/master/CMakeLists.txt
- Don't set SQLITECPP_USE_STATIC_RUNTIME by default when building with
unit tests. Use gtest_force_shared_crt to force googletest to link
against the default dynamic C++ runtime

Relates to #417
@UnixY2K
Copy link
Contributor

UnixY2K commented Aug 27, 2023

this should be ready to close as #438 was merged

@SRombauts
Copy link
Owner

Yes, thanks for the reminder!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants