From 115a37474429109617107b2edf97e6b0c95f20bd Mon Sep 17 00:00:00 2001 From: dev Date: Wed, 8 Nov 2023 18:44:00 -0500 Subject: [PATCH] Update install build tools to manually install both GTest and CMake to avoid version issues accross different ubuntu distributions --- cmake/Testing.cmake | 3 ++- scripts/build_script.sh | 2 +- scripts/install_build_tools.sh | 43 ++++++++++++++++++++-------------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/cmake/Testing.cmake b/cmake/Testing.cmake index 808a50a..e5d785f 100644 --- a/cmake/Testing.cmake +++ b/cmake/Testing.cmake @@ -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}) diff --git a/scripts/build_script.sh b/scripts/build_script.sh index f8d14b7..760dbc8 100755 --- a/scripts/build_script.sh +++ b/scripts/build_script.sh @@ -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 diff --git a/scripts/install_build_tools.sh b/scripts/install_build_tools.sh index 424c786..555db98 100755 --- a/scripts/install_build_tools.sh +++ b/scripts/install_build_tools.sh @@ -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[@]}" \ No newline at end of file +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