AW: [CMake] CMake 2.4.7: Generator "Visual Studio 7 .NET 2003"
seems to ignore certain LINK_FLAGS properties (worked in 2.4.6)
Bill Hoffman
bill.hoffman at kitware.com
Tue Jul 31 10:33:19 EDT 2007
Gerhard Grimm wrote:
> Hi Bill,
>
> here's a minimal example, consisting of three files.
>
> source.c:
> ---------------------------------------------
> #include <stdio.h>
>
> void MyExport1(void)
> {
> puts("MyExport1");
> }
>
> void MyExport2(void)
> {
> puts("MyExport2");
> }
> ---------------------------------------------
>
> source.def:
> ---------------------------------------------
> EXPORTS
> MyExport1
> MyExport2
> ---------------------------------------------
>
> CMakeLists.txt:
> ---------------------------------------------
> project(MyProject)
>
> add_library(MyLib SHARED source.c)
>
> set_target_properties(MyLib PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_SOURCE_DIR}/source.def")
> ---------------------------------------------
>
> When using the 2.4.7 Visual Studio .NET generator, the build will succeed, but the resulting "MyLib.dll" will not export any symbols, since the "/DEF:..." flag is missing in the project (reverting to 2.4.6 would fix this).
> Using the NMake makefiles generator, the "/DEF:..." flag will be passed to the linker, and voilà - we have exports.
>
OK, so I can reproduce the problem, and I will fix it. However, the
reason you are alone here is that you are not really using cmake correctly.
You can just add the .def as one of your sources and cmake knows what to
do with it. As you stated before the /NOENTRY works.
So, the following should be what you want. (The SHARED option will make
sure that /DLL is used as a flag)
add_library(MyLib SHARED source.c source.def)
set_target_properties(MyLib PROPERTIES LINK_FLAGS "/NOENTRY")
-Bill
More information about the CMake
mailing list