Durengo / Omni-Grid

Final project for Software Engineering and Software Testing courses made by students from Vilniaus Kolegija / University of Applied Sciences at the Faculty of Electronics and Informatics.
MIT License
0 stars 1 forks source link

CMake Builds with boost python libraries do not automatically include the necessary dll files to run the executable #15

Closed Durengo closed 11 months ago

Durengo commented 11 months ago

The executables build but upon launching them on Windows we get runtime errors that specific dll files are missing. This is automatically included in our Install definitions in CMake, but for some reason the builds themselves do not contain the specific runtime files.

Durengo commented 11 months ago

Fixed with #17. The workaround includes adding the following lines to the executable to include the missing DLLs.

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
    add_custom_command(TARGET EXECUTABLE_NAME POST_BUILD

        # COPY PYTHON RUNTIME DLLS
        COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${Python3_RUNTIME_LIBRARY}"
        $<TARGET_FILE_DIR:EXECUTABLE_NAME>

        # COPY BOOST PYTHON DEBUG DLLS
        COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${Boost_Python_Debug_DLL}"
        $<TARGET_FILE_DIR:EXECUTABLE_NAME>

        # ALSO COPY BOOST PYTHON RELEASE DLLS AS THEY ARE NEEDED FOR RUNTIME
        COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${Boost_Python_Release_DLL}"
        $<TARGET_FILE_DIR:EXECUTABLE_NAME>

        # ALSO COPY ZLIB RELEASE DLLS AS THEY ARE NEEDED FOR RUNTIME
        COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${VCPKG_CORE}/bin/zlib1.dll"
        $<TARGET_FILE_DIR:EXECUTABLE_NAME>
    )
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release")
    add_custom_command(TARGET EXECUTABLE_NAME POST_BUILD

        # COPY PYTHON RUNTIME DLLS
        COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${Python3_RUNTIME_LIBRARY}"
        $<TARGET_FILE_DIR:EXECUTABLE_NAME>

        # COPY BOOST PYTHON RELEASE DLLS
        COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${Boost_Python_Release_DLL}"
        $<TARGET_FILE_DIR:EXECUTABLE_NAME>

        # COPY ZLIB RELEASE DLLS
        COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${VCPKG_CORE}/bin/zlib1.dll"
        $<TARGET_FILE_DIR:EXECUTABLE_NAME>
    )
endif()

Tested this on CLion IDE as well: Before fix: BeforeFix After fix: AfterFix

The errors that are thrown after fix is related to #16 - but the main point is that the executables now have the missing dll files.