MantisBT - CMake
View Issue Details
0011753CMake(No Category)public2011-01-25 19:342016-06-10 14:31
James Bigler 
James Bigler 
normalminorhave not tried
closedmoved 
 
 
0011753: int main() can cause warnings when -Wstrict-prototypes and -Werror is used
In our projects we use -Wall -Wstrict-prototypes -Werror, and I just noticed that this causes all sorts of problems for the test code.

There seems like there are two solutions to this.

1. Fix all the test code, so that these warnings are tripped.
2. Somehow intercept try_compile so that it doesn't pass along things like -Werror.

I've attempted to implement #1 since it seems easier than modifying all the try_compile blocks with a compiler specific flag.

I've also attached a patch against my 2.8.3 installation.
grep -nH -e "int main()" *

CheckCCompilerFlag.cmake:28: CHECK_C_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT}
CheckCXXCompilerFlag.cmake:28: CHECK_CXX_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT}
CheckForPthreads.c:9:int main(){
CheckFunctionExists.c:5:int main(){
CheckIncludeFile.c.in:4:int main()
CheckIncludeFile.cxx.in:3:int main()
CheckIncludeFiles.cmake:45: "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n\nint main(){return 0;}\n")
CheckStructHasMember.cmake:41:int main()
CheckSymbolExists.cmake:50: "${CMAKE_CONFIGURABLE_FILE_CONTENT}\nvoid cmakeRequireSymbol(int dummy,...){(void)dummy;}\nint main()\n{\n#ifndef ${SYMBOL}\n cmakeRequireSymbol(0,&${SYMBOL});\n#endif\n return 0;\n}\n")
CheckVariableExists.c:6:int main(){
CMakeDetermineVSServicePack.cmake:64: "int main() { return 0; }\n")
CMakeTestCXXCompiler.cmake:28: "int main(){return 0;}\n")
CMakeTestForFreeVC.cxx:3:int main(){return 0;}
DummyCXXFile.cxx:1:int main()
FindOpenMP.cmake:57:int main() {
No tags attached.
related to 0011615closed Brad King CHECK_C_COMPILER_FLAG Problem, simple fix. 
patch main-void.patch (5,680) 2011-01-25 19:34
https://public.kitware.com/Bug/file/3656/main-void.patch
Issue History
2011-01-25 19:34James BiglerNew Issue
2011-01-25 19:34James BiglerFile Added: main-void.patch
2011-01-26 08:52Brad KingRelationship addedrelated to 0011615
2011-01-26 08:53Brad KingNote Added: 0025079
2011-01-26 08:54Brad KingAssigned To => James Bigler
2011-01-26 08:54Brad KingStatusnew => assigned
2011-01-26 08:54Brad KingNote Added: 0025080
2016-06-10 14:28Kitware RobotNote Added: 0041784
2016-06-10 14:28Kitware RobotStatusassigned => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0025079)
Brad King   
2011-01-26 08:53   
Fix from issue 0011615:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b3efdb58 [^]
(0025080)
Brad King   
2011-01-26 08:54   
This patch only affects the Modules/ directory.

As a module maintainer you should be able to commit your patch on top of 'master' and then merge to 'next' on the topic stage just as you do with FindCUDA changes.
(0041784)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.