CheckSymbolExists: force the compiler to keep the referenced symbol
Otherwise the compiler may optimize out the reference to the symbol as the previous version was not really using this. This leads to symbols that are only in a header but not in the given libraries to be reported as present. This came up on the first try to fix bug 11333 as "gcc -O3" would optimize out the reference to pthread_create() so the correct library the symbol is in was not detected. The new test code was suggested by Brad King.
This commit is contained in:
parent
9a20abf04a
commit
813eca6416
|
@ -60,7 +60,7 @@ MACRO(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
|
||||||
"${CMAKE_CONFIGURABLE_FILE_CONTENT}#include <${FILE}>\n")
|
"${CMAKE_CONFIGURABLE_FILE_CONTENT}#include <${FILE}>\n")
|
||||||
ENDFOREACH(FILE)
|
ENDFOREACH(FILE)
|
||||||
SET(CMAKE_CONFIGURABLE_FILE_CONTENT
|
SET(CMAKE_CONFIGURABLE_FILE_CONTENT
|
||||||
"${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")
|
"${CMAKE_CONFIGURABLE_FILE_CONTENT}\nint main(int argc, char** argv)\n{\n (void)argv;\n#ifndef ${SYMBOL}\n return ((int*)(&${SYMBOL}))[argc];\n#else\n (void)argc;\n return 0;\n#endif\n}\n")
|
||||||
|
|
||||||
CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
|
CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
|
||||||
"${SOURCEFILE}" @ONLY IMMEDIATE)
|
"${SOURCEFILE}" @ONLY IMMEDIATE)
|
||||||
|
|
Loading…
Reference in New Issue