Skip to content

PCRE2_STATIC_RUNTIME no longer works #752

@HertzDevil

Description

@HertzDevil

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions