From 74b41359dc001a0c2559da4a7db9b68b05411591 Mon Sep 17 00:00:00 2001 From: Tessil Date: Sun, 16 Jul 2017 13:01:57 +0200 Subject: [PATCH] Use target_compile_options instead of modifying CMAKE_CXX_FLAGS. --- CMakeLists.txt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cdcb10c..b5f5dcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,23 +1,21 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 2.8.12) project(test_hopscotch_map) enable_testing() find_package(Boost 1.54.0 REQUIRED COMPONENTS unit_test_framework) -if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") - #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wextra -Wold-style-cast -g --coverage -DTSL_DEBUG") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wextra -Wold-style-cast -O3 -DTSL_DEBUG") -elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX /W3 /DTSL_DEBUG") -endif() - set(TEST_EXECUTABLE "test_hopscotch_map") - - add_executable("${TEST_EXECUTABLE}" "tests/main.cpp" "tests/hopscotch_map_tests.cpp" "tests/hopscotch_set_tests.cpp") target_include_directories("${TEST_EXECUTABLE}" PRIVATE "${Boost_INCLUDE_DIRS}" "src") target_link_libraries("${TEST_EXECUTABLE}" ${Boost_LIBRARIES}) +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") +# target_compile_options("${TEST_EXECUTABLE}" PRIVATE -std=c++11 -Werror -Wall -Wextra -Wold-style-cast -g --coverage -DTSL_DEBUG) + target_compile_options("${TEST_EXECUTABLE}" PRIVATE -std=c++11 -Werror -Wall -Wextra -Wold-style-cast -O3 -DTSL_DEBUG) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + target_compile_options("${TEST_EXECUTABLE}" PRIVATE /WX /W3 /DTSL_DEBUG) +endif() + add_test(NAME "all_tests" COMMAND "${TEST_EXECUTABLE}")