Hi all,

I am setting CMAKE_CXX_FLAGS to "-Wall -ansi -pedantic" but would like to 
remove these flags for compilation
of UnitTest++.  I tried three methods of doing this with some issue with each:

1.   string (REPLACE "-Wall" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
     # And likewise for -ansi and -pedantic

2.   set (CMAKE_CXX_FLAGS "")

3.   unset (CMAKE_CXX_FLAGS CACHE)

I am doing the above for both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS.

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.

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.

Method 1 worked well for MSVC (using different flags than for GCC).

Here are all my files with relevant lines (shown only for CMAKE_CXX_FLAGS but 
done also for CMAKE_C_FLAGS):

CXX_Flag_Overrides.cmake:
    # ...
    if (CMAKE_COMPILER_IS_GNUCXX)
        # message ("CMAKE_COMPILER_IS_GNUCXX")
        set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -Wall -ansi 
-pedantic")
    endif()
    # ...

CMakeLists.txt (top-level)
    # ...
    set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX 
${CMAKE_CURRENT_SOURCE_DIR}/CXX_Flag_Overrides.cmake)
    project (projectname)
    # ...
    add_subdirectory (UnitTest++)
    # ...

CMakeLists.txt (UnitTest++)
    # ...
    if (CMAKE_COMPILER_IS_GNUCXX) # 
http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_COMPILER_IS_GNULANG
        message ("CMAKE_COMPILER_IS_GNUCXX")
        #string (REPLACE "-Wall" ""     CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
        #string (REPLACE "-ansi" ""     CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
        #string (REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
        #unset (CMAKE_CXX_FLAGS CACHE)
        set (CMAKE_CXX_FLAGS "")
        message ("${CMAKE_CXX_FLAGS}")
    endif()
    # ...
    add_library (UnitTest++ ${Sources})

Thanks,

Alok
                                          
_________________________________________________________________
The New Busy is not the old busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to