Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gnss_utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labrobotica
algorithms
gnss_utils
Commits
f71b18b7
Commit
f71b18b7
authored
3 years ago
by
Mederic Fourmy
Browse files
Options
Downloads
Patches
Plain Diff
Updated the gtest cmake to adopt Ubuntu 20 >= fetchcontent feature, still compatible with ubuntu 18
parent
d5cb5a8b
No related branches found
No related tags found
2 merge requests
!23
after cmake refactor
,
!22
Resolve "Adapt to wolf core CMakeLists.txt refactor"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/CMakeLists.txt
+1
-10
1 addition, 10 deletions
test/CMakeLists.txt
test/gtest/CMakeLists.txt
+65
-50
65 additions, 50 deletions
test/gtest/CMakeLists.txt
with
66 additions
and
60 deletions
test/CMakeLists.txt
+
1
−
10
View file @
f71b18b7
# Retrieve googletest from github & compile
add_subdirectory
(
gtest
)
# Include gtest directory.
include_directories
(
${
GTEST_INCLUDE_DIRS
}
)
############# USE THIS TEST AS AN EXAMPLE ####################
# #
# Create a specific test executable for gtest_example #
# gnss_utils_add_gtest(gtest_example gtest_example.cpp) #
# target_link_libraries(gtest_example ${PROJECT_NAME}) #
# #
##############################################################
# Navigation test
gnss_utils_add_gtest
(
gtest_navigation gtest_navigation.cpp
)
target_link_libraries
(
gtest_navigation libgtest
${
PROJECT_NAME
}
)
# Observations test
gnss_utils_add_gtest
(
gtest_observations gtest_observations.cpp
)
target_link_libraries
(
gtest_observations libgtest
${
PROJECT_NAME
}
)
# TDCP test
gnss_utils_add_gtest
(
gtest_tdcp gtest_tdcp.cpp
)
target_link_libraries
(
gtest_tdcp
${
PROJECT_NAME
}
)
# Transformations test
gnss_utils_add_gtest
(
gtest_transformations gtest_transformations.cpp
)
target_link_libraries
(
gtest_transformations
${
PROJECT_NAME
}
)
# ChiSquare test
gnss_utils_add_gtest
(
gtest_chisquare gtest_chisquare.cpp
)
target_link_libraries
(
gtest_chisquare
${
PROJECT_NAME
}
)
\ No newline at end of file
gnss_utils_add_gtest
(
gtest_chisquare gtest_chisquare.cpp
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test/gtest/CMakeLists.txt
+
65
−
50
View file @
f71b18b7
cmake_minimum_required
(
VERSION 2.8.8
)
project
(
gtest_builder C CXX
)
if
(
${
CMAKE_VERSION
}
VERSION_LESS
"3.11.0"
)
message
(
"CMake version less than 3.11.0"
)
# We need thread support
#find_package(Threads REQUIRED
)
# Enable ExternalProject CMake module
include
(
ExternalProject
)
# Enable ExternalProject CMake module
include
(
ExternalProject
)
set
(
GTEST_FORCE_SHARED_CRT ON
)
set
(
GTEST_DISABLE_PTHREADS OFF
)
set
(
GTEST_FORCE_SHARED_CRT ON
)
set
(
GTEST_DISABLE_PTHREADS OFF
)
# For some reason I need to disable PTHREADS
# with g++ (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3
# This is a known issue for MinGW :
# https://github.com/google/shaderc/pull/174
#if(MINGW)
# set(GTEST_DISABLE_PTHREADS ON)
#endif()
# For some reason I need to disable PTHREADS
# with g++ (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3
# This is a known issue for MinGW :
# https://github.com/google/shaderc/pull/174
#if(MINGW)
set
(
GTEST_DISABLE_PTHREADS ON
)
#endif()
# Download GoogleTest
ExternalProject_Add
(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.8.x
# TIMEOUT 1 # We'll try this
CMAKE_ARGS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs
-DCMAKE_CXX_FLAGS=
${
MSVC_COMPILER_DEFS
}
-Dgtest_force_shared_crt=
${
GTEST_FORCE_SHARED_CRT
}
-Dgtest_disable_pthreads=
${
GTEST_DISABLE_PTHREADS
}
-DBUILD_GTEST=ON
PREFIX
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
# Disable install step
INSTALL_COMMAND
""
UPDATE_DISCONNECTED 1
# 1: do not update googletest; 0: update googletest via github
)
# Download GoogleTest
ExternalProject_Add
(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.8.x
# TIMEOUT 1 # We'll try this
CMAKE_ARGS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs
-DCMAKE_CXX_FLAGS=
${
MSVC_COMPILER_DEFS
}
-Dgtest_force_shared_crt=
${
GTEST_FORCE_SHARED_CRT
}
-Dgtest_disable_pthreads=
${
GTEST_DISABLE_PTHREADS
}
-DBUILD_GTEST=ON
PREFIX
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
# Disable install step
INSTALL_COMMAND
""
UPDATE_DISCONNECTED 1
# 1: do not update googletest; 0: update googletest via github
)
# Get GTest source and binary directories from CMake project
# Get GTest source and binary directories from CMake project
# Specify include dir
ExternalProject_Get_Property
(
googletest source_dir
)
set
(
GTEST_INCLUDE_DIRS
${
source_dir
}
/googletest/include PARENT_SCOPE
)
# Specify
include dir
ExternalProject_Get_Property
(
googletest
source
_dir
)
set
(
GTEST_
INCLUDE
_DIR
S
${
source
_dir
}
/google
test/include
PARENT_SCOPE
)
# Specify
MainTest's link libraries
ExternalProject_Get_Property
(
googletest
binary
_dir
)
set
(
GTEST_
LIBS
_DIR
${
binary
_dir
}
/google
mock/gtest
PARENT_SCOPE
)
# Specify MainTest's link librarie
s
ExternalProject_Get_Property
(
googletest binary_dir
)
set
(
GTEST_LIBS_DIR
${
binary_dir
}
/googlemock/gtest PARENT_SCOPE
)
# Create a libgtest target to be used as a dependency by test program
s
add_library
(
libgtest IMPORTED STATIC GLOBAL
)
add_dependencies
(
libgtest googletest
)
# Create a libgtest target to be used as a dependency by test programs
add_library
(
libgtest IMPORTED STATIC GLOBAL
)
add_dependencies
(
libgtest googletest
)
# Set libgtest properties
set_target_properties
(
libgtest PROPERTIES
"IMPORTED_LOCATION"
"
${
binary_dir
}
/googlemock/gtest/libgtest.a"
"IMPORTED_LINK_INTERFACE_LIBRARIES"
"
${
CMAKE_THREAD_LIBS_INIT
}
"
)
# Set libgtest properties
set_target_properties
(
libgtest PROPERTIES
"IMPORTED_LOCATION"
"
${
binary_dir
}
/googlemock/gtest/libgtest.a"
"IMPORTED_LINK_INTERFACE_LIBRARIES"
"
${
CMAKE_THREAD_LIBS_INIT
}
"
)
else
()
message
(
"CMake version equal or greater than 3.11.0"
)
include
(
FetchContent
)
FetchContent_Declare
(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main
)
FetchContent_MakeAvailable
(
googletest
)
endif
()
function
(
gnss_utils_add_gtest target
)
add_executable
(
${
target
}
${
ARGN
}
)
add_dependencies
(
${
target
}
libgtest
)
target_link_libraries
(
${
target
}
libgtest
)
#WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
if
(
${
CMAKE_VERSION
}
VERSION_LESS
"3.11.0"
)
add_dependencies
(
${
target
}
libgtest
)
target_link_libraries
(
${
target
}
libgtest
${
PROJECT_NAME
}
)
target_include_directories
(
${
target
}
PUBLIC
${
GTEST_INCLUDE_DIRS
}
)
else
()
target_link_libraries
(
${
target
}
PUBLIC gtest_main
${
PROJECT_NAME
}
)
endif
()
add_test
(
NAME
${
target
}
COMMAND
${
target
}
)
endfunction
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment