Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » method for setting up separate src and build directories
method for setting up separate src and build directories [message #1820619] Thu, 23 January 2020 17:01 Go to next message
Eclipse UserFriend
Hello,

I have a makefile g++/gfortran project that I have imported into eclipse. This is a large project, so the src is spread over many directories and sub-directories. I build this for multiple platforms but like to keep the code base unified. I have a different build directory for each platform to hold the associated complied objects and binaries.

The different build directories are named and created by the makefile with code that looks something like this,
# determine platform
# this is not really  sufficient for all linux cases, might be hard coded
PLATFORM := $(shell echo $$OSTYPE)

# determine build directory name elements
OS   := $(shell uname -s)
ARCH := $(shell uname -m)
KERN := $(shell uname -r | cut -d. -f 1,2)

# determine g++ compiler version
GCMP := $(shell g++ --version | cut -d ' ' -f 4 | sed q)
# create version name for g++
CMP := gcc-$(GCMP)

# specify version of the application being built
VER := debug

# create build dir name
BDIR := bld_$(OS)_$(KERN).$(ARCH)_$(CMP)_$(VER)

# mkdir the build directory if it doesn't exist
$(shell mkdir -p $(BDIR))


I boot into the OS I want to build in (in a VM or hardware) and mount the shared directory with the program /trunk directory (contains the makefile, /src, /bld_*, /test, etc). I run make from the command line passing the makefile (and sometimes version information) as arguments. The makefile creates the required build directory based on the local environment and builds the application. I generally don't need to run a separate configure script.

I have used eclipse to work on java projects before but not for c++. I have some questions about how to set up an eclipse project that is suitable for the system I have described here.

Is it enough that the src file and build directory locations are coded into the makefile? Do I need to somehow register these locations in the eclipse project? If I just create a makefile project in the top directory (/trunk), will I be able to use all of the featuures in eclipse such as debugging?

It seems now as if I am using eclipse in the same way I was using a terminal. I have a project in eclipse and I build or run by pressing buttons in a gui instead of calling make or the application from the terminal. Is there a write-up somewhere about eclipse projects using multipel /src and /build directories?

Thanks,

LMHmedchem

[Updated on: Thu, 23 January 2020 17:05] by Moderator

Re: method for setting up separate src and build directories [message #1820623 is a reply to message #1820619] Thu, 23 January 2020 17:53 Go to previous messageGo to next message
Eclipse UserFriend
You have your own makefile
so the project layout is all on you.
Eclipse doesn't care where your files are.
Re: method for setting up separate src and build directories [message #1820624 is a reply to message #1820623] Thu, 23 January 2020 18:25 Go to previous messageGo to next message
Eclipse UserFriend
David Vavra wrote on Thu, 23 January 2020 22:53

You have your own makefile
so the project layout is all on you.
Eclipse doesn't care where your files are.

Thanks for the reply,

I know how to point to the makefile I want in a given project by modifying the default build command in the Builder Settings tab (my makefiles are never called just makefile). I often pass varying arguments to make to specify the version of the application (debug, release, etc) or sometimes the compiler version, etc. These would be done like,

make ver=debug -f Makefile.mak all


I can hard code this in the custom build command but I would have to manually change it there every time I wanted to do something different. Is there some built in method to handle variables passed to make?

This is not related, but is it customary to have the project files in the same directory structure as the workspace?

LMHmedchem

[Updated on: Thu, 23 January 2020 18:29] by Moderator

Re: method for setting up separate src and build directories [message #1820625 is a reply to message #1820624] Thu, 23 January 2020 18:58 Go to previous message
Eclipse UserFriend
I generally keep the projects separate from the workspace.
One reason is that they are referenced in multiple workspaces.
Though I keep toy projects in the workspace.
YMMV
Previous Topic:need to create a new eclipse project with existing code to use qt .pro file
Next Topic:Eclipse, how to generate "auto/update-makefile" for a project
Goto Forum:
  


Current Time: Sun Jun 15 15:38:45 EDT 2025

Powered by FUDForum. Page generated in 0.05825 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top