# Copyright 2019 - 2020 Alexander Grund # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt) include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-Wsuggest-override _BOOST_NOWIDE_SUGGEST_OVERRIDE_SUPPORTED) function(boost_nowide_add_test name) cmake_parse_arguments(PARSE_ARGV 1 ARG "COMPILE_ONLY" "SRC" "LIBRARIES;DEFINITIONS;ARGS") if(NOT ARG_SRC) set(ARG_SRC ${name}.cpp) endif() set(name ${PROJECT_NAME}-${name}) add_executable(${name} ${ARG_SRC}) target_link_libraries(${name} PRIVATE Boost::nowide ${ARG_LIBRARIES}) boost_add_warnings(${name} pedantic ${Boost_NOWIDE_WERROR}) if(_BOOST_NOWIDE_SUGGEST_OVERRIDE_SUPPORTED) target_compile_options(${name} PRIVATE -Wsuggest-override -Wno-error=suggest-override) endif() target_compile_definitions(${name} PRIVATE BOOST_ALL_NO_LIB ${ARG_DEFINITIONS}) if(NOT ARG_COMPILE_ONLY) add_test(NAME ${name} COMMAND ${name} ${ARG_ARGS}) endif() endfunction() boost_nowide_add_test(test_codecvt) boost_nowide_add_test(test_convert) boost_nowide_add_test(test_env) boost_nowide_add_test(test_env_win SRC test_env.cpp DEFINITIONS BOOST_NOWIDE_TEST_INCLUDE_WINDOWS) boost_nowide_add_test(test_fstream) boost_nowide_add_test(test_fstream_cxx11) boost_nowide_add_test(test_iostream) if(MSVC AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) set_target_properties(${PROJECT_NAME}-test_iostream PROPERTIES VS_DEBUGGER_COMMAND_ARGUMENTS -i) endif() boost_nowide_add_test(test_stackstring) boost_nowide_add_test(test_stat) boost_nowide_add_test(test_stdio) boost_nowide_add_test(test_system_n SRC test_system.cpp DEFINITIONS BOOST_NOWIDE_TEST_USE_NARROW=1) if(WIN32) boost_nowide_add_test(test_system_w SRC test_system.cpp DEFINITIONS BOOST_NOWIDE_TEST_USE_NARROW=0) else() boost_nowide_add_test(test_internal_fstream SRC test_fstream.cpp DEFINITIONS BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT=1) boost_nowide_add_test(test_internal_fstream_cxx11 SRC test_fstream_cxx11.cpp DEFINITIONS BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT=1) endif() if(NOT BOOST_SUPERPROJECT_SOURCE_DIR) # Default boost libs are static on windows and dynamic on linux if(WIN32 AND NOT DEFINED Boost_USE_STATIC_LIBS) set(Boost_USE_STATIC_LIBS ON) endif() find_package(Boost 1.56 REQUIRED COMPONENTS filesystem system) endif() boost_nowide_add_test(test_fs LIBRARIES Boost::filesystem) boost_nowide_add_test(benchmark_fstream COMPILE_ONLY DEFINITIONS BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT=1)