[CMake] Trying to find a directory

Filipe Sousa filipe at ipb.pt
Fri Nov 24 04:06:20 EST 2006


Timo Rumland wrote:
> Hello,
> 
> 
> yes I did. Perhaps I have not explained my problem properly.
> 
> My binary dir is "c:/project/test/buildfiles", the cmake variable ${PROJECT_BINARY_DIR} contains that automatically after I use the "PROJECT" command.
> 
> Now I want to set the path where to build the project binaries, in my case it is "c:/project/test/bin", BUT I never know the beginning of that path ("c:/project/test"), because I can't say where the user is on his system.
> 
> So I need to get the relative path "../bin" from "[whatever]/buildfiles" resulting in "[whatever]/bin".

What most of us usually do is setting the EXECUTABLE_OUTPUT_PATH
variable. SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin). In this
case, bin is a subdirectory in the build tree. If you want the bin
directory as a parent of the build tree (out of build tree) then you can
do something like this

GET_FILENAME_COMPONENT(EXECUTABLE_OUTPUT_PATH
                       ${CMAKE_BINARY_DIR}/../bin
                       ABSOLUTE
                       )
-- 
Filipe Sousa

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://public.kitware.com/pipermail/cmake/attachments/20061124/391d4682/signature.pgp


More information about the CMake mailing list