diff --git a/CMakeLists.txt b/CMakeLists.txt index eeb2a78..304cb3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,50 +1,50 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.14) -SET(Project minijson) -PROJECT(${Project} C CXX) - -SET(SOURCE_DIR ${${Project}_SOURCE_DIR}) -SET(CMAKE_C_STANDARD 99) -SET(CMAKE_CXX_STANDARD 11) -SET(CMAKE_POSITION_INDEPENDENT_CODE on) -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/") - -MESSAGE("Compiling minijson") -MESSAGE(STATUS "Source directory is " ${SOURCE_DIR}) -MESSAGE("Project = ${Project}") -MESSAGE("CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}") -MESSAGE("COVERAGE = ${COVERAGE}") +cmake_minimum_required(VERSION 3.14) +set(Project minijson) +project(${Project} C CXX) + +set(SOURCE_DIR ${${Project}_SOURCE_DIR}) +set(CMAKE_C_STANDARD 99) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_POSITION_INDEPENDENT_CODE on) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/") + +message("Compiling minijson") +message(STATUS "Source directory is " ${SOURCE_DIR}) +message("Project = ${Project}") +message("CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}") +message("COVERAGE = ${COVERAGE}") # supress MSVC/GCC warnings -IF(${CMAKE_HOST_WIN32}) - SET(CMAKE_CXX_FLAGS_DEBUG "/MTd /Zi /Ob0 /Od /RTC1") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") -ENDIF() +if(${CMAKE_HOST_WIN32}) + set(CMAKE_CXX_FLAGS_DEBUG "/MTd /Zi /Ob0 /Od /RTC1") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") +endif() # define headers and sources -SET(Headers Json.h) -SET(Sources Json.cpp) +set(Headers Json.h) +set(Sources Json.cpp) # build a dynamic library -MESSAGE("Build dynamic library ${MINIJSON_DYNAMIC_LIBRARY_TARGET}") -SET(MINIJSON_DYNAMIC_LIBRARY_TARGET ${Project}) -ADD_LIBRARY(${MINIJSON_DYNAMIC_LIBRARY_TARGET} SHARED ${Sources} ${Headers}) +message("Build dynamic library ${MINIJSON_DYNAMIC_LIBRARY_TARGET}") +set(MINIJSON_DYNAMIC_LIBRARY_TARGET ${Project}) +add_library(${MINIJSON_DYNAMIC_LIBRARY_TARGET} SHARED ${Sources} ${Headers}) # to generate export library when build dynamic library -TARGET_COMPILE_DEFINITIONS(${MINIJSON_DYNAMIC_LIBRARY_TARGET} PRIVATE -DLIBRARY_EXPORT) +target_compile_definitions(${MINIJSON_DYNAMIC_LIBRARY_TARGET} PRIVATE -DLIBRARY_EXPORT) # build a static library -MESSAGE("Build static library ${MINIJSON_STATIC_LIBRARY_TARGET}") -SET(MINIJSON_STATIC_LIBRARY_TARGET ${Project}_static) -ADD_LIBRARY(${MINIJSON_STATIC_LIBRARY_TARGET} STATIC ${Sources} ${Headers}) +message("Build static library ${MINIJSON_STATIC_LIBRARY_TARGET}") +set(MINIJSON_STATIC_LIBRARY_TARGET ${Project}_static) +add_library(${MINIJSON_STATIC_LIBRARY_TARGET} STATIC ${Sources} ${Headers}) # set -DCMAKE_BUILD_TYPE=Debug to enable LLT, set -DCOVERAGE=ON to enable code coverage -IF (CMAKE_BUILD_TYPE STREQUAL "Debug") +if (CMAKE_BUILD_TYPE STREQUAL "Debug") # these config must be put at the level of source code in order to append compile flags - IF (${COVERAGE} STREQUAL "lcov" OR ${COVERAGE} STREQUAL "gcovr") - MESSAGE("code coverage is enabled, COVERAGE = ${COVERAGE}, append coverage compiler flags") + if (${COVERAGE} STREQUAL "lcov" OR ${COVERAGE} STREQUAL "gcovr") + message("code coverage is enabled, COVERAGE = ${COVERAGE}, append coverage compiler flags") INCLUDE(${SOURCE_DIR}/test/CodeCoverage.cmake) APPEND_COVERAGE_COMPILER_FLAGS() - ENDIF() + endif() - ENABLE_TESTING() - ADD_SUBDIRECTORY("test") -ENDIF() \ No newline at end of file + enable_testing() + add_subdirectory("test") +endif() \ No newline at end of file diff --git a/Json.h b/Json.h index b6381f1..45c19f3 100644 --- a/Json.h +++ b/Json.h @@ -5,7 +5,6 @@ * Author: XUranus * Date: 2022-11-21 * Description: a tiny C++ Json library -* https://github.com/XUranus/minicpp * ================================================================*/ @@ -135,7 +134,6 @@ class MINIJSON_API JsonElement: public Serializable { explicit JsonElement(char const *str); JsonElement(const JsonObject& object); JsonElement(const JsonArray& array); - JsonElement(const JsonElement& ele); explicit JsonElement(JsonElement&& ele); JsonElement& operator = (const JsonElement& ele); diff --git a/README.md b/README.md index f39167d..7e96823 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,15 @@ # MiniJson > a mini Json library C++ implement +