Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake Cleanup #4792

Open
2 tasks
jmayclin opened this issue Sep 20, 2024 · 0 comments
Open
2 tasks

CMake Cleanup #4792

jmayclin opened this issue Sep 20, 2024 · 0 comments

Comments

@jmayclin
Copy link
Contributor

jmayclin commented Sep 20, 2024

Problem:

  • refactor to multiple files
  • common cflags

refactor to multiple files

Our CMakeLists.txt is nearly 750 lines long. Given that CMake syntax is quite difficult to read and parse (at least for me) we should consider splitting this into multiple CMakeLists.txt files.

My suggestion is that we add four new files

  • s2n-tls/tests/CMakeLists.txt: responsible for defining common test configuration. E.g. ASAN is used by both unit and fuzz tests.
  • s2n-tls/tests/testlib/CMakeLists.txt: responsible for defining the "testss2n" target
  • s2n-tls/tests/unit/CMakeLists.txt: responsible for defining all of the unit tests
  • s2n-tls/tests/fuzz/CMakeLists.txt: responsible for defining the fuzz tests

common cflags

We have a large collection of compile options that we use for libs2n.

s2n-tls/CMakeLists.txt

Lines 138 to 141 in 2467416

target_compile_options(${PROJECT_NAME} PRIVATE -pedantic -std=gnu99 -Wall -Wimplicit -Wunused -Wcomment -Wchar-subscripts
-Wuninitialized -Wshadow -Wcast-align -Wwrite-strings -Wno-deprecated-declarations -Wno-unknown-pragmas -Wformat-security
-Wno-missing-braces -Wsign-compare -Wno-strict-prototypes -Wa,--noexecstack
)

These are general hygiene options that should be applied everywhere, but we don't have a good mechanism for doing that.

My suggestion is that we collect all of the compilation variables into S2N_COMMON_COMPILE_OPTIONS or something like that. Then we'd change the S2N_WERROR_ALL section

s2n-tls/CMakeLists.txt

Lines 143 to 147 in 2467416

if (S2N_WERROR_ALL)
target_compile_options(${PROJECT_NAME} PUBLIC -Werror)
elseif (UNSAFE_TREAT_WARNINGS_AS_ERRORS)
target_compile_options(${PROJECT_NAME} PRIVATE -Werror )
endif ()

if (S2N_WERROR_ALL)
    # because the options are public, all attached targets will inherit all of the compile options.
    # this includes unit and fuzz tests and the testlib
    target_compile_options(${PROJECT_NAME} PUBLIC -Werror ${S2N_COMMON_COMPILE_OPTIONS})
elseif (UNSAFE_TREAT_WARNINGS_AS_ERRORS)
    target_compile_options(${PROJECT_NAME} PRIVATE -Werror ${S2N_COMMON_COMPILE_OPTIONS})
endif ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants