Print out the value of <span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">CMAKE_SOURCE_DIR in your CMakeLists.txt file... It&#39;s different in the context of your outer project and your test project.</span><br>
<br><div>If it&#39;s &quot;/my/proj&quot; for your outer project, it&#39;s going to be &quot;/my/proj/test&quot; in your test project.</div><div><br></div><div>Is there a directory named &quot;/my/proj/test/include1&quot;?</div>
<div><br></div><div>If not, you&#39;ll need to pass down:</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo">      --build-options</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo">        -DINCLUDE_DIR:PATH=${CMAKE_SOURCE_DIR}/include1</p><div>and reference that in your test/CMakeLists.txt file...</div><div><br></div><div><br></div><div>
HTH,</div><div>David</div><div><br></div><div><br><div class="gmail_quote">On Fri, Sep 10, 2010 at 5:06 AM, Frank Stappers <span dir="ltr">&lt;<a href="mailto:f.p.m.stappers@tue.nl">f.p.m.stappers@tue.nl</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hello,<br>
<br>
I try to accomplish to add a test, that compiles and runs afterward.<br>
For the test that I want to run I have defined a project<br>
CMakeLists.txt project in<br>
${CMAKE_SOURCE_DIR}/test/, which looks like:<br>
<br>
========<br>
project(test_tgt)<br>
cmake_minimum_required(VERSION 2.6)<br>
include_directories(${CMAKE_SOURCE_DIR}/include1)<br>
add_executable(test_tgt &quot;test.cpp&quot;  )<br>
target_link_libraries(test_tgt     a_compiled_lib)<br>
========<br>
<br>
Within the CMakeLists.txt of ${CMAKE_SOURCE_DIR}<br>
it is possible to compile &quot;test_tgt&quot;, by including<br>
<br>
========<br>
.....<br>
ENABLE_TESTING()<br>
add_subdirectory(test)<br>
========<br>
<br>
And run &quot;test_tgt&quot;<br>
<br>
Now I change the above code into:<br>
<br>
========<br>
.....<br>
ENABLE_TESTING()<br>
        ADD_TEST(test_tgt ${CMAKE_CTEST_COMMAND}<br>
           --build-and-test<br>
           &quot;${CMAKE_SOURCE_DIR}/test&quot;<br>
           &quot;${CMAKE_BINARY_DIR}/test&quot;<br>
           --build-generator &quot;${CMAKE_GENERATOR}&quot;<br>
           --build-project test_tgt<br>
           --build-makeprogram &quot;${CMAKE_MAKE_PROGRAM}&quot;<br>
           --test-command test_tgt<br>
            )<br>
=======<br>
<br>
I re-run my cmake in the ${CMAKE_BINARY_DIR} and<br>
execute:<br>
<br>
ctest -R test_tgt --verbose<br>
<br>
When I observe the output, I see something like:<br>
<br>
=======<br>
....<br>
Constructing a list of tests<br>
Done constructing a list of tests<br>
Checking test dependency graph...<br>
test 1<br>
    Start 1: test_tgt<br>
<br>
1: Test command: ...<br>
1: Test timeout computed to be: 1500<br>
1: Internal cmake changing into directory: ${CMAKE_BINARY_DIR}/test<br>
1: ======== CMake output     ======<br>
1: Configuring<br>
1: Configuring done<br>
1: Generating<br>
1: Generating done<br>
1: Build files have been written to: ${CMAKE_BINARY_DIR}/test<br>
1: ======== End CMake output ======<br>
1: Change Dir: ${CMAKE_BINARY_DIR}/test<br>
1:<br>
1: Run Clean Command:/usr/bin/gmake &quot;clean&quot;<br>
1:<br>
1: Run Build Command:/usr/bin/gmake<br>
1: [100%] Building CXX object CMakeFiles/test_tgt.dir/test.cpp.o<br>
1: In file included from ${CMAKE_SOURCE_DIR}/test/test.cpp:5:0:<br>
1: /usr/include/include1/xxx.h:18:20: fatal error: yyy.h: No such file<br>
or directory<br>
1: compilation terminated.<br>
1: gmake[2]: *** [CMakeFiles/test_tgt.dir/test.cpp.o] Error 1<br>
1: gmake[1]: *** [CMakeFiles/test_tgt.dir/all] Error 2<br>
1: gmake: *** [all] Error 2<br>
1/1 Test #1: test_tgt .........................***Failed    0.13 sec<br>
=======<br>
<br>
Observe that the test fails, while it tries to include &quot;yyy.h&quot; from<br>
&quot;xxx.h&quot; /usr/include/include1 from, whereas it<br>
should:<br>
1) pick the &quot;xxx.h&quot;, as it is located in the ${CMAKE_SOURCE_DIR}<br>
2) find &quot;yyy.h&quot; in the include_directories of project &quot;test_tgt&quot;, as<br>
it is stored in that location.<br>
<br>
My question:<br>
Is there something wrong with my code? Do I have to set additional<br>
variables? Or is it a bug?<br>
<br>
For the record, I&#39;m using Cmake/Ctest 2.8.2.<br>
<br>
Kind regards,<br>
Frank Stappers<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div>