Skip to content

Commit

Permalink
Eliminate Conan
Browse files Browse the repository at this point in the history
* Download and build Google Test on the fly on Windows, Linux: Windows
  because it is the only way to get it, Linux because we need a version
  that still supports C++. (macOS: homebrew does just fine.)

* Move C++11 build to Linux: it is the only one that requires boost, and
  installing boost on Windows via Chocolatey takes forever whereas on
  Linux "apt install" is done nearly instantaneously.

* PIP cacheing is no longer needed.

* Bison has not been needed for a long time, so stop installing it.

Signed-off-by: Erik Boasson <[email protected]>
  • Loading branch information
eboasson committed Aug 28, 2023
1 parent dca4563 commit d7d2578
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 91 deletions.
52 changes: 21 additions & 31 deletions .azure/templates/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,21 @@ steps:
echo "###vso[task.setvariable variable=build_type;]Debug"
name: setup
- bash: |
echo "###vso[task.setvariable variable=pip_cache;]${HOME}/.cache/pip"
echo "###vso[task.setvariable variable=conan_cache;]${HOME}/.conan/data"
echo "###vso[task.setvariable variable=PATH;]$(python3 -m site --user-base)/bin:${PATH}"
echo "###vso[task.setvariable variable=build_tool_options;]-j 4"
sudo apt-get install -y clang clang-tools clang-tidy
sudo apt install -y clang clang-tools clang-tidy libboost-dev
condition: eq(variables['Agent.OS'], 'Linux')
name: setup_linux
- bash: |
echo "###vso[task.setvariable variable=pip_cache;]${HOME}/Library/Caches/pip"
echo "###vso[task.setvariable variable=conan_cache;]${HOME}/.conan/data"
echo "###vso[task.setvariable variable=PATH;]$(python3 -m site --user-base)/bin:${PATH}"
echo "###vso[task.setvariable variable=build_tool_options;]-j 4"
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
brew install bison
brew install googletest
condition: eq(variables['Agent.OS'], 'Darwin')
name: setup_macos
# Use PowerShell rather than Bash to ensure Windows-style paths
- pwsh: |
$python_bin = python -m site --user-base
Write-Host "###vso[task.setvariable variable=pip_cache;]${env:LOCALAPPDATA}\\pip\\Cache"
Write-Host "###vso[task.setvariable variable=conan_cache;]${env:USERPROFILE}\\.conan\\data"
Write-Host "###vso[task.setvariable variable=PATH;]$python_bin\\bin;${env:PATH}"
# Visual Studio is most likely used on Windows agents
if (${env:GENERATOR} -match "2019" -and -not ${env:PLATFORM}) {
Expand All @@ -61,29 +55,27 @@ steps:
}
}
Write-Host "###vso[task.setvariable variable=build_tool_options;]-nologo -verbosity:minimal -maxcpucount:4 -p:CL_MPCount=4"
choco install winflexbison3
condition: eq(variables['Agent.OS'], 'Windows_NT')
name: setup_windows
- task: Cache@2
inputs:
key: pip | 2 | $(Agent.OS)
path: $(pip_cache)
name: cache_pip
- task: Cache@2
inputs:
key: conan | 2 | $(Agent.OS) | $(arch) | $(build_type)
path: $(conan_cache)
name: cache_conan
- bash: |
set -e -x
pip install "conan==1.59.0" --user
conan profile new default --detect
name: install_conan
- pwsh: |
# boost-msvc-14.1 for VS 2017
# boost-msvc-14.2 for VS 2019
# boost-msvc-14.3 for VS 2022
choco install -y boost-msvc-14.2
condition: and(eq(variables['Agent.OS'], 'Windows_NT'), eq(variables['legacy'], 'on'))
name: setup_windows_boost
# Google Test doesn't seem to be available in Chocolatey
# Google Test 1.12.1 is the latest one to support C++11 (only relevant if legacy=on)
# and "apt install googletest" doesn't seem to do the trick on Linux
- bash: |
set -e -x
conan profile update settings.compiler.libcxx=libstdc++11 default
condition: eq(variables['Agent.OS'], 'Linux')
name: update_conan_cxx_library
git clone --depth 1 --branch release-1.12.1 https://github.com/google/googletest.git
mkdir googletest/build
cd googletest/build
cmake -DCMAKE_INSTALL_PREFIX=install -DBUILD_SHARED_LIBS=on \
${GENERATOR:+-G} "${GENERATOR}" -A "${PLATFORM}" -T "${TOOLSET}" ..
cmake --build . --config ${BUILD_TYPE} --target install -- ${BUILD_TOOL_OPTIONS}
condition: or(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.OS'], 'Windows_NT'))
name: setup_googletest
- bash: |
set -e -x
sudo apt-get install libacl1-dev libncurses5-dev pkg-config
Expand All @@ -109,7 +101,6 @@ steps:
cyclonedds
mkdir cyclonedds/build
cd cyclonedds/build
conan install -b missing -s arch=${ARCH} -s build_type=${BUILD_TYPE} ..
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=install \
-DCMAKE_PREFIX_PATH="${BUILD_SOURCESDIRECTORY}/iceoryx/build/install" \
Expand All @@ -122,10 +113,9 @@ steps:
set -e -x
mkdir build
cd build
conan install -b missing -s arch=${ARCH} -s build_type=${BUILD_TYPE} ..
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=install \
-DCMAKE_PREFIX_PATH="${BUILD_SOURCESDIRECTORY}/cyclonedds/build/install;${BUILD_SOURCESDIRECTORY}/iceoryx/build/install" \
-DCMAKE_PREFIX_PATH="${BUILD_SOURCESDIRECTORY}/cyclonedds/build/install;${BUILD_SOURCESDIRECTORY}/iceoryx/build/install;${BUILD_SOURCESDIRECTORY}/googletest/build/install" \
-DANALYZER=${ANALYZER:-off} \
-DSANITIZER=${SANITIZER:-none} \
-DENABLE_SHM=${ICEORYX:-off} \
Expand Down
30 changes: 3 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,6 @@ project(CycloneDDS-CXX VERSION 0.10.4 LANGUAGES C CXX)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules")

# Conan
if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake" AND NOT CONAN_DEPENDENCIES)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
if(APPLE)
# By default Conan strips all RPATHs (see conanbuildinfo.cmake), which
# causes tests to fail as the executables cannot find the library target.
# By setting KEEP_RPATHS, Conan does not set CMAKE_SKIP_RPATH and the
# resulting binaries still have the RPATH information. This is fine because
# CMake will strip the build RPATH information in the install step.
#
# NOTE:
# Conan's default approach is to use the "imports" feature, which copies
# all the dependencies into the bin directory. Of course, this doesn't work
# quite that well for libraries generated in this Project (see Conan
# documentation).
#
# See the links below for more information.
# https://github.com/conan-io/conan/issues/337
# https://docs.conan.io/en/latest/howtos/manage_shared_libraries/rpaths.html
# https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
conan_basic_setup(KEEP_RPATHS)
else()
conan_basic_setup()
endif()
conan_define_targets()
endif()

# By default don't treat warnings as errors, else anyone building it with a
# different compiler that just happens to generate a warning, as well as
# anyone adding or modifying something and making a small mistake would run
Expand Down Expand Up @@ -165,6 +138,9 @@ if(SANITIZER)
add_compile_options("-fno-omit-frame-pointer")
add_link_options("-fno-omit-frame-pointer")
endif()
if(san STREQUAL "undefined")
add_compile_options("-fno-sanitize-recover=all")
endif()
if(san AND NOT san STREQUAL "none")
message(STATUS "Enabling sanitizer: ${san}")
add_compile_options("-fsanitize=${san}")
Expand Down
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,10 @@ variable `BUILD_TESTING` to on when configuring, e.g.:
$ cmake --build .
$ ctest

Such a build requires the presence of [Google Test][7]. You can install this
yourself, or you can choose to instead rely on the [Conan][8] package manager
that the CI build infrastructure also uses. In that case, install Conan and do:

$ conan install .. --build missing

in the build directory prior to running `cmake`. This will automatically
download and/or build Google Test.

For Windows, depending on the generator, you might also need to add switches
to select the architecture and build type, e.g.,

$ conan install -s arch=x86_64 -s build_type=Debug ..
Such a build requires the presence of [Google Test][7]. You need to install this
yourself.

[7]: https://github.com/google/googletest
[8]: https://conan.io/

## Documentation

Expand Down
43 changes: 33 additions & 10 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,33 @@ strategy:
'Ubuntu 20.04 LTS with Clang 10 (Release, x86_64)':
image: ubuntu-20.04
build_type: Release
cc: clang-10
cxx: clang++-10
'macOS 10.15 with Clang 12 (Debug, x86_64)':
image: macOS-10.15
sanitizer: address,undefined
cc: clang-12
cxx: clang++-12
'Ubuntu 22.04 LTS with CLang 12 (Release, x86_64, Iceoryx)':
image: ubuntu-22.04
build_type: Release
iceoryx: on
sanitizer: address,undefined
cc: clang-12
cxx: clang++-12
# C++11 requires boost, installing boost on Windows takes forever, so use Linux
# Google test requires C++14 at minimum, so we can't build tests ...
'Ubuntu 22.04 LTS with CLang 12 (Debug, x86_64, C++11)':
image: ubuntu-22.04
build_type: Debug
cc: clang-12
cxx: clang++-12
legacy: on
'Ubuntu 22.04 LTS with GCC 12 (Debug, x86_64, no type discovery)':
image: ubuntu-22.04
sanitizer: address
cc: gcc-12
cxx: g++-12
type_discovery: off
topic_discovery: off
'macOS 11 with Clang 12 (Debug, x86_64)':
image: macOS-11
sanitizer: address
cc: clang
cxx: clang++
Expand All @@ -58,7 +81,6 @@ strategy:
#'Windows 2019 with Visual Studio 2019 (Visual Studio 2017, Debug, x86)':
# arch: x86
# image: windows-2019
# conanfile: conanfile102.txt
# generator: 'Visual Studio 16 2019'
# toolkit: v141
'Windows 2019 with Visual Studio 2019 (Debug, x86_64)':
Expand All @@ -69,11 +91,12 @@ strategy:
image: windows-2019
build_type: Release
generator: 'Visual Studio 16 2019'
'Windows 2019 with Visual Studio 2019 (Release, x86_64, c++11)':
image: windows-2019
build_type: Release
generator: 'Visual Studio 16 2019'
legacy: on
#C++11 needs boost, installing boost takes forever on Windows
#'Windows 2019 with Visual Studio 2019 (Release, x86_64, c++11)':
# image: windows-2019
# build_type: Release
# generator: 'Visual Studio 16 2019'
# legacy: on

pool:
vmImage: $(image)
Expand Down
9 changes: 0 additions & 9 deletions conanfile.txt

This file was deleted.

0 comments on commit d7d2578

Please sign in to comment.