Skip to content

PCRE2_STATIC_RUNTIME no longer works #752

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

Closed
HertzDevil opened this issue May 20, 2025 · 1 comment · Fixed by #753
Closed

PCRE2_STATIC_RUNTIME no longer works #752

HertzDevil opened this issue May 20, 2025 · 1 comment · Fixed by #753
Labels
bug Something isn't working
Milestone

Comments

@HertzDevil
Copy link

HertzDevil commented May 20, 2025

CMakeLists.txt currently replaces the CMAKE_<LANG>_FLAGS_<CONFIG> variables directly in order to select a suitable MSVC runtime library:

pcre2/CMakeLists.txt

Lines 840 to 855 in 0986559

# Fix static compilation with MSVC: https://bugs.exim.org/show_bug.cgi?id=1681
# This code was taken from the CMake wiki, not from WebM.
if(MSVC AND PCRE2_STATIC_RUNTIME)
message(STATUS "** MSVC and PCRE2_STATIC_RUNTIME: modifying compiler flags to use static runtime library")
foreach(
flag_var
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO
)
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endforeach()
endif()

As of #542, however, the minimum CMake version is now 3.15, which means the /MD or MT flags are now provided by CMake's CMAKE_MSVC_RUNTIME_LIBRARY variable and absent in these FLAGS variables, unless CMAKE_POLICY_DEFAULT_CMP0091 is set to OLD.

Overriding CMAKE_MSVC_RUNTIME_LIBRARY at the command line now suffices, so it is best to remove PCRE2_STATIC_RUNTIME entirely, or make it modify CMAKE_MSVC_RUNTIME_LIBRARY instead. (Setting CMAKE_POLICY_DEFAULT_CMP0091 to NEW also allows CMake 3.15 or above to apply CMAKE_MSVC_RUNTIME_LIBRARY to previous PCRE2 releases that had a lower minimum version in CMakeLists.txt.)

@NWilson
Copy link
Member

NWilson commented May 20, 2025

Thank you for reporting this!

I agree with your description of the issue. Thank you for researching and linking to all the documentation so helpfully.

My preferred solution is to simply remove PCRE2_STATIC_RUNTIME, since our minimum CMake version allows us to recommend the new & better way instead.

I will make this change when I have some free time to test & document it.

@NWilson NWilson added this to the 10.46 milestone May 20, 2025
@NWilson NWilson added the bug Something isn't working label May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants