Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake command to only build include files #12

Open
lattice0 opened this issue Apr 26, 2018 · 4 comments
Open

Cmake command to only build include files #12

lattice0 opened this issue Apr 26, 2018 · 4 comments

Comments

@lattice0
Copy link

I'm working on top of https://github.com/Ansersion/myRtspClient. It doesn't have cmake, I'm adding so it can work on Android. The problem is that in order for me to link it together with with JRTPLIB, I need to build with JRTPLIB source files. But for now, when I add_subdirectory the jrtplib in the myRtspClient's cmakelists file, it will build the headers but in the end it will also build the entire jrtplib, which is unnecesary.

Wouldn't it be great to have a way to build only the include files?

@lattice0
Copy link
Author

lattice0 commented Apr 26, 2018

In fact, the only problem I'm having is that the generated .h files are going somewhere else that I can't access on my main project which uses yours by doing add_subdirectory. I just needed the include files to build mine. The simplest solution I can think of is adding the line

configure_file("${PROJECT_SOURCE_DIR}/src/rtptypes.h.in" "${PROJECT_BINARY_DIR}/src/rtptypes.h")

but with PROJECT_SOURCE_DIR instead of PROJECT_BINARY_DIR and for the other two configuration files add too.

Do you have a better idea?

@j0r1
Copy link
Owner

j0r1 commented May 1, 2018

A few thoughts:

  • If you only need the headers, then you need to take care that the settings they use match those of the compiled library (so the rtpconfig.h should contain the settings that were used when actually compiling the library)
  • In my opinion it's not a good idea to move the generated rtptypes.h and rtpconfig.h to the source directory: it would definitely mess things up when using different builds (with different settings) based on the same sources

But I don't really understand the problem. If I understand correctly, you need the headers, but not the compiled library in your project, right? Then where is the compiled library coming from? (You'll still need to link against it)

@lattice0
Copy link
Author

lattice0 commented May 2, 2018

For the purpose of compiling and installing JRTPLIB I think the cmake file is great, the files are going to be installed into the system. If I want to compile a library that uses yours, like https://github.com/Ansersion/myRtspClient, I'd just include the installed header files from the system. However the compilation will use the headers generated for my system, not for other systems. That's ok in general but not for Android I guess.

In order to build for Android, there's no way of installing the headers into the system and then using them to build my project. The way I'm doing right now is to add JRTPLIB as a subdirectory to be built before the main project. However, the header files generated by JRTPLIB compilation are needed, so I added a dependency. I had to add a dependency to the shared library target, but it could be a simple dependency to the configure files (if possible).

Anyways, even for the shared library target I'm not being able to get the genrated headers because they are installed into a custom folder of the android project, but that has nothing to do with the main problem of needing the header files to build projects based on yours.

Do you have a better idea?

@j0r1
Copy link
Owner

j0r1 commented May 3, 2018

You say

In order to build for Android, there's no way of installing the headers into the system and then using them to build my project.

But why not? Why not build and install the library and header files in another location, and include those in your project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants