Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support system copy of gtest #654

Closed
thesamesam opened this issue Oct 17, 2022 · 5 comments
Closed

Support system copy of gtest #654

thesamesam opened this issue Oct 17, 2022 · 5 comments
Labels
build system Build system and script changes

Comments

@thesamesam
Copy link
Contributor

Please consider reworking d03ca72 to allow using a system copy of gtest. Many package managers prohibit network access during the build.

While it may be possible to pre-download a copy and shove into the build dir, it's still a waste of resources and awkward to maintain.

Thanks!

@nmoinvaz
Copy link
Member

It supports that already. If you have a parent project and already include Gtest then it will detect it.

@thesamesam
Copy link
Contributor Author

thesamesam commented Oct 17, 2022

I don't think that helps when gtest is just installed on the system though and building minizip-ng by itself (i.e. no parent project). It least it doesn't for me, and other CMake packages pick it up fine.

I don't think the target test will ever pass as we're not doing find_package (or anything else) for it.

e.g.

>>> Unpacking source...
>>> Unpacking minizip-ng-3.0.7.tar.gz to /var/tmp/portage/sys-libs/minizip-ng-3.0.7/work
>>> Source unpacked in /var/tmp/portage/sys-libs/minizip-ng-3.0.7/work
>>> Preparing source in /var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7 ...
 * Source directory (CMAKE_USE_DIR): "/var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7"
 * Build directory  (BUILD_DIR):     "/var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7_build"
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7 ...
 * Source directory (CMAKE_USE_DIR): "/var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7"
 * Build directory  (BUILD_DIR):     "/var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7_build"
cmake -C /var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7_build/gentoo_common_config.cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DMZ_COMPAT=no -DMZ_BUILD_TESTS=yes -DMZ_BUILD_UNIT_TESTS=yes -DMZ_FETCH_LIBS=OFF -DMZ_FORCE_FETCH_LIBS=OFF -DMZ_ZLIB=ON -DMZ_BZIP2=ON -DMZ_LZMA=ON -DMZ_ZSTD=no -DMZ_LIBCOMP=OFF -DMZ_PKCRYPT=ON -DMZ_WZAES=ON -DMZ_OPENSSL=no -DMZ_LIBBSD=ON -DMZ_SIGNING=ON -DMZ_ICONV=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=/var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7_build/gentoo_toolchain.cmake /var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7
loading initial cache file /var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7_build/gentoo_common_config.cmake
-- Using CMake version 3.24.2
-- The C compiler identification is GNU 12.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib/ccache/bin/x86_64-pc-linux-gnu-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - found
-- Using ZLIB 1.2.13
-- Using BZIP2 1.0.8
-- Checking for module 'liblzma'
--   Found liblzma, version 5.3.3alpha
-- Using LZMA 5.3.3alpha
-- WinZIP AES support requires OpenSSL
-- Signing support requires OpenSSL
-- Looking for getrandom
-- Looking for getrandom - found
-- Looking for arc4random_buf
-- Looking for arc4random_buf - found
-- Performing Test Iconv_IS_BUILT_IN
-- Performing Test Iconv_IS_BUILT_IN - Success
-- Using Iconv
-- Project configured as minizip-ng
-- The CXX compiler identification is GNU 12.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
[1/9] Creating directories for 'googletest-populate'
[1/9] Performing download step (git clone) for 'googletest-populate'
Cloning into 'googletest-src'...
fatal: unable to access 'https://github.com/google/googletest.git/': Could not resolve host: github.com
Cloning into 'googletest-src'...
fatal: unable to access 'https://github.com/google/googletest.git/': Could not resolve host: github.com
Cloning into 'googletest-src'...
fatal: unable to access 'https://github.com/google/googletest.git/': Could not resolve host: github.com
-- Had to git clone more than once: 3 times.
CMake Error at googletest-subbuild/googletest-populate-prefix/tmp/googletest-populate-gitclone.cmake:39 (message):
  Failed to clone repository: 'https://github.com/google/googletest.git'


FAILED: googletest-populate-prefix/src/googletest-populate-stamp/googletest-populate-download /var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7_build/_deps/googletest-subbuild/googletest-populate-prefix/src/googletest-populate-stamp/googletest-populate-download
cd /var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7_build/_deps && /usr/bin/cmake -P /var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7_build/_deps/googletest-subbuild/googletest-populate-prefix/tmp/googletest-populate-gitclone.cmake && /usr/bin/cmake -E touch /var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7_build/_deps/googletest-subbuild/googletest-populate-prefix/src/googletest-populate-stamp/googletest-populate-download
ninja: build stopped: subcommand failed.

CMake Error at /usr/share/cmake/Modules/FetchContent.cmake:1604 (message):
  Build step for googletest failed: 1
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FetchContent.cmake:1744:EVAL:2 (__FetchContent_directPopulate)
  /usr/share/cmake/Modules/FetchContent.cmake:1744 (cmake_language)
  test/CMakeLists.txt:36 (FetchContent_Populate)


-- Configuring incomplete, errors occurred!
See also "/var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7_build/CMakeFiles/CMakeOutput.log".
See also "/var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7_build/CMakeFiles/CMakeError.log".
 * ERROR: sys-libs/minizip-ng-3.0.7::gentoo failed (configure phase):
 *   cmake failed
 *
 * Call stack:
 *     ebuild.sh, line  122:  Called src_configure
 *   environment, line 2351:  Called cmake_src_configure
 *   environment, line 1091:  Called die
 * The specific snippet of code:
 *       "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed";
 *
 * If you need support, post the output of `emerge --info '=sys-libs/minizip-ng-3.0.7::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=sys-libs/minizip-ng-3.0.7::gentoo'`.
 * The complete build log is located at '/var/log/portage/build/sys-libs/minizip-ng-3.0.7:20221017-033658.log'.
 * For convenience, a symlink to the build log is located at '/var/tmp/portage/sys-libs/minizip-ng-3.0.7/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-libs/minizip-ng-3.0.7/temp/environment'.
 * Working directory: '/var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7_build'
 * S: '/var/tmp/portage/sys-libs/minizip-ng-3.0.7/work/minizip-ng-3.0.7'

@nmoinvaz
Copy link
Member

Good idea. I am open to PRs.

nmoinvaz pushed a commit that referenced this issue Nov 19, 2022
Distributions often do builds with no network access available
for both security reasons and also to ensure reproducibility.

This change tells CMake to query the system for a copy of gtest,
but if it's not available, it'll fall back to downloading via
FetchContent.
nmoinvaz pushed a commit that referenced this issue Nov 19, 2022
Distributions often do builds with no network access available
for both security reasons and also to ensure reproducibility.

This change tells CMake to query the system for a copy of gtest,
but if it's not available, it'll fall back to downloading via
FetchContent.
@nmoinvaz
Copy link
Member

Thanks for the fix.

@nmoinvaz nmoinvaz added the build system Build system and script changes label Nov 19, 2022
@thesamesam
Copy link
Contributor Author

No worries!

nmoinvaz pushed a commit that referenced this issue Nov 30, 2022
Distributions often do builds with no network access available
for both security reasons and also to ensure reproducibility.

This change tells CMake to query the system for a copy of gtest,
but if it's not available, it'll fall back to downloading via
FetchContent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system Build system and script changes
Projects
None yet
Development

No branches or pull requests

2 participants