snitch-org / snitch

Lightweight C++20 testing framework.
Boost Software License 1.0
257 stars 7 forks source link

Cmake configuration error #120

Closed victimsnino closed 1 year ago

victimsnino commented 1 year ago

Hi. With last version of snitch i'm getting following error during configuration:

[cmake] CMake Error (dev) at build/_deps/snitch-src/CMakeLists.txt:52 (set):
[cmake]   uninitialized variable 'BUILD_SHARED_LIBS'
tocic commented 1 year ago

Looks like you use cmake -B "build/" -S . --warn-uninitialized -Werror=dev or an equivalent configure preset. We can get rid of this error by providing an explicit option(BUILD_SHARED_LIBS ...). At the moment, you can get rid of this error by either changing your warnings options (remove --warn-uninitialized or -Werror=dev or add -Wno-error=dev) or explicitly defining the variable (-D BUILD_SHARED_LIBS:BOOL="ON" or -DBUILD_SHARED_LIBS=OFF). Using SNITCH_HEADER_ONLY also helps, see https://github.com/cschreib/snitch/blob/main/CMakeLists.txt.

victimsnino commented 1 year ago

I'm getting it during configuring my own project where snitch fetched during configuration. So, suppression of all cmake warnings is not an option - I want to see my own :) Fixed by defining BUILD_SHARED_LIBS but ideally, I expect, snitch should fix it by its own

cschreib commented 1 year ago

Thanks both for reporting and pinpointing the issue. I've never used CMake warning levels, so I had assumed that CMake was always defining BUILD_SHARED_LIBS (to YES or NO). Should have know better than to assume something about CMake :)

Indeed there is something we can do to fix the warning on our end, I'll prepare a PR. I might turn on these warnings in CI as well, so it doesn't happen again.

cschreib commented 1 year ago

This is now fixed in the main branch. I'll probably issue another release (1.2.1) when more fixes have accumulated.

cschreib commented 1 year ago

v1.2.1 is now released with the fix. Thanks!