[CMake] CMake Error: Attempt at a recursive or nested TRY_COMPILE in directory

Brad King brad.king at kitware.com
Mon Jun 12 15:47:29 EDT 2006


Bernd Schubert wrote:
> Hi, 
> 
> I'm just beginning to learn CMake and now I'm lost.
> 
> I need to check for large file support and therefore need to use TRY_COMPILE. 
> In my main CMakeLists.txt file I tried similar to my Mastering CMake book 
> (for version 2.0):
> 
> TRY_COMPILE(C_MAKE_COMPILER_WORKS
>             ${CMAKE_BINARY_DIR}
>             ${PROJECT_SOURCE_DIR}/CMake_Modules/Test_64_Bit_Offset.c
>             OUTPUT_VARIABLE_OUTPUT)

You are trying to put the build tree of the try-compile test on top of 
the main build tree.  Try this:

TRY_COMPILE(C_MAKE_COMPILER_WORKS
             ${CMAKE_BINARY_DIR}/CMakeTmp
             ${PROJECT_SOURCE_DIR}/CMake_Modules/Test_64_Bit_Offset.c
             OUTPUT_VARIABLE_OUTPUT)

However, you may want to look at the CheckCSourceCompiles module.

-Brad


More information about the CMake mailing list