-
Notifications
You must be signed in to change notification settings - Fork 65
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
Support exported targets #40
Comments
Hi! I am currently working on exporting targets and creating appropriate files for library installation. I am not a cmake expert. So I think it will take a few days to figure out how to create proper cmake files. But I wanted to note that library target is called
or
|
Hi! Thank you for the prompt response. By digging a bit on what happens during the configuration process, I figure out that upon creation of the export targets in my project, cmake complains that libfort lacks one. The first strategy you suggested works for me, as long as I don’t export targets by myself. I am not a cmake expert either, so I may be missing something… Since it took several days for me to figure out the proper way to support exported targets, let me suggest you how you can do it. Actually, in the end it is pretty straightforward. Your CMakeLists.txt file should contain the following lines after target creation (via add_library or add_executable):
with the standard definitions Adding a The
This is, to my current understanding, what should be done. This should just work. :) Hope it helps! Best, |
Hi! Sorry for keep you waiting. find_package(libfort)
target_link_libraries(mylib libfort::fort) Also added some simple checks to CI to check how library is installed and used by other libraries. If something is still incorrect or doesn't work as expected feel free to write comments. As I understand what I've done and tested is not particular you case because you don't install libfort but use |
Hi! I am glad that it helped you. You are right, I mixed some things, but I actually need both methods... ;) As soon I have time to test myself, I will do! |
I have a C++ project using the CMake build system. I tried to link to libfort with
add_subdirectory(…)
+target_link_libraries(mylib libfort)
but cmake complains as it does not export targets. Indeed, there is noinstall(export )
for targets with CMake configuration files.It would be possible to support also exported targets for use in an external project?
Thanks in advance for any help!
The text was updated successfully, but these errors were encountered: