liboqs icon indicating copy to clipboard operation
liboqs copied to clipboard

Use modern CMake syntax

Open vsoftco opened this issue 2 years ago • 6 comments

Instead of depending on make/msbuild etc, we should use only modern cmake and ctest, such as

cmake -B build -DCMAKE_FLAGS...
cmake --build build --parallel 4 [--target ... ]
ctest --test-dir build

This is platform-independent and saves a lot of headaches, and completely removes make and msbuild explicit dependencies. See https://github.com/open-quantum-safe/liboqs-cpp/blob/main/.github/workflows/cmake.yml for an example.

vsoftco avatar Jun 09 '23 20:06 vsoftco

So cmake --build build would also replace ninja?

I don't mind, though I haven't had any trouble with our current build sequence.

The first two commands work fine for me, but ctest --test-dir build doesn't do anything. I'm guessing this is because our test suite is under a custom target (run_tests) rather than some default name?

dstebila avatar Jun 11 '23 18:06 dstebila

Yes, it'll replace ninja, and is completely platform-independent. I'll look into the test suite...

cmake --build build --target run_tests runs the test suite, but it'll be preferably to be able to use ctest instead.

vsoftco avatar Jun 12 '23 01:06 vsoftco

I like the platform-independence aspect (particularly looking at oqs-provider for Windows right now). What makes me wonder, though, is how this will impact build+test/CI runtime: ninja always nicely & automatically takes the maximum amount of CPUs available. The proposal above seems to require a hardcoded number of CPUs (that may or may not be available, i.e., run too slow if more CPUs were available and may overwhelm the machine if too many are spec'd).

baentsch avatar Jun 12 '23 07:06 baentsch

I did --parallel without a number, and it seemed to use the maximum number of CPUs on my machine, running about as fast as ninja does.

dstebila avatar Jun 12 '23 12:06 dstebila

@dstebila Thanks, that's good to know, I didn't know we can use the flag without a number

vsoftco avatar Jun 12 '23 14:06 vsoftco