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

Windows Static Build Problem / Changed behaviour of POCO_MT (CMake 3.15) #4817

Open
Enc-EE opened this issue Dec 12, 2024 · 1 comment · Fixed by #4823
Open

Windows Static Build Problem / Changed behaviour of POCO_MT (CMake 3.15) #4817

Enc-EE opened this issue Dec 12, 2024 · 1 comment · Fixed by #4823
Assignees
Labels
bug cmake Related to cmake build system fixed platform_specific

Comments

@Enc-EE
Copy link
Contributor

Enc-EE commented Dec 12, 2024

Describe the bug
I Build Poco on Windows.
After Updating from 1.13.3 to 1.14.0 I got linking issues complaining about Runtime Library. Basically me Building statically linking to non statically poco.
I use BUILD_SHARED_LIBS=OFF and POCO_MT=ON

I noticed in the Poco build Output the CXX flags /MT were gone after updating to 1.14.0
I investigated the issue and came up with the following:

In poco/CMakeLists.txt
cmake_minimum_required(VERSION 3.5.0) was updated to cmake_minimum_required(VERSION 3.15.0)
This leads to changed policy: https://cmake.org/cmake/help/latest/policy/CMP0091.html
This will change the default CXX flags to NOT include /MD.
POCO_MT Variable relies on on having /MD flag and than replacing them with /MT in poco/cmake/DefinePlatformSpecific.cmake
Since /MD is not there, it won't replace it and it won't change to static.
I added -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug to my cmake command, which probably is the intended way of setting static now.

To Reproduce
Build Poco with BUILD_SHARED_LIBS=OFF and POCO_MT=ON and then using it in a statically linked cmake project in Visual Studio. (That's how I ran into the problem.)

Expected behavior
Poco should build static or docs should be updated.

Please add relevant environment information:

  • Windows 11
  • Poco 1.14.0
  • Visual Studio 17.12.1
@Enc-EE Enc-EE added the bug label Dec 12, 2024
@matejk matejk added this to the Release 1.14.1 milestone Dec 12, 2024
@matejk matejk added this to 1.14 Dec 12, 2024
@matejk matejk added the cmake Related to cmake build system label Dec 12, 2024
@matejk matejk self-assigned this Dec 12, 2024
@matejk matejk changed the title Windows Static Build Porblem / Changed behaviour of POCO_MT Windows Static Build Problem / Changed behaviour of POCO_MT (CMake 3.15) Dec 12, 2024
@matejk matejk moved this to In Progress in 1.14 Dec 18, 2024
@matejk
Copy link
Contributor

matejk commented Dec 20, 2024

Hi @Enc-EE, would you be willing to verify if PR #4823 resolved the problem?

@matejk matejk closed this as completed in c9dc1f9 Dec 27, 2024
matejk added a commit that referenced this issue Dec 27, 2024
…IME_LIBRARY (fixes #4817) (#4823)

* fix(CMake): Select MSVC runtime library with variable CMAKE_MSVC_RUNTIME_LIBRARY instead of modifying compiler flags.

* enh(CI): Add static and MT MSVC builds.

* fix(CMake): Correct TestLibrary DLL name when building with MSVC
@matejk matejk added the fixed label Dec 27, 2024
@matejk matejk reopened this Dec 27, 2024
@matejk matejk moved this from In Progress to Done in 1.14 Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cmake Related to cmake build system fixed platform_specific
Projects
Status: Done
2 participants