Issue
Problem Background
I am trying to incorporate UnitTest++ into my linux-based C++17 project template. I have done this on windows pretty easily, but I am running into major issues on linux for some reason.
I used Cmake 3.21 on Windows and I am currently using CMake 3.17.5 on Linux.
I downloaded the UnitTest++ source code from the UnitTest++ Github. and proceeded to throw the tar.gz into my 3rdParty folder in my ProjectTemplate. I have had major trouble getting it to build. So I have stripped out everything except for the one 3rd party library I added and the things that folder affects. So at this point all the main() functions are very simple. I am just expecting to see executables that do nothing.
Problem Points
- The main executable gets made, but the unit testing executable (testExecutable) does not get made.
- The build fully finishes with no errors even though an executable failed to be made.
- The UnitTest++ 3rd party library fails to untar with no errors output.
I have included the build output.
Why is the testExecutable not getting made? More importantly, why is my UnitTest++ failing to untar?
Directory Structure
ProjectTemplate
+3rdParty
-CMakeLists.txt (3rd party cmake)
-unittest-cpp-2.0.0.tar.gz
+build
+src
-ClassTemplate.cpp (just a plain class file - compiles fine)
-ClassTemplate.hpp (just a plain class file - compiles fine)
-main.cpp (basic int main function)
+UnitTests
-CMakeLists.txt (unit test cmake)
-UnittestcppMain.cpp (basic int main function)
-CMakeLists.txt (root cmake)
Build Output
Output from cmake generation / configure
[main] Configuring folder: ProjectTemplate
[proc] Executing command: /usr/bin/cmake3 --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/opt/rh/devtoolset-8/root/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/opt/rh/devtoolset-8/root/usr/bin/g++ -S/path/to/ProjectTemplate -B/path/to/ProjectTemplate/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The CXX compiler identification is GNU 8.3.1
[cmake] -- Check for working CXX compiler: /opt/rh/devtoolset-8/root/usr/bin/g++
[cmake] -- Check for working CXX compiler: /opt/rh/devtoolset-8/root/usr/bin/g++ - works
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] Made it to this
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /path/to/ProjectTemplate/build
output from build
[main] Building folder: ProjectTemplate
[build] Starting build
[proc] Executing command: /usr/bin/cmake3 --build /path/to/ProjectTemplate/build --config Debug --target ExecutableName -j 18 --
[build] Scanning dependencies of target ExecutableLib
[build] [ 25%] Building CXX object CMakeFiles/ExecutableLib.dir/src/ClassTemplate.cpp.o
[build] [ 50%] Linking CXX static library libExecutableLib.a
[build] [ 50%] Built target ExecutableLib
[build] Scanning dependencies of target ExecutableName
[build] [ 75%] Building CXX object CMakeFiles/ExecutableName.dir/src/main.cpp.o
[build] [100%] Linking CXX executable ExecutableName
[build] [100%] Built target ExecutableName
[build] Build finished with exit code 0
UPDATE
Thanks to 273K a solution was pointed out. I had accidentally switched my target from "All" to "ExecutableName" in VSCode. I have included a screenshot of the problem area and what it had to be set to in order to avoid this problem for future users who might be using VSCode and stumble on this question.
This is the bottom edge of VSCode, this is where the CMake extension puts it build options.
Solution
Somehow you set --target ExecutableName
, that limits the build to a single target, the main executable ExecutableName
. Try to select another target, or let it unset.
Answered By - 273K Answer Checked By - Mildred Charles (WPSolving Admin)