Skip to content

gtest not building properly when a second main is present in the project [BUG] #27

@riera90

Description

@riera90

Description
When compiling and executing a gtest, and a second main is added in the / path of the project, this main is build under the name of the gtest and executed

Configuration

# DIRECTORIES
# src directory
SRC_DIR         :=./src
GTEST_DIR       :=./gtests
OUTPUT_DIR      :=./output
# aditional project libs directory
EXTRA_LIB_DIR   :=
# temporal files directory
TMP_DIR         :=./tmp
SRC_CODE_EXT    :=cpp
SRC_HEADERS_EXT :=hpp
MAIN_FILE       :=main.cpp
# excluded files from the project
EXCLUDED_FILES  :=


# binary file name
BIN_NAME:=bin.out
# binary arguments (if executed by the makefile).
BIN_ARGUMENTS:=
# compiler
CXX:=g++
# compilation flags
CXXFLAGS:=-Wpedantic -DNDEBUG

# [YES/NO]
EXECUTE_AFTER_COMPILATION:=YES
ALLOW_FOR_GNU_DEBUGGER:=YES

Tree output

.
├── Doxyfile
├── gtests
│   └── MonomioUnittest.cpp
├── Makefile
├── make-files
│   ├── banner.txt
│   ├── config.sh
│   ├── CONTRIBUTING.md
│   ├── fancy_banner_short.txt
│   ├── fancy_banner.txt
│   ├── gmf.gif
│   ├── help.txt
│   ├── LICENSE.md
│   ├── logo.png
│   ├── Makefile
│   └── README.md
├── output
│   └── MonomioUnittest.out
├── Practica-1.pdf
├── src
│   ├── Auxiliar
│   │   ├── AuxiliarFunctions
│   │   │   ├── funcionesAuxiliares.cpp
│   │   │   └── funcionesAuxiliares.hpp
│   │   └── macros.hpp
│   ├── Controller
│   │   └── Monomio
│   │       ├── auxiliarFunctions.cpp
│   │       ├── auxiliarFunctions.hpp
│   │       ├── operadoresExternosMonomios.cpp
│   │       └── operadoresExternosMonomios.hpp
│   ├── Entity
│   │   └── Monomio
│   │       ├── Monomio.cpp
│   │       └── Monomio.hpp
│   ├── main.cpp
│   └── testfile.cpp
└── tmp
    ├── Auxiliar
    │   └── AuxiliarFunctions
    │       └── funcionesAuxiliares.o
    ├── Controller
    │   └── Monomio
    │       ├── auxiliarFunctions.o
    │       └── operadoresExternosMonomios.o
    ├── Entity
    │   └── Monomio
    │       └── Monomio.o
    ├── gtest-all.o
    ├── gtest_main.o
    ├── libgtest.a
    ├── libproject.a
    └── testfile.o

Log


$ make clean
	Removing temporal files
	Removing binary files

$ make config
./make-files/config.sh

$ make googletest 
                     ___
                   /'___\
   __     ___ ___ /\ \__/
 /'_ `\ /' __` __`\ \ ,__\
/\ \L\ \/\ \/\ \/\ \ \ \_/
\ \____ \ \_\ \_\ \_\ \_\
 \/___L\ \/_/\/_/\/_/\/_/ 3.0
  /\____/
  \_/__/
	Precompiling googletest object for ./make-files/googletest/googletest/src/gtest_main.cc.
	Precompiling googletest object for ./make-files/googletest/googletest/src/gtest-all.cc
	Compiling googletest library.
	Precompiling object for ./src/Entity/Monomio/Monomio.cpp.
	Precompiling object for ./src/Auxiliar/AuxiliarFunctions/funcionesAuxiliares.cpp.
	Precompiling object for ./src/Controller/Monomio/operadoresExternosMonomios.cpp.
	Precompiling object for ./src/Controller/Monomio/auxiliarFunctions.cpp.
	Precompiling object for ./src/testfile.cpp.
	Building project library.
	Building googletest ./gtests/MonomioUnittest.cpp.

	Running ./output/MonomioUnittest.out
./output/MonomioUnittest.out
this is beeing executed when googletest should be
make: *** [make-files/Makefile:63: googletest] Error 1

Additional context
the name of the second main is not important, in this case is testfile.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions