← All tasks
cpplibjxl/libjxl #3834Not a task: already works

An incorrect MSVC option is applied in a debug build with static linking

envgap__libjxl__libjxl-3834

01 / FAILURE SIGNATURE

As reported upstream

No identifying execution failure has been captured.
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
8f22cb1fb98ed27ceee59887bd291ef4d277c89d
Manifest
CMakeLists.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

libjxl/libjxl #3834 · read the original issue
**Describe the bug**

The `/MT` option is applied instead of the `/MTd` option in a statically linked debug build with Visual Studio.

There is an issue with commit b5cb2464c6d42c3688b4f51e5101adf2ae291bfd(#3803).



**To Reproduce**

Build with the `-DCMAKE_BUILD_TYPE=Debug` option and the `-DJPEGXL_STATIC=ON` option.



**Expected behavior**

The `/MTd` option is applied.



**Environment**

 - OS: Windows 11 23H2

 - Compiler version: cl.exe Version 19.41.34120 for x64

 - CPU type: x86_64



**Additional context**

I have two proposals for a fix.

- Proposal 1

    Replace the following code in `CMakeLists.txt`:



    ```cmake

    set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)

    ```



    with:



    ```cmake

    set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

    ```

- Proposal 2

    1. Remove the following code in `CMakeLists.txt`:



        ```cmake

        set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)

        ```



    2. Add the `-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>"` option to cmake.exe.



I would prefer Proposal 2 for general purpose.



**Reference**

[CMAKE_MSVC_RUNTIME_LIBRARY](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html)
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]