KDevelop 4.1 simple configurations?

Started by
3 comments, last by Yours3!f 12 years, 11 months ago
I'm trying figure out how to add include directories and specific libraries to my project. But I'm at a complete lost as to how to do it. Going through the menu Project->Open Configuration takes me to a window with two panels (cmake and make) which have no way to do those things as far as I can see. The KDevelop site was no help in figuring this out. It tells me where to find the automake configuration manager in version 3 (which I guess was also very confusing) but nothing about it in verison 4 which uses cmake. I'd appreciate any insight.
Advertisement
I'll post my own answer here that I've discovered, maybe it will help somebody else's future search.

As of writing this there is no way to either add include directories or libraries to a project with in the IDE. You have to manually edit CMakeLists.txt to do those things. The way to add libraries is to put this in the file:

target_link_libraries(project_name library1 library2 library3 ...)
you need to customize the CMakeLists.txt file

I use something like this:


#cmake ver req
cmake_minimum_required(VERSION 2.6)

set(project_name here_comes_the_project_name)

#project name
project(${project_name})

#so that it talks to us
set(CMAKE_VERBOSE_MAKEFILE ON)

#dependencies
include_directories(/usr/include/)
include_directories(/usr/local/include/)
link_directories(/usr/lib/)
link_directories(/usr/local/lib/)

#header files source
include_directories("${CMAKE_SOURCE_DIR}")
link_directories("${CMAKE_SOURCE_DIR}")

#setting the libraries that will be compiled
set(${project_name}_files here_come_the_libraries_you_want_to_compile)

#setting the external libraries that will be needed
set(${project_name}_external_libs here_come_the_external_libs_you_want_to_link)

#adding the project's own libraries
foreach(lib ${${project_name}_files})
add_library(${lib} SHARED ${lib}.cpp)
endforeach()

#adding the project's exe
add_executable(${project_name} src/main)

#adding the project's own headers
foreach(lib ${${project_name}_files})
add_dependencies(${project_name} ${lib})
endforeach()

#linking in libraries from other sources
foreach(lib ${${project_name}_external_libs})
target_link_libraries(${project_name} ${lib})
endforeach()

#linking against the project's own libraries
foreach(lib ${${project_name}_files})
target_link_libraries(${project_name} ${lib})
endforeach()
Actually, you should just write your CMakeLists.txt in the natural way, using FindPackage commands and others to link in the libraries that you need. KDevelop 4 is supposed to be able to automatically figure out the include paths that are used during compilation, and then use those include paths for the Duchain parsing that provides auto-completion and other features.

If your project uses CMake in a natural way and KDevelop fails to find the include paths, then this is a bug and you should talk to the KDevelop developers about it.

It seems the underlying misunderstanding is one of philosophy, that may be especially problematic for people coming from Visual Studio. KDevelop is built with a focus on playing well in the open source ecosystem, where everybody has their own favourite IDE, ranging from Vim or Emacs all the way to tools like Eclipse and KDevelop. So naturally, the focus is on helping you get on with developing in a wide range of typical open source projects, and less attention is placed on helping you with those few times where you have to mess with the build system itself.
Widelands - laid back, free software strategy

Actually, you should just write your CMakeLists.txt in the natural way, using FindPackage commands and others to link in the libraries that you need. KDevelop 4 is supposed to be able to automatically figure out the include paths that are used during compilation, and then use those include paths for the Duchain parsing that provides auto-completion and other features.


yes you could use it, but for me it worked the best if I just went this way, because from synaptics I pulled everything and they went to the right places. if they didn't you could search for the lib files and include/link them.
I also had very bad experiences with findpackage. To add, this way a developer would instantly know that either he didn't install it or he did, but it's not in the usual place. With findpackage you'd have to search for the findpackage file edit it and hope for the best...

This topic is closed to new replies.

Advertisement