CMake on Windows does not see source directories 'created' by MKLINK during the 'configure' phase.
CMake on Windows 7 (confirmed on 7, 8.x) does not see source directories 'created' by MKLINK during the 'configure' phase.
How to reproduce?
- Lets have 'SomeLib' CMake project
- Create another simple CMake project
- To such project add following command (which will create symlink during the configure phase)
EXECUTE_PROCESS( COMMAND "cmd.exe" "/K" "mklink" "/D" "${CMAKE_CURRENT_SOURCE_DIR}\\SomeLib C:\\Somepath\\SomeLib" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
3. Then add_subdirectory( SomeLib )
into it.
4. Let CMake generate buidsystem in this newly created project
or
- Download attached sample project CMakeSymlinkIssueSample.7z
- Go to the CMakeSymlinkIssueSample/CMakeSymlinkIssueProject
- Run the build.cmd
What happens?
CMake will complain about nonexisting 'SomeLib' directory.
What is expected?
CMake should should enter to this newly symlinked subdirectory.
Observations
- This 'wrong' behavior is NOT observed on Linux systems.
- When I call CMake for second time, everything works well.
- The MKLINK does not fail, it asks for admin privileges when required.
- The add_subdirectory( SomeLib ) is not the only one which fails, also
IF(EXISTS SomeLib)
andIF(IS_SYMLINK SomeLib)
does not work as expected.