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

"Found gtest sources under '/usr/src/googletest': gtests will be built" but message(STATUS ${GTEST_INCLUDE_DIRS}) print '/usr/include' #1149

Open
osjacky430 opened this issue Aug 25, 2021 · 0 comments

Comments

@osjacky430
Copy link

Platform version information:

  • ROS: melodic
  • Ubuntu distro: 18.04
  • catkin version: 0.7.29
  • cmake version: 3.21.1

gtest version:

  • libgtest-dev, version: 1.10.0-2~18.04.sav0
  • googletest, versoin: 1.10.0-2~18.04.sav0
  • no googletest or gtest under catkin workspace

Minimum reproducible example:

under catkin workspace source directory

catkin_create_pkg catkin_issue

modify top-level CMakeLists.txt (comments removed)

cmake_minimum_required(VERSION 3.0.2)
project(catkin_issue)

find_package(catkin REQUIRED)

message(STATUS "GTEST_LIBRARIES: " ${GTEST_LIBRARIES})
message(STATUS "GTEST_FROM_SOURCE_LIBRARY_DIRS: " ${GTEST_FROM_SOURCE_LIBRARY_DIRS})
message(STATUS "GTEST_FROM_SOURCE_INCLUDE_DIRS: " ${GTEST_FROM_SOURCE_INCLUDE_DIRS})
message(STATUS "GTEST INCLUDE DIRS: " ${GTEST_INCLUDE_DIRS})
message(STATUS "GMOCK INCLUDE DIRS: " ${GMOCK_INCLUDE_DIRS})

catkin_package()
include_directories()

Build

source /opt/ros/melodic/setup.bash
catkin clean --yes
catkin build catkin_issue -v

Result

--------------------------------------------------------------
Profile:                     default
Extending:             [env] /opt/ros/melodic
Workspace:                   /home/gyro/Desktop/catkin
--------------------------------------------------------------
Build Space:        [exists] /home/gyro/Desktop/catkin/build
Devel Space:        [exists] /home/gyro/Desktop/catkin/devel
Install Space:      [unused] /home/gyro/Desktop/catkin/install
Log Space:         [missing] /home/gyro/Desktop/catkin/logs
Source Space:       [exists] /home/gyro/Desktop/catkin/src
DESTDIR:            [unused] None
--------------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
--------------------------------------------------------------
Additional CMake Args:       None
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
--------------------------------------------------------------
Whitelisted Packages:        None
Blacklisted Packages:        None
--------------------------------------------------------------
Workspace configuration appears valid.

NOTE: Forcing CMake to run for each package.
--------------------------------------------------------------
[build] Found '27' packages in 0.0 seconds.                                                                                                                                                  
[build] Updating package table.                                                                                                                                                              
Starting  >>> catkin_tools_prebuild                                                                                                                                                          
Starting   >> catkin_tools_prebuild:loadenv                                                                                                                                                  
Output     << catkin_tools_prebuild:loadenv /home/gyro/Desktop/catkin/logs/catkin_tools_prebuild/build.loadenv.000.log                                                                       
Loading environment from: /home/gyro/Desktop/catkin/devel/env.sh
Finished   << catkin_tools_prebuild:loadenv                                                                                                                                                  
Starting   >> catkin_tools_prebuild:mkdir                                                                                                                                                    
Starting   >> catkin_tools_prebuild:mkdir                                                                                                                                                    
Starting   >> catkin_tools_prebuild:cache-manifest                                                                                                                                           
Starting   >> catkin_tools_prebuild:ctr-nuke                                                                                                                                                 
Starting   >> catkin_tools_prebuild:cmake                                                                                                                                                    
Subprocess  > catkin_tools_prebuild:cmake `cd /home/gyro/Desktop/catkin/build/catkin_tools_prebuild; catkin build --get-env catkin_tools_prebuild | catkin env -si  /usr/local/bin/cmake /home/gyro/Desktop/catkin/build/catkin_tools_prebuild --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/gyro/Desktop/catkin/devel/.private/catkin_tools_prebuild -DCMAKE_INSTALL_PREFIX=/home/gyro/Desktop/catkin/install; cd -`
_____________________________________________________________________________________________________________________________________________________________________________________________
Warnings   << catkin_tools_prebuild:cmake /home/gyro/Desktop/catkin/logs/catkin_tools_prebuild/build.cmake.000.log                                                                           
Not searching for unused variables given on the command line.
Re-run cmake no build system arguments
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.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
-- Using CATKIN_DEVEL_PREFIX: /home/gyro/Desktop/catkin/devel/.private/catkin_tools_prebuild
-- Using CMAKE_PREFIX_PATH: /opt/ros/melodic
-- This workspace overlays: /opt/ros/melodic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.18", minimum required is "2")
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/gyro/Desktop/catkin/build/catkin_tools_prebuild/test_results
-- Forcing gtest/gmock from source, though one was otherwise available.
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
CMake Deprecation Warning at /usr/src/googletest/CMakeLists.txt:4 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at /usr/src/googletest/googlemock/CMakeLists.txt:45 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at /usr/src/googletest/googletest/CMakeLists.txt:56 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Found PythonInterp: /usr/bin/python2 (found version "2.7.18")
-- Found Threads: TRUE
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.29
-- BUILD_SHARED_LIBS is on
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gyro/Desktop/catkin/build/catkin_tools_prebuild
cd /home/gyro/Desktop/catkin/build/catkin_tools_prebuild; catkin build --get-env catkin_tools_prebuild | catkin env -si  /usr/local/bin/cmake /home/gyro/Desktop/catkin/build/catkin_tools_prebuild --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/gyro/Desktop/catkin/devel/.private/catkin_tools_prebuild -DCMAKE_INSTALL_PREFIX=/home/gyro/Desktop/catkin/install; cd -
.............................................................................................................................................................................................
Finished   << catkin_tools_prebuild:cmake                                                                                                                                                    
Starting   >> catkin_tools_prebuild:make                                                                                                                                                     
Subprocess  > catkin_tools_prebuild:make `cd /home/gyro/Desktop/catkin/build/catkin_tools_prebuild; catkin build --get-env catkin_tools_prebuild | catkin env -si  /usr/bin/make --jobserver-fds=6,7 -j; cd -`
Output     << catkin_tools_prebuild:make /home/gyro/Desktop/catkin/logs/catkin_tools_prebuild/build.make.000.log                                                                             
/usr/local/bin/cmake -S/home/gyro/Desktop/catkin/build/catkin_tools_prebuild -B/home/gyro/Desktop/catkin/build/catkin_tools_prebuild --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /home/gyro/Desktop/catkin/build/catkin_tools_prebuild/CMakeFiles /home/gyro/Desktop/catkin/build/catkin_tools_prebuild//CMakeFiles/progress.marks
/usr/bin/make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/gyro/Desktop/catkin/build/catkin_tools_prebuild'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/gyro/Desktop/catkin/build/catkin_tools_prebuild'
/usr/local/bin/cmake -E cmake_progress_start /home/gyro/Desktop/catkin/build/catkin_tools_prebuild/CMakeFiles 0
cd /home/gyro/Desktop/catkin/build/catkin_tools_prebuild; catkin build --get-env catkin_tools_prebuild | catkin env -si  /usr/bin/make --jobserver-fds=6,7 -j; cd -
Finished   << catkin_tools_prebuild:make                                                                                                                                                     
Starting   >> catkin_tools_prebuild:symlink                                                                                                                                                  
Output     << catkin_tools_prebuild:symlink /home/gyro/Desktop/catkin/logs/catkin_tools_prebuild/build.symlink.000.log                                                                       
Symlinking /home/gyro/Desktop/catkin/devel/./env.sh
Symlinking /home/gyro/Desktop/catkin/devel/./local_setup.zsh
Symlinking /home/gyro/Desktop/catkin/devel/./cmake.lock
Symlinking /home/gyro/Desktop/catkin/devel/./local_setup.sh
Symlinking /home/gyro/Desktop/catkin/devel/./_setup_util.py
Symlinking /home/gyro/Desktop/catkin/devel/./local_setup.bash
Symlinking /home/gyro/Desktop/catkin/devel/./setup.sh
Symlinking /home/gyro/Desktop/catkin/devel/./setup.zsh
Symlinking /home/gyro/Desktop/catkin/devel/./setup.bash
Symlinking /home/gyro/Desktop/catkin/devel/share/catkin_tools_prebuild/cmake/catkin_tools_prebuildConfig-version.cmake
Symlinking /home/gyro/Desktop/catkin/devel/share/catkin_tools_prebuild/cmake/catkin_tools_prebuildConfig.cmake
Symlinking /home/gyro/Desktop/catkin/devel/lib/pkgconfig/catkin_tools_prebuild.pc
Finished   << catkin_tools_prebuild:symlink                                                                                                                                                  
Finished  <<< catkin_tools_prebuild                [ 0.8 seconds ]                                                                                                                           
Starting  >>> catkin_issue                                                                                                                                                                   
Starting   >> catkin_issue:loadenv                                                                                                                                                           
Output     << catkin_issue:loadenv /home/gyro/Desktop/catkin/logs/catkin_issue/build.loadenv.000.log                                                                                         
Loading environment from: /home/gyro/Desktop/catkin/devel/env.sh
Finished   << catkin_issue:loadenv                                                                                                                                                           
Starting   >> catkin_issue:mkdir                                                                                                                                                             
Starting   >> catkin_issue:mkdir                                                                                                                                                             
Starting   >> catkin_issue:cache-manifest                                                                                                                                                    
Starting   >> catkin_issue:ctr-nuke                                                                                                                                                          
Starting   >> catkin_issue:cmake                                                                                                                                                             
Subprocess  > catkin_issue:cmake `cd /home/gyro/Desktop/catkin/build/catkin_issue; catkin build --get-env catkin_issue | catkin env -si  /usr/local/bin/cmake /home/gyro/Desktop/catkin/src/catkin_issue --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/gyro/Desktop/catkin/devel/.private/catkin_issue -DCMAKE_INSTALL_PREFIX=/home/gyro/Desktop/catkin/install; cd -`
_____________________________________________________________________________________________________________________________________________________________________________________________
Warnings   << catkin_issue:cmake /home/gyro/Desktop/catkin/logs/catkin_issue/build.cmake.000.log                                                                                             
Not searching for unused variables given on the command line.
Re-run cmake no build system arguments
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.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
-- Using CATKIN_DEVEL_PREFIX: /home/gyro/Desktop/catkin/devel/.private/catkin_issue
-- Using CMAKE_PREFIX_PATH: /home/gyro/Desktop/catkin/devel;/opt/ros/melodic
-- This workspace overlays: /home/gyro/Desktop/catkin/devel;/opt/ros/melodic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.18", minimum required is "2")
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/gyro/Desktop/catkin/build/catkin_issue/test_results
-- Forcing gtest/gmock from source, though one was otherwise available.
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
CMake Deprecation Warning at /usr/src/googletest/CMakeLists.txt:4 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at /usr/src/googletest/googlemock/CMakeLists.txt:45 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at /usr/src/googletest/googletest/CMakeLists.txt:56 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Found PythonInterp: /usr/bin/python2 (found version "2.7.18")
-- Found Threads: TRUE
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.29
-- BUILD_SHARED_LIBS is on
-- GTEST_LIBRARIES: gtest
-- GTEST_FROM_SOURCE_LIBRARY_DIRS: /home/gyro/Desktop/catkin/build/catkin_issue/gtest
-- GTEST_FROM_SOURCE_INCLUDE_DIRS: /usr/include
-- GTEST INCLUDE DIRS: /usr/include
-- GMOCK INCLUDE DIRS: /usr/src/googletest/googlemock/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gyro/Desktop/catkin/build/catkin_issue
cd /home/gyro/Desktop/catkin/build/catkin_issue; catkin build --get-env catkin_issue | catkin env -si  /usr/local/bin/cmake /home/gyro/Desktop/catkin/src/catkin_issue --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/gyro/Desktop/catkin/devel/.private/catkin_issue -DCMAKE_INSTALL_PREFIX=/home/gyro/Desktop/catkin/install; cd -
.............................................................................................................................................................................................
Finished   << catkin_issue:cmake                                                                                                                                                             
Starting   >> catkin_issue:make                                                                                                                                                              
Subprocess  > catkin_issue:make `cd /home/gyro/Desktop/catkin/build/catkin_issue; catkin build --get-env catkin_issue | catkin env -si  /usr/bin/make --jobserver-fds=6,7 -j; cd -`          
Output     << catkin_issue:make /home/gyro/Desktop/catkin/logs/catkin_issue/build.make.000.log                                                                                               
/usr/local/bin/cmake -S/home/gyro/Desktop/catkin/src/catkin_issue -B/home/gyro/Desktop/catkin/build/catkin_issue --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /home/gyro/Desktop/catkin/build/catkin_issue/CMakeFiles /home/gyro/Desktop/catkin/build/catkin_issue//CMakeFiles/progress.marks
/usr/bin/make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/gyro/Desktop/catkin/build/catkin_issue'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/gyro/Desktop/catkin/build/catkin_issue'
/usr/local/bin/cmake -E cmake_progress_start /home/gyro/Desktop/catkin/build/catkin_issue/CMakeFiles 0
cd /home/gyro/Desktop/catkin/build/catkin_issue; catkin build --get-env catkin_issue | catkin env -si  /usr/bin/make --jobserver-fds=6,7 -j; cd -
Finished   << catkin_issue:make                                                                                                                                                              
Starting   >> catkin_issue:symlink                                                                                                                                                           
Output     << catkin_issue:symlink /home/gyro/Desktop/catkin/logs/catkin_issue/build.symlink.000.log                                                                                         
Symlinking /home/gyro/Desktop/catkin/devel/share/catkin_issue/cmake/catkin_issueConfig.cmake
Symlinking /home/gyro/Desktop/catkin/devel/share/catkin_issue/cmake/catkin_issueConfig-version.cmake
Symlinking /home/gyro/Desktop/catkin/devel/lib/pkgconfig/catkin_issue.pc
Finished   << catkin_issue:symlink                                                                                                                                                           
Finished  <<< catkin_issue                         [ 0.9 seconds ]                                                                                                                           
[build] Summary: All 2 packages succeeded!                                                                                                                                                   
[build]   Ignored:   26 packages were skipped or are blacklisted.                                                                                                                            
[build]   Warnings:  2 packages succeeded with warnings.                                                                                                                                     
[build]   Abandoned: None.                                                                                                                                                                   
[build]   Failed:    None.                                                                                                                                                                   
[build] Runtime: 1.7 seconds total.

It looks like a bug to me, due to this, I need to manually specify the path to googletest instead of ${GTEST_INCLUDE_DIRS} when running CPPCheck in order to suppress warning from it.

After digging into the source code, it seems that catkin assume libgtest-dev's header at /usr/include and source at /usr/src/gtest. However, ls -l under /usr/src I found that /usr/src/gtest is symlinked to googletest, so base_dir will always point to /usr/src/googletest, thus the message `Found gtest sources under '/usr/src/googletest''.

As for gmock, since libgmock-dev isn't installed, GMock related paths are shown as expected. If libgmock-dev is installed, same thing happens to GMock as well. (verified)

Perhaps re-setting gtest_<VAR> in here is the right way to fix the issue?

if(_gtest_found)
get_filename_component(_gtest_base_dir_realpath ${_gtest_base_dir} REALPATH)
get_filename_component(_global_base_dir ${_gtest_base_dir_realpath} PATH)
if(EXISTS "${_global_base_dir}/CMakeLists.txt")
set(${base_dir} ${_global_base_dir} PARENT_SCOPE)
endif()
endif()

@osjacky430 osjacky430 changed the title "Found gtest sources under '/usr/src/googletest': gtests will be built" but message(STATUS ${GTEST_INCLUDE_DIRS} print '/usr/include') "Found gtest sources under '/usr/src/googletest': gtests will be built" but message(STATUS ${GTEST_INCLUDE_DIRS}) print '/usr/include' Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant