[CMake] CMake and VPATH

Bill Hoffman bill.hoffman at kitware.com
Mon Mar 9 08:35:23 EDT 2009


laurent at marzu.org wrote:
> Hello all,
> 
>  
> 
> I've just began trying to port my project from autoconf to CMake and 
> I've got a question.
> 
> My project use 'vpath' variable in order to locate source file from 
> different directory according to argument pass to autoconf.
> 
> Typically, my C++ source file may be from src/libxml2 or src/xerces-c++ 
> or any other directory depending on XML parser used.
> 
> I've look up around a little a came on a message saying CMake have no 
> replacement for VPATH.
> 
> So, my question is:
> 
> - How to use CMake in such case ?
> 
No need for VPATH in CMAke, it always builds out of source.  In the 
CMakeLists.txt file there are several variables that can give you 
locations of files.

PROJECTNAME_SOURCE_DIR
PROJECTNAME_BIANRY_DIR
(where PROJECTNAME is the name used in the this command: 
project(PROJECTNAME)

CMAKE_CURRENT_SOURCE_DIR
CMAKE_CURRENT_BINARY_DIR

-Bill


More information about the CMake mailing list