This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Project: source code in subdirectory of repository

Tags: None
(comma "," separated)
wolfb
Registered Member
Posts
3
Karma
0
Dear all,

first of all: thanks for KDevelop, and I really like the new correct code parsing of KDev 5.0.1!

My question is about projects. I have many projects, most of them come with the following directory structure:

Code: Select all
GreatProject (root of git repo)
 + configuration
 + other_important_text_files
 + src
    - CMakeLists.txt
    - someCode.cpp


I.e. it is a CMake project but the src directory is not the root of the project, I also need to edit files in the configuration folder. When opening the CMakeLists project in KDevelop, I don't know how to tell KDev that I want the project to be called "GreatProject" instead of "src" (otherwise I end up with 5 different "src" projects) and I also want to edit configuration files in KDev (and be able to open them with Ctrl-Alt-o) - i.e. the "root" should be the root of the corresponding git repository. Is there a way to achieve that when opening/importing a CMake project?

-> My current solution is to open the project and then close KDevelop. Then "mv src.kdev4 ../GreatProject.kdev4; mv .kdev4 ..; mv ../.kdev4/src.kdev4 ../.kdev4/GreatProject.kdev4; vim ../.kdev4/GreatProject.kdev4" and add ProjectRootRelative=./src in the CMake section. Is there a simpler solution? And by the way, it is still called .kdev4 in KDevelop 5 :-)
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
Did you consider moving your top-level CMakeLists.txt to the top-level instead of the src/ folder? That is how people usually do it (at least, all KDE projects do it like this). It kind of makes sense, since CMake might need to do something with files that are not source code as well, for example install icons or so.
In the simplest case, I think you can just create top-level CMakeLists.txt with nothing but add_subdirectory(src/).


I'm working on the KDevelop IDE.
wolfb
Registered Member
Posts
3
Karma
0
Hm, that would indeed be a possibility.

I can see two drawbacks:
1) I also have files in src/cmake which are referenced like this:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
So I need to move the src/cmake folder to .. or change the src/CMakeLists.txt

2) the binaries will be created in build/src instead of build. For some common projects some scripts expect the binaries in $HOME/project/src/build. (it shouldn't be like this, I know...)

Also, I am abolutely NOT an expert in CMake. Happy when everything is compiled and linked together. Maybe I could somehow tweak directories in the root/CMakeLists to make the add_subdirectory work? But then on the other hand KDevelop supports my request when you manually edit the project file. So it shouldn't be too hard to make this feature available in the project import GUI dialog?
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
I think it's typical to have the cmake/Modules/ folder on the same level as src/ -- again, look at other projects, they do it in the same way.

In my opinion relying on where anything is built is not good style; use install() to install your files to a sensible and fixed location.

Anyways, I can see why this might be a use case ... maybe put a wish on bugs.kde.org about this?

Best,
Sven


I'm working on the KDevelop IDE.
wolfb
Registered Member
Posts
3
Karma
0
In my opinion relying on where anything is build is not good style; use install() to install your files to a sensible and fixed location.


Well, it is faster. Every time you change something you can just hit F8 and be done. No need to "install" anything, no need to add install commands to CMakeLists! Our projects are usually very small.

But I can see the point that we should probably reconsider how we work. Maybe I will add it as a wish.
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
Map F8 to "install selection" and you have the same effect :-)
You don't have to install system-wide, ~/install or something is fine.


I'm working on the KDevelop IDE.


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], lockheed, Sogou [Bot], Yahoo [Bot]