mirror of
https://github.com/boostorg/predef.git
synced 2025-07-29 11:37:13 +02:00
[CMake] Generate cmake target that other libraries can use (#86)
Generates cmake target that other libraries can use to express their dependency on this library and retrieve any configuration information such as the include directory.
This commit is contained in:
18
.travis.yml
18
.travis.yml
@ -48,6 +48,24 @@ matrix:
|
||||
exclude:
|
||||
- env: TRAVIS_EMPTY_JOB_WORKAROUND=true
|
||||
include:
|
||||
# cmake self-test
|
||||
- env: TEST_CMAKE=TRUE #Only for easier identification in travis web gui
|
||||
os: linux
|
||||
|
||||
# skip all the unneeded steps from the normal unit test jobs
|
||||
install: true
|
||||
before_script: true
|
||||
before_cache: true
|
||||
before_cache: true
|
||||
after_success: true
|
||||
after_failure: true
|
||||
after_script: true
|
||||
script:
|
||||
- mkdir __build__ && cd __build__
|
||||
- cmake ../test/test_cmake
|
||||
- cmake --build .
|
||||
|
||||
|
||||
- env: TOOLSET=clang-3.4
|
||||
- env: TOOLSET=clang-3.5
|
||||
- env: TOOLSET=clang-3.6
|
||||
|
26
CMakeLists.txt
Normal file
26
CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
||||
# 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: CMake support for Boost.Predef is currently experimental at best
|
||||
# and the interface is likely to change in the future
|
||||
#
|
||||
# This file provides mininmal cmake support (no unit-tests,
|
||||
# no installation) for integration into a "host" cmake project
|
||||
# via the "add_subdirectory( <path-to-boost-predef> )" command.
|
||||
#
|
||||
# Other cmake targets can then use the public target name
|
||||
# "Boost::predef" in order to express their dependency
|
||||
# on this library. I.e:
|
||||
#
|
||||
# target_link_libraries( <my-exe/lib> PUBLIC Boost::predef )
|
||||
#
|
||||
|
||||
cmake_minimum_required( VERSION 3.5 )
|
||||
project( BoostPredef )
|
||||
|
||||
add_library( boost_predef INTERFACE )
|
||||
target_include_directories( boost_predef INTERFACE include )
|
||||
|
||||
add_library( Boost::predef ALIAS boost_predef )
|
||||
|
21
test/test_cmake/CMakeLists.txt
Normal file
21
test/test_cmake/CMakeLists.txt
Normal file
@ -0,0 +1,21 @@
|
||||
# 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.Predef.
|
||||
# It only tests, if the CMakeLists.txt file in predef's
|
||||
# root directory works as expected (i.e. it provides the
|
||||
# target Boost::predef which in turn provides the
|
||||
# correct include directory )
|
||||
|
||||
cmake_minimum_required( VERSION 3.5 )
|
||||
|
||||
project( BoostPredefCMakeSelfTest )
|
||||
|
||||
# Process cmake file at root of library and use ${CMAKE_CURRENT_BINARY_DIR}/libs/boost_predef as workspace
|
||||
add_subdirectory( ../.. ${CMAKE_CURRENT_BINARY_DIR}/libs/boost_predef )
|
||||
|
||||
add_executable( boost_predef_cmake_test_prj main.cpp )
|
||||
|
||||
target_link_libraries( boost_predef_cmake_test_prj Boost::predef )
|
||||
|
7
test/test_cmake/main.cpp
Normal file
7
test/test_cmake/main.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
// Dummy executable, just to make sure
|
||||
// that we can find the Boost.predef header files
|
||||
#include <boost/predef.h>
|
||||
|
||||
int main() {
|
||||
|
||||
}
|
Reference in New Issue
Block a user