[CMake] get the relative path of current directory

Philip Lowman philip at yhbt.com
Sun Mar 22 12:29:19 EDT 2009


On Sun, Mar 22, 2009 at 7:06 AM, blinkeye <gentoo at blinkeye.ch> wrote:

> Use case:
>
> You start developing src/prototype1 which implements feature X. Next, you
> copy
> src/prototype1 to src/prototype2 and implement feature Y or enhance feature
> X.
> You don't branch because you're constantly comparing these prototypes
> against
> each others (say for speed).
>
> To make this really easy I need a way of getting the ${RELATIVE_SOURCE_DIR}
> of
> such a prototype so I can copy src/prototype1 to src/prototypeX without
> adjusting src/prototypeX/CMakeLists.txt:
>
> set( EXECUTABLE_OUTPUT_PATH
> ${PROJECT_BINARY_DIR}/bin/${RELATIVE_SOURCE_DIR} )
>
> So, the only thing one needs to adjust is the project's top CMakeLists.txt
> and
> add the new prototype's source dir to the SUBDIRS directive.
>
> Is this possible?


You can use the NAME option to get_filename_component() and pass in
${CMAKE_CURRENT_SOURCE_DIR}.

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090322/9d6f542a/attachment.htm>


More information about the CMake mailing list