Clang compile a project

How can I use Clang to compile a project? And I load pass.so simulateneously.

The following command can compile a single .cpp file.

clang++ 
  -flegacy-pass-manager 
  -Xclang 
  -load
  ../build/skeleton/libSkeletonPass.so  // here is pass.so
  -c
  main.cpp

And my problem is: how can I compile a project using similar approch?

A project, such as, main.cpp dep1.cpp dep2.cpp dep3.cpp.

Whatever build system you would normally use to build the project should let you specify command-line options to use when invoking the compiler.

I don’t think -Xclang -load foo.so works, pretty sure it needs to be -Xclang -load -Xclang foo.so.

Yes, you are right. I made a typo. And I wanna know how to compile a project in a similar way. :smiley: Could you give me some recommendations? Tks~

I used VSCode, so I have to write command line myself. So do you have any suggestion for build system automatically compiling a project with Clang? Tks!

Switch to a proper build system. Something like CMake or Make.

Sorry, I think cmake also need to write commd?

So, how to write CMakeLists.txt for clang to compie a project?Tks!

I don’t think this forum is the best for CMake help. You can find many good tutorials on cmake.org and similar sites.