1
votes

I have an Eclipse managed make c++ project where the source code is in several subdirectories, one of these directories is named "test". Eclipse automatically creates makefiles for each subdirectory (Debug/test/subdir.mk) and that part works beautifully.

However if I change the compiler (say icpc instead of gcc) in the project properties, the main makefile (Debug/makefile) is changed to use the new compiler but subdir.mk is not changed. subdir.mk still has gcc, while Debug/makefile has icpc as the compiler command. I tried setting properties for each sub directory, but I still have the same problem.

I am using Eclipse Mars

Is there any way to change this?

This is Debug/makefile ################################################################################ # Automatically-generated file. Do not edit! ################################################################################

-include ../makefile.init
RM := rm -rf

# All of the sources participating in the build are defined here
-include sources.mk
-include test/subdir.mk
-include subdir.mk
-include objects.mk

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif

-include ../makefile.defs

# Add inputs and outputs from these tool invocations to the build variables

# All Target
all: TestProject

# Tool invocations
TestProject: $(OBJS) $(USER_OBJS)
        @echo 'Building target: $@'
        @echo 'Invoking: GCC C++ Linker'
        icpc -L<LinkerStuff> -lrt -openmp -inline-forceinline -o "TestProject" $(OBJS) $(USER_OBJS) $(LIBS)
        @echo 'Finished building target: $@'
        @echo ' '

# Other Targets
clean:
        -$(RM) $(CC_DEPS)$(C++_DEPS)$(EXECUTABLES)$(C_UPPER_DEPS)$(CXX_DEPS)$(OBJS)$(CPP_DEPS)$(C_DEPS) TestProject
        -@echo ' '

.PHONY: all clean dependents
.SECONDARY:

-include ../makefile.targets

Here is Debug/test/subdir.mk

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
../test/TestProject.cpp

OBJS += \
./test/TestProject.o

CPP_DEPS += \
./test/TestProject.d


# Each subdirectory must supply rules for building sources it contributes
test/TestProject.o: ../test/TestProject.cpp
        @echo 'Building file: $<'
        @echo 'Invoking: GCC C++ Compiler'
        icc-I<includes stuff> -O3 -g3 -Wall -c -fmessage-length=0 -openmp -MMD -MP -MF"$(@:%.o=%.d)" -MT"test/TestProject.d" -o "$@" "$<"
        @echo 'Finished building: $<'
        @echo ' '
1
I have attempted to answer the question, but in your Debug/test/subdir.mk the command looks wrong no matter what. icc-I... has three problems 1. Not gcc, 2. not ipcc 3. no space before -I. I assume this was an editing issue and have answered the question as if it had said gcc -I... - Jonah Graham
You are correct, I was attempting to change things and on one try I got the subdir.mk file to have "icc" instead of "gcc", but still not "icpc". This is after I changed both compiler and linker settings - Anu
Not sure I follow. Sounds like a bug if you typed in icpc in a setting and icc came in the makefile. If you have a reproducible test case I am sure a bug report would be welcome bugs.eclipse.org/bugs/enter_bug.cgi?product=CDT - Jonah Graham

1 Answers

1
votes

It looks like you have only changed the Linking command from gcc to ipcc and not the compiling command. The top level makefile does the linking (collect *.o into an exe) where the subdirectories do the individual object compiles (compile *.c into *.o).

This screenshot may help. The arrows point to the compile and linking build settings:

linking