[CMake] Enhancement to CHECK_C_RUNS_SOURCE
Rolf Eike Beer
eike at sf-mail.de
Wed Feb 1 02:35:08 EST 2012
Am Dienstag, 31. Januar 2012, 19:27:22 schrieb Clifford Yapp:
> We currently have a minor local enhancement to CHECK_C_RUNS_SOURCE
> that I would like to contribute back to the main module, if it is
> acceptable to the developers of CMake:
>
> We often have our own .c file stored in our tree for TRY_RUN testing,
> and it is convenient to be able to use CHECK_C_RUNS_SOURCE for testing
> those .c files. At the moment, CHECK_C_RUNS_SOURCE assumes the
> incoming SOURCE variable actually holds the source code - our
> enhancement checks to see if SOURCE holds a valid file path first. If
> it DOES hold a valid file path, TRY_RUN then trys that .c file,
> otherwise the existing CHECK_C_RUNS_SOURCE is preserved. I don't know
> of any sane pathname that would be valid C code or vice versa, so
> there should be no danger of passing in a C source snippit and having
> it mistaken for a file path.
>
> The diff is below - would this be of interest for main-line CMake?
>
> Thanks,
> CY
>
> --- ../../CheckCSourceRuns.cmake 2012-01-31 19:19:58.000000000 -0500
> +++ misc/CMake/CheckCSourceRuns.cmake 2012-01-31 19:16:05.000000000 -0500
> @@ -86,13 +86,18 @@
> ELSE(CMAKE_REQUIRED_INCLUDES)
> SET(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
> ENDIF(CMAKE_REQUIRED_INCLUDES)
> - FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"
> - "${SOURCE}\n")
> -
> + IF(EXISTS "${SOURCE}")
> + SET(CHECK_SRC "${SOURCE}")
> + ELSE(EXISTS "${SOURCE}")
> + FILE(WRITE
> "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" +
> "${SOURCE}\n")
> + SET(CHECK_SRC
> "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c")
> + ENDIF(EXISTS "${SOURCE}")
> +
> MESSAGE(STATUS "Performing Test ${VAR}")
> TRY_RUN(${VAR}_EXITCODE ${VAR}_COMPILED
> ${CMAKE_BINARY_DIR}
> - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
> + ${CHECK_SRC}
> COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
> CMAKE_FLAGS
> -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
> -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
This is at least missing documentation ;)
Eike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120201/bc5a67d8/attachment.pgp>
More information about the CMake
mailing list