Skip to content

Commit

Permalink
Update install build tools to manually install both
Browse files Browse the repository at this point in the history
GTest and CMake to avoid version issues accross different ubuntu
distributions
  • Loading branch information
paulbourelly999 committed Nov 8, 2023
1 parent ecbadec commit 115a374
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
3 changes: 2 additions & 1 deletion cmake/Testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ IF(NOT DEFINED ENV{BUILD_ARCHITECTURE} AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/te
target_link_libraries(${UNIT_TEST} PUBLIC
${PROJECT_NAME}
${TEST_LINK_LIBRARIES}
GTest::gtest_main)
GTest::gtest_main
GTest::gmock_main)
add_test(NAME ${UNIT_TEST} COMMAND ${UNIT_TEST})
include(GoogleTest)
gtest_discover_tests(${UNIT_TEST})
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if [ $GENERATE_COVERAGE -eq 1 ]; then
COVERAGE_FLAGS=-DGENERATE_COVERAGE=True
fi

cmake -B${BUILD_DIR} ${TOOLCHAIN_ARG} -DCMAKE_CXX_FLAGS="${CXXFLAGS}" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" ${PACKAGE_VERSION_SUFFIX} ${COVERAGE_FLAGS}
cmake -B${BUILD_DIR} ${TOOLCHAIN_ARG} -DCMAKE_CXX_FLAGS="${CXXFLAGS}" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" ${PACKAGE_VERSION_SUFFIX} ${COVERAGE_FLAGS} .
cd ${BUILD_DIR}
cmake --build .
if [ $GENERATE_DEBIAN_PACKAGE -eq 1 ]; then
Expand Down
43 changes: 25 additions & 18 deletions scripts/install_build_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,31 @@ set -e
. /etc/lsb-release
echo "Distribution code name : ${DISTRIB_CODENAME}"
apt-get update
if [ "$DISTRIB_CODENAME" = "bionic" ];then
echo "Installing bionic build tools ..."
DEPENDENCIES=(
build-essential
cmake
googletest
google-mock
gdb
git)
else
echo "Installing other linux distribution (focal or jammy) build tools ..."
DEPENDENCIES=(
apt-get -y install
DEPENDENCIES=(
wget
ca-certificates
build-essential
cmake
build-essential
libgtest-dev
libgmock-dev
gdb
git)
fi
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends --yes --quiet "${DEPENDENCIES[@]}"
DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends --yes --quiet "${DEPENDENCIES[@]}"
CMAKE_VERSION="3.27.7"
echo "Installing CMake ${CMAKE_VERSION}"
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz
chmod u+x cmake-${CMAKE_VERSION}-linux-x86_64.sh
./cmake-${CMAKE_VERSION}-linux-x86_64.sh --skip-license --include-subdir --prefix=/opt
rm cmake-${CMAKE_VERSION}-linux-x86_64.sh
rm cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz
echo "export PATH=/opt/cmake-${CMAKE_VERSION}-linux-x86_64/bin:$PATH" >> /root/.bashrc
# shellcheck source=/dev/null
export PATH=/opt/cmake-${CMAKE_VERSION}-linux-x86_64/bin:$PATH
echo "CMake installation complete"
GTEST_VERSION="1.14.0"
echo "Installing Google Test ${GTEST_VERSION}"
git clone https://github.com/google/googletest.git -b "v{GTEST_VERSION}"
cd googletest/
cmake -Bbuild
cd build/
make
make install

0 comments on commit 115a374

Please sign in to comment.