On Mon, Nov 24, 2008 at 4:02 PM, Michael Jackson <span dir="ltr"><<a href="mailto:mike.jackson@bluequartz.net">mike.jackson@bluequartz.net</a>></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 <<a href="mailto:mike.jackson@bluequartz.net" target="_blank">mike.jackson@bluequartz.net</a>> wrote:<br>
typically you do:<br>
<br>
add_executable(main 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'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 [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 "a_windows". If your library is liba_linux.so then supply "a_linux" on linux.<br>
<br>
So, in practice you have:<br>
<br>
set(lib_a_name "a")<br>
if (WINDOWS)<br>
set(lib_a_name "a_windows")<br>
elseif(APPLE)<br>
set(lib_a_name "a_osx")<br>
elseif(LINUX)<br>
set(lib_a_name "a_linux")<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 "if(WINDOWS)" pseudocode? Is WINDOWS a valid usage here? If not, what would the actual conditional look like to check for windows/mac/linux? Thanks.<br>