Unfortunately I encountered exactly the same problem. It would be nice to describe in documentation that file(TO_NATIVE_PATH ...) means "native for target system" and also would be nice to introduce the file(TO_HOST_NATIVE_PATH ...) subcommand.
On 26.3.2018 19:40, Miroslav Keš wrote: > I'm cross-compiling in Windows to another target system (VxWorks) but this is > not so important. > > I thought the idea behind the TO_NATIVE_PATH option was that the internal > CMake path representation could be transformed to the system native path so > that external programs that rely on the native path convention could be > easily used during the build. > > Either this my assumption is wrong or the CMake implementation is wrong. And > the documentation should be more detailed on the exact behavior. > > Mira > > On 03/21/2018 09:29 PM, Stephen McDowell wrote: >> Disclaimer: I cannot speak to intent, and have never used these before. >> >> So since you’re cross compiling, when looking at the docs ( >> https://cmake.org/cmake/help/v3.0/command/file.html ), I *think* you can get >> away with using TO_CMAKE_PATH. I do *not* know how you actually determine >> this, but the idea would be >> >> if (CMAKE_CROSSCOMPILING) >> if (… host is windows …) >> if (… target is unix …) >> … use TO_CMAKE_PATH … >> else() >> … use TO_NATIVE_PATH … >> endif() >> else() # … host is unix … >> if (… target is unix …) >> … use TO_CMAKE_PATH or TO_NATIVE_PATH … >> else() # … target is windows >> … PROBLEM … >> endif() >> endif() >> >> That is, I think if you are compiling *on* Windows *for* Unix, you can cheat >> and use TO_CMAKE_PATH to get unix style paths. But if you are compiling >> *on* unix *for* Windows, I don’t know how you get it to be Windows paths. >> >> But if this does solve Windows -> Unix, you could maybe just >> message(FATAL_ERROR …) saying that cross compiling for Windows from Unix is >> not supported. You could also take a look at the implementation of >> TO_NATIVE_PATH and just snag the Windows code and make your own function >> that converts it, maybe calling it to_windows_path() or something? >> >> I hope that is helpful, but I really don’t know if anything in the above is >> possible :/ >> >> >> -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake