[CMake] CMake and def files

Nils Gladitz nilsgladitz at gmail.com
Sun Jan 5 04:47:48 EST 2014


On 01/04/2014 11:26 PM, Totte Karlsson wrote:
>
> When I build the dll using CMAKE, however, even after adding the .def 
> file, the resulting dll don't have the aliased names.
>
> I have tried adding the def file to sources, but that seem no to work, 
> and setting the module linker flags, e.g.
>     set (CMAKE_MODULE_LINKER_FLAGS   "${CMAKE_MODULE_LINKER_FLAGS} 
> \"/DEF:${CMAKE_CURRENT_SOURCE_DIR}/myllib.def\"")
>
> is not doing it either.
>
> Anyone knowing how to do it properly?
>
Just listing a .def file in the sources for a target worked for me 
(using the Microsoft compiler).

Are you using one of the Makefile generators?

In those CMAKE_LINK_DEF_FILE_FLAG seems to be used to handle .def source 
files.
For the Microsoft compiler this is defined as such:
     set (CMAKE_LINK_DEF_FILE_FLAG "/DEF:")

For Borland I don't see any such definition (but I am not really 
familiar with the Borland setup either).

Your workaround with CMAKE_MODULE_LINKER_FLAGS I expect can only work if 
you used add_library(foo MODULE) rather than add_library(foo SHARED).
For the later you would have to set CMAKE_SHARED_LINKER_FLAGS.

Nils



More information about the CMake mailing list