From d206a7b5eda517496d8168a855bcbba1675dfcbd Mon Sep 17 00:00:00 2001 From: Mike Dev Date: Sat, 22 Sep 2018 22:33:21 +0200 Subject: [PATCH 1/3] [CMake] Add minimal cmake file Generate cmake target that can be used by other libraries to express their dependency on this library and retrieve any configuration information such as the include directory, transitive dependencies, necessary compiler options or the required c++ standards level. --- CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9869747 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright 2018 Mike Dev +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +cmake_minimum_required(VERSION 3.5) +project(BoostIO LANGUAGES CXX) + +add_library(boost_io INTERFACE) +add_library(Boost::io ALIAS boost_io) + +target_include_directories(boost_io INTERFACE include) + +target_link_libraries(boost_io + INTERFACE + Boost::config +) From 20f343cc0373459c4513d829f5a6a66abcb63310 Mon Sep 17 00:00:00 2001 From: Mike Dev Date: Mon, 12 Nov 2018 10:37:13 +0100 Subject: [PATCH 2/3] [CMake] Add test for cmake file --- .travis.yml | 12 ++++++++++++ test/test_cmake/CMakeLists.txt | 16 ++++++++++++++++ test/test_cmake/main.cpp | 5 +++++ 3 files changed, 33 insertions(+) create mode 100644 test/test_cmake/CMakeLists.txt create mode 100644 test/test_cmake/main.cpp diff --git a/.travis.yml b/.travis.yml index 1c23ece..4837e72 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,18 @@ branches: - master - develop +matrix: + include: + - os: linux + env: TEST_CMAKE=TRUE #Only for easier identification in travis web gui + install: + - git clone --depth 1 https://github.com/boostorg/config.git ../config + + script: + - mkdir __build__ && cd __build__ + - cmake ../test/test_cmake + - cmake --build . + install: - cd .. - git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root diff --git a/test/test_cmake/CMakeLists.txt b/test/test_cmake/CMakeLists.txt new file mode 100644 index 0000000..0384dae --- /dev/null +++ b/test/test_cmake/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright 2018 Mike Dev +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt +# +# NOTE: This does NOT run the unit tests for Boost.IO. +# It only tests, if the CMakeLists.txt file in it's root works as expected + +cmake_minimum_required( VERSION 3.5 ) + +project( BoostIoCMakeSelfTest ) + +add_subdirectory( ../../../config ${CMAKE_CURRENT_BINARY_DIR}/libs/config ) +add_subdirectory( ../.. ${CMAKE_CURRENT_BINARY_DIR}/libs/io ) + +add_executable( boost_io_cmake_self_test main.cpp ) +target_link_libraries( boost_io_cmake_self_test Boost::io ) diff --git a/test/test_cmake/main.cpp b/test/test_cmake/main.cpp new file mode 100644 index 0000000..e5c3372 --- /dev/null +++ b/test/test_cmake/main.cpp @@ -0,0 +1,5 @@ +#include +#include + +int main() { +} From fbceb17be37b7e218841dc2101d2a81eb2de06c4 Mon Sep 17 00:00:00 2001 From: Mike Dev Date: Mon, 12 Nov 2018 13:59:42 +0100 Subject: [PATCH 3/3] [CMake] Small formatting and comment changes --- CMakeLists.txt | 12 ++++++------ test/test_cmake/CMakeLists.txt | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9869747..1078f1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,15 +2,15 @@ # Distributed under the Boost Software License, Version 1.0. # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt -cmake_minimum_required(VERSION 3.5) -project(BoostIO LANGUAGES CXX) +cmake_minimum_required( VERSION 3.5 ) +project( BoostIO LANGUAGES CXX ) -add_library(boost_io INTERFACE) -add_library(Boost::io ALIAS boost_io) +add_library( boost_io INTERFACE ) +add_library( Boost::io ALIAS boost_io ) -target_include_directories(boost_io INTERFACE include) +target_include_directories( boost_io INTERFACE include ) -target_link_libraries(boost_io +target_link_libraries( boost_io INTERFACE Boost::config ) diff --git a/test/test_cmake/CMakeLists.txt b/test/test_cmake/CMakeLists.txt index 0384dae..46bfcf4 100644 --- a/test/test_cmake/CMakeLists.txt +++ b/test/test_cmake/CMakeLists.txt @@ -3,7 +3,8 @@ # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt # # NOTE: This does NOT run the unit tests for Boost.IO. -# It only tests, if the CMakeLists.txt file in it's root works as expected +# It only tests, if the CMakeLists.txt file in the +# Boost.IO root directory works as expected. cmake_minimum_required( VERSION 3.5 )