I found a way to do this before I saw your reply
Basically, I got the ProjectBuildTarget for the project and the active target. Then I called target->GetIncludeDirs() and target->GetLinkLibs(). I then used popen() to call any pkg-config or wx-config commands and parsed the result. It seems to work well
(although, it's probably a roundabout way of doing it)
I just want to tidy up a bit more before I post the plugin, but just as a teaser.. here is the output of calling the plugin on its own sources:
# Generated by Kazade's CMake Generator plugin!
CMAKE_MINIMUM_REQUIRED( VERSION 2.6 )
PROJECT ( cmake_generator )
SET( CMAKE_GENERATOR_SOURCES
"CMake Generator/CMake_Generator.cpp"
"CMake Generator/Project.cpp"
"CMake Generator/Workspace.cpp"
)
INCLUDE_DIRECTORIES(
"/usr/include/codeblocks"
"/usr/include/codeblocks/tinyxml"
"/usr/include/codeblocks/scripting/include"
"/usr/include/codeblocks/scripting/bindings"
"/usr/include/codeblocks/scripting/sqplus"
"/usr/include/codeblocks/wxFlatNotebook/include"
"/usr/include/codeblocks/wxscintilla/include"
"/usr/lib/wx/include/gtk2-unicode-release-2.8"
"/usr/include/wx-2.8"
)
LINK_LIBRARIES(
"codeblocks"
"wx_gtk2u_richtext-2.8"
"wx_gtk2u_aui-2.8"
"wx_gtk2u_xrc-2.8"
"wx_gtk2u_qa-2.8"
"wx_gtk2u_html-2.8"
"wx_gtk2u_adv-2.8"
"wx_gtk2u_core-2.8"
"wx_baseu_xml-2.8"
"wx_baseu_net-2.8"
"wx_baseu-2.8"
)
ADD_DEFINITIONS(
"-D_FILE_OFFSET_BITS=64"
"-D_LARGE_FILES"
"-D__WXGTK__"
)
ADD_EXECUTABLE( cmake_generator ${CMAKE_GENERATOR_SOURCES} )
At the moment it doesn't recognise the difference between libraries and applications so it's not quite right yet. But it compiles it just complains about "unresolved reference to 'main'"