mirror of
https://github.com/boostorg/mincmake.git
synced 2026-01-19 04:22:10 +00:00
Add boost_fetch.cmake
This commit is contained in:
@@ -8,10 +8,14 @@ project(BoostMinCMake LANGUAGES CXX)
|
|||||||
|
|
||||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
|
|
||||||
|
include(cmake/boost_fetch.cmake)
|
||||||
include(cmake/boost_test.cmake)
|
include(cmake/boost_test.cmake)
|
||||||
|
|
||||||
enable_testing()
|
boost_fetch(boostorg/config TAG develop)
|
||||||
|
boost_fetch(boostorg/assert TAG develop)
|
||||||
|
boost_fetch(boostorg/core TAG develop)
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||||
|
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
|||||||
73
cmake/boost_fetch.cmake
Normal file
73
cmake/boost_fetch.cmake
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
# Copyright 2018 Peter Dimov
|
||||||
|
# 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
|
||||||
|
|
||||||
|
if(NOT COMMAND FetchContent_Populate)
|
||||||
|
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 3.11)
|
||||||
|
|
||||||
|
message(STATUS "Fetching FetchContent.cmake")
|
||||||
|
|
||||||
|
file(DOWNLOAD
|
||||||
|
"https://gitlab.kitware.com/cmake/cmake/raw/v3.11.3/Modules/FetchContent.cmake"
|
||||||
|
"${CMAKE_BINARY_DIR}/Modules/FetchContent.cmake"
|
||||||
|
)
|
||||||
|
|
||||||
|
file(DOWNLOAD
|
||||||
|
"https://gitlab.kitware.com/cmake/cmake/raw/v3.11.3/Modules/FetchContent/CMakeLists.cmake.in"
|
||||||
|
"${CMAKE_BINARY_DIR}/Modules/FetchContent/CMakeLists.cmake.in"
|
||||||
|
)
|
||||||
|
|
||||||
|
include(${CMAKE_BINARY_DIR}/Modules/FetchContent.cmake)
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
function(boost_fetch)
|
||||||
|
|
||||||
|
cmake_parse_arguments(_ "" "TAG" "" ${ARGN})
|
||||||
|
|
||||||
|
if(NOT __UNPARSED_ARGUMENTS)
|
||||||
|
|
||||||
|
message(FATAL_ERROR "boost_fetch: missing required argument, repository name")
|
||||||
|
return()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(GET __UNPARSED_ARGUMENTS 0 REPO)
|
||||||
|
list(REMOVE_AT __UNPARSED_ARGUMENTS 0)
|
||||||
|
|
||||||
|
if(__UNPARSED_ARGUMENTS)
|
||||||
|
|
||||||
|
message(WARNING "boost_fetch: extra arguments ignored: ${__UNPARSED_ARGUMENTS}")
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT __TAG)
|
||||||
|
|
||||||
|
set(__TAG master)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(MAKE_C_IDENTIFIER ${REPO} NAME)
|
||||||
|
|
||||||
|
message(STATUS "Fetching ${REPO}:${__TAG}")
|
||||||
|
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 3.6)
|
||||||
|
|
||||||
|
FetchContent_Populate(${NAME} QUIET GIT_REPOSITORY "https://github.com/${REPO}" GIT_TAG ${__TAG})
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
FetchContent_Populate(${NAME} QUIET GIT_REPOSITORY "https://github.com/${REPO}" GIT_TAG ${__TAG} GIT_SHALLOW 1)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR})
|
||||||
|
|
||||||
|
endfunction(boost_fetch)
|
||||||
@@ -18,6 +18,6 @@ boost_test(TYPE run-fail SOURCES run_fail.cpp)
|
|||||||
|
|
||||||
boost_test_jamfile(FILE Jamfile PREFIX BoostMinCMake2)
|
boost_test_jamfile(FILE Jamfile PREFIX BoostMinCMake2)
|
||||||
|
|
||||||
#
|
# arguments
|
||||||
|
|
||||||
boost_test(TYPE run SOURCES arguments.cpp ARGUMENTS pumpkin)
|
boost_test(TYPE run SOURCES arguments.cpp ARGUMENTS pumpkin LIBRARIES Boost::core)
|
||||||
|
|||||||
@@ -2,17 +2,17 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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
|
// See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
#include <iostream>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define TEST(expr) if(!(expr)) { std::cerr << __FILE__ << "(" << __LINE__ << "): test '" #expr "' failed." << std::endl; r = 1; }
|
|
||||||
|
|
||||||
int main( int ac, char const* av[] )
|
int main( int ac, char const* av[] )
|
||||||
{
|
{
|
||||||
int r = 0;
|
BOOST_TEST_EQ( ac, 2 );
|
||||||
|
|
||||||
TEST( ac == 2 )
|
if( ac >= 2 )
|
||||||
TEST( ac >= 2 && strcmp( av[1], "pumpkin" ) == 0 )
|
{
|
||||||
|
BOOST_TEST_CSTR_EQ( av[1], "pumpkin" );
|
||||||
|
}
|
||||||
|
|
||||||
return r;
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user