[CMake] ignoring a specific library

Philip Lowman philip at yhbt.com
Fri Nov 2 10:11:37 EDT 2007


Mark Wyszomierski wrote:
> Is it possible to add an ignore library to CMakeLists.txt? This is
> specifically for a win32 project. I want to ignore:
> 
>     nafxcwd.lib
>     libcmtd.lib

Here's how I do this with CMake 2.4.6.  Unfortunately passing more than
one /NODEFAULTLIB arguments was broken in CMake 2.4.7 (see Bug #5455).

In short, use the SET_TARGET_PROPERTIES() with the LINK_FLAGS or
LINK_FLAGS_DEBUG, LINK_FLAGS_RELEASE, etc. options.


SET(VS_MULTITHREADED_DEBUG_DLL_IGNORE_LIBRARY_FLAGS
    "/NODEFAULTLIB:libc.lib
     /NODEFAULTLIB:libcmt.lib
     /NODEFAULTLIB:msvcrt.lib
     /NODEFAULTLIB:libcd.lib
     /NODEFAULTLIB:libcmtd.lib"
)
SET(VS_MULTITHREADED_RELEASE_DLL_IGNORE_LIBRARY_FLAGS
    "/NODEFAULTLIB:libc.lib
     /NODEFAULTLIB:libcmt.lib
     /NODEFAULTLIB:libcd.lib
     /NODEFAULTLIB:libcmtd.lib
     /NODEFAULTLIB:msvcrtd.lib"
)

IF(MSVC)
     SET_TARGET_PROPERTIES(simulator-static PROPERTIES
        LINK_FLAGS_DEBUG
        ${VS_MULTITHREADED_DEBUG_DLL_IGNORE_LIBRARY_FLAGS})

     SET_TARGET_PROPERTIES(simulator-static PROPERTIES
         LINK_FLAGS_RELWITHDEBINFO
         ${VS_MULTITHREADED_RELEASE_DLL_IGNORE_LIBRARY_FLAGS})
     SET_TARGET_PROPERTIES(simulator-static PROPERTIES
         LINK_FLAGS_RELEASE
         ${VS_MULTITHREADED_RELEASE_DLL_IGNORE_LIBRARY_FLAGS})
     SET_TARGET_PROPERTIES(simulator-static PROPERTIES
         LINK_FLAGS_MINSIZEREL
         ${VS_MULTITHREADED_RELEASE_DLL_IGNORE_LIBRARY_FLAGS})
ENDIF(MSVC)


-- 
Philip Lowman
Sr. Simulation Development Engineer, Modeling and Simulation Technology
General Dynamics Land Systems
http://www.gdls.com


More information about the CMake mailing list