diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..b03d1ba0 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "extern/googletest"] + path = extern/googletest + url = https://github.com/google/googletest diff --git a/CMakeLists.txt b/CMakeLists.txt index 25f94196..1064e1c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,9 +135,11 @@ if(BUILD_FAIRMQ) endif() if(BUILD_TESTING) - find_package2(PRIVATE GTest REQUIRED - VERSION 1.7.0 - ) + find_package2(PRIVATE GTest VERSION 1.7.0) + if(NOT GTest_FOUND) + build_bundled(GTest extern/googletest) + find_package2(PRIVATE GTest REQUIRED) + endif() endif() if(BUILD_DOCS) @@ -311,7 +313,9 @@ if(PROJECT_PACKAGE_DEPENDENCIES) else() get_filename_component(prefix ${${dep}_INCLUDE_DIR}/.. ABSOLUTE) endif() - message(STATUS " ${BWhite}${dep_padded}${CR}${version_padded}${prefix}") + if(NOT ${dep}_BUNDLED) + message(STATUS " ${BWhite}${dep_padded}${CR}${version_padded}${prefix}") + endif() unset(version_str) unset(version_padded) unset(version_req_str) diff --git a/COPYRIGHT b/COPYRIGHT index 8a17c34a..ad561455 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -15,6 +15,10 @@ Files: cmake/cotire.cmake Copyright: 2012-2018 Sascha Kratky License: COTIRE +Files: extern/googletest +Copyright: 2008, Google Inc. +License: GOOGLE + License: LGPL-3.0-only [see LICENSE file] @@ -39,3 +43,33 @@ License: COTIRE WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +License: GOOGLE + Copyright 2008, Google Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index ee3dcd1d..985a1e33 100644 --- a/README.md +++ b/README.md @@ -33,15 +33,6 @@ configuration and control services. FairMQ has been developed in the context of its mother project [FairRoot](https://github.com/FairRootGroup/FairRoot) - a simulation, reconstruction and analysis framework. -## Dependencies - - * PUBLIC: [**Boost**](https://www.boost.org/), [**FairLogger**](https://github.com/FairRootGroup/FairLogger) - * BUILD: [CMake](https://cmake.org/), [GTest](https://github.com/google/googletest), [Doxygen](http://www.doxygen.org/) - * PRIVATE: [ZeroMQ](http://zeromq.org/), [Msgpack](https://msgpack.org/index.html), [nanomsg](http://nanomsg.org/), -[asiofi](https://github.com/FairRootGroup/asiofi), [DDS](http://dds.gsi.de), [PMIx](https://pmix.org/) - - Supported platforms: Linux and MacOS. - ## Installation from Source Recommended: @@ -98,6 +89,25 @@ find_package(FairMQ 1.1.0 COMPONENTS nanomsg_transport dds_plugin) When building FairMQ, CMake will print a summary table of all available package components. +## Dependencies + + * [asio](https://github.com/chriskohlhoff/asio) + * [asiofi](https://github.com/FairRootGroup/asiofi) + * [Boost](https://www.boost.org/) + * [CMake](https://cmake.org/) + * [DDS](http://dds.gsi.de) + * [Doxygen](http://www.doxygen.org/) + * [FairLogger](https://github.com/FairRootGroup/FairLogger) + * [GTest](https://github.com/google/googletest) (optionally bundled) + * [Msgpack](https://msgpack.org/index.html) + * [nanomsg](http://nanomsg.org/) + * [PMIx](https://pmix.org/) + * [ZeroMQ](http://zeromq.org/) + + Which dependencies are required depends on which components are built. + + Supported platforms: Linux and MacOS. + ## CMake options On command line: diff --git a/cmake/FairMQLib.cmake b/cmake/FairMQLib.cmake index 005150ad..0acb764a 100644 --- a/cmake/FairMQLib.cmake +++ b/cmake/FairMQLib.cmake @@ -397,3 +397,51 @@ macro(find_package2 qualifier pkgname) set(CMAKE_PREFIX_PATH ${__old_cpp__}) unset(__old_cpp__) endmacro() + +macro(exec cmd) + join("${ARGN}" " " args) + file(APPEND ${${package}_BUILD_LOGFILE} ">>> ${cmd} ${args}\n") + + execute_process(COMMAND ${cmd} ${ARGN} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + OUTPUT_VARIABLE log + ERROR_VARIABLE log + RESULT_VARIABLE res + ) + file(APPEND ${${package}_BUILD_LOGFILE} ${log}) + + if(res) + message(FATAL_ERROR "${res} \nSee also \"${${package}_BUILD_LOGFILE}\"") + endif() +endmacro() + +function(build_bundled package bundle) + message(STATUS "Building bundled ${package}") + + set(${package}_SOURCE_DIR ${CMAKE_SOURCE_DIR}/${bundle}) + set(${package}_BINARY_DIR ${CMAKE_BINARY_DIR}/${bundle}) + file(MAKE_DIRECTORY ${${package}_BINARY_DIR}) + set(${package}_INSTALL_DIR ${CMAKE_BINARY_DIR}/${bundle}_install) + file(MAKE_DIRECTORY ${${package}_INSTALL_DIR}) + set(${package}_BUILD_LOGFILE ${${package}_BINARY_DIR}/build.log) + file(REMOVE ${${package}_BUILD_LOGFILE}) + set(${package}_ROOT ${${package}_INSTALL_DIR}) + + if(Git_FOUND) + exec(${GIT_EXECUTABLE} submodule update --init --recursive --depth 1 -- ${${package}_SOURCE_DIR}) + endif() + + if(${package} STREQUAL GTest) + exec(${CMAKE_COMMAND} -S ${${package}_SOURCE_DIR} -B ${${package}_BINARY_DIR} -G ${CMAKE_GENERATOR} + -DCMAKE_INSTALL_PREFIX=${${package}_INSTALL_DIR} -DBUILD_GMOCK=OFF + ) + exec(${CMAKE_COMMAND} --build ${${package}_BINARY_DIR}) + exec(${CMAKE_COMMAND} --build ${${package}_BINARY_DIR} --target install) + endif() + + string(TOUPPER ${package} package_upper) + set(${package_upper}_ROOT "${${package}_INSTALL_DIR}" CACHE PATH "Bundled ${package} install dir") + set(${package}_BUNDLED ON CACHE BOOL "Whether bundled ${package} was used") + + message(STATUS "Building bundled ${package} - done") +endfunction() diff --git a/extern/googletest b/extern/googletest new file mode 160000 index 00000000..90a443f9 --- /dev/null +++ b/extern/googletest @@ -0,0 +1 @@ +Subproject commit 90a443f9c2437ca8a682a1ac625eba64e1d74a8a