[CMake] find_package config mode question
Mclendon, William C III
wcmclen at sandia.gov
Fri Apr 18 12:33:46 EDT 2014
Hi,
I'm trying to set up a project pulls in information from another CMake project (include dirs, libraries, etc.). As I understand it the right thing to do is create a <Project>config.cmake.in in the source project and then use find_package in config mode to pull in the information to the dependent project.
So far things seem to be working properly but I'd like to pull the content of include_directories from the master project into the dependent project because it has to reference a few headers. I haven't found any built in CMake variable that collects all the include_directory commands but I can do something like this:
get_property (dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach (dir ${dirs})
message (STATUS "MyProject INCLUDE DIRECTORY: '${dir}'")
list (APPEND MyProject_INCLUDE_DIRS ${dir})
endforeach ()
message( STATUS "MyProject_INCLUDE_DIRS: " ${MyProject_INCLUDE_DIRS} )
this seems to do the right thing and lists all the directories in include_directory() statements, but when I go to the MyProjectConfig.cmake.in file and have something like this:
set (MYPROJECT_INCLUDE_DIRS ${MyProject_INCLUDE_DIRS})
it doesn't get anything. I have other statements in the MyProjectConfig.cmake.in file that have a similar pattern and are expanded but for this one I get something like this:
set (MYPROJECT_INCLUDE_DIRS )
I've used CMake for a while, generated a couple simple project scripts in the past but this is my first time developing a project using find_package in config mode. Any suggestions would be helpful :)
Thanks!
-William
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140418/7578304b/attachment.html>
More information about the CMake
mailing list