How add a Header Search Path to Xcode project via CMake?

1,645 views
Skip to first unread message

Jerry Krinock

unread,
Dec 9, 2010, 12:15:04 AM12/9/10
to firebre...@googlegroups.com
I'm trying very hard to appreciate "The CMake Way". Today I studied the entire Mac Video tutorial, have visited cmake.org, and have now run prepmac.sh a couple dozen times.

Last week I added the following lines of source code:

FB::DOM::WindowPtr domWindowPtr = [self host]->getDOMWindow() ;
FB::detail::VariantListInserter variant_list = FB::variant_list_of([jsonText UTF8String]) ;
domWindowPtr->callMethod<void>("receiveChanges", variant_list);

In order for this to compile, in my project's plugin target, I needed to add the following Header Search path to declare that callMethod template function…

$(PROJECT_DIR)/../firebreath/src/NPAPIHost

But I now appreciate that touching Xcode Build Settings is not acceptable in The CMake Way; I need to add this to a cmake file. Obviously this is do-able because prepmac adds a dozen Header Search Paths when it creates the project. I looked at cmake's "Properties on Targets" here:

http://www.cmake.org/cmake/help/cmake-2-8-docs.html#section_PropertiesonTargets

but can't find a property which seems to be equivalent to Header Search Paths.

How does one add a Header Search Path via CMake?

Thanks,

Jerry Krinock


Richard Bateman

unread,
Dec 9, 2010, 1:57:13 AM12/9/10
to firebre...@googlegroups.com

I'm not sure if I'm really fully following what you're doing there... I would expect the second line to read more like this:

FB::VariantList variant_list = FB::variant_list_of([jsonText UTF8String]) ;

Also the callMethod template function is defined in ScriptingCore/src/DOM/Node.h (https://github.com/firebreath/FireBreath/blob/master/src/ScriptingCore/DOM/Node.h#L101) so I don't know why you would need to include anything from NPAPIHost. NPAPIHost is currently only used by the unit tests (and not as much as it should be there) and is essentially the framework for something to pretend to be a web browser and load a plugin; in short, 99% of our users will never use anything from it.

Where did you get the idea that callMethod was in NPAPIHost?

All you should need to include is "DOM.h" which will include the other needed headers: https://github.com/firebreath/FireBreath/blob/master/src/ScriptingCore/DOM.h

You could also include "DOM/Window.h" if you wanted to be more explicit.

Anyway, back to your original question (though I don't think it is the solution to what you were aiming for): http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:include_directories

Somewhere before the add_library call (which occurs in the projectDef.cmake platform-specific file, in some cases inside another macro that would look like add_mac_plugin or add_x11_plugin you need to put an include_directories(....) command with the list of directories to add to the header search path.

Hope that helps,

Richard

Jerry Krinock

unread,
Dec 11, 2010, 1:42:43 AM12/11/10
to firebre...@googlegroups.com

On 2010 Dec 08, at 22:57, Richard Bateman wrote:

> I'm not sure if I'm really fully following what you're doing there...

This code is in a method which listens for an interprocess message from my app. These three lines of code forward the message to JavaScript in my browser extension.

>> FB::DOM::WindowPtr domWindowPtr = [self host]->getDOMWindow() ;
>> FB::detail::VariantListInserter variant_list = FB::variant_list_of([jsonText UTF8String]) ;
>> domWindowPtr->callMethod<void>("receiveChanges", variant_list);

> I would expect the second line to read more like this:


>
>>
> FB::VariantList variant_list = FB::variant_list_of([jsonText UTF8String]) ;

OK. I don't remember where I got that type.



> Where did you get the idea that callMethod was in NPAPIHost?

Same thing I always do whenever the Xcode complains of an undeclared method. Doubleclick it to search the project and find the declaration or definition.

> All you should need to include is "DOM.h" which will include the other needed headers: https://github.com/firebreath/FireBreath/blob/master/src/ScriptingCore/DOM.h

Oh, OK. That's what I call an "handy umbrella header".

> Anyway, back to your original question (though I don't think it is the solution to what you were aiming for):

Indeed it is not, but now I need to do this for some of my own headers…

> http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:include_directories

OK, I was thinking that one might work.

> Somewhere before the add_library call (which occurs in the projectDef.cmake platform-specific file, in some cases inside another macro that would look like add_mac_plugin or add_x11_plugin you need to put an include_directories(....) command with the list of directories to add to the header search path.

Thank you. I added this and it produces "Header Search Paths" in Xcode as desired…

set (MY_HEADERS
# Add any "Header Search Paths" needed by your plugin target here.
# Enter each as a full path on a line by itself, double-quoted, no comma.
"/Users/jk/Documents/Programming/Projects/MyApp/"
"/Users/jk/Documents/Programming/CategoriesObjC/"
"/Users/jk/Documents/Programming/ClassesObjC/"
"/Users/jk/Documents/Programming/ProtocolsObjC/"
)

include_directories(
${MY_HEADERS}
)


Reply all
Reply to author
Forward
0 new messages