Two different projects with common library in cmake - cmake

I want to create two applications with common code. Suppose to have a structure like this
root
|-libcommon
|-projA
|-projB
But without CMakeLists.txt in the root.
The main reason is that I want to package projA and projB as separate packages (not two components of one project). But as far as I understand you can create only one package using CPack. Is I'm correct with CPack? And if so, how can I resolve my situation? Do I need to install libcommon system-wise?

Related

CMake building a project for two different targets with different build-tools

I have a project that I compile to two very different target (desktop and web-assembly), using a different environment, different compiler and different parameters.
So far I have two CMakeLists files, building into two different folders. But that forces me to copy-paste the list of source files, some configuration about the version etc. And they cannot be in the same folder because of the fixed name for CMakeLists files.
I would like to have a common cmake file that contains all the shared project configuration, while configuring the build differently depending on an option for example, and including one of the two sub-cmake files that would be specific to each build.
What is the modern-cmake strategy to do this?
I see answers about debug/release builds or shared/static but I fail to understand one best practice of how to define different targets+buildchains depending on an option.
Should I use include and an option?
Is passing the shared configuration and source files as variables a good practice?

CI build failed in case project reference is from another .net solution

I have two independent .net projects. One is like a project which is baiscalliy to process invoice and another project is something which I am calling as common as I am keeping all sharable/reusable code under that.
Now any project can consume this common-project by adding it via add Existing project option so that source code will not move to consumer project which is Invoice management in my case.
Now if I add common project as reference and run my CI pipeline its failed as its not able to find the path of common project which is obvious as it may be different from my local machine to build server.
Now the solution that I am aware of are below :
Make common as Nuget package and use it under invoice management.
Build common project dll at some centralized file server and give that path in Invoice management
for reference instead of absolute path.
Both solutions are not simple to implement so I am looking for any better quick solution for the situation where project setup is like this and CI build has to execute.
The best would be actually reference via NuGet package. However, there is a third option which I do not recommend. You can use multiple repository pipeline. You will checkout there two repositories. In thi case you have to mimic folder structure wich you will get on AzureDevops. Otherwise build will fail as it will not find the references.

CMake: How to pack a target/file into multiple packages in Linux?

I'm working on a project which generates quite a few executables, libraries
and configs, they need to be packed into different packages for deployment.
The problem is, the inclusion of those targets/files is not mutual
exclusive. One target/file can belong to multiple packages.
I'm using CMake 2.8.9 and trying CPack. I know it's kind of doable with
install types. But my platform is Ubuntu, so on Archives/Debs are
acceptable and they don't seem to support that.
With components/groups/parent groups it seems only possible to pack one
target/file into one component/group.
Is there any way out of this?
Thanks
Why not use components? If I got it right, you want to generate more then one deb from your project.
I am achieving that like this:
SET(CPACK_DEB_COMPONENT_INSTALL 1)
INSTALL(TARGETS buildA DESTINATION lib/myproj COMPONENT main)
INSTALL(TARGETS buildB DESTINATION include/myproj COMPONENT dev)
When I call make package I get two deb's with the suffixes main and dev containing only what I specified with the INSTALL() statements.
Well, I'll answer it myself for convinience of late comers: from CMake mail list, I got the answer: with cmake 2.8.9 or earlier (so far), run CPack multiple times with different component settings. That's a bit adhoc but does the job.

What is the best way of creating several rpm's (deb's) packages in one CMake project?

I need to create several different rpm's (deb's) (with different list of files) from one CMake project.
What is the best way for this? Can some one suggest some project (CMakeList.txt) with such options?
You will want to use CPack.
Packaging With CPack

How can I use maven to build a tarball for a project?

OK, lemme set the stage. I have a parent pom, project_maven, that contains 3 modules in its POM, project_common, project_explode, and project_client. project_client has dependencies on both project_common and project_explode. project_client also contains an /ext directory, which contains third-party executables, scripts, etc.
In our current Ant build of the project, there is a target, build-client-tarball, that copies the /ext directory to the build directory, copies the project_common.jar and project_explode.jar files into specific locations in the build dir, and tarballs the whole thing.
I'd like to duplicate this behavior in maven without having to resort to calling the ant tasks. From what I can tell, it looks like the assembly plugin might be the way to go, but I'm having trouble figuring out how to get it to work. Seems like I would need a custom assembly descriptor? Anybody have any boilerplate or examples I can work from?
You need to use the Maven Assembly plugin. It's worth the effort to investigate it. It will do exactly what you need.
You can use it to include dependencies and sources. Have a look at this link. There're a bunch of sample assembly descriptors there. You need to define a format tar in order for it to produce a tar for you. In addition, you also need to define <dependencySets/> in order to include the modules you mentioned.