0

I am building cross platform project. It was started on Linux enviroment, and built using cmake. There is way to use cmake on windows too, but I think Visual Studio is would handle it easier.

So now I have created empty solution on separate folder(not to mix source files with VS). But problem is that I need to add every folder into visual studio by using absolute path. Which is bad when this solution will be used from another windows machine.

Main question: is there way to specify relative path to include directory? Something like $(solution_source_folder)..\source\some_component_folder Where solution_folder_path is path where solution really is and solution folder is on same level as source folder.

legends2k
  • 31,634
  • 25
  • 118
  • 222
insanebits
  • 818
  • 1
  • 6
  • 24

2 Answers2

2

I am not sure why you feel the necessity to keep your solution away from your code. They won't get in the way of one another and it will make adding files to your VS projects a lot easier.

Back to your question, you can use property sheets to specify include directories across projects. Simply set a variable where your headers are and add that to the include path (in the property sheet). Then add that property sheet to your project in visual studio.

The variable $(SolutionDir) points to the directory your solution is in. You can use this as your starting point to get the relative paths for your files.

Boumbles
  • 2,473
  • 3
  • 24
  • 42
0

I don't know how you managed to get the absolute paths, if you just add files or projects they are relative. Also you can edit the file and write there whatever you see fit.

In project settings you have a ton of macros, including all kinds of paths that you can use as prefix.

Also projects include a user-specific .props file from the local user account, you can define installation/machine-specific properties there, if the stock macros are not enough.

Look here and here for more details. For your code question $(SolutionPath) is the prefix.

Community
  • 1
  • 1
Balog Pal
  • 16,195
  • 2
  • 23
  • 37