[CMake] How can I link to my MinSizeRel project in msvc

Meng Zhang tomengzhang at gmail.com
Mon Nov 9 22:55:34 EST 2009


Dear CMakers,
  I am a beginner of CMake. My problem is that in MSVC, I have two projects:
one is executable project A, and the other is library project B. A depends
on B and A has to link B. I want A to link the corresponding B separately
under different configurations. For example, if I build Release version,
then A should link Release version of B, while if I build MinSizeRel
version, A should  link B in MinSizeRel/.

  For this purpose, I tried 2 ways but both failed. The first one is to set
dependency in CMake, however, CMake automatically set the property "Link
Library Dependencies" in the generated MSVC project to "No", which means it
won't link B automatically. Hence it seems I have to explicitly specify B as
a input library to A. So then I did this:

target_link_libraries(A debug Debug/B)
target_link_libraries(A optimized Release/B)

 Nevertheless, obviously, since optimized means all the other three
configurations except "Debug",  project A won't find library B if I directly
build "MinSizeRel" version because the compiler can not find library B in
directory Release/.

 So I am wondering, what is the standard way to do this? It will be great if
there is portable and unified way which is also working on Linux and Mac.

  Thanks in advance!

Best,
Meng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091109/56fef977/attachment-0001.htm>


More information about the CMake mailing list