On 01/04/2011 05:47 AM, John McGehee wrote: > I am using CMake 2.8 on Linux and Windows. > > When I include() or find_package() a .cmake file, is there a variable that I > can use within the included .cmake file that will tell me its path? > > For example, > > # In CMakeLists.txt > include(somePath/foo.cmake) > > Within somePath/foo.cmake, I want to include bar.cmake which is in the same > directory as foo.cmake, > > # In somePath/foo.cmake > include(${CMAKE_VARIABLE_THAT_IS_THE_ANSWER_TO_THIS_QUESTION}/bar.cmake) > > where ${CMAKE_VARIABLE_THAT_IS_THE_ANSWER_TO_THIS_QUESTION} = "somePath", the > path to foo.cmake, which is currently being evaluated.
Use CMAKE_CURRENT_LIST_FILE in conjunction with GET_FILENAME_COMPONENT(): # In somePath/foo.cmake get_filename_component(somePath ${CMAKE_CURRENT_LIST_FILE} PATH) include(${somePath}/bar.cmake) Regards, Michael _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake