简体   繁体   中英

Eclipse C++: Setting Compiler Options For Specific Files

I have a CUDA C++ project I am writing and compiling using Eclipse Nsight. My goal is to end up with an executable from the file that contains the main function, then to produce an individual shared library for each class in the project without needing to compile outside of the IDE. I can do this by creating a project for each class, then including all of them in the main project, but I would like a way to write all the files in a single Eclipse project and still end up with the desired artifacts. The project structure is as follows:

ClassA.h
ClassA.cu
ClassB.h
ClassB.cu
main.cpp

I am looking to compile the project and end up with the following artifacts:

ClassA.so
ClassB.so
main.exe

Ideally, I would like to know if there is a way to group specific files and set the compiler options for just that group of files. ie

nvcc ClassA.cu -shared -fPIC -o ClassA.so
nvcc ClassB.cu -shared -fPIC -o ClassB.so
g++  main.cpp -lClassA.so -lClassB.so -o main.exe

I know this is an unusual request, but this is part of a larger project architecture I am trying to bring from the land of emacs and compile shell scripts into the world of IDEs.

Option A: Write and maintain a custom make file.

Option B: Create 3 projects - exe and two shared libraries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM