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

Static and Dynamic lib #178

Closed
fvella opened this issue Jun 2, 2017 · 10 comments
Closed

Static and Dynamic lib #178

fvella opened this issue Jun 2, 2017 · 10 comments

Comments

@fvella
Copy link

fvella commented Jun 2, 2017

Hi,
any option to compile both static and dynamic lib via cmake?

@FSMaxB
Copy link
Collaborator

FSMaxB commented Jun 2, 2017

I am actually not sure how to do that with CMake.

@FSMaxB
Copy link
Collaborator

FSMaxB commented Jun 2, 2017

According to this answer on stackoverflow it requires changing the CMakeLists.txt.

I might add a new build option. Give me a few days. Otherwise pull requests welcome.

@FSMaxB
Copy link
Collaborator

FSMaxB commented Jun 2, 2017

The easiest way for now is just to build in two separate build directories. One with -DBUILD_SHARED_LIBS=On and the other with -DBUILD_SHARED_LIBS=Off.

@FSMaxB
Copy link
Collaborator

FSMaxB commented Jun 6, 2017

What exactly is your use case for this? Since adding this to the build system is quite ugly, I'd like to avoid it.

@FSMaxB
Copy link
Collaborator

FSMaxB commented Jun 6, 2017

Especially because you can get both by just building twice with different parameters. There is no problem as long as you don't try to install both.

@fvella
Copy link
Author

fvella commented Jun 6, 2017

Hi, we have an automatic wrapper for compilation (on top of cmake) and experimental evaluation of HPC libraries.
Unfortunately, I tried using two separate build directories but it is not easy to integrate/maintain since cjson is a dependency of different libraries.

@FSMaxB
Copy link
Collaborator

FSMaxB commented Jun 6, 2017

Hm. So let's add an option BUILD_SHARED_AND_STATIC_LIBS that creates shared and static libraries for cJSON and cJSON utils, but not for the tests (unity). The tests will then link against the shared library.

@FSMaxB
Copy link
Collaborator

FSMaxB commented Jun 6, 2017

With this hack applied to make it work on Windows with identical names.

Care has to be taken to not break compatibility with old CMake versions. Although not supporting this feature on older versions of CMake is fine by me.

I'll see what I can do.

@FSMaxB
Copy link
Collaborator

FSMaxB commented Jun 6, 2017

I've implemented this on the develop branch, it will be included in the next minor release.

@FSMaxB FSMaxB removed the undecided label Jun 6, 2017
@FSMaxB FSMaxB added this to the 1.6 milestone Jul 3, 2017
@FSMaxB
Copy link
Collaborator

FSMaxB commented Oct 8, 2017

This is included in 1.6

@FSMaxB FSMaxB closed this as completed Oct 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants