Jim Dishaw wrote:
Arjen Markus writes:

  
Jim Dishaw wrote:

    
Third, CMake does not provide an option for omitting the default
library information when building with MSVC.  This is an issue if you
want to build a runtime independent library.  A runtime independent
library is handy because you do not have to build a debug version, a
non-debug version, a static version, a multithreaded version, etc.  The
other option is to have the person using Plplot specify
/nodefaultlib:<library> as a linker option.  I find that option less
desireable than building a runtime independent version of Plplot.

      
Hm, that does sound interesting. Is this a problem with MSVC only? How
does this change with the later versions of MSVC (7, 8, ...)? (I
usually try to avoid getting involved in these issues, but I do not
always succeed.)

    

>From what I can tell, almost all versions of MSVC put default library
information into the .obj file.  The only exceptions maybe some of the
really old ones.  The available default libraries are:

libcmt    Multithreaded, static link
msvcrt    Multithreaded, dynamic link (e.g. MSVCR80.DLL)
libcmtd   Multithreaded, static link, debug
msvcrtd   Multithreaded, dynamic link, debug
msvcmrt   C Runtime import library for CLR
msvcurt   C Runtime import library for pure MSIL code

Older version of MSVC had

libc      Singlethreaded, static link
libcd     Singlethreaded, static link, debug

The changes that I have so far (they may not be pretty because my grasp
of CMake is weak):

In UserOverride.cmake

message(STATUS "NOTICE: Checking for MSVC on WIN32")
if(WIN32)
  if(MSVC)
    message(STATUS "NOTICE: MSVC, setting /Zl for library builds")
    # Copied from the CMake defaults as of 2.6.0
    # W3 = Warning Level 3
    # Zm1000 = Max Memory Allocation (% of default)
    # Zl = Omit default library information
    SET (LIB_C_FLAGS "/DWIN32 /D_WINDOWS /W3 /Zm1000 /Zl")
    if(CMAKE_BUILD_TYPE MATCHES "Debug")
      # Zi = Enable debugging information
      # Ob0 = Disable inline expansion
      # Od = Disable optimization
      # RTC1 = Enable fast checks
      SET (LIB_C_FLAGS_DEBUG "/D_DEBUG /Zi /Ob0 /Od /RTC1")
    endif(CMAKE_BUILD_TYPE MATCHES "Debug")
  endif(MSVC)
  
  if(TARGET_FORTRAN MATCHES "IVF") 
    SET(TARGET_LIB_FC_FLAGS "${CMAKE_FC_FLAGS} /libdir:none")
  endif(TARGET_FORTRAN MATCHES "IVF")
endif(WIN32)

Next, in the CMakeLists.txt files that are in src, bindings, drivers,
and lib need to have the following added

if(WIN32 AND MSVC)
  SET(CMAKE_C_FLAGS "${LIB_C_FLAGS}")
  SET(CMAKE_C_FLAGS_DEBUG "${LIB_C_FLAGS_DEBUG}")
endif(WIN32 AND MSVC)

These changes basically create a different set of C flags (I left C++
alone because I was not sure if this is the best way to implement this,
however it could be added with CXX_FLAGS) for files that are destined to
go into the library.

Additional work is needed to get this working for DLL builds--I did not
put the effort in because there may be a better way.
  
This looks okay to me, but perhaps we should try and append, rather than replace,
the flags that suppress the default libraries. That way we can retain all other flags.

I am not sure about DLLs, but we will certainly have to look into that aspect.

Regards,

Arjen