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

[feature] Define namespaces for generated entities, such as exported CMake targets #7385

Closed
1 task done
TimSimpson opened this issue Jul 19, 2020 · 3 comments
Closed
1 task done

Comments

@TimSimpson
Copy link
Contributor

It is sometimes desired to change the namespace used for the targets created by the various CMake generators so they can match the targets created by naming schemes outside of Conan (such as the built in find modules or system installed packages).

One way to tackle this problem would be to use the filename attribute to control the name given to the fine module, and then change the names attribute to be whatever the namespace needs to be.

However to emulate related packages which may share a namespace for targets generated amongst themselves it becomes necessary to share the value for cppinfo.names attribute between packages. Because that value is then no longer unique, it's necessary to use the filename attribtue to represent a "more unique" value which can be used for generated variables (see the implementation of this PR where the global variables had to incorporate the filename to work with this recreate which contains multiple packages that share a namespace).

It could simplify things to introduce a seperate attribute explicitly tied to the concept of a namespace in generated entities. This could then be used by the cmake generators.

As an example of how this attribute might be used, consider two packages from a theoretical modularized Boost:

def package_info(self):
    self.cpp_info.namespaces["cmake_find_package"] = "boost"
    self.cpp_info.components["coroutine"].names = "coroutine"
def package_info(self):
    self.cpp_info.namespaces["cmake_find_package"] = "boost"
    self.cpp_info.components["asio"].names = "asio"
@danimtb
Copy link
Member

danimtb commented Jul 20, 2020

Thanks for the proposal!

I think that namespaces could be a more easy to understand word, however, the use case you are proposing can already be achieved with something like:

def package_info(self):
    self.cpp_info.names["cmake_find_package"] = "boost"
    self.cpp_info.components["coroutine"].names["cmake_find_package"] = "coroutine"

and

def package_info(self):
    self.cpp_info.names["cmake_find_package"] = "boost"
    self.cpp_info.components["asio"].names["cmake_find_package"]  = "asio"

the only thing missing IMO to achieve full integration is #7254, so I'd rather have that first and then evaluate if a namespace attribute is really needed in case it makes things easier 😄

@TimSimpson
Copy link
Contributor Author

@danimtb After some more thinking I agree that either approach is acceptable.

@jgsogo
Copy link
Contributor

jgsogo commented Aug 3, 2020

Feature for filenames has been merged, this is no longer needed: #7320

Thanks!

@jgsogo jgsogo closed this as completed Aug 3, 2020
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

3 participants