[CMake] problems with Visual Studio Express 2013 compile

Michael Surette mjsurette at gmail.com
Mon Mar 24 20:42:24 EDT 2014


I have the following macro.

macro(FL_ADD_LIBRARY LIBNAME LIBTYPE LIBFILES)

     if(${LIBTYPE} STREQUAL "SHARED")
         set(LIBRARY_NAME "${LIBNAME}_SHARED")
     else()
         set(LIBRARY_NAME "${LIBNAME}")
     endif(${LIBTYPE} STREQUAL "SHARED")

     add_library(${LIBRARY_NAME} ${LIBTYPE} ${LIBFILES})

     if(_MSC_VER AND ${LIBTYPE} STREQUAL "SHARED")
         set_target_properties(${LIBRARY_NAME}
             PROPERTIES
             OUTPUT_NAME "${LIBNAME}dll"
             DEBUG_OUTPUT_NAME "${LIBNAME}dll${DEBUG_LIB_SUFFIX}"
             COMPILE_DEFINITIONS "FL_DLL"
             )
     else()
         set_target_properties(${LIBRARY_NAME}
             PROPERTIES
             OUTPUT_NAME "${LIBNAME}"
             DEBUG_OUTPUT_NAME "${LIBNAME}${DEBUG_LIB_SUFFIX}"
             )
     endif(_MSC_VER AND ${LIBTYPE} STREQUAL "SHARED")

     set_target_properties(${LIBRARY_NAME}
         PROPERTIES
         CLEAN_DIRECT_OUTPUT TRUE
         COMPILE_DEFINITIONS "FL_LIBRARY"
         )

     if(${LIBTYPE} STREQUAL "SHARED")
         set_target_properties(${LIBRARY_NAME}
             PROPERTIES
             VERSION ${FLTK_VERSION_FULL}
             SOVERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
             )
     endif(${LIBTYPE} STREQUAL "SHARED")

     if(_MSC_VER)
         if(OPTION_LARGE_FILE)
             set_target_properties(${LIBRARY_NAME}
                 PROPERTIES
                 LINK_FLAGS /LARGEADDRESSAWARE
                 )
         endif(OPTION_LARGE_FILE)
     endif(_MSC_VER)

     list(APPEND LIBRARIES "${LIBRARY_NAME}")

endmacro(FL_ADD_LIBRARY LIBNAME LIBTYPE LIBFILES)

I pass it the library name followed by either STATIC or SHARED and a 
list of files to build the expected library.  For each library I build I 
first pass STATIC then call it again with SHARED.

Under Linux this generates for library a
liba.a liba.so.1.3.2 with the links liba.so.1.3.2 and liba.so.1.3.
All is good

With TDM-GCC under Windows I get liba.a liba.dll and liba.dll.a
Again all is good.

With VS Express 2013 I get a.dll a.ilk a.lib and a.pdb

What I want is a.lib (static library) adll.lib (dynamic loader) and 
adll.dll (dynamic library)

How do I go from what I have to what I want?

Any pointers, insights or suggestions welcome.

Mike





More information about the CMake mailing list