From 9122a78a46fe2f08ff520d075806e918eda7cfa5 Mon Sep 17 00:00:00 2001 From: Andrii Senkovych Date: Wed, 11 Feb 2015 12:50:36 +0200 Subject: [PATCH 1/5] Add new unittests. Refs #240. --- test/unittest/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index 66cf0c6c..fb98d140 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -1,12 +1,15 @@ set(UNITTEST_SOURCES + bigintegertest.cpp documenttest.cpp encodedstreamtest.cpp encodingstest.cpp filestreamtest.cpp jsoncheckertest.cpp + namespacetest.cpp readertest.cpp + stringbuffertest.cpp + strtodtest.cpp unittest.cpp - unittest.h valuetest.cpp writertest.cpp) From 3ae2a29986c56cdb4dc50b1b903b72aeb433bb97 Mon Sep 17 00:00:00 2001 From: Andrii Senkovych Date: Wed, 11 Feb 2015 14:10:09 +0200 Subject: [PATCH 2/5] Backport compiler options from premake configuration. Refs #240. --- CMakeLists.txt | 9 +++++++-- example/CMakeLists.txt | 8 ++++++++ test/unittest/CMakeLists.txt | 8 ++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b30625fe..9ae444c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,13 @@ if(RAPIDJSON_HAS_STDSTRING) add_definitions(-DRAPIDJSON_HAS_STDSTRING) endif() +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + add_definitions(_CRT_SECURE_NO_WARNINGS) +endif() #add extra search paths for libraries and includes SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in") @@ -36,9 +43,7 @@ ELSEIF(WIN32) ENDIF() SET(CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" CACHE PATH "The directory cmake fiels are installed in") - include_directories(${CMAKE_SOURCE_DIR}/include) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RAPIDJSON_CXX_FLAGS}") if(RAPIDJSON_BUILD_DOC) add_subdirectory(doc) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index ae498345..2856e6be 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -14,6 +14,14 @@ set(EXAMPLES simplewriter tutorial) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + add_definitions(_CRT_SECURE_NO_WARNINGS) +endif() + foreach (example ${EXAMPLES}) add_executable(${example} ${example}/${example}.cpp) endforeach() diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index fb98d140..3e9752d0 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -13,6 +13,14 @@ set(UNITTEST_SOURCES valuetest.cpp writertest.cpp) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Weffc++ -Wswitch-default") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Weffc++ -Wswitch-default") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + add_definitions(_CRT_SECURE_NO_WARNINGS) +endif() + add_library(namespacetest STATIC namespacetest.cpp) add_executable(unittest ${UNITTEST_SOURCES}) From aa0fdd3b0dbe9929d186a7c5b562bb93d1630e84 Mon Sep 17 00:00:00 2001 From: Andrii Senkovych Date: Wed, 11 Feb 2015 17:18:27 +0200 Subject: [PATCH 3/5] Cleaning up gitignore. Refs #240. --- .gitignore | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e4478e0f..95acb0cb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,10 @@ !/bin/data !/bin/encodings !/bin/jsonchecker +/build /doc/html /doc/doxygen_*.db -/thirdparty/lib -/intermediate +*.a # Temporary files created during CMake build CMakeCache.txt @@ -20,4 +20,3 @@ Testing install_manifest.txt Doxyfile DartConfiguration.tcl -/build/* \ No newline at end of file From 553dc0a8b09e883e2fe6dd6faa2fa341e021f056 Mon Sep 17 00:00:00 2001 From: Andrii Senkovych Date: Thu, 19 Feb 2015 18:09:14 +0200 Subject: [PATCH 4/5] Add a workaround for valgrind bug. Refs: #171, #240 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index cbc5c0f6..aa65e163 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ before_install: install: true before_script: + - sed -i 's/march=native/msse4.2/' CMakeLists.txt - mkdir build - > (cd build && cmake From 122170b362e98aaec401764cd89000a628ff3d50 Mon Sep 17 00:00:00 2001 From: Andrii Senkovych Date: Thu, 19 Feb 2015 22:41:31 +0200 Subject: [PATCH 5/5] Fix definitions for VS compiler --- CMakeLists.txt | 2 +- example/CMakeLists.txt | 2 +- test/unittest/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ae444c4..4cde7e2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - add_definitions(_CRT_SECURE_NO_WARNINGS) + add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) endif() #add extra search paths for libraries and includes diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 2856e6be..64632127 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -19,7 +19,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - add_definitions(_CRT_SECURE_NO_WARNINGS) + add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) endif() foreach (example ${EXAMPLES}) diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index 3e9752d0..5e4a3e9d 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -18,7 +18,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Weffc++ -Wswitch-default") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - add_definitions(_CRT_SECURE_NO_WARNINGS) + add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) endif() add_library(namespacetest STATIC namespacetest.cpp)