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

Fix MSVC Debug build with internal zlib #1321

Merged

Conversation

markreidvfx
Copy link
Contributor

I found this issue when trying to build in debug mode with msvc and it not being able to link to the internal zlib.

To replicate in a MSVC Developer command prompt and a clean build dir run

cmake .. -DOPENEXR_FORCE_INTERNAL_ZLIB=ON
cmake --build .

I get this error

LINK : fatal error LNK1104: cannot open file '..\..\..\zlib-install\lib\zlibstatic.lib' [D:\Dev\openexr\build\src\lib\OpenEXR\OpenEXR.vcxproj]

zlib's cmake script is setting CMAKE_DEBUG_POSTFIX to "d" with msvc. The lib name should be zlibstaticd.lib in debug. The current scripts don't take the "d" into account.

There might be a better way fix this. I couldn't figure out a way in cmake to override this behavior without modifying zlib. I ended up going with setting the additional IMPORTED_LOCATION_DEBUG property instead. I also tried those fancy generator expressions but they didn't appear to work with the IMPORTED_LOCATION property.

zlib sets CMAKE_DEBUG_POSTFIX to "d" with msvc in debug

Signed-off-by: Mark Reid <mindmark@gmail.com>
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 16, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: markreidvfx / name: Mark Reid (5578cdb)

Copy link
Contributor

@meshula meshula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think a fancy generator would help here. This looks good to me, thanks!

@cary-ilm cary-ilm merged commit 71bffa3 into AcademySoftwareFoundation:main Dec 21, 2022
cary-ilm pushed a commit to cary-ilm/openexr that referenced this pull request Mar 3, 2023
zlib sets CMAKE_DEBUG_POSTFIX to "d" with msvc in debug

Signed-off-by: Mark Reid <mindmark@gmail.com>

Signed-off-by: Mark Reid <mindmark@gmail.com>
cary-ilm pushed a commit that referenced this pull request Mar 5, 2023
zlib sets CMAKE_DEBUG_POSTFIX to "d" with msvc in debug

Signed-off-by: Mark Reid <mindmark@gmail.com>

Signed-off-by: Mark Reid <mindmark@gmail.com>
@cary-ilm cary-ilm added the v3.1.6 label Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants