diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4f16ac8..a50631a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,11 +4,25 @@ find_package(Boost 1.58 REQUIRED COMPONENTS unit_test_framework thread) -add_library(TurtleTestMain STATIC main.cpp) -target_link_libraries(TurtleTestMain PUBLIC Boost::unit_test_framework Boost::disable_autolinking) +add_library(TurtleTestMain INTERFACE) +target_link_libraries(TurtleTestMain INTERFACE Boost::unit_test_framework Boost::disable_autolinking) +target_compile_definitions(TurtleTestMain INTERFACE BOOST_AUTO_TEST_MAIN) # Heuristically guess if we are compiling against dynamic boost if(NOT Boost_USE_STATIC_LIBS AND Boost_UNIT_TEST_FRAMEWORK_LIBRARY AND NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}\$") - target_compile_definitions(TurtleTestMain PUBLIC BOOST_TEST_DYN_LINK) + target_compile_definitions(TurtleTestMain INTERFACE BOOST_TEST_DYN_LINK) +endif() +# Enable warnings +option(TURTLE_WERROR "Treat warnings as errors" ON) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(TurtleTestMain INTERFACE -Wall -Wextra -pedantic -Wno-long-long) + if(TURTLE_WERROR) + target_compile_options(TurtleTestMain INTERFACE -Werror) + endif() +elseif(MSVC) + target_compile_options(TurtleTestMain INTERFACE /W4) + if(TURTLE_WERROR) + target_compile_options(TurtleTestMain INTERFACE /WX) + endif() endif() file(GLOB_RECURSE testFiles test_*.cpp) diff --git a/test/main.cpp b/test/main.cpp deleted file mode 100644 index 7045d4e..0000000 --- a/test/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// http://turtle.sourceforge.net -// -// Copyright Mathieu Champlon 2009 -// -// 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) - -#define BOOST_AUTO_TEST_MAIN -#include