On Mon, Nov 24, 2008 at 4:02 PM, Michael Jackson <span dir="ltr">&lt;<a href="mailto:mike.jackson@bluequartz.net">mike.jackson@bluequartz.net</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c"><br>
On Nov 24, 2008, at 4:29 PM, Robert Dailey wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Mon, Nov 24, 2008 at 2:41 PM, Michael Jackson &lt;<a href="mailto:mike.jackson@bluequartz.net" target="_blank">mike.jackson@bluequartz.net</a>&gt; wrote:<br>
typically you do:<br>
<br>
add_executable(main &nbsp;main.cpp)<br>
target_link_libraries(main a)<br>
<br>
and CMake _usually_ picks the correct library for the given platform (a.lib, a.so, a.dylib... )<br>
<br>
Is that what you were asking?<br>
<br>
Yes, you did answer my question exactly, however I did not specify the more complex issue.<br>
<br>
Some libraries we&#39;re using have different library names depending on the platform. For example:<br>
<br>
a_windows.lib<br>
a_linux.o<br>
<br>
This is why I believed I would need the conditional logic. What would you do in this case? Thanks for your help.<br>
<br>
</blockquote>
<br>
<br></div></div>
I guess it would depend on if those other libraries were being compiled in the same project as the current one.<br>
<br>
Basically when you use target_link_libraries (EXE &nbsp;[lib1] [lib2]... )<br>
<br>
you need to supply everything between the platform prefix and the platform suffix.<br>
<br>
So, if your library on Windows is a_windows.lib you would supply &quot;a_windows&quot;. If your library is liba_linux.so then supply &quot;a_linux&quot; on linux.<br>
<br>
So, in practice you have:<br>
<br>
set(lib_a_name &quot;a&quot;)<br>
if (WINDOWS)<br>
 &nbsp;set(lib_a_name &quot;a_windows&quot;)<br>
elseif(APPLE)<br>
 &nbsp;set(lib_a_name &quot;a_osx&quot;)<br>
elseif(LINUX)<br>
 &nbsp;set(lib_a_name &quot;a_linux&quot;)<br>
endif()<br>
<br>
<br>
target_link_Libraries(exe ${lib_a_name})</blockquote></div><br>Thanks everyone for the help. Michael, in your example code, is &quot;if(WINDOWS)&quot; pseudocode? Is WINDOWS a valid usage here? If not, what would the actual conditional look like to check for windows/mac/linux? Thanks.<br>