serge1 / ELFIO

ELFIO - ELF (Executable and Linkable Format) reader and producer implemented as a header only C++ library
http://serge1.github.io/ELFIO
MIT License
706 stars 152 forks source link

tests: allow using system gtest copy #113

Closed thesamesam closed 1 year ago

thesamesam commented 1 year ago

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.

serge1 commented 1 year ago

Accepted. Thank you!

thesamesam commented 1 year ago

Thanks!

serge1 commented 1 year ago

Unfortunately, the change does not go plain. Here is my build log:

user@linux-on-jaguar:~/.local/share/Trash/files$ cd ~/ELFIO/ user@linux-on-jaguar:~/ELFIO$ mkdir build && cd build user@linux-on-jaguar:~/ELFIO/build$ cmake .. -DELFIO_BUILD_TESTS=ON -- The C compiler identification is GNU 11.3.0 -- The CXX compiler identification is GNU 11.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 CMake Error at /usr/share/cmake-3.22/Modules/ExternalProject.cmake:2806 (message): At least one entry of URL is a path (invalid in a list) Call Stack (most recent call first): /usr/share/cmake-3.22/Modules/ExternalProject.cmake:3716 (_ep_add_download_command) CMakeLists.txt:15 (ExternalProject_Add)

-- Configuring incomplete, errors occurred! See also "/home/user/ELFIO/build/_deps/googletest-subbuild/CMakeFiles/CMakeOutput.log".

CMake Error at /usr/share/cmake-3.22/Modules/FetchContent.cmake:1075 (message): CMake step for googletest failed: 1 Call Stack (most recent call first): /usr/share/cmake-3.22/Modules/FetchContent.cmake:1216:EVAL:2 (__FetchContent_directPopulate) /usr/share/cmake-3.22/Modules/FetchContent.cmake:1216 (cmake_language) /usr/share/cmake-3.22/Modules/FetchContent.cmake:1259 (FetchContent_Populate) tests/CMakeLists.txt:12 (FetchContent_MakeAvailable)

-- Configuring incomplete, errors occurred! See also "/home/user/ELFIO/build/CMakeFiles/CMakeOutput.log".

serge1 commented 1 year ago

I have reverted the change for the meantime. Please resubmit after the fix

thesamesam commented 1 year ago

Thanks, I'll give it another look, it definitely fetched for me.

serge1 commented 1 year ago

While testing, please don't forget to turn on the testing: ELFIO_BUILD_TESTS=ON

thesamesam commented 1 year ago

Oh dear. It's because it needs CMake 3.24 minimum.

serge1 commented 1 year ago

The library switched to a newer 'googletest' archive with your change in