cJSON icon indicating copy to clipboard operation
cJSON copied to clipboard

DLL ends up in LIBDIR, when it is expected to be in BINDIR

Open marcbertola opened this issue 7 years ago • 1 comments

I have been working at supporting cJSON under Microsoft's vcpkg package management system, and I ran into an issue with the following line:

https://github.com/DaveGamble/cJSON/blob/3c8935676a97c7c97bf006db8312875b4f292f6c/CMakeLists.txt#L152

This line installs the library into the CMAKE_INSTALL_FULL_LIBDIR directory, defined by GNUInstallDirs. My understanding is that under Windows, when the library is shared (.dll shared library + .lib import library), the dll file is expected to go into BINDIR, and the import library is still expected to go to LIBDIR.

Replacing the line above with the following line fixed the issue for me under Windows, but I'm not set up to verify if this breaks anything under Linux (yet). I am now able to use it as a package under vcpkg. I may contribute the portfiles back to the main vcpkg repo at some point if I find time to make it ready for prime-time (just need to get that Linux box up and running).

I hope this helps.

install(TARGETS "${CJSON_LIB}" 
    EXPORT "${CJSON_LIB}"
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
    )

marcbertola avatar Aug 05 '19 21:08 marcbertola

Hmm Just looked at the latest release of vcpkg, and it would appear someone has already ported cjson and resolved the issue above with a patch (like I was doing). I guess this must be a known issue.

marcbertola avatar Aug 10 '19 04:08 marcbertola