Check version of GCC C/C++ compiler and find closest compiler family match
$ gcc --version
gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
nuc ~
$ cpptestcli -list-compilers | grep 'GNU GCC'
GNU GCC 10.x (x86_64) - gcc_10-64
GNU GCC 11.x (x86_64) - gcc_11-64
GNU GCC 12.x (x86_64) - gcc_12-64
GNU GCC 13.x (x86_64) - gcc_13-64 <------- I will use this closest matching family ID
GNU GCC 6.x - gcc_6
GNU GCC 6.x (x86_64) - gcc_6-64
GNU GCC 7.x - gcc_7
GNU GCC 7.x (x86_64) - gcc_7-64
GNU GCC 8.x - gcc_8
GNU GCC 8.x (x86_64) - gcc_8-64
GNU GCC 9.x - gcc_9
GNU GCC 9.x (x86_64) - gcc_9-64
GNU GCC 10.x (aarch32/arm) - gcc_10-aarch32
GNU GCC 10.x (aarch64/arm64) - gcc_10-aarch64
GNU GCC 11.x (aarch32/arm) - gcc_11-aarch32
GNU GCC 11.x (aarch64/arm64) - gcc_11-aarch64
GNU GCC 11.x (powerpc) - gcc_11-powerpc
GNU GCC 12.x (aarch64/arm64) - gcc_12-aarch64
GNU GCC 13.x (aarch64/arm64) - gcc_13-aarch64
GNU GCC 8.x (aarch32/arm) - gcc_8-aarch32
GNU GCC 8.x (aarch64/arm64) - gcc_8-aarch64
GNU GCC 9.x (aarch32/arm) - gcc_9-aarch32
GNU GCC 9.x (aarch64/arm64) - gcc_9-aarch64
TI® ARM C/C++ Compiler GNU GCC 7.x - tiarmgcc_7
nuc ~
Let's use the example cmake
in the installation folder. Adjust the value of CPPTEST_COMPILER_ID
parameter to cpptest_add_executable
extension function:
nuc /opt/parasoft/cpptest_professional-2024.2.0-linux.x86_64/examples/CMakeProject
$ git diff
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 2cbca51..1e32182 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -7,6 +7,7 @@ target_link_libraries(main PUBLIC mod1 mod2 mod3)
# Test cases will be generated into ${CMAKE_SOURCE_DIR}/tests/cpptest_app/tests
cpptest_add_executable(
cpptest_app
+ CPPTEST_COMPILER_ID gcc_13-64
CPPTEST_PROJECT_LOC
${CMAKE_SOURCE_DIR}/tests/cpptest_app
CPPTEST_PROJECT_FOLDERS
diff --git a/modules/mod1/CMakeLists.txt b/modules/mod1/CMakeLists.txt
index 4e68720..16d9430 100644
--- a/modules/mod1/CMakeLists.txt
+++ b/modules/mod1/CMakeLists.txt
@@ -9,6 +9,6 @@ target_include_directories(mod1 PUBLIC include)
# Project will be located in the current directory (./)
# Test cases will be generated into ./tests
cpptest_add_executable(cpptest_mod1
- CPPTEST_COMPILER_ID gcc_9-64
+ CPPTEST_COMPILER_ID gcc_13-64
SOURCES mod1.cpp)
target_include_directories(cpptest_mod1 PRIVATE include)
diff --git a/tests/cpptest_modules/CMakeLists.txt b/tests/cpptest_modules/CMakeLists.txt
index 22a335b..15666d6 100644
--- a/tests/cpptest_modules/CMakeLists.txt
+++ b/tests/cpptest_modules/CMakeLists.txt
@@ -4,10 +4,11 @@
# mod1 and mod2 source directories will be linked
cpptest_add_executable(
cpptest_modules
+ CPPTEST_COMPILER_ID gcc_13-64
CPPTEST_PROJECT_FOLDERS
mod2=${CMAKE_SOURCE_DIR}/modules/mod2
mod3=${CMAKE_SOURCE_DIR}/modules/mod3
TARGETS mod2 mod3)
file(GLOB modules_INCLUDES "${CMAKE_SOURCE_DIR}/modules/**/include")
target_include_directories(cpptest_modules PRIVATE ${modules_INCLUDES})
-target_link_libraries(cpptest_modules PRIVATE mod1)
\ No newline at end of file
+target_link_libraries(cpptest_modules PRIVATE mod1)
$
Generate build files with CPPTEST_PROJECT turned ON.
nuc /opt/parasoft/cpptest_professional-2024.2.0-linux.x86_64/examples/CMakeProject
$ cmake -DCPPTEST_PROJECT=ON -B build -S .
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (3.7s)
-- Generating done (0.1s)
-- Build files have been written to: /opt/parasoft/cpptest_professional-2024.2.0-linux.x86_64/examples/CMakeProject/build
Then do a build to generate a bdf
file:
nuc /opt/parasoft/cpptest_professional-2024.2.0-linux.x86_64/examples/CMakeProject
$ cmake --build build/
[ 5%] Building CXX object modules/mod2/CMakeFiles/mod2.dir/mod2.cpp.o
[ 11%] Linking CXX static library libmod2.a
[ 11%] Built target mod2
[ 17%] Building CXX object modules/mod1/CMakeFiles/mod1.dir/mod1.cpp.o
[ 23%] Linking CXX static library libmod1.a
[ 23%] Built target mod1
[ 29%] Building CXX object modules/mod3/CMakeFiles/mod3.dir/mod3.cpp.o
[ 35%] Linking CXX static library libmod3.a
[ 35%] Built target mod3
[ 41%] Building CXX object app/CMakeFiles/main.dir/main.cpp.o
[ 47%] Building CXX object app/CMakeFiles/main.dir/util.cpp.o
[ 52%] Linking CXX executable main
[ 52%] Built target main
[ 58%] Building CXX object app/CMakeFiles/cpptest_app.dir/main.cpp.o
[ 64%] Building CXX object app/CMakeFiles/cpptest_app.dir/util.cpp.o
[ 70%] Linking CXX executable cpptest_app
[ 70%] Built target cpptest_app
[ 76%] Building CXX object modules/mod1/CMakeFiles/cpptest_mod1.dir/mod1.cpp.o
[ 82%] Linking CXX executable cpptest_mod1
[ 82%] Built target cpptest_mod1
[ 88%] Building CXX object tests/cpptest_modules/CMakeFiles/cpptest_modules.dir/__/__/modules/mod2/mod2.cpp.o
[ 94%] Building CXX object tests/cpptest_modules/CMakeFiles/cpptest_modules.dir/__/__/modules/mod3/mod3.cpp.o
[100%] Linking CXX executable cpptest_modules
[100%] Built target cpptest_modules
$ find . -type f -name '*.bdf'
./build/app/cpptest_app.bdf
./build/tests/cpptest_modules/cpptest_modules.bdf
./build/modules/mod1/cpptest_mod1.bdf
Use Parasoft Eclipse-based IDE to load the cpptest_app.bdf
file:
- Use the IDE to autogenerate unit test cases.
- Use the IDE to run the test cases and see the code coverage