No subject


Tue Aug 6 13:31:21 EDT 2013


<br>
get_filename_component( BUILD_PRODUCT_ROOT ${CMAKE_SOURCE_DIR}/../.. ABSOLU=
TE )<br>
set( CMAKE_MODULE_PATH<br>
=A0 =A0 &quot;${BUILD_PRODUCT_ROOT}/cmake&quot;<br>
=A0 =A0 &quot;${BUILD_PRODUCT_ROOT}/cmake/find&quot;<br>
)<br>
<br>
add_subdirectory( ${BUILD_PRODUCT_ROOT}/source source )<br>
<br>
Note that the script &quot;root/source/CMakeLists.txt&quot; is where I begi=
n<br>
defining targets, and it never steps into &quot;build&quot; (to avoid infin=
ite<br>
recursion).<br>
<br>
Later on (still in the root script) I do:<br>
<br>
include( common )<br>
<br>
This includes &quot;root/cmake/common.cmake&quot; as expected, but inside<b=
r>
common.cmake when I try to include a file (not a module) relative to<br>
common.cmake, it says it can&#39;t find it. Example:<br>
<br>
include( foo/bar/stuff.cmake )<br>
<br>
The absolute path for this would be:<br>
<br>
root/cmake/foo/bar/stuff.cmake<br>
<br>
Naturally I assume that when including a FILE (not a module!) that it<br>
is relative to the CMAKE_CURRENT_LIST_DIR, which in this case<br>
correctly displays as &quot;root/cmake&quot;.<br>
<br>
Can anyone explain why I can&#39;t include files from common.cmake? Thanks<=
br>
in advance.<br></blockquote><div><br></div><div>Your expectation is wrong h=
ere, IMO. The include() command works very much like the preprocessor&#39;s=
 #include in C/C++, it takes the content of the file and puts it verbatim i=
nto the place where the include() occurs. In particular once the data has b=
een read the command forgets where it came from and this is before the code=
 gets executed. So the &#39;context&#39; CMakeLists.txt file is still the o=
ne in root/build/.</div>
<div><br></div><div>Andreas=A0<br></div></div><br></div></div>

--089e0149ca3a10f2b104e5b16723--


More information about the CMake mailing list