Author Topic: Finding the search directories for a project/target?  (Read 4844 times)

Offline Kazade

  • Multiple posting newcomer
  • *
  • Posts: 73
Finding the search directories for a project/target?
« on: February 15, 2009, 10:06:47 am »
Hi, I'm writing a CMake project generator plugin (which generates a CMakeLists.txt file for the workspace). I need to somehow get a list of include/library search directories for each project/build target... how do I do this with the SDK?

Thanks,

Luke.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Finding the search directories for a project/target?
« Reply #1 on: February 15, 2009, 10:25:59 am »
You might want to have alook at the sources of the cbMakeFileGen-plugin (see this thread), it does something similar.

Also GetCompileCommands in directcommands.cpp  (part of compilergcc-plugin) can be a good starting point.

Offline Kazade

  • Multiple posting newcomer
  • *
  • Posts: 73
Re: Finding the search directories for a project/target?
« Reply #2 on: February 15, 2009, 01:33:25 pm »
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:

Code
#	 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'" :D

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Finding the search directories for a project/target?
« Reply #3 on: February 15, 2009, 05:59:11 pm »
Nice work Kazade :)
Be patient!
This bug will be fixed soon...