Mklink issue when building on Windows #103

Open
opened 2019-05-06 11:33:10 -05:00 by gyuri-szing · 1 comment
gyuri-szing commented 2019-05-06 11:33:10 -05:00 (Migrated from github.com)

Description

When building with CMake on a Win 10 machine, creation of links using mklink (see CMakeLists.txt) doesn't always work.

This is a similar issue to https://github.com/ARMmbed/mbedtls/issues/1496 reported for mbed-tls.

The root cause is: cmd.exe does allays only accept \ as directory separator, but file(TO_NATIVE_PATH ) is target host system specific and under some conditions will return PATHs with /.
In addition on some of our machines CMAKE_UNIX_HOST is set while ln is not available.
So I suggest checking if CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" is true and to use string manipulation to convert directory separators and drive letters (i.e. /c/foo/bar -> c:\foo\bar and /cygdrive/c/foo/bar -> c:\foo\bar).

Howto reproduce:
Assumptions:

  1. arm-none-eabi-gcc and gnumake is available on the PATH.
    Steps:
  2. Start menu -> run -> cmd.exe
  3. cd <mbed-crypto path>
  4. mkdir build; cd build
  5. cmake -DCMAKE_C_COMPILER=arm-none-eabi-gcc -DCMAKE_C_COMPILER_WORKS=True -G"Unix Makefiles" ..

Result:

C:\work\mbed-crypto\build>cmake -DCMAKE_C_COMPILER=arm-none-eabi-gcc -DCMAKE_C_COMPILER_WORKS=True -G"Unix Makefiles" ..
-- The C compiler identification is GNU 6.3.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - failed
-- Found PythonInterp: C:/Program Files/Python36/python.exe (found version "3.6.1")
-- Could NOT find Perl (missing: PERL_EXECUTABLE)
CMake Error at CMakeLists.txt:106 (message):
  Could not create symbolic link for: C:/work/mbed-crypto/include/mbedtls -->
  Invalid switch - "work".

Call Stack (most recent call first):
  include/CMakeLists.txt:20 (link_to_source)


-- Configuring incomplete, errors occurred!
See also "C:/work/mbed-crypto/build/CMakeFiles/CMakeOutput.log".
See also "C:/work/mbed-crypto/build/CMakeFiles/CMakeError.log".

C:\work\mbed-crypto\build>

Issue request type

[ ] Question
[ ] Enhancement
[x] Bug
<!-- ************************************** WARNING ************************************** The ciarcom bot parses this header automatically. Any deviation from the template may cause the bot to automatically correct this header or may result in a warning message, requesting updates. Please ensure that nothing follows the Issue request type section, all issue details are within the Description section and no changes are made to the template format (as detailed below). ************************************************************************************* --> ### Description When building with CMake on a Win 10 machine, creation of links using mklink (see [CMakeLists.txt](https://github.com/ARMmbed/mbed-crypto/blob/development/CMakeLists.txt#L85)) doesn't always work. This is a similar issue to https://github.com/ARMmbed/mbedtls/issues/1496 reported for mbed-tls. The root cause is: cmd.exe does allays only accept `\` as directory separator, but `file(TO_NATIVE_PATH )` is `target host system` specific and under some conditions will return PATHs with `/`. In addition on some of our machines CMAKE_UNIX_HOST is set while `ln` is not available. So I suggest checking if `CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows"` is true and to use string manipulation to convert directory separators and drive letters (i.e. `/c/foo/bar` -> `c:\foo\bar` and `/cygdrive/c/foo/bar` -> `c:\foo\bar`). Howto reproduce: Assumptions: 1. arm-none-eabi-gcc and gnumake is available on the PATH. Steps: 1. Start menu -> run -> cmd.exe 2. `cd <mbed-crypto path>` 3. `mkdir build; cd build` 4. ` cmake -DCMAKE_C_COMPILER=arm-none-eabi-gcc -DCMAKE_C_COMPILER_WORKS=True -G"Unix Makefiles" ..` Result: ``` C:\work\mbed-crypto\build>cmake -DCMAKE_C_COMPILER=arm-none-eabi-gcc -DCMAKE_C_COMPILER_WORKS=True -G"Unix Makefiles" .. -- The C compiler identification is GNU 6.3.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - failed -- Detecting C compile features -- Detecting C compile features - failed -- Found PythonInterp: C:/Program Files/Python36/python.exe (found version "3.6.1") -- Could NOT find Perl (missing: PERL_EXECUTABLE) CMake Error at CMakeLists.txt:106 (message): Could not create symbolic link for: C:/work/mbed-crypto/include/mbedtls --> Invalid switch - "work". Call Stack (most recent call first): include/CMakeLists.txt:20 (link_to_source) -- Configuring incomplete, errors occurred! See also "C:/work/mbed-crypto/build/CMakeFiles/CMakeOutput.log". See also "C:/work/mbed-crypto/build/CMakeFiles/CMakeError.log". C:\work\mbed-crypto\build> ``` <!-- Required Add detailed description of what you are reporting. Good example: https://os.mbed.com/docs/latest/reference/workflow.html Things to consider sharing: - What target does this relate to? - What toolchain (name + version) are you using? - What tools (name + version - is it mbed-cli, online compiler or IDE) are you using? - What is the SHA of Mbed OS (git log -n1 --oneline)? - Steps to reproduce. (Did you publish code or a test case that exhibits the problem?) --> ### Issue request type <!-- Required Please add only one X to one of the following types. Do not fill multiple types (split the issue otherwise.) Please note this is not a GitHub task list, indenting the boxes or changing the format to add a '.' or '*' in front of them would change the meaning incorrectly. The only changes to be made are to add a description text under the description heading and to add a 'x' to the correct box. --> [ ] Question [ ] Enhancement [x] Bug
ciarmcom commented 2019-05-06 15:49:42 -05:00 (Migrated from github.com)

Internal Jira reference: https://jira.arm.com/browse/IOTCRYPT-760

*Internal Jira reference: https://jira.arm.com/browse/IOTCRYPT-760*
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-ARMmbed/mbed-crypto#103
No description provided.