PIC dependecies (#110)

* Add PIC selection on Micro-CDR.

* Update Micro-CDR version to 1.1.1.

* Change version temporarily to 1.1.3.

* Modify connection attempts and interval default configuration.

* Change Micro-CDR dependency from submodule to git external project.

* Remove submodules.

* Change Micro-CDR tag.

* Test cases (#111)

* Refs #6972. Move Jenkins file from root to ci folder.

* Refs #6972. Add Linux and Windows CI projects.

* Refs #6972. Add CTestConfig.cmake file.

* Refs #6972. Add UCLIENT_BUILD_CI_TESTS flag.

* Refs #6972. Add test cases.

* Refs #6972. Add dependencies to Config.cmake file.
This commit is contained in:
Julián Bermúdez Ortega 2019-12-03 15:39:38 +01:00 committed by Borja Outerelo
parent 46c79cf198
commit 139a6bb9a1
16 changed files with 283 additions and 14 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "thirdparty/microcdr"]
path = thirdparty/microcdr
url = https://github.com/eProsima/micro-CDR.git

View File

@ -27,11 +27,20 @@ option(UCLIENT_VERBOSE_SERIALIZATION "Build with serialization verbosity." OFF)
option(UCLIENT_VERBOSE_MESSAGE "Build with message verbosity." OFF)
option(UCLIENT_PIC "Control Position Independent Code." ON)
option(BUILD_SHARED_LIBS "Control shared/static library building." OFF)
option(UCLIENT_BUILD_CI_TESTS "Build CI test cases." OFF)
if(UCLIENT_BUILD_CI_TESTS)
set(UCLIENT_BUILD_TESTS ON)
set(UCLIENT_BUILD_EXAMPLES ON)
endif()
if((CMAKE_SYSTEM_NAME STREQUAL "") AND (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux"))
option(UCLIENT_MEMORY_TESTS "Build memory tests." OFF)
option(UCLIENT_PERFORMANCE_TESTS "Build performance tests." OFF)
endif()
option(UCLIENT_BIG_ENDIANNESS "Set the machine endianness to big endianness (by default is little endianness)." OFF)
set(UCLIENT_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/client.config" CACHE PATH "Configuration client file.")
include(GNUInstallDirs)
@ -45,12 +54,21 @@ else()
set(LICENSE_INSTALL_DIR ${DATA_INSTALL_DIR}/${PROJECT_NAME} CACHE PATH "Installation directory for licenses")
endif()
###############################################################################
# Dependencies
###############################################################################
set(_microcdr_version 1.1.1)
set(_microcdr_tag v1.1.1)
set(_deps "")
list(APPEND _deps "microcdr\;${_microcdr_version}")
###############################################################################
# Project
###############################################################################
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
if(NOT UCLIENT_SUPERBUILD)
project(microxrcedds_client VERSION "1.1.3" LANGUAGES C)
project(microxrcedds_client VERSION "1.1.4" LANGUAGES C)
else()
project(uclient_superbuild NONE)
include(${PROJECT_SOURCE_DIR}/cmake/SuperBuild.cmake)
@ -89,7 +107,13 @@ endif()
###############################################################################
# Load external eProsima projects.
###############################################################################
find_package(microcdr 1.1.0 EXACT REQUIRED PATHS ${PROJECT_BINARY_DIR}/temp_install)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${PROJECT_BINARY_DIR}/temp_install)
foreach(d ${_deps})
list(GET d 0 _name)
list(GET d 1 _version)
find_package(${_name} ${_version} EXACT REQUIRED)
endforeach()
###############################################################################
# Sources
@ -193,7 +217,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
C_STANDARD_REQUIRED
YES
POSITION_INDEPENDENT_CODE
${UCLIENT_PIC}
${UCLIENT_PIC}
)
target_compile_options(${PROJECT_NAME}
@ -274,6 +298,11 @@ endif()
###############################################################################
# Tests
###############################################################################
if(UCLIENT_BUILD_CI_TESTS)
include(CTest)
add_subdirectory(test/case)
endif()
if(UCLIENT_BUILD_TESTS)
include(${PROJECT_SOURCE_DIR}/cmake/common/gtest.cmake)
find_package(GTest REQUIRED)

22
CTestConfig.cmake Normal file
View File

@ -0,0 +1,22 @@
# Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# MemoryCheck configuration.
find_program(MEMORYCHECK_COMMAND NAMES valgrind)
set(MEMORYCHECK_COMMAND_OPTIONS "${MEMORYCHECK_COMMAND_OPTIONS} --quiet --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=50 --xml=yes --xml-file=test_%p_memcheck.xml \"--suppressions=${CMAKE_CURRENT_SOURCE_DIR}/ci/valgrind.supp\"")
# Coverage configuration.
find_program(COVERAGE_COMMAND NAMES gcov)
endif()

48
ci/linux/CMakeLists.txt Normal file
View File

@ -0,0 +1,48 @@
# Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR)
project(microxrcedds_client_ci LANGUAGES C CXX)
include(ExternalProject)
set(_c_flags "-fwrapv -fprofile-arcs -ftest-coverage")
set(_cxx_flags "-fwrapv -fprofile-arcs -ftest-coverage")
set(_exe_linker_flags "-fprofile-arcs -ftest-coverage")
set(_shared_linker_flags "-fprofile-arcs -ftest-coverage")
ExternalProject_Add(microxrcedds_client
SOURCE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/../../
BINARY_DIR
${PROJECT_BINARY_DIR}/microxrcedds_client-build
INSTALL_DIR
${PROJECT_BINARY_DIR}/temp_install
TEST_AFTER_INSTALL
TRUE
TEST_COMMAND
COMMAND ${CMAKE_CTEST_COMMAND} -VV -T Test
COMMAND ${CMAKE_CTEST_COMMAND} -VV -T MemCheck -E "test-case*"
COMMAND ${CMAKE_CTEST_COMMAND} -VV -T Coverage -E "test-case*"
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_C_FLAGS:STRING=${_c_flags}
-DCMAKE_CXX_FLAGS:STRING=${_cxx_flags}
-DCMAKE_EXE_LINKER_FLAGS:STRING=${_exe_linker_flags}
-DCMAKE_SHARED_LINKER_FLAGS:STRING=${_shared_linker_flags}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DUCLIENT_BUILD_CI_TESTS:BOOL=ON
-DGTEST_INDIVIDUAL:BOOL=ON
)

39
ci/windows/CMakeLists.txt Normal file
View File

@ -0,0 +1,39 @@
# Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR)
project(microxrcedds_client_ci LANGUAGES C CXX)
include(ExternalProject)
ExternalProject_Add(microxrcedds_client
SOURCE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/../../
BINARY_DIR
${PROJECT_BINARY_DIR}/microxrcedds_client-build
INSTALL_DIR
${PROJECT_BINARY_DIR}/temp_install
TEST_AFTER_INSTALL
TRUE
TEST_COMMAND
COMMAND ${CMAKE_CTEST_COMMAND} -VV -C ${CMAKE_BUILD_TYPE} -T Test
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_GENERATOR_TOOLSET:STRING=${CMAKE_GENERATOR_TOOLSET}
-DCMAKE_GENERATOR_PLATFORM:STRING=${CMAKE_GENERATOR_PLATFORM}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DUCLIENT_BUILD_CI_TESTS:BOOL=ON
-DGTEST_INDIVIDUAL:BOOL=ON
)

View File

@ -8,8 +8,8 @@ CONFIG_MAX_OUTPUT_RELIABLE_STREAMS=1
CONFIG_MAX_INPUT_BEST_EFFORT_STREAMS=1
CONFIG_MAX_INPUT_RELIABLE_STREAMS=1
CONFIG_MAX_SESSION_CONNECTION_ATTEMPTS=12
CONFIG_MIN_SESSION_CONNECTION_INTERVAL=1
CONFIG_MAX_SESSION_CONNECTION_ATTEMPTS=5
CONFIG_MIN_SESSION_CONNECTION_INTERVAL=500
CONFIG_MIN_HEARTBEAT_TIME_INTERVAL=1
CONFIG_BIG_ENDIANNESS=FALSE

View File

@ -18,15 +18,15 @@ unset(_deps)
# Micro CDR.
unset(microcdr_DIR CACHE)
find_package(microcdr "1.1.0" EXACT QUIET)
find_package(microcdr ${_microcdr_version} EXACT QUIET)
if(NOT microcdr_FOUND)
ExternalProject_Add(ucdr
DOWNLOAD_COMMAND
cd ${PROJECT_SOURCE_DIR} && git submodule update --init thirdparty/microcdr/
GIT_REPOSITORY
https://github.com/eProsima/Micro-CDR.git
GIT_TAG
${_microcdr_tag}
PREFIX
${PROJECT_BINARY_DIR}/ucdr
SOURCE_DIR
${PROJECT_SOURCE_DIR}/thirdparty/microcdr
INSTALL_DIR
${PROJECT_BINARY_DIR}/temp_install
CMAKE_ARGS
@ -36,6 +36,7 @@ if(NOT microcdr_FOUND)
-DCMAKE_SYSROOT:PATH=${CMAKE_SYSROOT}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCONFIG_BIG_ENDIANNESS=${UCLIENT_BIG_ENDIANNESS}
-DUCDR_PIC=${UCLIENT_PIC}
)
list(APPEND _deps ucdr)
endif()

View File

@ -23,4 +23,10 @@ set_and_check(@PROJECT_NAME@_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
set_and_check(@PROJECT_NAME@_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@")
set_and_check(@PROJECT_NAME@_DATA_DIR "@PACKAGE_DATA_INSTALL_DIR@")
foreach(d @_deps@)
list(GET d 0 _name)
list(GET d 1 _version)
find_package(${_name} ${_version} EXACT REQUIRED)
endforeach()
include(${@PROJECT_NAME@_DATA_DIR}/@PROJECT_NAME@/cmake/@PROJECT_NAME@Targets.cmake)

36
test/case/CMakeLists.txt Normal file
View File

@ -0,0 +1,36 @@
# Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
add_test(
NAME
test-case-installation
COMMAND
${CMAKE_COMMAND}
-DINSTALL_PATH=${CMAKE_INSTALL_PREFIX}
-DLIBRARY_NAME=$<TARGET_FILE_NAME:${PROJECT_NAME}>
-P ${CMAKE_CURRENT_SOURCE_DIR}/installation/InstallationTest.cmake
)
add_test(
NAME
test-case-packaging
COMMAND
${CMAKE_COMMAND}
-DORIGINAL_DIR=${CMAKE_CURRENT_SOURCE_DIR}/packaging
-DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}
-DREQUIRED_VERSION=${PROJECT_VERSION}
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-P ${CMAKE_CURRENT_SOURCE_DIR}/packaging/Packaging.cmake
)

View File

@ -0,0 +1,26 @@
# Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Check directories.
set(_directories "lib" "include" "share")
foreach(_dir ${_directories})
if(NOT EXISTS ${INSTALL_PATH}/${_dir})
message(FATAL_ERROR "Directory ${_dir} not found.")
endif()
endforeach()
# Check library.
if(NOT EXISTS ${INSTALL_PATH}/lib/${LIBRARY_NAME})
message(FATAL_ERROR "Library lib/${LIBRARY_NAME} not found.")
endif()

View File

@ -0,0 +1,23 @@
# Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR)
project(packaging LANGUAGES C)
find_package(microxrcedds_client EXACT ${REQUIRED_VERSION} REQUIRED)
add_executable(${PROJECT_NAME} main.c)
target_link_libraries(${PROJECT_NAME} microxrcedds_client)

View File

@ -0,0 +1,37 @@
# Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
execute_process(
COMMAND
${CMAKE_COMMAND} ${ORIGINAL_DIR}
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
-DREQUIRED_VERSION=${REQUIRED_VERSION}
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
RESULT_VARIABLE _result
)
if(_result)
message(FATAL_ERROR "Error in find_package.")
endif()
execute_process(
COMMAND
${CMAKE_COMMAND} --build .
RESULT_VARIABLE _result
)
if(_result)
message(FATAL_ERROR "Error compiling example.")
endif()

View File

@ -0,0 +1,6 @@
#include <uxr/client/client.h>
int main()
{
return 0;
}

1
thirdparty/microcdr vendored

@ -1 +0,0 @@
Subproject commit ef671568fba72cc2dbf146ab6b6c9ffdc09dd0a8