<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="State"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="City"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="place"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=1 face=Consolas><span style='font-size:8.0pt;
font-family:Consolas'>Our software team is having problems upgrading to CMake
2.6.2 from our current working build system that uses CMake 2.4.7. In
particular, we are using the "Visual Studio 7 .NET 2003", "NMake
Makefiles", "Unix Makefiles", and "CodeBlocks - Unix Makefiles"
project/makefile generators.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>We are having a problem generating
"Visual Studio 7 .NET 2003" project files. The primary symptom (among
others) is that the compiler definitions are not being set properly for the
Debug and Release build configurations. We do not create RelWithDebugInfo and
MinSizeRel build configurations (not useful for us), by specifically calling
Set(CMAKE_CONFIGURATION_TYPES "Debug;Release"). Anyway, the strategy
we have used to set the compiler definitions for each build configuration is to
(1) construct a "debug" string that contains all the debug compiler
switches, (2) construct a "release" string that contains all the
release compiler switches, (3) set CMAKE_CXX_FLAGS_DEBUG and
CMAKE_CXX_FLAGS_RELEASE to use these switches, then call (4) Add_Library() or
Add_Executable() to use those switches for the build configurations. We have a
main executable project that depends on several static library projects, each
of which are brought into the solution using the Add_Subdirectory() cmake
command before calling Add_Executable(). <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Our actual CMakeLists.txt are
pretty complex, and we have a ton of wrapper macros, so I'll just provide some
pseudocode of the relevant portions instead (I'll call the executable project
"Exec" and the static library project "Util"):<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>------------------------------------------------------------------------<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Util/CMakeLists.txt<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>------------------------------------------------------------------------<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Project("Util")<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>...<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Set(sources Util.cpp)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Set(compilerFlagsDebug "/D
_DEBUG /D WIN32 /DENABLE_UTIL_FLAG1 /DENABLE_UTIL_FLAG2") <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Set(compilerFlagsRelease "/D
NDEBUG /D WIN32 /DENABLE_UTIL_FLAG1 /DENABLE_UTIL_FLAG2")<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Set(CMAKE_CXX_FLAGS_DEBUG
"${compilerFlagsDebug}" CACHE INTERNAL "" FORCE)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Set(CMAKE_CXX_FLAGS_RELEASE
"${compilerFlagsRelease}" CACHE INTERNAL "" FORCE) <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Add_Library(Util STATIC
${sources})<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Set_Target_Properties(Util <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'> DEBUG_OUTPUT_NAME
"${targetFilenameDebug}"<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'> RELEASE_OUTPUT_NAME
"${targetFilenameRelease}"<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'> COMPILE_FLAGS_DEBUG
"${compilerFlagsDebug}"<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'> COMPILE_FLAGS_RELEASE
"${compilerFlagsRelease}"<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'> LINK_FLAGS_DEBUG
"${linkerFlagsDebug}"<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'> LINK_FLAGS_RELEASE
"${linkerFlagsRelease}"<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>------------------------------------------------------------------------<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Exec/CMakeLists.txt<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>------------------------------------------------------------------------<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Project("Exec")<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Add_Subdirectory("${ABSOLUTE_PATH_UTIL_PROJECT_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}/Util")<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>...<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Set(sources Exec.cpp) <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Set(compilerFlagsDebug "/D
_DEBUG /D WIN32 /DENABLE_EXEC_FLAG1 /DENABLE_EXEC_FLAG2") <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Set(compilerFlagsRelease "/D
NDEBUG /D WIN32 /DENABLE_EXEC_FLAG1 /DENABLE_EXEC_FLAG2")<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Set(CMAKE_CXX_FLAGS_DEBUG
"${compilerFlagsDebug}" CACHE INTERNAL "" FORCE)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Set(CMAKE_CXX_FLAGS_RELEASE
"${compilerFlagsRelease}" CACHE INTERNAL "" FORCE) <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Add_Executable(Exec WIN32
${sources})<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Set_Target_Properties(Exec <o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'> DEBUG_OUTPUT_NAME
"${targetFilenameDebug}"<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'> RELEASE_OUTPUT_NAME
"${targetFilenameRelease}"<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'> COMPILE_FLAGS_DEBUG
"${compilerFlagsDebug}"<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'> COMPILE_FLAGS_RELEASE
"${compilerFlagsRelease}"<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'> LINK_FLAGS_DEBUG
"${linkerFlagsDebug}"<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'> LINK_FLAGS_RELEASE
"${linkerFlagsRelease}"<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Target_Link_Libraries(Exec Util)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Add_Dependencies(Exec Util)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>------------------------------------------------------------------------<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>After we run cmake 2.6.2 for MSVC
7.1 successfully, the project/solution files are generated. The compiler
definitions are set correctly in the Exec project, but now the Util project
contains the same exact flags as the Exec project, as if the Exec project's
CMAKE_CXX_FLAGS_DEBUG and CMAKE_CXX_FLAGS_RELEASE were applied to both the Exec
and Util projects. With CMake 2.4.7, by setting the CMAKE_CXX_FLAGS just prior
to the Add_Library() or Add_Executable() command, it would apply the flags to
just that library or executable. But now it seems like the Exec project's CXX
flags are overriding the Util project's CXX flags.<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>If anyone can look into these
issues and offer some insight into why this behavior has changed since 2.4.7,
it would be greatly appreciated. If we are doing something wrong with respect
to setting specific debug/release flags for visual studio build configuration,
please let us know what we need to do to get this to work again. I tried a
variety of different solutions but I'm completely stumped at this point. I
tried applying debug/release flags to each source file independently using
Set_Source_Files_Properties(), and setting the target properties using
Set_Target_Properties(), but nothing seems to work for cmake 2.6.2. The only
way we could get this to work using CMake 2.4.7 is by setting the
CMAKE_CXX_FLAGS_<CONFIG> properties.<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Thanks in advance!<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Luke K<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>Senior Software Engineer<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-autospace:none'><font size=1 face=Consolas><span
style='font-size:8.0pt;font-family:Consolas'>D&S Consultants, Inc<o:p></o:p></span></font></p>
<p class=MsoNormal><st1:place w:st="on"><st1:City w:st="on"><font size=1
face=Consolas><span style='font-size:8.0pt;font-family:Consolas'>Columbus</span></font></st1:City><font
size=1 face=Consolas><span style='font-size:8.0pt;font-family:Consolas'>, <st1:State
w:st="on">Ohio</st1:State></span></font></st1:place><font size=1
face=Consolas><span style='font-size:8.0pt;font-family:Consolas'><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
</div>
</body>
</html>