zlib icon indicating copy to clipboard operation
zlib copied to clipboard

Add package export to installation

Open AndrewAtAvenza opened this issue 3 years ago • 3 comments

I'm trying build minizip with a locally built zlib because my circumstances don't allow for an internet connection while building minizip. Minizip will basically only look for zlib with find_package or fetch it, so I've had to add package export to my local copy of zlib. But I'm not sure there's a downside to having that all the time, so maybe you add it to the CMakeLists.txt? Replace:

    install(TARGETS zlib zlibstatic
    	  EXPORT ${PROJECT_NAME}
        RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
        ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
        LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )

with

    install(TARGETS zlib zlibstatic
    	  EXPORT ${PROJECT_NAME}
        RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
        ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
        LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )

    install(EXPORT ${PROJECT_NAME}
            DESTINATION "${INSTALL_LIB_DIR}/cmake/${PROJECT_NAME}"
            NAMESPACE "ZLIB::")

Or something similar at any rate! Thanks!

AndrewAtAvenza avatar Dec 31 '22 18:12 AndrewAtAvenza

@gvollant: Can you look?

Neustradamus avatar Jan 04 '23 04:01 Neustradamus

I should mention: I'm not 100% sure what the generally accepted 'proper' location for the CMake package export is within the installation folder structure. I've seen in the 'lib' folder, but maybe it should go in the root in a 'cmake' folder? I honestly have no idea. So long as it's there somewhere, that's good enough for me 😄

AndrewAtAvenza avatar Jan 04 '23 04:01 AndrewAtAvenza

@Neustradamus I did not write myself CMake package, no I prefer CMake expert review this change

gvollant avatar Jul 29 '23 08:07 gvollant