[CMake] BUG in TRY_COMPILE with multiple includes

Fernando Cacciola fernando.cacciola at gmail.com
Mon Sep 8 09:39:19 EDT 2008


Hi,

Consider the following sample project:

project( FOOL C CXX )

try_compile( X_COMPILE_RES
            ${CMAKE_BINARY_DIR}
            ${CMAKE_SOURCE_DIR}/X.cpp
            CMAKE_FLAGS 
-DINCLUDE_DIRECTORIES:STRING="${CMAKE_SOURCE_DIR}/includeA;${CMAKE_SOURCE_DIR}/includeB"
            OUTPUT_VARIABLE X_OUTPUT
           )

message( STATUS "${X_OUTPUT}" )


X.cpp includes "foo.h" from "includeA" and "bar.h" from "includeB".

When trying compile this, I get an error that "bar.h" is not found.

Using --debug-trycompile I can see that the second include is indeed 
missing, as the temporary cache shows this:

//No help, variable specified on the command line.
INCLUDE_DIRECTORIES:STRING="C:/Work/Active/Projects/includeA


AFAICT this is a bug.

I tested it in versions 2.4.5, 2.4.7, 2.6.0 and CMake 2.6.1

Has it been reported before? If not, I'll file a report.

Does anyone know of a workaround?

TIA

Fernando Cacciola



More information about the CMake mailing list