[Feature Request] Handling CMake Project dependencies

Discussion about CodeLite development process and patches
srini2174
CodeLite Enthusiast
Posts: 24
Joined: Sun Nov 08, 2015 3:40 pm
Genuine User: Yes
IDE Question: C++
Contact:

[Feature Request] Handling CMake Project dependencies

Post by srini2174 »

Currently the CMake Project dependency handling is not clean. Currently it is not possible to even a normal configuration with one Application dependent on one library for the following use cases
1) I should be able to compile the library separately
2) If I compile the application without compiling the library then the library has to be compiled first and then the application has to be compiled
3) I should be able to compile the libray first and then I should be able to compile the Application (without recompiling the lib once again)
4) The project folders should be organized as include, include->PublicInterfaces, include->PrivateInterfaces, include->GeneratedInterfaces, src etc.,

The following links gives the best way to organize the projects for handling such usecases.

http://foonathan.net/blog/2016/03/03/cmake-install.html
http://foonathan.net/blog/2016/03/03/cmake-install.html
https://rix0r.nl/blog/2015/08/13/cmake-guide/

and also incorporate the best practices given in the following url

https://www.slideshare.net/DanielPfeife ... e-48475415
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: [Feature Request] Handling CMake Project dependencies

Post by eranif »

srini2174 wrote:Currently it is not possible to even a normal configuration with one Application dependent on one library for the following use cases
1) I should be able to compile the library separately
Which version of CodeLite? With my tests it is possible to build the library and then link it with the application.
Can you please upload a minimal workspace example?

About the project layout: it's up to the user to create the layout he chooses, CodeLite does not force a layout
Make sure you have read the HOW TO POST thread
srini2174
CodeLite Enthusiast
Posts: 24
Joined: Sun Nov 08, 2015 3:40 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: [Feature Request] Handling CMake Project dependencies

Post by srini2174 »

I am using the latest version i.e Codelite 10.0.1.

I have added a sample workspace which I am using it for testing. Try to compile this without using any additional include options in the Application CMakeLists.txt file. I would like to have each of the library project acting as module. So when I try to add one of the project as a dependency to an application it should be intelligent enough to get the corresponding "Include" directories, compiler flags and defines along with it. This is explained clearly in the links I had provided above.

BR
Srinivasan.B
You do not have the required permissions to view the files attached to this post.
srini2174
CodeLite Enthusiast
Posts: 24
Joined: Sun Nov 08, 2015 3:40 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: [Feature Request] Handling CMake Project dependencies

Post by srini2174 »

Sorry I have attached the workspace including the binaries. I have attached the simplified workspace. Please use this for the testing.

BR,
Srinivasan.B
You do not have the required permissions to view the files attached to this post.
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: [Feature Request] Handling CMake Project dependencies

Post by eranif »

Thanks for reporting this.
I have now fixed this in git HEAD

I planned on released CodeLite 10.0.3 tonight - so this fix will be included
After my changes to the CMake plugin, I needed to update your workspace a bit:

* For project "helloWorldApp", I add the following include path to the project settings: "$(WorkspacePath)/mylibrary/include"
* For project "mylibrary" i added the following include path to the project settings: "$(ProjectPath)/include" (your .hpp files are located there)

Run CMake for both projects and compiled successfully
Make sure you have read the HOW TO POST thread
srini2174
CodeLite Enthusiast
Posts: 24
Joined: Sun Nov 08, 2015 3:40 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: [Feature Request] Handling CMake Project dependencies

Post by srini2174 »

* For project "helloWorldApp", I add the following include path to the project settings: "$(WorkspacePath)/mylibrary/include"
This is what I would like to avoid. Suppose I have an application which is dependent on many different libraries and each of those modules have some include option, then I need to add all those as include options in the main application it would be difficult. Rather I would have the module be intelligent enough to know what are the include options as well as compiler and linker definitions to link against it then we could just use it and let CMake figure out all the dependencies on it own.

This is achieved by using target_include_directories option instead of just include_directories option. The detailed explanation is given in the links which I have provided.

With the modifications done in codelite 10.0.3 & the customization which I had done in the mylibrary CMakeLists.txt file (See the attached SimpletestWS), I was able to compile the application without adding the include directories just by adding the line target_include_directory(helloWorldApp PUBLIC mylibary) in the user section 3.
You do not have the required permissions to view the files attached to this post.
Post Reply