Automatically add all files in a folder to a target using CMake?

I am considering switching a cross platform project from separate build management systems in Visual C++, XCode and makefiles to CMake. One essential feature I need is to add automatically all files in a directory to a target. While this is easy to do with make, it is not easily doable with Visual C++ and … Read more

How do I monitor the computer’s CPU, memory, and disk usage in Java?

I would like to monitor the following system information in Java: Current CPU usage** (percent) Available memory* (free/total) Available disk space (free/total) *Note that I mean overall memory available to the whole system, not just the JVM. I’m looking for a cross-platform solution (Linux, Mac, and Windows) that doesn’t rely on my own code calling … Read more

How to execute XPath one-liners from shell?

Is there a package out there, for Ubuntu and/or CentOS, that has a command-line tool that can execute an XPath one-liner like foo //element@attribute filename.xml or foo //element@attribute < filename.xml and return the results line by line? I’m looking for something that would allow me to just apt-get install foo or yum install foo and … Read more

What is the naming standard for path components?

I keep getting myself in knots when I am manipulating paths and file names because I don’t follow a naming standard for path components. Consider the following toy problem (Windows example, but hopefully the answer should be platform independent). You have been given the path of a folder: C:\users\OddThinking\Documents\My Source\ You want to walk the … Read more

How to detect reliably Mac OS X, iOS, Linux, Windows in C preprocessor? [duplicate]

This question already has answers here: How do I check OS with a preprocessor directive? (16 answers) Closed 2 years ago. The community reviewed whether to reopen this question 3 months ago and left it closed: Original close reason(s) were not resolved If there’s some cross-platform C/C++ code that should be compiled on Mac OS … Read more