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

[POC] cmake: Add option to run include-what-you-use with compiler #1204

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ option(SECP256K1_BUILD_EXHAUSTIVE_TESTS "Build exhaustive tests." ON)
option(SECP256K1_BUILD_CTIME_TESTS "Build constant-time tests." ${SECP256K1_VALGRIND})
option(SECP256K1_BUILD_EXAMPLES "Build examples." OFF)

if(CMAKE_VERSION VERSION_GREATER 3.2)
option(SECP256K1_ENABLE_IWYU "Run include-what-you-use (IWYU) with the compiler." OFF)
if(SECP256K1_ENABLE_IWYU)
find_program(INCLUDE_WHAT_YOU_USE_COMMAND NAMES include-what-you-use)
if(NOT INCLUDE_WHAT_YOU_USE_COMMAND)
message(FATAL_ERROR "SECP256K1_ENABLE_IWYU is ON but include-what-you-use is not found.")
endif()
set(CMAKE_C_INCLUDE_WHAT_YOU_USE "${INCLUDE_WHAT_YOU_USE_COMMAND}")
endif()
endif()

# Redefine configuration flags.
# We leave assertions on, because they are only used in the examples, and we want them always on there.
if(MSVC)
Expand Down Expand Up @@ -269,6 +280,9 @@ get_directory_property(definitions COMPILE_DEFINITIONS)
string(REPLACE ";" " " definitions "${definitions}")
message("Preprocessor defined macros ........... ${definitions}")
message("C compiler ............................ ${CMAKE_C_COMPILER}")
if(SECP256K1_ENABLE_IWYU)
message("Run IWYU with the compiler ............ ${CMAKE_C_INCLUDE_WHAT_YOU_USE}")
endif()
message("CFLAGS ................................ ${CMAKE_C_FLAGS}")
get_directory_property(compile_options COMPILE_OPTIONS)
string(REPLACE ";" " " compile_options "${compile_options}")
Expand Down