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

conan support #802

Open
blockspacer opened this issue Jun 5, 2020 · 3 comments
Open

conan support #802

blockspacer opened this issue Jun 5, 2020 · 3 comments

Comments

@blockspacer
Copy link

Proof-of-concept https://github.com/blockspacer/llvm_tools
(MIT license)

Goal: easy install include-what-you-use with conan install command.

After conan install you will be able to use cmake find_program like so:

find_program(IWYU include-what-you-use
  PATHS
    ${CONAN_BIN_DIRS}
    ${CONAN_BIN_DIRS_LLVM_TOOLS}
  NO_SYSTEM_ENVIRONMENT_PATH
  NO_CMAKE_SYSTEM_PATH
)
if(NOT IWYU)
  message(FATAL_ERROR "IWYU not found")
endif()

Note that conan supports not only cmake (for example, scons also can be used)

See for details about conan https://docs.conan.io/en/latest/getting_started.html

@kimgr
Copy link
Contributor

kimgr commented Jul 8, 2020

@blockspacer Sounds cool. There's nothing we need to do from the upstream IWYU side, right? Feel free to package IWYU for conan.

@blockspacer
Copy link
Author

blockspacer commented Jul 20, 2020

Usage example for cmake users:

https://github.com/blockspacer/cmake_helper_utils_conan/blob/0e2ce31820fff0045d7228614afe8c084ee73af5/cmake/Findcmake_helper_utils.cmake#L2373

https://github.com/blockspacer/flextool/blob/da4cb5e7d44c7b205328923b018f5caee3282642/cmake/setup_iwyu.cmake

https://github.com/blockspacer/flextool/blob/da4cb5e7d44c7b205328923b018f5caee3282642/tools/run_tool.cmake#L366

Install IWYU (ENABLE_LLVM_TOOLS=TRUE):

cmake \
  -DEXTRA_CONAN_OPTS=\
"--profile;clang\
;-s;build_type=Debug\
;-s;cling_conan:build_type=Release\
;-s;llvm_tools:build_type=Release\
;--build;missing" \
  -DENABLE_LLVM_TOOLS=TRUE \
  -DENABLE_CLING=TRUE \
  -DENABLE_FLEXTOOL=TRUE \
  -DENABLE_FLEX_REFLECT_PLUGIN=TRUE \
  -DENABLE_SQUARETS=TRUE \
  -DENABLE_FLEX_SQUARETS_PLUGIN=TRUE \
  -DENABLE_FLEX_PIMPL_PLUGIN=TRUE \
  -DENABLE_FLEX_TYPECLASS_PLUGIN=TRUE \
  -DENABLE_FLEX_META_PLUGIN=TRUE \
  -DENABLE_FLEX_META_DEMO=TRUE \
  -P tools/buildConanThirdparty.cmake

Run IWYU:

# creates local build in separate folder and runs cmake targets
cmake -DIWYU="ON" -DCLEAN_OLD="ON" -P tools/run_tool.cmake

@blockspacer
Copy link
Author

I was stuck with IWYU could not find stddef.h issue
#679

and found that i can bundle required includes with conan package (llvm)

Now i pass to IWYU:

    -nostdinc++
    -nodefaultlibs
    -isystem${CONAN_LLVM_TOOLS_ROOT}/include/c++/v1/
    -isystem${CONAN_LLVM_TOOLS_ROOT}/lib/clang/10.0.1/include/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants