On Mon, Nov 24, 2008 at 4:02 PM, Michael Jackson < [EMAIL PROTECTED]> wrote:
> > On Nov 24, 2008, at 4:29 PM, Robert Dailey wrote: > > On Mon, Nov 24, 2008 at 2:41 PM, Michael Jackson < >> [EMAIL PROTECTED]> wrote: >> typically you do: >> >> add_executable(main main.cpp) >> target_link_libraries(main a) >> >> and CMake _usually_ picks the correct library for the given platform >> (a.lib, a.so, a.dylib... ) >> >> Is that what you were asking? >> >> Yes, you did answer my question exactly, however I did not specify the >> more complex issue. >> >> Some libraries we're using have different library names depending on the >> platform. For example: >> >> a_windows.lib >> a_linux.o >> >> This is why I believed I would need the conditional logic. What would you >> do in this case? Thanks for your help. >> >> > > I guess it would depend on if those other libraries were being compiled in > the same project as the current one. > > Basically when you use target_link_libraries (EXE [lib1] [lib2]... ) > > you need to supply everything between the platform prefix and the platform > suffix. > > 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. > > So, in practice you have: > > set(lib_a_name "a") > if (WINDOWS) > set(lib_a_name "a_windows") > elseif(APPLE) > set(lib_a_name "a_osx") > elseif(LINUX) > set(lib_a_name "a_linux") > endif() > > > target_link_Libraries(exe ${lib_a_name}) 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.
_______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake