[CMake] Relative path to CMAKE_SOURCE_DIR

Howard Rubin howard.rubin at hl.konicaminolta.us
Fri Oct 9 17:09:03 EDT 2015


Is it possible to get the relative path from PROJECT_BINARY_DIR (or
CMAKE_BINARY_DIR) to CMAKE_SOURCE_DIR?

 

I'm using CMAKE_SOURCE_DIR to add files to *.csproj file (copied with
configure_file) using CMake on Windows. This results in lots of warnings
like the below that I'd like to get rid of. If I change the absolute path
that's inserted by CMake's substitution of CMAKE_SOURCE_DIR to a relative
path with dots (e.g. ..\..\somewhere) the warning goes away.

 

Warning               43           The file
'D:/directory1/directory2/directory3\directory4\Open-XML-SDK\DocumentFormat.
OpenXml\src\Framework\AlternateContent.cs' could not be added to the
project.  The specified path contains invalid characters, is an absolute
path, or is a path outside of the project directory. DocumentFormat.OpenXml

 

References:

https://cmake.org/cmake/help/v2.8.10/cmake.html#command:configure_file

https://cmake.org/Wiki/CMake_Useful_Variables

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151009/286fe067/attachment.html>


More information about the CMake mailing list