Re: [CMake] Turning on warnings when compiling.
I do something like this (I think it was taken from the VTK CmakeLists.txtfile): #- # Let's use the highest warning level. #- IF(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv|nmake)") # Use the highest warning level for visual studio. IF(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") ELSE(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") ENDIF(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") IF(CMAKE_C_FLAGS MATCHES "/W[0-4]") STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") ELSE(CMAKE_C_FLAGS MATCHES "/W[0-4]") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") ENDIF(CMAKE_C_FLAGS MATCHES "/W[0-4]") # Disable deprecation warnings for standard C functions in VS2005 and later IF(CMAKE_COMPILER_2005) ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) ENDIF(CMAKE_COMPILER_2005) ENDIF(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv|nmake)") IF(CMAKE_BUILD_TOOL MATCHES "make") IF(NOT CMAKE_CXX_FLAGS MATCHES "-Wall") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") ENDIF(NOT CMAKE_CXX_FLAGS MATCHES "-Wall") IF(NOT CMAKE_C_FLAGS MATCHES "-Wall") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") ENDIF(NOT CMAKE_C_FLAGS MATCHES "-Wall") ENDIF(CMAKE_BUILD_TOOL MATCHES "make") Andrew On 8/28/07, Michael Wagner <[EMAIL PROTECTED]> wrote: > > Hi, > > Whenever I'm compiling, there are no warnings shown. > Is there a command or variable that can be used to turn on warnings? > > When searching the wiki, the only information I found was this page: > http://www.cmake.org/Wiki/CMake_Platform_Dependent_Issues > which tells me the right flags for all the different compilers. That is > wonderfull, I just need to know how to turn that stuff on! > > Maybe somebody out there knows how to turn on warnings. (Hopefully you > are not all fearless coders that laugh in the face of warnings... ;-) > > cheers, > > Michael > ___ > CMake mailing list > CMake@cmake.org > http://www.cmake.org/mailman/listinfo/cmake > -- ___ Andrew J. P. Maclean Centre for Autonomous Systems The Rose Street Building J04 The University of Sydney 2006 NSW AUSTRALIA Ph: +61 2 9351 3283 Fax: +61 2 9351 7474 URL: http://www.acfr.usyd.edu.au/ ___ ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
RE: [CMake] Turning on warnings when compiling.
ADD_DEFINITIONS(-Wall) should work for both the gnu c and c++ compiler and other compilers supporting gnu option emulation. You can also do: make VERBOSE=1 on a unix system to see the commands being executed. Regards, Juan -Original Message- From: [EMAIL PROTECTED] on behalf of Michael Wagner Sent: Tue 8/28/2007 8:07 AM To: cmake@cmake.org Subject: [CMake] Turning on warnings when compiling. Hi, Whenever I'm compiling, there are no warnings shown. Is there a command or variable that can be used to turn on warnings? When searching the wiki, the only information I found was this page: http://www.cmake.org/Wiki/CMake_Platform_Dependent_Issues which tells me the right flags for all the different compilers. That is wonderfull, I just need to know how to turn that stuff on! Maybe somebody out there knows how to turn on warnings. (Hopefully you are not all fearless coders that laugh in the face of warnings... ;-) cheers, Michael ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Turning on warnings when compiling.
Michael Wagner wrote: Hi, Whenever I'm compiling, there are no warnings shown. Is there a command or variable that can be used to turn on warnings? I don't know of a specific CMake mechanism to turn on warnings. I figure out which compiler I'm using and turn on flags manually by adding the flags to the CMAKE_CXX_FLAGS or something: ## # Sets some variables depending on which compiler you are using # # USING_GCC : gcc is being used for C compiler # USING_GPP : g++ is being used for C++ compiler # USING_ICC : icc is being used for C compiler # USING_ICPC : icpc is being used for C++ compiler SET(MANTA_COMPILER_NAME_REGEXPR "icc.*$") IF(NOT CMAKE_COMPILER_IS_GNUCC) # This regular expression also matches things like icc-9.1 IF (CMAKE_C_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR}) SET(USING_ICC TRUE) ENDIF(CMAKE_C_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR}) ELSE(NOT CMAKE_COMPILER_IS_GNUCC) SET(USING_GCC TRUE) ENDIF(NOT CMAKE_COMPILER_IS_GNUCC) # Do something similar for C++ (see code on line) ## Add flags based on compiler IF(USING_GCC) # to really make this stick, set this as a forced cache variable SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wall) ENDIF(USING_GCC) -- You might also want to add code to only set the flags on the first configure. This allows users to remove flags you have set by default. You can see the code here: https://code.sci.utah.edu/svn/Manta/trunk/CMake/CompilerInfo.cmake https://code.sci.utah.edu/svn/Manta/trunk/CMake/ConfigCompilerFlags.cmake James ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Turning on warnings when compiling.
Michael Wagner wrote: Maybe somebody out there knows how to turn on warnings. (Hopefully you are not all fearless coders that laugh in the face of warnings... ;-) Real Programmers(tm) don't need warnings! For mortals like myself, here's how I do it: Go into the CMake cache via `make edit_cache', `ccmake .' or similar from your build directory. Depending on the value of CMAKE_BUILD_TYPE and the language you're using, the variable you'll need to set will be different: For C, you have CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE} (but in uppercase), so CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_MINSIZEREL ... and so on You could also lock down required flags by SETting the variables in CMakeLists.txt if you wanted. -- Jack ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake