为什么Cmake+包括您使用的内容不打印任何输出?
我已经安装了您使用的内容。 我克隆了存储库,检查了标签0.18并编译了。
$ include-what-you-use -v
clang version 14.0.0 (Fedora 14.0.0-1.fc36)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/12
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/12
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
error: unable to handle compilation, expected exactly one compiler job in ''
我将该工具集成到cmake中:
find_program(iwyu_path NAMES include-what-you-use iwyu)
if(iwyu_path)
message("Found iwyu")
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path})
endif()
我运行cmake:
$ CC="clang" CXX="clang++" cmake -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use ..
-- The CXX compiler identification is Clang 14.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Found iwyu
-- Configuring done
-- Generating done
-- Build files have been written to: /home/...
并编译:make
,但是我在终端中没有看到任何IWYU输出。 为什么这样?
制造的输出:
[steddy@nowhere build]$ CC="clang" CXX="clang++" cmake -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use ..
-- The CXX compiler identification is Clang 14.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found nlohmann_json: /usr/local/lib64/cmake/nlohmann_json/nlohmann_jsonConfig.cmake (found suitable version "3.10.5", minimum required is "3.10.5")
Found iwyu
-- Configuring done
-- Generating done
-- Build files have been written to: /home/steddy/CLionProjects/barnes-hut/build
[steddy@nowhere build]$ make VERBOSE=1
/usr/bin/cmake -S/home/steddy/CLionProjects/barnes-hut -B/home/steddy/CLionProjects/barnes-hut/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/steddy/CLionProjects/barnes-hut/build/CMakeFiles /home/steddy/CLionProjects/barnes-hut/build//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
make -f src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/build.make src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/depend
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
cd /home/steddy/CLionProjects/barnes-hut/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/steddy/CLionProjects/barnes-hut /home/steddy/CLionProjects/barnes-hut/src/barnes_hut /home/steddy/CLionProjects/barnes-hut/build /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
make -f src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/build.make src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/build
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 6%] Building CXX object src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/body.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/body.cpp.o -MF CMakeFiles/barnes_hut_lib.dir/body.cpp.o.d -o CMakeFiles/barnes_hut_lib.dir/body.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/body.cpp
[ 12%] Building CXX object src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/node.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/node.cpp.o -MF CMakeFiles/barnes_hut_lib.dir/node.cpp.o.d -o CMakeFiles/barnes_hut_lib.dir/node.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node.cpp
[ 18%] Building CXX object src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/node_json.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/node_json.cpp.o -MF CMakeFiles/barnes_hut_lib.dir/node_json.cpp.o.d -o CMakeFiles/barnes_hut_lib.dir/node_json.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node_json.cpp
In file included from /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node_json.cpp:1:
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node.h:42:33: warning: inline function 'bh::Node::top_left' is not defined [-Wundefined-inline]
[[nodiscard]] inline Vector2f top_left() const;
^
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node_json.cpp:33:27: note: used here
{"top_left", {node.top_left().x(), node.top_left().y()}},
^
In file included from /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node_json.cpp:1:
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node.h:46:30: warning: inline function 'bh::Node::length' is not defined [-Wundefined-inline]
[[nodiscard]] inline float length() const;
^
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node_json.cpp:34:24: note: used here
{"length", node.length()},
^
2 warnings generated.
[ 25%] Building CXX object src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/force.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/force.cpp.o -MF CMakeFiles/barnes_hut_lib.dir/force.cpp.o.d -o CMakeFiles/barnes_hut_lib.dir/force.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/force.cpp
In file included from /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/force.cpp:4:
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node.h:46:30: warning: inline function 'bh::Node::length' is not defined [-Wundefined-inline]
[[nodiscard]] inline float length() const;
^
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/force.cpp:44:14: note: used here
if (node.length() / distance < OMEGA) {
^
1 warning generated.
[ 31%] Linking CXX static library libbarnes_hut_lib.a
cd /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut && /usr/bin/cmake -P CMakeFiles/barnes_hut_lib.dir/cmake_clean_target.cmake
cd /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut && /usr/bin/cmake -E cmake_link_script CMakeFiles/barnes_hut_lib.dir/link.txt --verbose=1
/usr/bin/llvm-ar qc libbarnes_hut_lib.a CMakeFiles/barnes_hut_lib.dir/body.cpp.o CMakeFiles/barnes_hut_lib.dir/node.cpp.o CMakeFiles/barnes_hut_lib.dir/node_json.cpp.o CMakeFiles/barnes_hut_lib.dir/force.cpp.o
/usr/bin/llvm-ranlib libbarnes_hut_lib.a
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 31%] Built target barnes_hut_lib
make -f src/simulation/CMakeFiles/simulation_lib.dir/build.make src/simulation/CMakeFiles/simulation_lib.dir/depend
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
cd /home/steddy/CLionProjects/barnes-hut/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/steddy/CLionProjects/barnes-hut /home/steddy/CLionProjects/barnes-hut/src/simulation /home/steddy/CLionProjects/barnes-hut/build /home/steddy/CLionProjects/barnes-hut/build/src/simulation /home/steddy/CLionProjects/barnes-hut/build/src/simulation/CMakeFiles/simulation_lib.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
make -f src/simulation/CMakeFiles/simulation_lib.dir/build.make src/simulation/CMakeFiles/simulation_lib.dir/build
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 37%] Building CXX object src/simulation/CMakeFiles/simulation_lib.dir/simulation.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/simulation && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/simulation/CMakeFiles/simulation_lib.dir/simulation.cpp.o -MF CMakeFiles/simulation_lib.dir/simulation.cpp.o.d -o CMakeFiles/simulation_lib.dir/simulation.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/simulation/simulation.cpp
[ 43%] Building CXX object src/simulation/CMakeFiles/simulation_lib.dir/simulation_json.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/simulation && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/simulation/CMakeFiles/simulation_lib.dir/simulation_json.cpp.o -MF CMakeFiles/simulation_lib.dir/simulation_json.cpp.o.d -o CMakeFiles/simulation_lib.dir/simulation_json.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/simulation/simulation_json.cpp
[ 50%] Building CXX object src/simulation/CMakeFiles/simulation_lib.dir/simple_simulator.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/simulation && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/simulation/CMakeFiles/simulation_lib.dir/simple_simulator.cpp.o -MF CMakeFiles/simulation_lib.dir/simple_simulator.cpp.o.d -o CMakeFiles/simulation_lib.dir/simple_simulator.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/simulation/simple_simulator.cpp
[ 56%] Linking CXX static library libsimulation_lib.a
cd /home/steddy/CLionProjects/barnes-hut/build/src/simulation && /usr/bin/cmake -P CMakeFiles/simulation_lib.dir/cmake_clean_target.cmake
cd /home/steddy/CLionProjects/barnes-hut/build/src/simulation && /usr/bin/cmake -E cmake_link_script CMakeFiles/simulation_lib.dir/link.txt --verbose=1
/usr/bin/llvm-ar qc libsimulation_lib.a CMakeFiles/simulation_lib.dir/simulation.cpp.o CMakeFiles/simulation_lib.dir/simulation_json.cpp.o CMakeFiles/simulation_lib.dir/simple_simulator.cpp.o
/usr/bin/llvm-ranlib libsimulation_lib.a
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 56%] Built target simulation_lib
make -f tests/CMakeFiles/testlib.dir/build.make tests/CMakeFiles/testlib.dir/depend
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
cd /home/steddy/CLionProjects/barnes-hut/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/steddy/CLionProjects/barnes-hut /home/steddy/CLionProjects/barnes-hut/tests /home/steddy/CLionProjects/barnes-hut/build /home/steddy/CLionProjects/barnes-hut/build/tests /home/steddy/CLionProjects/barnes-hut/build/tests/CMakeFiles/testlib.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
make -f tests/CMakeFiles/testlib.dir/build.make tests/CMakeFiles/testlib.dir/build
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 62%] Building CXX object tests/CMakeFiles/testlib.dir/testlib.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/tests && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -I/home/steddy/CLionProjects/barnes-hut/src/simulation -std=c++17 -MD -MT tests/CMakeFiles/testlib.dir/testlib.cpp.o -MF CMakeFiles/testlib.dir/testlib.cpp.o.d -o CMakeFiles/testlib.dir/testlib.cpp.o -c /home/steddy/CLionProjects/barnes-hut/tests/testlib.cpp
[ 68%] Building CXX object tests/CMakeFiles/testlib.dir/test_quadtree.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/tests && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -I/home/steddy/CLionProjects/barnes-hut/src/simulation -std=c++17 -MD -MT tests/CMakeFiles/testlib.dir/test_quadtree.cpp.o -MF CMakeFiles/testlib.dir/test_quadtree.cpp.o.d -o CMakeFiles/testlib.dir/test_quadtree.cpp.o -c /home/steddy/CLionProjects/barnes-hut/tests/test_quadtree.cpp
In file included from /home/steddy/CLionProjects/barnes-hut/tests/test_quadtree.cpp:5:
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node.h:42:33: warning: inline function 'bh::Node::top_left' is not defined [-Wundefined-inline]
[[nodiscard]] inline Vector2f top_left() const;
^
/home/steddy/CLionProjects/barnes-hut/tests/test_quadtree.cpp:25:16: note: used here
REQUIRE(root.top_left() == Vector2f{0, 10});
^
In file included from /home/steddy/CLionProjects/barnes-hut/tests/test_quadtree.cpp:5:
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node.h:46:30: warning: inline function 'bh::Node::length' is not defined [-Wundefined-inline]
[[nodiscard]] inline float length() const;
^
/home/steddy/CLionProjects/barnes-hut/tests/test_quadtree.cpp:26:16: note: used here
REQUIRE(root.length() == 10);
^
2 warnings generated.
[ 75%] Building CXX object tests/CMakeFiles/testlib.dir/test_force.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/tests && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -I/home/steddy/CLionProjects/barnes-hut/src/simulation -std=c++17 -MD -MT tests/CMakeFiles/testlib.dir/test_force.cpp.o -MF CMakeFiles/testlib.dir/test_force.cpp.o.d -o CMakeFiles/testlib.dir/test_force.cpp.o -c /home/steddy/CLionProjects/barnes-hut/tests/test_force.cpp
[ 81%] Building CXX object tests/CMakeFiles/testlib.dir/test_body.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/tests && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -I/home/steddy/CLionProjects/barnes-hut/src/simulation -std=c++17 -MD -MT tests/CMakeFiles/testlib.dir/test_body.cpp.o -MF CMakeFiles/testlib.dir/test_body.cpp.o.d -o CMakeFiles/testlib.dir/test_body.cpp.o -c /home/steddy/CLionProjects/barnes-hut/tests/test_body.cpp
[ 87%] Linking CXX executable testlib
cd /home/steddy/CLionProjects/barnes-hut/build/tests && /usr/bin/cmake -E cmake_link_script CMakeFiles/testlib.dir/link.txt --verbose=1
/usr/bin/clang++ CMakeFiles/testlib.dir/testlib.cpp.o CMakeFiles/testlib.dir/test_quadtree.cpp.o CMakeFiles/testlib.dir/test_force.cpp.o CMakeFiles/testlib.dir/test_body.cpp.o -o testlib ../src/barnes_hut/libbarnes_hut_lib.a ../src/simulation/libsimulation_lib.a ../src/barnes_hut/libbarnes_hut_lib.a
cd /home/steddy/CLionProjects/barnes-hut/build/tests && /usr/bin/cmake -D TEST_TARGET=testlib -D TEST_EXECUTABLE=/home/steddy/CLionProjects/barnes-hut/build/tests/testlib -D TEST_EXECUTOR= -D TEST_WORKING_DIR=/home/steddy/CLionProjects/barnes-hut/build/tests -D TEST_SPEC= -D TEST_EXTRA_ARGS= -D TEST_PROPERTIES= -D TEST_PREFIX= -D TEST_SUFFIX= -D TEST_LIST=testlib_TESTS -D TEST_REPORTER= -D TEST_OUTPUT_DIR= -D TEST_OUTPUT_PREFIX= -D TEST_OUTPUT_SUFFIX= -D CTEST_FILE=/home/steddy/CLionProjects/barnes-hut/build/tests/testlib_tests-b12d07c.cmake -P /usr/local/lib64/cmake/Catch2/CatchAddTests.cmake
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 87%] Built target testlib
make -f apps/CMakeFiles/app.dir/build.make apps/CMakeFiles/app.dir/depend
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
cd /home/steddy/CLionProjects/barnes-hut/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/steddy/CLionProjects/barnes-hut /home/steddy/CLionProjects/barnes-hut/apps /home/steddy/CLionProjects/barnes-hut/build /home/steddy/CLionProjects/barnes-hut/build/apps /home/steddy/CLionProjects/barnes-hut/build/apps/CMakeFiles/app.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
make -f apps/CMakeFiles/app.dir/build.make apps/CMakeFiles/app.dir/build
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 93%] Building CXX object apps/CMakeFiles/app.dir/app.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/apps && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -I/home/steddy/CLionProjects/barnes-hut/src/simulation -std=c++17 -MD -MT apps/CMakeFiles/app.dir/app.cpp.o -MF CMakeFiles/app.dir/app.cpp.o.d -o CMakeFiles/app.dir/app.cpp.o -c /home/steddy/CLionProjects/barnes-hut/apps/app.cpp
[100%] Linking CXX executable app
cd /home/steddy/CLionProjects/barnes-hut/build/apps && /usr/bin/cmake -E cmake_link_script CMakeFiles/app.dir/link.txt --verbose=1
/usr/bin/clang++ CMakeFiles/app.dir/app.cpp.o -o app ../src/barnes_hut/libbarnes_hut_lib.a ../src/simulation/libsimulation_lib.a ../src/barnes_hut/libbarnes_hut_lib.a
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
[100%] Built target app
make[1]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
/usr/bin/cmake -E cmake_progress_start /home/steddy/CLionProjects/barnes-hut/build/CMakeFiles 0
I have installed Include What You Use.
I cloned the repository, checked out tag 0.18 and compiled.
$ include-what-you-use -v
clang version 14.0.0 (Fedora 14.0.0-1.fc36)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/12
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/12
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
error: unable to handle compilation, expected exactly one compiler job in ''
I integrated the tool in CMake as follows:
find_program(iwyu_path NAMES include-what-you-use iwyu)
if(iwyu_path)
message("Found iwyu")
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path})
endif()
I run CMake:
$ CC="clang" CXX="clang++" cmake -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use ..
-- The CXX compiler identification is Clang 14.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Found iwyu
-- Configuring done
-- Generating done
-- Build files have been written to: /home/...
And compile: make
, but I don't see any IWYU output in the terminal.
Why is this the case?
Make's output:
[steddy@nowhere build]$ CC="clang" CXX="clang++" cmake -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use ..
-- The CXX compiler identification is Clang 14.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found nlohmann_json: /usr/local/lib64/cmake/nlohmann_json/nlohmann_jsonConfig.cmake (found suitable version "3.10.5", minimum required is "3.10.5")
Found iwyu
-- Configuring done
-- Generating done
-- Build files have been written to: /home/steddy/CLionProjects/barnes-hut/build
[steddy@nowhere build]$ make VERBOSE=1
/usr/bin/cmake -S/home/steddy/CLionProjects/barnes-hut -B/home/steddy/CLionProjects/barnes-hut/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/steddy/CLionProjects/barnes-hut/build/CMakeFiles /home/steddy/CLionProjects/barnes-hut/build//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
make -f src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/build.make src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/depend
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
cd /home/steddy/CLionProjects/barnes-hut/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/steddy/CLionProjects/barnes-hut /home/steddy/CLionProjects/barnes-hut/src/barnes_hut /home/steddy/CLionProjects/barnes-hut/build /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
make -f src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/build.make src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/build
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 6%] Building CXX object src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/body.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/body.cpp.o -MF CMakeFiles/barnes_hut_lib.dir/body.cpp.o.d -o CMakeFiles/barnes_hut_lib.dir/body.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/body.cpp
[ 12%] Building CXX object src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/node.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/node.cpp.o -MF CMakeFiles/barnes_hut_lib.dir/node.cpp.o.d -o CMakeFiles/barnes_hut_lib.dir/node.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node.cpp
[ 18%] Building CXX object src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/node_json.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/node_json.cpp.o -MF CMakeFiles/barnes_hut_lib.dir/node_json.cpp.o.d -o CMakeFiles/barnes_hut_lib.dir/node_json.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node_json.cpp
In file included from /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node_json.cpp:1:
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node.h:42:33: warning: inline function 'bh::Node::top_left' is not defined [-Wundefined-inline]
[[nodiscard]] inline Vector2f top_left() const;
^
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node_json.cpp:33:27: note: used here
{"top_left", {node.top_left().x(), node.top_left().y()}},
^
In file included from /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node_json.cpp:1:
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node.h:46:30: warning: inline function 'bh::Node::length' is not defined [-Wundefined-inline]
[[nodiscard]] inline float length() const;
^
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node_json.cpp:34:24: note: used here
{"length", node.length()},
^
2 warnings generated.
[ 25%] Building CXX object src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/force.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/barnes_hut/CMakeFiles/barnes_hut_lib.dir/force.cpp.o -MF CMakeFiles/barnes_hut_lib.dir/force.cpp.o.d -o CMakeFiles/barnes_hut_lib.dir/force.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/force.cpp
In file included from /home/steddy/CLionProjects/barnes-hut/src/barnes_hut/force.cpp:4:
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node.h:46:30: warning: inline function 'bh::Node::length' is not defined [-Wundefined-inline]
[[nodiscard]] inline float length() const;
^
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/force.cpp:44:14: note: used here
if (node.length() / distance < OMEGA) {
^
1 warning generated.
[ 31%] Linking CXX static library libbarnes_hut_lib.a
cd /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut && /usr/bin/cmake -P CMakeFiles/barnes_hut_lib.dir/cmake_clean_target.cmake
cd /home/steddy/CLionProjects/barnes-hut/build/src/barnes_hut && /usr/bin/cmake -E cmake_link_script CMakeFiles/barnes_hut_lib.dir/link.txt --verbose=1
/usr/bin/llvm-ar qc libbarnes_hut_lib.a CMakeFiles/barnes_hut_lib.dir/body.cpp.o CMakeFiles/barnes_hut_lib.dir/node.cpp.o CMakeFiles/barnes_hut_lib.dir/node_json.cpp.o CMakeFiles/barnes_hut_lib.dir/force.cpp.o
/usr/bin/llvm-ranlib libbarnes_hut_lib.a
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 31%] Built target barnes_hut_lib
make -f src/simulation/CMakeFiles/simulation_lib.dir/build.make src/simulation/CMakeFiles/simulation_lib.dir/depend
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
cd /home/steddy/CLionProjects/barnes-hut/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/steddy/CLionProjects/barnes-hut /home/steddy/CLionProjects/barnes-hut/src/simulation /home/steddy/CLionProjects/barnes-hut/build /home/steddy/CLionProjects/barnes-hut/build/src/simulation /home/steddy/CLionProjects/barnes-hut/build/src/simulation/CMakeFiles/simulation_lib.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
make -f src/simulation/CMakeFiles/simulation_lib.dir/build.make src/simulation/CMakeFiles/simulation_lib.dir/build
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 37%] Building CXX object src/simulation/CMakeFiles/simulation_lib.dir/simulation.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/simulation && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/simulation/CMakeFiles/simulation_lib.dir/simulation.cpp.o -MF CMakeFiles/simulation_lib.dir/simulation.cpp.o.d -o CMakeFiles/simulation_lib.dir/simulation.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/simulation/simulation.cpp
[ 43%] Building CXX object src/simulation/CMakeFiles/simulation_lib.dir/simulation_json.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/simulation && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/simulation/CMakeFiles/simulation_lib.dir/simulation_json.cpp.o -MF CMakeFiles/simulation_lib.dir/simulation_json.cpp.o.d -o CMakeFiles/simulation_lib.dir/simulation_json.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/simulation/simulation_json.cpp
[ 50%] Building CXX object src/simulation/CMakeFiles/simulation_lib.dir/simple_simulator.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/src/simulation && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -isystem /usr/local/include/eigen3 -std=c++17 -MD -MT src/simulation/CMakeFiles/simulation_lib.dir/simple_simulator.cpp.o -MF CMakeFiles/simulation_lib.dir/simple_simulator.cpp.o.d -o CMakeFiles/simulation_lib.dir/simple_simulator.cpp.o -c /home/steddy/CLionProjects/barnes-hut/src/simulation/simple_simulator.cpp
[ 56%] Linking CXX static library libsimulation_lib.a
cd /home/steddy/CLionProjects/barnes-hut/build/src/simulation && /usr/bin/cmake -P CMakeFiles/simulation_lib.dir/cmake_clean_target.cmake
cd /home/steddy/CLionProjects/barnes-hut/build/src/simulation && /usr/bin/cmake -E cmake_link_script CMakeFiles/simulation_lib.dir/link.txt --verbose=1
/usr/bin/llvm-ar qc libsimulation_lib.a CMakeFiles/simulation_lib.dir/simulation.cpp.o CMakeFiles/simulation_lib.dir/simulation_json.cpp.o CMakeFiles/simulation_lib.dir/simple_simulator.cpp.o
/usr/bin/llvm-ranlib libsimulation_lib.a
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 56%] Built target simulation_lib
make -f tests/CMakeFiles/testlib.dir/build.make tests/CMakeFiles/testlib.dir/depend
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
cd /home/steddy/CLionProjects/barnes-hut/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/steddy/CLionProjects/barnes-hut /home/steddy/CLionProjects/barnes-hut/tests /home/steddy/CLionProjects/barnes-hut/build /home/steddy/CLionProjects/barnes-hut/build/tests /home/steddy/CLionProjects/barnes-hut/build/tests/CMakeFiles/testlib.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
make -f tests/CMakeFiles/testlib.dir/build.make tests/CMakeFiles/testlib.dir/build
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 62%] Building CXX object tests/CMakeFiles/testlib.dir/testlib.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/tests && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -I/home/steddy/CLionProjects/barnes-hut/src/simulation -std=c++17 -MD -MT tests/CMakeFiles/testlib.dir/testlib.cpp.o -MF CMakeFiles/testlib.dir/testlib.cpp.o.d -o CMakeFiles/testlib.dir/testlib.cpp.o -c /home/steddy/CLionProjects/barnes-hut/tests/testlib.cpp
[ 68%] Building CXX object tests/CMakeFiles/testlib.dir/test_quadtree.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/tests && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -I/home/steddy/CLionProjects/barnes-hut/src/simulation -std=c++17 -MD -MT tests/CMakeFiles/testlib.dir/test_quadtree.cpp.o -MF CMakeFiles/testlib.dir/test_quadtree.cpp.o.d -o CMakeFiles/testlib.dir/test_quadtree.cpp.o -c /home/steddy/CLionProjects/barnes-hut/tests/test_quadtree.cpp
In file included from /home/steddy/CLionProjects/barnes-hut/tests/test_quadtree.cpp:5:
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node.h:42:33: warning: inline function 'bh::Node::top_left' is not defined [-Wundefined-inline]
[[nodiscard]] inline Vector2f top_left() const;
^
/home/steddy/CLionProjects/barnes-hut/tests/test_quadtree.cpp:25:16: note: used here
REQUIRE(root.top_left() == Vector2f{0, 10});
^
In file included from /home/steddy/CLionProjects/barnes-hut/tests/test_quadtree.cpp:5:
/home/steddy/CLionProjects/barnes-hut/src/barnes_hut/node.h:46:30: warning: inline function 'bh::Node::length' is not defined [-Wundefined-inline]
[[nodiscard]] inline float length() const;
^
/home/steddy/CLionProjects/barnes-hut/tests/test_quadtree.cpp:26:16: note: used here
REQUIRE(root.length() == 10);
^
2 warnings generated.
[ 75%] Building CXX object tests/CMakeFiles/testlib.dir/test_force.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/tests && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -I/home/steddy/CLionProjects/barnes-hut/src/simulation -std=c++17 -MD -MT tests/CMakeFiles/testlib.dir/test_force.cpp.o -MF CMakeFiles/testlib.dir/test_force.cpp.o.d -o CMakeFiles/testlib.dir/test_force.cpp.o -c /home/steddy/CLionProjects/barnes-hut/tests/test_force.cpp
[ 81%] Building CXX object tests/CMakeFiles/testlib.dir/test_body.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/tests && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -I/home/steddy/CLionProjects/barnes-hut/src/simulation -std=c++17 -MD -MT tests/CMakeFiles/testlib.dir/test_body.cpp.o -MF CMakeFiles/testlib.dir/test_body.cpp.o.d -o CMakeFiles/testlib.dir/test_body.cpp.o -c /home/steddy/CLionProjects/barnes-hut/tests/test_body.cpp
[ 87%] Linking CXX executable testlib
cd /home/steddy/CLionProjects/barnes-hut/build/tests && /usr/bin/cmake -E cmake_link_script CMakeFiles/testlib.dir/link.txt --verbose=1
/usr/bin/clang++ CMakeFiles/testlib.dir/testlib.cpp.o CMakeFiles/testlib.dir/test_quadtree.cpp.o CMakeFiles/testlib.dir/test_force.cpp.o CMakeFiles/testlib.dir/test_body.cpp.o -o testlib ../src/barnes_hut/libbarnes_hut_lib.a ../src/simulation/libsimulation_lib.a ../src/barnes_hut/libbarnes_hut_lib.a
cd /home/steddy/CLionProjects/barnes-hut/build/tests && /usr/bin/cmake -D TEST_TARGET=testlib -D TEST_EXECUTABLE=/home/steddy/CLionProjects/barnes-hut/build/tests/testlib -D TEST_EXECUTOR= -D TEST_WORKING_DIR=/home/steddy/CLionProjects/barnes-hut/build/tests -D TEST_SPEC= -D TEST_EXTRA_ARGS= -D TEST_PROPERTIES= -D TEST_PREFIX= -D TEST_SUFFIX= -D TEST_LIST=testlib_TESTS -D TEST_REPORTER= -D TEST_OUTPUT_DIR= -D TEST_OUTPUT_PREFIX= -D TEST_OUTPUT_SUFFIX= -D CTEST_FILE=/home/steddy/CLionProjects/barnes-hut/build/tests/testlib_tests-b12d07c.cmake -P /usr/local/lib64/cmake/Catch2/CatchAddTests.cmake
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 87%] Built target testlib
make -f apps/CMakeFiles/app.dir/build.make apps/CMakeFiles/app.dir/depend
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
cd /home/steddy/CLionProjects/barnes-hut/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/steddy/CLionProjects/barnes-hut /home/steddy/CLionProjects/barnes-hut/apps /home/steddy/CLionProjects/barnes-hut/build /home/steddy/CLionProjects/barnes-hut/build/apps /home/steddy/CLionProjects/barnes-hut/build/apps/CMakeFiles/app.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
make -f apps/CMakeFiles/app.dir/build.make apps/CMakeFiles/app.dir/build
make[2]: Entering directory '/home/steddy/CLionProjects/barnes-hut/build'
[ 93%] Building CXX object apps/CMakeFiles/app.dir/app.cpp.o
cd /home/steddy/CLionProjects/barnes-hut/build/apps && /usr/bin/cmake -E __run_co_compile --iwyu="/usr/local/bin/include-what-you-use;--driver-mode=g++" -- /usr/bin/clang++ -I/home/steddy/CLionProjects/barnes-hut/src/barnes_hut -I/home/steddy/CLionProjects/barnes-hut/src/simulation -std=c++17 -MD -MT apps/CMakeFiles/app.dir/app.cpp.o -MF CMakeFiles/app.dir/app.cpp.o.d -o CMakeFiles/app.dir/app.cpp.o -c /home/steddy/CLionProjects/barnes-hut/apps/app.cpp
[100%] Linking CXX executable app
cd /home/steddy/CLionProjects/barnes-hut/build/apps && /usr/bin/cmake -E cmake_link_script CMakeFiles/app.dir/link.txt --verbose=1
/usr/bin/clang++ CMakeFiles/app.dir/app.cpp.o -o app ../src/barnes_hut/libbarnes_hut_lib.a ../src/simulation/libsimulation_lib.a ../src/barnes_hut/libbarnes_hut_lib.a
make[2]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
[100%] Built target app
make[1]: Leaving directory '/home/steddy/CLionProjects/barnes-hut/build'
/usr/bin/cmake -E cmake_progress_start /home/steddy/CLionProjects/barnes-hut/build/CMakeFiles 0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
cmake 调用
includ-what-you-use
它忽略了任何错误返回代码,只有打印包含的输出才能删除...
或应添加...
。因此,如果有任何运行的错误包括 - 您使用
,它根本没有打印。您可能可以通过运行运行来诊断错误,并使用冗长 make 中的编译选项手动诊断错误。
When
cmake
invokesinclude-what-you-use
it ignores any error return codes, and only prints output that containsshould remove...
orshould add...
. So if there are any errors runninginclude-what-you-use
, it prints nothing at all.You can probably diagnose the error by running
include-what-you-use
manually using the compile options from the verbosemake
.