liboqs
liboqs copied to clipboard
Modernize the CMake
This commit aims to bring modern CMake to liboqs.
Today, add_compile_options
is widely used for settings compiler flags.
However, this way of settings flags pollutes the global namespace of CMake,
making harder for other projects to embed liboqs.
Moreover, some redundant code have been refactored. This simplify some build configuration and make the CMake scripts more readable.
Here is a list of functions this commit added:
- oqs_define_architecture: simplify the detection of the processor and the way for adding a new supported architecture
- oqs_test_c_flag: test a compiler flag on the current C compiler, if it is supported
- oqs_add_c_flags: add flag(s) to a specific target, with some policies like REQUIRED/OPTIONAL and PUBLIC/PRIVATE
- oqs_add_sanitizers: add a sanitizer option (address, leak, thread) The list of sanitizers is then applied using oqs_apply_sanitizers
- oqs_add_ld_flags: add a linker flag with a chosen policy PUBLIC/PRIVATE
Finally, some variables have been prefixed by OQS_ (like OQS_ARCH_)
~* [ ] Does this PR change the input/output behaviour of a cryptographic algorithm (i.e., does it change known answer test values)? (If so, a version bump will be required from x.y.z to x.(y+1).0.)~ ~* [ ] Does this PR change the the list of algorithms available -- either adding, removing, or renaming? (If so, PRs in OQS-OpenSSL, OQS-BoringSSL, and OQS-OpenSSH will also be required by the time this is merged.)~
Thanks for your contribution! It's a very good goal to have liboqs
be more easily "embeddable" into other cmake
driven projects. The "OQS_" namespacing prefixing also makes sense. Will you also update the other "CMakeLists.txt" files suitably? e.g., the tests
directory contains more add_compile_options
etc....
Hello,
Yes, I plan to update the CMakeLists.txt
under the tests
directory.
However, I am not sure if I can modify the CMakeLists.txt
s related to kem
and sig
namespaces (like /src/kem/bike/CMakeLists.txt
), because those files seems to be imported. I wanted to ask someone before doing it, so if it is fine to you, I will modify them too.
Also, I am not familiar with CircleCI, I do not know why the build is not autorized, do you have an idea ?
Yes, I plan to update the CMakeLists.txt under the tests directory.
Thanks in advance!
However, I am not sure if I can modify the CMakeLists.txts related to kem and sig namespaces (like /src/kem/bike/CMakeLists.txt), because those files seems to be imported. I wanted to ask someone before doing it, so if it is fine to you, I will modify them too.
I'd say OK to go ahead as the changes seem to be rather syntactic (using the newly introduced functions), so any future algorithm update on those files should be straightforward. But asking @jschanck and @dstebila for their opinion to get a more well-founded answer.
Also, I am not familiar with CircleCI, I do not know why the build is not autorized, do you have an idea ?
Yes. Those builds are intentionally restricted to team members for security reasons. You could run tests locally using circleci local execute --job <jobname>
after installing circleci CLI.
Yes, I plan to update the CMakeLists.txt under the tests directory.
Thanks in advance!
However, I am not sure if I can modify the CMakeLists.txts related to kem and sig namespaces (like /src/kem/bike/CMakeLists.txt), because those files seems to be imported. I wanted to ask someone before doing it, so if it is fine to you, I will modify them too.
I'd say OK to go ahead as the changes seem to be rather syntactic (using the newly introduced functions), so any future algorithm update on those files should be straightforward. But asking @jschanck and @dstebila for their opinion to get a more well-founded answer.
It is fine to edit any of the CMakeLists.txt files in this project, we aren't importing CMakeLists.txt from anywhere else. Some of them (e.g., src/kem/kyber/CMakeLists.txt) however are generated using some code generators under oqs_scripts
. It's probably easiest for you if you make the changes in one or two of the src/kem/*/CMakeLists.txt
and one or two of the src/sig/*/CMakeLists.txt
, and then we can apply those to the code generator templates which should take care of the rest.
Hello,
It is fine to edit any of the CMakeLists.txt files in this project, we aren't importing CMakeLists.txt from anywhere else. Some of them (e.g., src/kem/kyber/CMakeLists.txt) however are generated using some code generators under oqs_scripts. It's probably easiest for you if you make the changes in one or two of the src/kem//CMakeLists.txt and one or two of the src/sig//CMakeLists.txt, and then we can apply those to the code generator templates which should take care of the rest.
Thank your for the details. I will have a look on these code generators.