[CMake] target_link_libraries can't link shared libraries not listed in LD_LIBRARY_PATH

Rolf Eike Beer eike at sf-mail.de
Mon Apr 23 10:27:04 EDT 2012


> Hi!
>
> I just find the solution. The problem was in order how libraries were
> specified.
> target_link_libraries(${lib_name}
> general rt
> general dl
> general pthread
> debug ${do_scoring_debug}
> optimized ${do_scoring}
> general ${spinx}
> general ${cblas}
> general ${atlas}
> )

You don't need the general keyword, specifying just a library will make it
be used with any build type.

Also you may want to replace "general dl" with ${CMAKE_DL_LIBS} and
"general pthread" with ${CMAKE_THREAD_LIBS_INIT} for portability. Note
that you need find_package(Threads) for the latter to work.

Eike


More information about the CMake mailing list