Initial commit

This commit is contained in:
Peter Dimov
2018-09-20 16:20:15 +03:00
parent d413ab3145
commit 9a64ca8da6
10 changed files with 127 additions and 0 deletions

19
CMakeLists.txt Normal file
View File

@@ -0,0 +1,19 @@
# 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
cmake_minimum_required(VERSION 3.5)
project(BoostMinCMake LANGUAGES CXX)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
include(cmake/boost_test.cmake)
enable_testing()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
add_subdirectory(test)
endif()

32
cmake/boost_test.cmake Normal file
View File

@@ -0,0 +1,32 @@
# 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
function(boost_test)
cmake_parse_arguments(_ "" "TYPE;PREFIX;NAME" "SOURCES;LIBRARIES" ${ARGN})
if(NOT __TYPE)
set(__TYPE run)
endif()
if(NOT __PREFIX)
set(__PREFIX ${PROJECT_NAME})
endif()
if(NOT __NAME)
list(GET __SOURCES 0 __NAME)
string(MAKE_C_IDENTIFIER ${__NAME} __NAME)
endif()
set(__NAME ${__PREFIX}-${__NAME})
add_executable(${__NAME} EXCLUDE_FROM_ALL ${__SOURCES})
target_link_libraries(${__NAME} ${__LIBRARIES})
add_test(NAME compile-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${__NAME})
add_test(NAME run-${__NAME} COMMAND ${__NAME})
set_tests_properties(run-${__NAME} PROPERTIES DEPENDS compile-${__NAME})
endfunction(boost_test)

10
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,10 @@
# 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
boost_test(TYPE compile SOURCES compile.cpp)
boost_test(TYPE compile-fail SOURCES compile_fail.cpp)
boost_test(TYPE link SOURCES link.cpp)
boost_test(TYPE link-fail SOURCES link_fail.cpp)
boost_test(TYPE run SOURCES run.cpp)
boost_test(TYPE run-fail SOURCES run_fail.cpp)

12
test/Jamfile Normal file
View File

@@ -0,0 +1,12 @@
# 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
import testing ;
compile compile.cpp ;
compile-fail compile_fail.cpp ;
link link.cpp ;
link-fail link_fail.cpp ;
run run.cpp ;
run-fail run_fail.cpp ;

8
test/compile.cpp Normal file
View File

@@ -0,0 +1,8 @@
// 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
int f()
{
return 0;
}

8
test/compile_fail.cpp Normal file
View File

@@ -0,0 +1,8 @@
// 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
int f()
{
return x;
}

13
test/link.cpp Normal file
View File

@@ -0,0 +1,13 @@
// 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
int f()
{
return 0;
}
int main()
{
return f();
}

10
test/link_fail.cpp Normal file
View File

@@ -0,0 +1,10 @@
// 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
int f();
int main()
{
return f();
}

7
test/run.cpp Normal file
View File

@@ -0,0 +1,7 @@
// 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
int main()
{
}

8
test/run_fail.cpp Normal file
View File

@@ -0,0 +1,8 @@
// 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
int main()
{
return 1;
}