Add CMake install support, tests

This commit is contained in:
Peter Dimov
2020-01-05 04:32:16 +02:00
parent 688c3f2ee6
commit 1ab9385a91
7 changed files with 419 additions and 43 deletions

View File

@ -1,16 +1,31 @@
# Copyright 2018 Mike Dev
# Copyright 2018, 2019 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
#
# NOTE: This does NOT run the unit tests for Boost.Preprocessor (yet).
# It only tests, if the CMakeLists.txt file works as expected
cmake_minimum_required( VERSION 3.5 )
include(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
project( BoostPreprocessorCMakeSelfTest )
if(NOT HAVE_BOOST_TEST)
return()
endif()
add_subdirectory( .. ${CMAKE_CURRENT_BINARY_DIR}/boost_preprocessor )
set(tests_common arithmetic array comparison control debug facilities list logical punctuation selection seq slot stringize tuple variadic isempty)
set(tests_c ${tests_common})
set(tests_cpp ${tests_common} iteration repetition quick)
add_executable( boost_preprocessor_cmake_self_test config_info.cpp )
target_link_libraries( boost_preprocessor_cmake_self_test Boost::preprocessor )
set(BOOST_TEST_LINK_LIBRARIES Boost::preprocessor)
include_directories(../../..) # for `include <libs/preprocessor/...>` to work
foreach(test IN LISTS tests_c)
boost_test(TYPE compile SOURCES ${test}.c)
boost_test(TYPE compile NAME ${test}_c_nvm SOURCES ${test}.c COMPILE_DEFINITIONS BOOST_PP_VARIADICS=0)
endforeach()
foreach(test IN LISTS tests_cpp)
boost_test(TYPE compile SOURCES ${test}.cpp)
boost_test(TYPE compile NAME ${test}_cpp_nvm SOURCES ${test}.cpp COMPILE_DEFINITIONS BOOST_PP_VARIADICS=0)
endforeach()

View File

@ -22,17 +22,17 @@ alias preprocessor : :
<toolset>gcc
<toolset-gcc:version>3.4
;
alias preprocessor : :
<toolset>gcc
<toolset-gcc:version>4.1
;
alias preprocessor : :
<toolset>gcc
<toolset-gcc:version>4.2
;
alias preprocessor
:
[ compile arithmetic.cpp ]
@ -192,22 +192,22 @@ alias preprocessor_c_nvm
: tuple_c_nvm
]
;
alias preprocessor_isempty : :
<toolset>gcc
<toolset-gcc:version>3.4
;
alias preprocessor_isempty : :
<toolset>gcc
<toolset-gcc:version>4.1
;
alias preprocessor_isempty : :
<toolset>gcc
<toolset-gcc:version>4.2
;
alias preprocessor_isempty
:
[ compile isempty.cpp ]
@ -216,12 +216,12 @@ alias preprocessor_isempty
[ compile-fail isempty_variadic_standard_failure2.cpp : <define>BOOST_PP_VARIADICS=1 ]
[ compile vaopt.cpp ]
;
alias preprocessor_isempty_nvm
:
[ compile isempty.cpp : <define>BOOST_PP_VARIADICS=0 : isempty_nvm ]
;
alias preprocessor_isempty_c
:
[ compile isempty.c
@ -237,7 +237,7 @@ alias preprocessor_isempty_c
: isempty_variadic_standard_failure2_c
]
;
alias preprocessor_isempty_c_nvm
:
[ compile isempty.c
@ -250,7 +250,7 @@ alias preprocessor_config
:
[ run config_info.cpp ]
;
alias test_clang_cuda
:
[ compile [ cast _ cpp : clang_cuda.cu ]
@ -267,5 +267,7 @@ alias test_iso
:
[ run cpp_standard.cpp ]
;
explicit test_iso ;
compile quick.cpp ; # "Quick" test (for CI)

View File

@ -0,0 +1,17 @@
# Copyright 2018, 2019 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...3.16)
project(cmake_install_test LANGUAGES CXX)
find_package(boost_preprocessor REQUIRED)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::preprocessor)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@ -0,0 +1,17 @@
# Copyright 2018, 2019 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...3.16)
project(cmake_subdir_test LANGUAGES CXX)
add_subdirectory(../.. boostorg/preprocessor)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::preprocessor)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

39
test/quick.cpp Normal file
View File

@ -0,0 +1,39 @@
// Copyright 2002 Paul Mensonides
// Copyright 2019 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/preprocessor/comparison.hpp>
#include "test_macro.h"
/* equality */
BEGIN BOOST_PP_EQUAL(2, 0) == 0 END
BEGIN BOOST_PP_EQUAL(2, 2) == 1 END
/* inequality */
BEGIN BOOST_PP_NOT_EQUAL(2, 0) == 1 END
BEGIN BOOST_PP_NOT_EQUAL(2, 2) == 0 END
/* less */
BEGIN BOOST_PP_LESS(2, 1) == 0 END
BEGIN BOOST_PP_LESS(1, 2) == 1 END
/* less_equal */
BEGIN BOOST_PP_LESS_EQUAL(2, 1) == 0 END
BEGIN BOOST_PP_LESS_EQUAL(1, 2) == 1 END
BEGIN BOOST_PP_LESS_EQUAL(2, 2) == 1 END
/* greater */
BEGIN BOOST_PP_GREATER(2, 1) == 1 END
BEGIN BOOST_PP_GREATER(1, 2) == 0 END
/* greater_equal */
BEGIN BOOST_PP_GREATER_EQUAL(2, 1) == 1 END
BEGIN BOOST_PP_GREATER_EQUAL(1, 2) == 0 END
BEGIN BOOST_PP_GREATER_EQUAL(2, 2) == 1 END