CMake - is there a way to check if testing is enabled? - testing

I believe I found a piece of code that did just that, but with the documentation of CMake being so poor, I can't seem to find it anymore.
In short: is there something like:
if(testing_enabled)
I can use in CMakeLists?

I guess you're thinking of the BUILD_TESTING option which is enabled by doing:
include(CTest)
and is ON by default.

You can try to check the option CMAKE_TESTING_ENABLED:
if(CMAKE_TESTING_ENABLED)
do_your_job_here()
endif()

Related

GNU Radio missing Osmocom. Cant even build it to install

I am trying to follow along with some Youtube tutorials by the maker of HackRF and when using GNU Radio it seems they no longer have Osmocom, or WX blocks. So I go to the repo found here https://github.com/osmocom/gr-osmosdr/tree/master , also note they dont have an "issues" tab to ask questions in. Anyways I follow the instructions and get this failure:
CMake Error at /usr/lib/cmake/pybind11/pybind11Tools.cmake:165 (add_library):
Target "osmosdr_python" links to target "sndfile::sndfile" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
Call Stack (most recent call first):
/usr/lib/x86_64-linux-gnu/cmake/gnuradio/GrPybind.cmake:261 (pybind11_add_module)
python/bindings/CMakeLists.txt:28 (GR_PYBIND_MAKE_OOT)
CMake Error at lib/CMakeLists.txt:51 (add_library):
Target "gnuradio-osmosdr" links to target "sndfile::sndfile" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
So I am not sure where to go from here. Is there a replacement to Osmocom? I noticed a "soapy" source called HackRF but it is so basic compared to the Osmocom one. I dont really understand how GNURadio works but nerfing a feature that is documented all over the internet in GNU Radio tutorials seems odd.
Any ideas?
Yes, gr-soapy is the what I'd recommend you use. It's not a "replacement", it's an alternative. But unlike gr-osmosdr (which was never part of GNU Radio), it's part of modern GNU Radio.
Your youtube tutorials must be really outdated if they still use WXGui (we've started telling people WXGUI was no longer maintained and will be removed about 10 years ago). That's a bad start. Instead, try to go through the official GNU Radio Academy at https://tutorials.gnuradio.org
but it is so basic compared to the Osmocom one
What feature that the HackRF actually has and that is useful to you are you missing?

Generate Lint targets using cmake (Flexelint/Linux)

I am working on a C/C++ product that only builds in the Linux environment. It is a massive code base and generating lint targets manually is going to be incredibly painful. I know that you can link Lint into cmake so cmake generates these targets for you while it builds the code. Cmake has a macro called add_pc_lint (https://cmake.org/Wiki/PC-Lint) which does this for you. I wanted to know if there is something similar that could be used for Flexelint?
I currently have a PC-Lint license and wanted to ask this question before spending $998 on a Flexelint license. Thanks!
FlexeLint and PC-lint share the same manual so I'm pretty sure they are fully compatible on the command line. You should be able to use the same make files for both, or with minor changes. Otherwise they do offer a 30-day money-back guarantee.
Another option might be to run PC-lint under Wine. I tried this once and I got it working, but then I never used it much so I'm not sure how well it worked.
So I did get a FlexeLint license yesterday and now I am trying to integrate it into my CMakeLists. I am looking at the source code of cmake's add_pc_lint function and trying to modify it to work for FlexeLint. If anyone has played around with it before, please comment. The FlexeLint manual is not at all helpful.

Warn-as-error for MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved

After I have fixed this warning, how can I make it an error, so it doesn't slip in again?
msbuild /p:TreatWarningsAsErrors doesn't work
No happy answer to give you here. The TreatWarningsAsErrors property only affects the C# and VB.NET compiler (not C++), it determines the value of their /warnaserror command line option.
But MSB3277 is generated by an MSBuild task, ResolveAssemblyReference, its internal LogResult() method generates the diagnostic. The only property the class has that helps treat warnings as errors conditionally is WarnOrErrorOnTargetArchitectureMismatch, not what you are trying to achieve. You can have a look-see for yourself with a decompiler, look at C:\Program Files (x86)\MSBuild\12.0\Bin\Microsoft.Build.Tasks.v12.0.dll. The resource name for the localized MSB3277 message is "ResolveAssemblyReference.FoundConflicts".
So only way to get ahead here is to write a little utility that parses the log file and looks for the warning.
You can use the generic mechanism MSBuildTreatWarningsAsErrors or <MSBuildWarningsAsErrors>MSB3277</MSBuildWarningsAsErrors> (introduced in #1928) to accomplish this.
credit: rainersigwald
Run Update-Package via Package Manager Console, this will fix MSB3277, what it does it reinstall all the packages and all related assemblies they come with to the highest version possible.
More info on official docs https://learn.microsoft.com/en-us/nuget/consume-packages/reinstalling-and-updating-packages
It looks like the /warnaserror will promote all msbuild warnings to errors:
TreatWarningsAsErrors vs /warnaserror

how can i suppress all compiler and code analysis warnings from msbuild at the command line?

This has been asked, but wasn't answered. The answer (use /warn:1) doesn't work for msbuild.exe, only csc.exe. Perhaps I'm missing something between csc and msbuild?
I'd like to suppress all compiler warnings and code analysis warnings (e.g. "The variable 'variableNameHere' is assigned but its value ..." or Code Analysis Warning : CA1805 : Microsoft.Performance : ...) when I'm using command line msbuild. I don't want to alter the solution file. There are several hundred warning messages in the very large solution that I'm building -- fixing them is far out of scope for my project.
I tried /v:quiet but that didn't work.
Is there any way to do this via the command line?
Update: this:
C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe C:\Dev\ReallyBigSolution.sln /p:NoWarn=true /p:NoWarn=CA1031
Absolutely doesn't work. I still get hundreds of warnings, including the one I specifically blocked (CA1031).
Using /p:RunCodeAnalysis=Never or /p:RunCodeAnalysis=false apparently doesn't suppress code analysis warnings or errors.
Can use nowarn flag on the compiler, which corresponds to <NoWarn> property in the .csproj file. So maybe msbuild /p:NoWarn="37;68" will turn off those warning numbers (haven't tried it).
Or use
http://msdn.microsoft.com/en-us/library/13b90fz7.aspx
to turn off warnings altogether. I don't know the property name offhand, try /p:Warn=0.
Edit: read the comments toward the end; seems like really getting rid of all these warnings isn't possible.
I know this is an old post but it got me on the right track and by adding the following to my msbuild call it suppressed all of the warnings and output as it built the project. I have this in a batch file so the only output I get I believe are the end results and any messages I prompt with echo. The secret was in the /clp switch. So I looked that up and put in all of the ones that supress output. Each one got rid of more but there were still the yellow warnings coming up and when I added the ErrorsOnly switch, there was no more output.
call msbuild /clp:NoSummary;NoItemAndPropertyList;ErrorsOnly /verbosity:quiet /nologo
Try this:
msbuild.exe C:\Dev\BigSolution.sln /p:WarningLevel=0 /p:RunCodeAnalysis=false
I have tried this and cannot suppress the warnings either, unless I list them out on the /NoWarn property for msbuild.exe
http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/96b3ea2e-92ed-4483-bbfe-a4dda3231eb9
According to this, it cannot be suppressed.
Looks like it is not possible...
Warnings with MSB prefix are thrown by
MSBuild. Currently, we can't suppress
MSBuild warnings.

Where can I browse the sourcecode for libc online (like doxygen)

Sometimes I want to look up the implementations of functions in the stdlib, I've downloaded the sourcecode, but it's quite messy.
Just greping is not really suitable because of the many hits.
Does anyone know a webpage doxygen style that has the documentation.
The same goes for the linux kernel.
Thanks
You should check if your distribution is using the vanilla GLIBC or the EGLIBC fork (Debian and Ubuntu have switched to EGLIBC EDIT: they switched back around 2014).
Anyway, the repository browser for GLIBC is at http://sourceware.org/git/?p=glibc.git
http://code.woboq.org/userspace/glibc/, posted by #guruz below, is a good alternative.
The source is a bit complicated by the presence of multiple versions of the same files.
How about this for libc documentation? And perhaps this for the kernel? There is also Google Code search; here is an example search.
More on Google Code Search You can enter search queries like this: package:linux-2.6 malloc for any references to malloc in the linux-2.6 kernel.
Edit: Google Code search is now shut down. But you can access the git repo at http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git and it has search as well.
You can try http://code.woboq.org/userspace/glibc/
It has nice navigation/hilighting similar to an IDE.
To help navigate the source to glibc, perhaps try something like ctags or cscope?
Note: I get dumber every time I look at the glibc source, so please be careful! :)
If you are using GNU C (glibc), the functions (beyond the GNU extensions) follow the POSIX standard as far as their arguments, implementation, failure and return values. If you want to peek under the hood of static members, you'll have to look at the code.
Every push (that I can remember) to try and adopt something like Doxygen for glibc was rejected for the following reasons:
Redundant, POSIX already documents almost everything thats exposed, as well as man and info pages.
Too much work initially
More work for maintainers
As far as the kernel goes, Linux does use a system very similar to Doxygen called Kerneldoc.
You can also get actual Doxygen-generated docs from http://fossies.org/dox/glibc.