<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hi all,<br><br>I am setting CMAKE_CXX_FLAGS to "-Wall -ansi -pedantic" but would like to remove these flags for compilation<br>of UnitTest++. I tried three methods of doing this with some issue with each:<br><br>1. string (REPLACE "-Wall" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})<br><font style="" color="#00b050"> # And likewise for -ansi and -pedantic</font><br><br>2. set (CMAKE_CXX_FLAGS "")<br><br>3. unset (CMAKE_CXX_FLAGS CACHE)<br><br>I am doing the above for both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS.<br><br>The problem with 1 and 2 is that they are not working. GCC (MinGW-W32) still gives the concerned warnings. I do not get these warnings if I do not set these flags at all to begin with.<br><br>Method 3 does work. The problem however is that it removes CMAKE_CXX_FLAGS globally, not just from CMakeList.txt for UnitTest++. I could in principle recreate CMAKE_CXX_FLAGS but would like to understand what's going on first.<br><br>Method 1 worked well for MSVC (using different flags than for GCC).<br><br>Here are all my files with relevant lines (shown only for CMAKE_CXX_FLAGS but done also for CMAKE_C_FLAGS):<br><br><u>CXX_Flag_Overrides.cmake</u>:<br><font style="" color="#00b050"> # ...</font><br> if (CMAKE_COMPILER_IS_GNUCXX)<br><font style="" color="#00b050"> # message ("CMAKE_COMPILER_IS_GNUCXX")</font><br> set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -Wall -ansi -pedantic")<br> endif()<br><font style="" color="#00b050"> # ...</font><br><br><u>CMakeLists.txt (top-level)</u><br><font style="" color="#00b050"> # ...</font><br> set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/CXX_Flag_Overrides.cmake)<br> project (projectname)<br><font style="" color="#00b050"> # ...</font><br> add_subdirectory (UnitTest++)<br><font style="" color="#00b050"> # ...</font><br><br><u>CMakeLists.txt (UnitTest++)</u><br><font style="" color="#00b050"> # ...</font><br> if (CMAKE_COMPILER_IS_GNUCXX) # http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_COMPILER_IS_GNULANG<br> message ("CMAKE_COMPILER_IS_GNUCXX")<br> <font style="" color="#00b050">#string (REPLACE "-Wall" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})</font><font style="" color="#00b050"><br></font><font style="" color="#00b050"> #string (REPLACE "-ansi" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})</font><font style="" color="#00b050"><br></font><font style="" color="#00b050"> #string (REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})</font><font style="" color="#00b050"><br></font><font style="" color="#00b050"> #unset (CMAKE_CXX_FLAGS CACHE)</font><br> set (CMAKE_CXX_FLAGS "")<br> message ("${CMAKE_CXX_FLAGS}")<br> endif()<br><font style="" color="#00b050"> # ...</font><br> add_library (UnitTest++ ${Sources})<br><br>Thanks,<br><br>Alok<br>                                            <br /><hr />The New Busy is not the old busy. Search, chat and e-mail from your inbox. <a href='http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3' target='_new'>Get started.</a></body>
</html>