Skip to content

Commit 838f7fc

Browse files
committed
vcpkg build fixes, attempt 2/2
'vcpkg install io2d' was not working when building a Debug copy of io2d, as 'd'ebug versions of certain libraries, namely Cairo, LibPNG, and zlib, could not be found. Each of those libraries, on Windows, had different library names, if and when a Debug copy was used. For example, "cairod" for Debug, "cairo" for Release. When building the Debug copy of io2d, it would not find the 'd' versions of these libraries, which caused CMake to fail during its 'config' stage. The Release copy of io2d would pass cmake configuration, but not the Debug copy. Fix attempt 1, which is-being (or by now, perhaps, has-been) rescinded, tried to ignore 'd' versions of libraries. This got 'vcpkg install io2d' working, however it caused problems when building and running io2d standalone, using older build instructions (that involved running CMake manually, then building io2d.sln manually). The problems involved .dll files that could not be found. Fix attempt 2 (this one!), does two things: 1. it doesn't attempt to directly link to LibPNG and zlib, when using MSVC. This is unnecessary, as GraphicsMagick is suitably-used instead. 2. for Cairo, it looks for both 'd' (Debug) and not-'d' (Release) libraries, however, if the 'd' version is not found, it'll fall back to using the not-'d' version. The two things above combine to allow vcpkg to successfully configure, then build io2d, while allowing io2d to also be built manually.
1 parent 980a14c commit 838f7fc

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

P0267_RefImpl/P0267_RefImpl/cairo/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ target_include_directories(io2d_cairo SYSTEM PUBLIC ${CAIRO_INCLUDE_DIR} ${GRAPH
4646
target_link_libraries(io2d_cairo PUBLIC ${GRAPHICSMAGICK_LIB})
4747

4848
if(MSVC)
49-
target_link_libraries(io2d_cairo PUBLIC debug ${CAIRO_LIB_DEBUG} optimized ${CAIRO_LIB_RELEASE})
49+
if(CAIRO_LIB_DEBUG STREQUAL "CAIRO_LIB_DEBUG-NOTFOUND")
50+
message(STATUS "io2d: Can't find Debug build of Cairo. Will try to use Release build, instead.")
51+
target_link_libraries(io2d_cairo PUBLIC ${CAIRO_LIB_RELEASE})
52+
else()
53+
target_link_libraries(io2d_cairo PUBLIC debug ${CAIRO_LIB_DEBUG} optimized ${CAIRO_LIB_RELEASE})
54+
endif()
5055
else()
5156
target_link_libraries(io2d_cairo PUBLIC ${CAIRO_LIB})
5257
endif()

P0267_RefImpl/P0267_RefImpl/cairo/win32/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,14 @@ if(MSVC)
3030
find_library(FREETYPE_LIB freetype)
3131
find_library(FONTCONFIG_LIB fontconfig)
3232
find_library(BZ_LIB bz2)
33-
find_library(ZLIB_LIB_DEBUG zlibd)
34-
find_library(ZLIB_LIB_RELEASE zlib)
3533
find_library(JPEG_LIB jpeg)
36-
find_library(PNG_LIB_DEBUG libpng16d)
37-
find_library(PNG_LIB_RELEASE libpng16)
3834
find_library(TIFF_LIB tiff)
3935
find_library(EXPAT_LIB expat)
4036
find_library(LZMA_LIB lzma)
4137
find_library(ICONV_LIB libiconv)
4238
find_library(CHARSET_LIB libcharset)
4339

4440
target_link_libraries(io2d_cairo_win32 PUBLIC ${PIXMAN_LIB} ${FREETYPE_LIB} ${FONTCONFIG_LIB} ${BZ_LIB} ${JPEG_LIB} ${TIFF_LIB} ${EXPAT_LIB} ${LZMA_LIB} ${ICONV_LIB} ${CHARSET_LIB})
45-
target_link_libraries(io2d_cairo_win32 PUBLIC debug ${PNG_LIB_DEBUG} optimized ${PNG_LIB_RELEASE})
46-
target_link_libraries(io2d_cairo_win32 PUBLIC debug ${ZLIB_LIB_DEBUG} optimized ${ZLIB_LIB_RELEASE})
4741
endif()
4842

4943
install(

0 commit comments

Comments
 (0)