How to add CMake includes and libraries to Visual Studio Solution ?

hellhound_01 104 Jan 15, 2012 at 14:39


I use CMake to generate a Visual Studio 2010 project and solution file. Actually I could set different settings,
like warning level, incremental building flag ect. from CMake. But I can’t set additional includes and libraries,
listed in the VC++ Directory configuration tab. Actually I’ve to set up those directories manually. This is stupid
and boring…

I tried to set the following CMake variables: CMAKE_INCLUDE_PATH, INCLUDE_DIRECTORY
but nothing happend. If i open the project, the additional include directory is always empty (only standard
MSVE settings are given).

I also tired to set this variables after executable creation, but this has also no effect.

Knows anyone how I could perform those settings at the solution using CMake?
Thanks for any help.

Best regards,

2 Replies

Please log in or register to post a reply.

Cybernator 101 Jan 16, 2012 at 16:39

You can add additional include directories using the include_directories command (as opposed to variable). As for library directories, I believe the right way to go is using find_library.The only trouble is that you may need to write additional search modules if the library you need to use is not supported. Another option is to add additional cached variables where you can set the paths to your libraries. Or, if you keep the libraries packaged with the source code, perhaps you could link the libraries using paths relative to CMAKE_SOURCE_DIR.

Hope this helps.

hellhound_01 104 Jan 16, 2012 at 20:50

You are right INCLUDE_DIRECTORIES and LINK_DIRECTORIES are the correct commands.
I’ve checked the wrong configuration tab of my project solution:

project properties–> Configurations –> VC++ Directories to check my includes

But it must be :

project properties –> Configurations –> C++ –> General …