[SOLVED] Building a self-contained unix executable (CMake)?
-
- Posts: 19
- Joined: Sat Aug 21, 2021 11:16 pm
Re: Building a self-contained unix executable (CMake)?
Than
Last edited by mangoesfruit on Tue Aug 31, 2021 4:47 pm, edited 1 time in total.
Re: Building a self-contained unix executable (CMake)?
If you want to use system libraries then find_library is good because it can automatically search for the library in the "usual" places where libraries are installed. Which can be different depending on OS - so it allows creating CMakefiles which work for people who may compile a project on some completely different system.
But if you build libraries yourself you have to directly set the path as CMake can't know where you put them (as you can put them anywhere you like). So link_directories is needed in that case. If you set find_library it would go back to searching for system libraries first, which is not what you want. But it also means if you ever open source the project or pass the source on to other people you have to put the libraries you used into your project as well or other people will have a harder time compiling it.
It's something Unix people frown upon a bit - especially distributions. But personally I prefer working that way a lot as it tends to make maintenance rather easier as you know exactly which library versions you used to get your project running. There's more advantages/disadvantages, but in short - for your case find_library is probably the best.
But if you build libraries yourself you have to directly set the path as CMake can't know where you put them (as you can put them anywhere you like). So link_directories is needed in that case. If you set find_library it would go back to searching for system libraries first, which is not what you want. But it also means if you ever open source the project or pass the source on to other people you have to put the libraries you used into your project as well or other people will have a harder time compiling it.
It's something Unix people frown upon a bit - especially distributions. But personally I prefer working that way a lot as it tends to make maintenance rather easier as you know exactly which library versions you used to get your project running. There's more advantages/disadvantages, but in short - for your case find_library is probably the best.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 19
- Joined: Sat Aug 21, 2021 11:16 pm
Re: Building a self-contained unix executable (CMake)?
thanks f
Last edited by mangoesfruit on Tue Aug 31, 2021 4:47 pm, edited 1 time in total.
-
- Posts: 19
- Joined: Sat Aug 21, 2021 11:16 pm
Re: Building a self-contained unix executable (CMake)?
I have trie
Last edited by mangoesfruit on Tue Aug 31, 2021 4:46 pm, edited 1 time in total.
Re: [SOLVED] Building a self-contained unix executable (CMake)?
No problem, nice it works now.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm