CppUnit project page CppUnit home page

autolink.h

Go to the documentation of this file.
00001 // No gards, this header can be included multiple time
00002 
00003 // Generic header to automatically link against a specified library
00004 // The library name prefix must be defined in CPPTL_AUTOLINK_NAME.
00005 // CPPTL_AUTOLINK_NAME will be undefined after including this header.
00006 
00007 // The full library name is build according to the following rules:
00008 // (0) CPPTL_AUTOLINK_NAME: library name prefix (json,...)
00009 // (a) TOOLSET: vc6, vc70, vc71, vc80, bcb4, bcb5, bcb6
00010 // (b) LINKAGE: lib(static), dll(dynamic)
00011 //              The macro CPPTL_AUTOLINK_DLL must be defined to indicate that we are linking
00012 //              against a DLL.
00013 // (c) This suffix depends on threading mode and CRT linkage
00014 //     This suffix follow Microsoft Visual Studio c++ compiler command-line option
00015 //     used to select the CRT library (/mt, /mtd...)
00016 //     Threading    / Run-time library / suffix
00017 //     single       / static           / ml
00018 //     mutli-thread / static           / mt
00019 //     multi-thread / dynamic library  / md
00020 // (e) DEBUG MODE: nothing (release), d(debug)
00021 // FULLNAME: 0_(a)_bcd.lib
00022 // Example:
00023 // Compiling library "cpptl" with vc 7.1 as a static library with debug dll CRT (/MDD)
00024 // "cpptl_vc71_libmdd"
00025 #if !defined(CPPTL_AUTOLINK_NAME)
00026 # error Macro CPPTL_AUTOLINK_NAME should be defined. You should not include this header directly.
00027 #endif
00028 
00029 #undef CPPTL_AUTOLINK_TOOLSET_
00030 #undef CPPTL_AUTOLINK_CRT_
00031 #undef CPPTL_AUTOLINK_LINKAGE_
00032 #undef CPPTL_AUTOLINK_DEBUG_MODE_
00033 
00034 // Select compiler
00035 // Visual Studio
00036 #if defined(_MSC_VER)
00037 # if defined(_WIN32_WCE)
00038 #  define CPPTL_AUTOLINK_TOOLSET_ "evc4"
00039 # elif (_MSC_VER < 1300) //VC6
00040 #  define CPPTL_AUTOLINK_TOOLSET_ "vc6"
00041 # elif (_MSC_VER < 1310) //VC7.0 (.NET 2002)
00042 #  define CPPTL_AUTOLINK_TOOLSET_ "vc70"
00043 # elif (_MSC_VER < 1400) //VC7.1 (.NET 2003)
00044 #  define CPPTL_AUTOLINK_TOOLSET_ "vc71"
00045 # else
00046 #  define CPPTL_AUTOLINK_TOOLSET_ "vc80"
00047 # endif
00048 // Borland C++
00049 #elif defined(__BORLANDC__)
00050 # if (__BORLANDC__ >= 0x560) // CBuilder 6
00051 #  define CPPTL_AUTOLINK_TOOLSET_ "bcb6"
00052 # elif (__BORLANDC__ >= 0x550)
00053 #  define CPPTL_AUTOLINK_TOOLSET_ "bcb5"
00054 # elif (__BORLANDC__ >= 0x540)
00055 #  define CPPTL_AUTOLINK_TOOLSET_ "bcb4"
00056 # endif
00057 #endif
00058 
00059 // Select CRT library: threading & linkage
00060 #if defined(_MT) || defined(__MT__)
00061 # if defined(_DLL)
00062 #  define CPPTL_AUTOLINK_CRT_ "md"
00063 # else
00064 #  define CPPTL_AUTOLINK_CRT_ "mt"
00065 # endif
00066 #else
00067 # define CPPTL_AUTOLINK_CRT_ "ml"
00068 #endif
00069 
00070 // Select debug mode
00071 #if defined(_DEBUG)
00072 # define CPPTL_AUTOLINK_DEBUG_MODE_ "d"
00073 #else
00074 # define CPPTL_AUTOLINK_DEBUG_MODE_ ""
00075 #endif
00076 
00077 // Select linkage
00078 #if defined(CPPTL_AUTOLINK_DLL)
00079 # define CPPTL_AUTOLINK_LINKAGE_ "dll"
00080 #else
00081 # define CPPTL_AUTOLINK_LINKAGE_ "lib"
00082 #endif
00083 
00084 // Automatic link
00085 #if defined(CPPTL_AUTOLINK_TOOLSET_)    && \
00086     defined(CPPTL_AUTOLINK_CRT_)  && \
00087     defined(CPPTL_AUTOLINK_LINKAGE_)    && \
00088     defined(CPPTL_AUTOLINK_DEBUG_MODE_)
00089 # define CPPTL_AUTOLINK_FULL_NAME                                              \
00090     CPPTL_AUTOLINK_NAME "_" CPPTL_AUTOLINK_TOOLSET_ "_" CPPTL_AUTOLINK_LINKAGE_  \
00091     CPPTL_AUTOLINK_CRT_ CPPTL_AUTOLINK_DEBUG_MODE_ ".lib"
00092 # pragma comment(lib,CPPTL_AUTOLINK_FULL_NAME)
00093 
00094 # if defined(CPPTL_AUTOLINK_VERBOSE)  &&  defined(_MSC_VER)
00095 #  pragma message( "Linking with" CPPTL_AUTOLINK_FULL_NAME )
00096 # endif
00097 
00098 #endif
00099 
00100 #undef CPPTL_AUTOLINK_TOOLSET_
00101 #undef CPPTL_AUTOLINK_CRT_
00102 #undef CPPTL_AUTOLINK_LINKAGE_
00103 #undef CPPTL_AUTOLINK_DEBUG_MODE_
00104 #undef CPPTL_AUTOLINK_FULL_NAME
00105 

SourceForge Logo hosts this site. Send comments to:
CppUnit Developers