In my attempt to get Fortran built correctly using the Intel compiler I
noticed a problem with the compiler flag string.

I used the following cmake command

C:\cygwin\opt\cmake-2.4.5-win32-x86\bin\cmake ^
  -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug ^
  -DCMAKE_INSTALL_PREFIX=\opt\test ^
  -DCMAKE_INSTALL_LIBDIR=\opt\test\lib\i686-pc-win32-ivf ^
  -DBUILD_SHARED_LIBS=OFF -G "NMake Makefiles" ^
  -DBUILD_TEST=ON ^
  ..\plplot-cvs

In the CMakeCache.txt there are the following definitions

//Flags for C compiler.
CMAKE_C_FLAGS:STRING= /DWIN32 /D_WINDOWS /W3 /Zm1000

//Flags used by the compiler during debug builds.
CMAKE_C_FLAGS_DEBUG:STRING=/D_DEBUG /MDd /Zi /Ob0 /Od /GZ

//Flags used by the compiler during release minsize builds.
CMAKE_C_FLAGS_MINSIZEREL:STRING=/MD /O1 /Ob1 /D NDEBUG

//Flags used by the compiler during release builds (/MD /Ob1 /Oi
// /Ot /Oy /Gs will produce slightly less optimized but smaller
// files).
CMAKE_C_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /D NDEBUG

Notice the presence of the /MD and /MDd flags in the release and debug
variants.  This sets the default library to MSVCRT.DLL and MSVCRTD.DLL,
which will cause problems if someone was expecting a static library
version, which is what I thought I was getting with
BUILD_SHARED_LIBS=OFF.  

There are several options.  For static libraries the simplest option is
to use the /Zl flag, which omits the default library information from
the object file.  The end user would then be free to use any library in
their application.  Of course, we should test the behaviour to make sure
it works "as advertised by the compiler documentation" before releasing
the change.  For dyanmic libraries I have had problems using the /Zl
option.  From what I understand, all the parts that make up the DLL need
to have a library specified because the DLL needs to be internally
consistent.  For example, you can create a DLL that consists of static
linked parts (which makes one DLL that is complete) or you can create a
DLL that uses the runtime DLL's (e.g. MSVCRT.DLL).  I've used the static
linked version to create DLL's that work.

Another option would be to have a cmake parameter where the user
specifies which runtime library to use (maybe there is one already).


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to