Skip to content

Commit

Permalink
updating googletest
Browse files Browse the repository at this point in the history
  • Loading branch information
gangatp committed Dec 18, 2023
1 parent 3bee0c5 commit 42eec9d
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "Tests/googletest"]
path = Tests/googletest
url = https://github.com/google/googletest.git
[submodule "Tests/libressl"]
path = Tests/libressl
url = https://github.com/3MFConsortium/forks-libressl-distribution.git
Expand All @@ -19,3 +16,6 @@
[submodule "submodules/libzip"]
path = submodules/libzip
url = https://github.com/nih-at/libzip.git
[submodule "submodules/googletest"]
path = submodules/googletest
url = https://github.com/google/googletest.git
8 changes: 0 additions & 8 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
enable_testing()

if (USE_INCLUDED_GTEST)
SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
ADD_SUBDIRECTORY (googletest EXCLUDE_FROM_ALL)
SET_TARGET_PROPERTIES (gtest PROPERTIES FOLDER gtest)
SET_TARGET_PROPERTIES (gtest_main PROPERTIES FOLDER gtest)
SET(gtest_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/googletest/googletest")
endif()

if (USE_INCLUDED_SSL)
SET(LIBRESSL_APPS OFF CACHE BOOL "" FORCE)
SET(LIBRESSL_TESTS OFF CACHE BOOL "" FORCE)
Expand Down
6 changes: 4 additions & 2 deletions Tests/CPP_Bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

SET(TESTNAME "Test_CPP_Bindings")

file(GLOB GTEST_SRC_FILES "${CMAKE_SOURCE_DIR}/Libraries/googletest/Source/*cc")

set(SRCS_UNITTEST
./Source/AllTests.cpp
./Source/Attachments.cpp
Expand Down Expand Up @@ -38,7 +40,7 @@ set(SRCS_UNITTEST
)

set(CMAKE_CURRENT_BINARY_DIR ${CMAKE_BINARY_DIR})
add_executable(${TESTNAME} ${SRCS_UNITTEST})
add_executable(${TESTNAME} ${SRCS_UNITTEST} ${GTEST_SRC_FILES})

set(STARTUPPROJECT ${TESTNAME})

Expand All @@ -52,7 +54,7 @@ add_dependencies(${TESTNAME} crypto)

target_include_directories(${TESTNAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/Include
${gtest_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/Libraries/googletest/Include
${CMAKE_CURRENT_SOURCE_DIR}/../libressl/include
${CMAKE_CURRENT_SOURCE_DIR_AUTOGENERATED}/Bindings/Cpp
)
Expand Down
1 change: 0 additions & 1 deletion Tests/googletest
Submodule googletest deleted from b796f7
1 change: 1 addition & 0 deletions submodules/googletest
Submodule googletest added at f8d7d7
25 changes: 25 additions & 0 deletions submodules/update_libs.bat
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,28 @@ for %%A in ("libzip" "") do (
echo "!tag!" >"!lib_path_dest!!lib_name!_!tag!.txt"
)
)

for %%A in ("googletest" "") do (
if "%update_lib%"==%%A (
REM updating the googletest library
set lib_name=googletest
set lib_path_src=!base_path!!lib_name!\googletest\
cd !lib_name!
set "tag="
for /f %%i in ('git describe --contains HEAD') do set "tag=%%i"

cd !base_path!
REM delete the destination library folder when updating
RD /S /Q "..\Libraries\!lib_name!"
set lib_path_dest=..\Libraries\!lib_name!\
mkdir !lib_path_dest!

mkdir "!lib_path_dest!Include"
mkdir "!lib_path_dest!Source"
robocopy *.h !lib_path_src!include\gtest\ "!lib_path_dest!Include\gtest" /E
robocopy *.h !lib_path_src!src\ "!lib_path_dest!Include\src"
robocopy *.cc !lib_path_src!src\ "!lib_path_dest!Source" /XF *main* *all*

echo "!tag!" >"!lib_path_dest!!lib_name!_!tag!.txt"
)
)
36 changes: 36 additions & 0 deletions submodules/update_libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,40 @@ if [[ "$1" == "libzip" || "$update_all_libs" == true ]]; then
cmake -DPROJECT_SOURCE_DIR=${lib_path_src} -P ${lib_path_src}cmake/GenerateZipErrorStrings.cmake
cd "$base_path"
echo "\"$tag\"" > "$lib_path_dest${lib_name}_$tag.txt"
fi

if [[ "$1" == "googletest" || "$update_all_libs" == true ]]; then
# updating the googletest library
lib_name="googletest"
lib_path_src="$base_path$lib_name/googletest/"

cd "$lib_name"
tag=$(git describe --contains HEAD)
cd "$base_path"

# Delete the destination library folder when updating
lib_path_dest="../Libraries/$lib_name/"
rm -rf "$lib_path_dest"
mkdir -p "$lib_path_dest"

mkdir "$lib_path_dest/Include"
mkdir "$lib_path_dest/Include/gtest"
mkdir "$lib_path_dest/Include/gtest/internal"
mkdir "$lib_path_dest/Include/gtest/internal/custom"
mkdir "$lib_path_dest/Source"
mkdir "$lib_path_dest/Include/src"

cp ${lib_path_src}include/gtest/*.h "${lib_path_dest}Include/gtest"
cp ${lib_path_src}include/gtest/internal/*.h "${lib_path_dest}Include/gtest/internal"
cp ${lib_path_src}include/gtest/internal/custom/*.h "${lib_path_dest}Include/gtest/internal/custom"

find "${lib_path_src}src/" -name "*.h" \
-exec cp {} "${lib_path_dest}Include/src" \;

find "${lib_path_src}src/" -name "*.cc" \
! -name "*all*" \
! -name "*main*" \
-exec cp {} "${lib_path_dest}Source" \;

echo "\"$tag\"" > "$lib_path_dest${lib_name}_$tag.txt"
fi

0 comments on commit 42eec9d

Please sign in to comment.