Submitted a fix here: https://gitlab.kitware.com/cmake/cmake/merge_requests/2177
David: I think the source dir is stripped because that path is effectively the same as source_group() command. It's a path relative to the root of the solution explorer panel. That's a big assumption, I honestly don't know what the inner workings of the CSPROJ file are. Yes, they are sibling directories On Fri, Jun 29, 2018 at 3:37 PM, David Cole <dlrd...@aol.com> wrote: > The code looks wrong like this, too: > > You shouldn't strip the source directory from the path of the file > name unless the character after the source directory is "/" or "\\", > should you? If the thing you're trying to end up with is a path name > to the file under the source directory, then this is incorrect in this > case. > > I'm guessing you have "layout-composer" and "layout-composer-build" as > sibling directories of each other? > > > > On Fri, Jun 29, 2018 at 4:12 PM Robert Dailey <rcdailey.li...@gmail.com> > wrote: >> >> According to the code, the logic is wrong: >> >> void cmVisualStudio10TargetGenerator::GetCSharpSourceLink( >> cmSourceFile const* sf, std::string& link) >> { >> std::string f = sf->GetFullPath(); >> if (!this->InSourceBuild) { >> const std::string stripFromPath = >> this->Makefile->GetCurrentSourceDirectory(); >> if (f.find(stripFromPath) != std::string::npos) { >> link = f.substr(stripFromPath.length() + 1); >> if (const char* l = sf->GetProperty("VS_CSHARP_Link")) { >> link = l; >> } >> ConvertToWindowsSlash(link); >> } >> } >> } >> >> >> It's checking if the whole binary dir is rooted where source dir is, >> instead it should be checking each file to see if they are descendents >> of CMAKE_BINARY_DIR, and if so, use the <Link>, otherwise don't use >> it. This allows <Link> to be variable between files in the project. >> >> Does anyone know if there's already a function in CMake for checking >> if a file is in the CMAKE_BINARY_DIR? Or do I have to write my own >> code for that check? >> >> On Fri, Jun 29, 2018 at 3:08 PM, Robert Dailey <rcdailey.li...@gmail.com> >> wrote: >> > When I use configure_file() to generate AssemblyInfo.cs, which I allow >> > to go to the CMAKE_CURRENT_BINARY_DIR, Visual Studio 2017 reports: >> > >> > Warning The file >> > 'E:\code\layout-composer-build\Properties\AssemblyInfo.cs' could not >> > be added to the project. Cannot add a link to the file >> > E:\code\layout-composer-build\Properties\AssemblyInfo.cs. This file is >> > within the project directory tree. >> > >> > When I define a target using C# language, it adds this for files under >> > the same directory as the generated CSPROJ file: >> > >> > <Compile >> > Include="E:\code\layout-composer-build\Properties\AssemblyInfo.cs"> >> > <Link>build\Properties\AssemblyInfo.cs</Link> >> > </Compile> >> > >> > The CSPROJ file is located: >> > E:\code\layout-composer-build\LayoutComposer.csproj >> > >> > Is there a way to make the <Link> element not needed in this scenario? >> -- >> >> 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-developers -- 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-developers