[Cmake] Why debug info for release mode application?

Reinhold Füreder R . Fureder at exeter . ac . uk
Fri, 31 Oct 2003 09:29:46 +0100


Hi,

(Windows2000/XP, CMake 1.8.1, MSVC++ 6 SP 5, wxWindows 2.4.?, ...) When
using CMake to build an wxWindows-GUI application (statically) linking
with VTK, Crypto++ and of course wxWindows the final .dsp has the debug
info switched on, even for the release mode application. Thus, when
compiling we get a lot of the following warnings:

Cryptlib.lib (...obj): warning LNK4099: PDB .. Was not found ... Linking
object as if no debug info.

As we do not want the debug info in the release mode this switch should
not be on (it is the /debug option in LINK32 section in .dsp file). (And
there is no adequate .pdb file in the otherwise correct location pointed
out by the linking warning.)

The corresponding CMakeLists.txt contains:
---
ADD_EXECUTABLE (OurApp WIN32 ${SRC} ${HDR}) 
 
TARGET_LINK_LIBRARIES (OurApp
    debug ${CryptoPP_DEBUG_LIBRARIES} 
    optimized ${CryptoPP_LIBRARIES}   

    ...

    ${WXWINDOWS_LIBRARY}   
) 
---

The CMake flag WIN32 for the ADD_EXECUTABLE is necessary because it is
not a console application. If we omit this flag the debug info is
switched off (but of course, then the compiling fails...). If we remove
the debug info switch manually in MSVC++ project settings we can compile
and link the application without any problems.

Maybe it helps but in the concerned section in the .dsp file, the line
containing the unwanted /debug is a duplicate of a line without this
flag:
---
!IF  "$(CFG)" == "OurApp - Win32 Release" 

# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
/IGNORE:4089 
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
/IGNORE:4089
...
---

And all ..._LINKER_FLAGS_RELEASE are empty; in other words, do not
contain /debug as ..._LINKER_FLAGS_DEBUG or
..._LINKER_FLAGS_RELWITHDEBINFO, for example.


Thanks,
	Reinhold


------------------------
Reinhold Füreder
School of Engineering and Computer Science
University of Exeter, UK