[CMake] Add library at compiling time

Michael Wild themiwi at gmail.com
Tue Apr 12 11:33:20 EDT 2011


On 04/12/2011 05:20 PM, pellegrini wrote:
> Michael Wild a écrit :
>> On 04/12/2011 04:52 PM, pellegrini wrote:
>>  
>>> Hello everybody,
>>>
>>> I am using CMake 2.8 on a Fortran 90 project using ifort compiler.
>>>
>>> I would like to specify the path for Winteracter graphical library not
>>> only when linking but also when compiling.
>>> By the way the library is not in a standard location.
>>>
>>> I tried to use target_link_libraries function but obviously as indicated
>>> by its name, it may do the job when linking but certainly not when
>>> compiling.
>>>
>>> Any idea ?
>>>
>>> thans in advance
>>>
>>> Eric
>>>
>>>
>>>     
>>
>> Sorry, but that doesn't make any sense at all. Why would you want to do
>> that? Libraries only come into play during linking.
>>
>>   
> Sorry I was not clear enough. In fact I need the path for the 'lib'
> directory of my library because it is the place where the
> 'mod' files, compulsory for compiling,  are stored.
> 
> Eric

Ahh, much better ;-) just add the directory in question to the include
path with include_directories(). At least gfortran and the Intel Fortran
compiler will use the resulting -I flag correctly. gfortran has also the
specialized -J flag. You can set the variable CMAKE_INCLUDE_FLAG_Fortran
after enabling the Fortran language to specify a different flag.

Michael


More information about the CMake mailing list