How can I set with CMake in VisualStudio2010 the property "Additional Library Directories".
Example:
%(AdditionalLibraryDiretories) = "d:/librarys/wnt/i386/debug/"
configuration parameter -> linker -> general-> "Additional Library Directories"
I tried this and it doesn't work.
link_directories("d:/librarys/wnt/i386/debug/")
Turning my comments into an answer
What does link_directories()
cover?
I tested it with VS2012 / CMake 3.3.0 and if you put your link_directories(...)
before your add_executable(...)
call it seems to work fine.
link_directories("d:/librarys/wnt/i386")
get_directory_property(_my_link_dirs LINK_DIRECTORIES)
message(STATUS "_my_link_dirs = ${_my_link_dirs}")
add_executable(...)
Everything you add with link_directories()
will be appended to the directory property LINK_DIRECTORIES
and assigned to whatever targets are listed afterwards.
In the upper example I get in Visual Studio "Additional Library Directories" property:
d:/librarys/wnt/i386;d:/librarys/wnt/i386/$(Configuration);%(AdditionalLibraryDirectories)
CMake does - to cover libraries depending on Config - include two variants of what you have given in link_directories(): d:/librarys/wnt/i386
and d:/librarys/wnt/i386/$(Configuration)
.
What if you need more flexiblity?
If your debug
/release
path names are not matching the VS configuration name (e.g. fooba
for debug
), then you can't use link_directories()
. One approach would be to extend the linker flags directly:
project(...)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /LIBPATH:\"d:/librarys/wnt/i386/fooba\"")
Then I get in the Debug
config properties:
%(AdditionalLibraryDirectories);d:/librarys/wnt/i386/fooba
For the lack of flexibility of link_directories()
I normally only use the target_link_libraries()
command. E.g.:
target_link_libraries(MyExe debug "d:/librarys/wnt/i386/fooba/foo.lib")
would give in the Debug "Additional Dependencies" property:
kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib;d:\librarys\wnt\i386\fooba\foo.lib
References
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With