Skip to content

Windows build fails trying to create symlinks #204

@pezcode

Description

@pezcode

There are a few custom targets that create symlinks, like this one:

if (WIN32)
    add_custom_target(ResourcesDir ALL
        COMMAND IF NOT EXIST ${RESOURCES_DST} mklink /J ${RESOURCES_DST} ${RESOURCES_SRC}
    )
else ()
    add_custom_target(ResourcesDir ALL
        COMMAND ${CMAKE_COMMAND} -E create_symlink ${RESOURCES_SRC} ${RESOURCES_DST}
    )
endif ()

This fails trying to compile on Win10 1803 with VS 2017:

6>You do not have sufficient privilege to perform this operation.
5>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5): error MSB6006: "cmd.exe" exited with code 1.

The reason behind it failing is a bit odd but the solution is pretty straightforward: Replace all mklink /D with mklink /J.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions