[CMake] Eclipse project and MKL libraries

Eric Noulard eric.noulard at gmail.com
Sat Apr 28 07:29:42 EDT 2012


2012/4/28 Giovanni Azua <bravegag at gmail.com>:
>
> On Apr 28, 2012, at 8:56 AM, Eric Noulard wrote:
>
> I mean that I can build all the targets in command line without problem and
>
> execute them without any problems.
>
>
> Command line that you crafted by hand or command line generated
> by CMake using say Makefile generator?
>
>
> OK I hope this is more clear otherwise I can try writing in french :)

Posso provare in Italiano anch'io :-]

> I have a cmake project,
> with a bunch of library and exec cmake targets,
> no manual make files and no by hand anything,
> they all build correctly from cmake generated make,
> and they execute correctly without any manual tweaking,
> why this works correctly from command line and the Eclipse project doesn't?
>
> e.g.
>
> $ rm -rf build && mkdir build && cd build && cmake -G "Unix Makefiles"
> -DCMAKE_BUILD_TYPE=Debug ../code/
> $ make
> 100% all good
>
> now if I do:
>
> $ cmake -G "Eclipse CDT4 - Unix Makefiles" ../code/
>
> the generated eclipse project does not compile and does not execute/debug
> correctly.

Now its clear, thanks.
Which version of CMake are you using?

The discrepancy between Eclipse and Makefile may be explained
by difference in the environment.

In your shell do you define some value for LD_LIBRARY_PATH?
Try: echo $(LD_LIBRARY_PATH)

Do you launch eclipse from the command line or by clicking
on some menu/icon?

Try launching eclipse from the very same command line you launch "make".

>> Using link_directories is as stated in the documentation
>> "rarely necessary"
>> see cmake --help-command link_directories
>
> why is it supported then?

For backward compatibility reason mainly and some rare case
I don't even have one in mind.

> You should bettte use absolute path to libraries in your
> target_link_libraries(benchmark ....)
>
> really???  this sounds like breaking the build from one environment to the
> next.

Nope because you do something like:

find_package(MKL REQUIRED)
include_directories(${MKL_INCLUDE_DIRS})
add_executable(bench bench.c)
target_link_libraries(bench ${MKL_LIBRARIES})

which is perfectlty portable, as soon as
find_package(MKL REQUIRED)

does its job and define
MKL_xxx variables properly.

>> I cannot ensure this is OK because the FindMKL.cmake module
>> does not seem to be in CMake source.
>
> it is just another cmake script to find the MKL library ... there are
> several versions of this in the net.

precisely.
Check in the copy you have if MKL_LIBRARIES is defined or not,
if it is then use it, if it is not then I  suggest you defined it yourself then
use it.

-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org


More information about the CMake mailing list