At the moment, the Makefile generated by cmake does not include an install rule.
To make packagers' lives a lot simpler, it would be great if this could be added.
It seems like it should be as simple as making a few calls to install() in the CMakeLists.txt files to put everything where it needs to go.
libui itself needs to be installed, as well as ui.h and ui_(current OS).h. Do the other OS files need to be installed as well? And how would I specify the headers?
The library needs to be installed (e.g., libui.so.0 and symlinks if applicable鈥攅.g., libui.so), and the headers need to be installed (that are relevant to the system).
At some point (perhaps this should be a separate issue or a PR), but having a pkg-config file would be helpful for people.
As for how to "specify the headers", I suppose I am not sure what you mean.
I meant what cmake syntax do I use to do this
Looks like the cmake docs are the best place to check.
I am not personally that familiar with cmake; my understanding of what is necessary to complete this comes from inferences drawn by looking at other projects that have done the same thing.
CMake should be installed with a ProjectConfig.cmake file that allows one to find and include it with find_package(libui). There is a tutorial for how to do this here https://cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file
That would be good to have. I use xgo to cross compile libui for each OS and the utility assumes that the libraries are properly installed via make install. Sadly, libui doesn't provide the target for install. Would be nice to have it.
I would help out but I mainly program in Java and have zero experience with cmake and make.
_Edit:_ As far as I understand, one needs to copy the resulting library file and symlink it if necessary alongside the ui_OS.h file and the general ui.h file.
Would be nice if someone could do this :)
This is a pretty simple task. I can try to tackle it in the the coming week or so.
Hi I forgot this wasn't solved yet. Why did I wait on it?
Oh right, I need to figure out what and how needs to be installed. I'll read over this report again and see what I can do. Feel free to contribute in the meantime.
Okay, so will this be sufficient?
install(TARGET ${_LIBUINAME}
INCLUDES DESTINATION include
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
? Will the include stuff only work if I have a FRAMEWORK instead of a LIBRARY? It should already include only what we need.
Can cmake be used to generate the pkg-config for us? The Nix folks told me that it'd be best if I didn't provide one in libui itself, since the pakcage maintainers decide where to put everything ultimately...
After reading the cmake docs, I'm still unsure what I need to change to produce a ProjectConfig.cmake file, especially given how this build setup is configured.
To be honest, I have no idea on how cmake works. Maybe someone with more knowledge can provide better help, @mpiannucci @hugows @pcwalton @HalosGhost
Take a look here https://cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file . The process of creating the project configs and installing the files is covered better than I can explain it. Basically, you need to create a ProjectConfig template file, send it to cmake, which will generate the finished version that users can find for their projects.
However, because this project is being used more for the bindings, it is probably substantial to just install the headers and libraries in <PREFIX> as @andlabs wrote above.
Okay, so I tried
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb1696d..2e2d05b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -217,3 +217,8 @@ macro(_add_exec _name)
endmacro()
add_subdirectory("test")
add_subdirectory("examples")
+
+install(TARGETS ${_LIBUINAME}
+ PUBLIC_HEADER DESTINATION include
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
and while it does copy the object files, it does not copy the headers. It seems that I do in fact need to make this a FRAMEWORK project, which I do not want (it should be just a flat shared library on OS X). What now? Do I have to explicitly name out the header files in a install(FILES)?
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb1696d..8560a5e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -217,3 +217,15 @@ macro(_add_exec _name)
endmacro()
add_subdirectory("test")
add_subdirectory("examples")
+
+install(TARGETS ${_LIBUINAME}
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
+install(FILES ui.h uitable.h DESTINATION include)
+if (APPLE)
+ install(FILES ui_darwin.h DESTINATION include)
+elseif (WIN32)
+ install(FILES ui_windows.h DESTINATION include)
+else()
+ install(FILES ui_unix.h DESTINATION include)
+endif()
Possibly, only tested on unix ...
@krakjoe I just tested it on OS X and it looks like it properly installs the headers and library files.
The switch to meson has happened and I've set up an install rule there; closing.
Most helpful comment
Possibly, only tested on unix ...