Skip to content
Snippets Groups Projects
Commit 01c96725 authored by Mederic Fourmy's avatar Mederic Fourmy
Browse files

Merge branch '451-refactoring-wolf-installation-system' of...

Merge branch '451-refactoring-wolf-installation-system' of https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/wolf into 451-refactoring-wolf-installation-system
parents ab615c4a 8c7e5dba
No related branches found
No related tags found
2 merge requests!451After cmake and const refactor,!445Resolve "Refactoring WOLF installation system"
Pipeline #10091 canceled
...@@ -103,7 +103,7 @@ build_and_test:bionic: ...@@ -103,7 +103,7 @@ build_and_test:bionic:
except: except:
- master - master
script: script:
- *cmake316_definition #- *cmake316_definition
- *build_and_test_definition - *build_and_test_definition
############ UBUNTU 20.04 TESTS ############ ############ UBUNTU 20.04 TESTS ############
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
MESSAGE(STATUS "Starting WOLF CMakeLists ...") MESSAGE(STATUS "Starting WOLF CMakeLists ...")
# Pre-requisites about cmake itself # Pre-requisites about cmake itself
CMAKE_MINIMUM_REQUIRED(VERSION 3.16) CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
if(COMMAND cmake_policy) if(COMMAND cmake_policy)
cmake_policy(SET CMP0005 NEW) cmake_policy(SET CMP0005 NEW)
......
include(FetchContent) if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
FetchContent_Declare( message("CMake version less than 3.11.0")
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main)
FetchContent_MakeAvailable(googletest)
# Enable ExternalProject CMake module
include(ExternalProject)
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()
# 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
# Specify include dir
ExternalProject_Get_Property(googletest source_dir)
set(GTEST_INCLUDE_DIRS ${source_dir}/googletest/include PARENT_SCOPE)
# Specify MainTest's link libraries
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 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}"
)
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(wolf_add_gtest target) function(wolf_add_gtest target)
add_executable(${target} ${ARGN}) add_executable(${target} ${ARGN})
target_link_libraries(${target} gtest_main) target_link_libraries(${target} gtest_main)
add_test(NAME ${target} COMMAND ${target}) add_test(NAME ${target} COMMAND ${target})
endfunction() endfunction()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment