![]() Maybe a generator expression, inverse of LINK_ONLY? Target_link_libraries(tgt INTERFACE_NO_LINK lib1) Not sure on scope of implementing this (or if there is any proper means of working around it), but I assume CMake could add an option which along scope of linking, also specifies to what to link to. Some bindings generation mechanism now tries to parse the library headers as well…) (currently facing this issue myself, trying to integrate this into our project. If some consuming CMake code would like to get all include directories of myExe, those would then also include lib3’s include directories. (Same issue over at official documentation: ) target_link_libraries(myExe lib1 lib2 lib3)īoth Petrs and above examples have one specific flaw, which puts it into a hack/workaround section instead of a proper means of doing it - it sets these include directories to the “myExe” target instead of the “lib3”. The workaround mentioned by looks great, but one issue is that its actually not the same as a “header/define only linking” would be. Our use case is that we compile a couple of static libraries into a single shared library, but we still need to expose some include headers and defines down to consumers, without having the link to those static libraries again, causing issues. (As it was constantly mentioned in relation with header only libraries). I initially (wrongfully) thought that this is what INTERFACE linking did. I also think that this should be an option. ![]() So, can I somehow set an option on the MODULE library that when somebody calls target_link_libraries() on it, it will only add the headers, but will not link in any way?įorgot to mention: This is Linux only question. ![]() Problem is, I feel this is ugly, and I am making everybody who wants to add another module to the software package to add basically two targets instead of one (not every module will have both shared library and MODULE library version). Any additional module which will depend on this module will just target_link_libraries() the INTERFACE library. One way how to solve this is to create an INTERFACE library with only the PUBLIC headers and target_link_libraries() this to both the shared library and the MODULE library. But I cannot use the target_link_libraries() call to get the same functionality for MODULE library because in that case that library will be linked in the binary, which cannot be. For the normal shared library, this works well as I just set the include directory PUBLIC and every library depending on it with target_link_libraries() will transitively get the headers. From this I want to compile a shared library for normal linkage and then similar (just some different DEFINEs) MODULE library used to dynamically load the functionality as a module with RTLD_GLOBAL, so the namespace will be afterwards infused with its symbols.įor modules which depends on symbols from previous modules, I need to create an interface - set of header files. I have a set of C source files and headers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |