diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d8497cbecea856af25a853ce399fe69ec0d63ed..7be418bede5135d4a7f6bc5be80fe8b6855b7913 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,10 @@ enable_language(CXX) set(SAVED_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # compilation flags -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++11 -pthread -Wall") +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") +include("CompilerOptions") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXXOPT_DEBUG} ${CXXOPT_CXX11} ${CXXOPT_PTHREAD} ${CXXOPT_WALL}") +# -g -std=c++11 -pthread -Wall") # this generates a .json file with full compilation command for each file set(CMAKE_EXPORT_COMPILE_COMMANDS "YES") diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e5447d88e7d0009f8ec697bb1463e3a7b737b0d8 --- /dev/null +++ b/cmake/CompilerOptions.cmake @@ -0,0 +1,14 @@ +# Compiler-aware compiler options + +set(CXXOPT_DEBUG "-g") +set(CXXOPT_PTHREAD "-pthread") +set(CXXOPT_CXX11 "-std=c++11") +set(CXXOPT_WALL "-Wall") + +if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + # Disable 'missing-braces' warning: this will inappropriately + # flag initializations such as + # std::array<int,3> a={1,2,3}; + + set(CXXOPT_WALL "${CXXOPT_WALL} -Wno-missing-braces") +endif() diff --git a/tests/test_optional.cpp b/tests/test_optional.cpp index 64df6cac9da0dcdeff1661381a46d933c6356210..4fe6301085b69c6fb2efcb7e7685306b8e8c3071 100644 --- a/tests/test_optional.cpp +++ b/tests/test_optional.cpp @@ -7,7 +7,7 @@ #if defined(__clang__) // refer: https://llvm.org/bugs/show_bug.cgi?id=21629 -#pragma clang diagnostic ignored "-Wmissing-braces" +//#pragma clang diagnostic ignored "-Wmissing-braces" #endif using namespace nest::mc::util; @@ -66,7 +66,7 @@ TEST(optionalm,deref) { TEST(optionalm,ctor_conv) { optional<std::array<int,3>> x{{1,2,3}}; - EXPECT_EQ(3,x->size()); + EXPECT_EQ(3u,x->size()); } TEST(optionalm,ctor_ref) { diff --git a/tests/util.hpp b/tests/util.hpp index 6252c7e439b334342c14b17285418a0e1f7a1c63..cfa89896af8039e6188d8fbc460f412d3407a1b3 100644 --- a/tests/util.hpp +++ b/tests/util.hpp @@ -60,7 +60,7 @@ nlohmann::json load_spike_data(const std::string& input_name) { nlohmann::json cell_data; - auto fid = std::ifstream(input_name); + std::ifstream fid(input_name); if(!fid.is_open()) { std::cerr << "error : unable to open file " << input_name << " : run the validation generation script first\n";