Packaging on Linux is rough
I was attempting to package this before I tried it out, but a few things cropped up that were causing issues.
- No option/alternative way to use system libraries. Note that literally all used libraries (except Glslang) can be found using
find_package()
, although FindVulkan requires minimum Cmake v3.7 -
These lines cause install to prefix all header install locations with junk. Example:
/usr/include/Acid/home/sum01/dev/Acid/Sources/Acid.hpp
when it should be/usr/include/Acid/Acid.hpp
Some Cmake notes:
- I recommend
include(GNUInstallDirs)
for sensible, user-overridable installation default locations instead of all of this - All references to
LIB_TYPE
in the Cmake files can be removed, even fromadd_library()
. This is becauseadd_library()
already changes to STATIC/SHARED based on whatBUILD_SHARED_LIBS
is set to. -
BUILD_TESTING
is a more common/standard name for a Cmake testing flag (it's defined in CTest) - I'm pretty sure all of this will only work for single-configuration systems, such as Make & Ninja. MSVC (and others?) use multi-configuration, which ignores
CMAKE_BUILD_TYPE
. Note you can check for#ifdef NDEBUG
as Cmake defines it automatically on release builds, at least when I've tested it. - You can do project versioning in the
project()
call, which automatically sets all the variousACID_XXX_VERSION
andACID_VERSION
vars. Example:project(Acid VERSION 0.10.0 LANGUAGES C CXX)
(specifying the used languages is also nice). - Having
ACID_INSTALL
as an option is pointless. If someone doesn't want to install they can just not use the--target install
flag when calling cmake. - The threads library from FindThreads is never actually linked against your lib. Either link against
${CMAKE_THREAD_LIBS_INIT}
or require minimum Cmake v3.1 and link against the targetThreads::Threads
- Using file globbing makes Cmake re-run everything every time, as it can't track changes. While annoying, it is recommended to put each file name in the CMakeLists.txt. I recommend using target_sources with the proper private/public settings for headers & sources.
Hopefully I'm not coming off as annoying, just trying to be helpful.