Unless your source code uses both C and C++ it is good to provide LANGUAGES in project()
For BOOL type cache variable you may prefer to use option()
Why do you add NDEBUG flag manually? Anyway, it will not work for a multi-config generator so please never do a branch like if (CMAKE_BUILD_TYPE ...
Warning flags should be used only in development and CI build. They should not be enforced on the customers.
Handling dependencies with add_subdirectory() does not scale and does not even work correctly in some cases. Please prefer using a packet manager like Conan. For more info see my talks on this subject.
You could add CTest support
Why do you force spice to be a shared library? It is better to not provide anything here and leave the choice to the user via cmake configuration command line.
There is no installation step. You probably want your library to be reused, right?
Talking about reuse it could also be distributed as a Conan package.
Why compile options and include directories a PRIVATE thus not transitive?
CMAKE_SOURCE_DIR is not a good variable to use in most cases. It points to the CMake entry point and if someone will add you as a third party dependency through add_subdirectory() the include directory will not be found
You should not explicitly provide include directories of dependencies. They should be transitively added with target_link_libraries.
The same applies to include directory of spice in test directory
according to Mateusz Pusz' feedback:
LANGUAGES
inproject()
option()
NDEBUG
flag manually? Anyway, it will not work for a multi-config generator so please never do a branch likeif (CMAKE_BUILD_TYPE ...
add_subdirectory()
does not scale and does not even work correctly in some cases. Please prefer using a packet manager like Conan. For more info see my talks on this subject.spice
to be a shared library? It is better to not provide anything here and leave the choice to the user via cmake configuration command line.PRIVATE
thus not transitive?CMAKE_SOURCE_DIR
is not a good variable to use in most cases. It points to the CMake entry point and if someone will add you as a third party dependency throughadd_subdirectory()
the include directory will not be foundtarget_link_libraries
.spice
intest
directory