[Insight-developers] Path of External Module in CMake

Brad King brad.king at kitware.com
Fri Jul 1 09:21:08 EDT 2011


On 07/01/2011 09:11 AM, Bradley Lowekamp wrote:
> In my External module I was hoping to be able to do something like the following:
> 
> file( READ "${CMAKE_CURRENT_SOURCE_DIR}/README" DOCUMENTATION )
> 
> But the CMAKE_CURRENT_SOURCE_DIR is not right.

The itk-module.cmake file is supposed to approximate a declarative
specification.  It can be loaded from multiple unspecified contexts
so no includer-dependent variable like CMAKE_CURRENT_SOURCE_DIR is
reliable.

You can use get_filename_component to extract the directory name
from CMAKE_CURRENT_LIST_FILE which should be set correctly.  CMake
2.8.4 introduced CMAKE_CURRENT_LIST_DIR to contain the location of
the current file, but ITK does not currently require a version of
CMake that new.

-Brad K


More information about the Insight-developers mailing list