Skip to content

Commit

Permalink
updated to use vcpkg/system for most deps
Browse files Browse the repository at this point in the history
  • Loading branch information
beached committed Mar 4, 2022
1 parent 4d2c3b5 commit ecc30d1
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 80 deletions.
97 changes: 50 additions & 47 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,71 @@
#
# Official repository: https://github.com/beached/json_to_cpp
#


cmake_minimum_required(VERSION 3.13)

project("json_to_cpp"
VERSION "2.0.1"
DESCRIPTION "Try to use the JSON structures to make C++ structures and bindings"
VERSION "2.1.0"
DESCRIPTION "Try to use the JSON structures to make C++ structures and bindings"
HOMEPAGE_URL "https://github.com/beached/json_to_cpp"
LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard whose features are requested.")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(Boost_NO_WARN_NEW_VERSIONS ON)

find_package( Boost 1.60.0 COMPONENTS program_options REQUIRED )
find_package( CURL REQUIRED )
find_package( OpenSSL REQUIRED )
find_package(Boost 1.60.0 COMPONENTS program_options REQUIRED)
find_package(CURL REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(daw-header-libraries REQUIRED)
find_package(daw-utf-range REQUIRED)
find_package(date REQUIRED)
find_package(fmt REQUIRED)
add_subdirectory(extern)

set( HEADER_FOLDER include )
set( SOURCE_FOLDER src )
set(HEADER_FOLDER include)
set(SOURCE_FOLDER src)

set( HEADER_FILES
${HEADER_FOLDER}/curl_t.h
${HEADER_FOLDER}/json_to_cpp.h
${HEADER_FOLDER}/json_to_cpp_config.h
${HEADER_FOLDER}/ti_value.h
${HEADER_FOLDER}/types/ti_array.h
${HEADER_FOLDER}/types/ti_base.h
${HEADER_FOLDER}/types/ti_boolean.h
${HEADER_FOLDER}/types/ti_integral.h
${HEADER_FOLDER}/types/ti_kv.h
${HEADER_FOLDER}/types/ti_null.h
${HEADER_FOLDER}/types/ti_object.h
${HEADER_FOLDER}/types/ti_real.h
${HEADER_FOLDER}/types/ti_string.h
${HEADER_FOLDER}/types/ti_types.h
)
set(HEADER_FILES
${HEADER_FOLDER}/curl_t.h
${HEADER_FOLDER}/json_to_cpp.h
${HEADER_FOLDER}/json_to_cpp_config.h
${HEADER_FOLDER}/ti_value.h
${HEADER_FOLDER}/types/ti_array.h
${HEADER_FOLDER}/types/ti_base.h
${HEADER_FOLDER}/types/ti_boolean.h
${HEADER_FOLDER}/types/ti_integral.h
${HEADER_FOLDER}/types/ti_kv.h
${HEADER_FOLDER}/types/ti_null.h
${HEADER_FOLDER}/types/ti_object.h
${HEADER_FOLDER}/types/ti_real.h
${HEADER_FOLDER}/types/ti_string.h
${HEADER_FOLDER}/types/ti_types.h
)

set( SOURCE_FILES
${SOURCE_FOLDER}/curl_t.cpp
${SOURCE_FOLDER}/json_to_cpp.cpp
${SOURCE_FOLDER}/ti_array.cpp
${SOURCE_FOLDER}/ti_kv.cpp
${SOURCE_FOLDER}/ti_object.cpp
${SOURCE_FOLDER}/main.cpp
)
set(SOURCE_FILES
${SOURCE_FOLDER}/curl_t.cpp
${SOURCE_FOLDER}/json_to_cpp.cpp
${SOURCE_FOLDER}/ti_array.cpp
${SOURCE_FOLDER}/ti_kv.cpp
${SOURCE_FOLDER}/ti_object.cpp
${SOURCE_FOLDER}/main.cpp
)

add_executable( ${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES} )
target_link_libraries( ${PROJECT_NAME} PRIVATE
daw::parse_json
daw::utf_range
daw::header_libraries
Boost::program_options
daw::libtemp_file
date::date
OpenSSL::SSL
OpenSSL::Crypto
CURL::libcurl
fmt::fmt
)
target_include_directories( ${PROJECT_NAME} PRIVATE ${HEADER_FOLDER} )
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} PRIVATE
daw::daw-utf-range
daw::daw-header-libraries
daw::parse_json
Boost::program_options
daw::libtemp_file
date::date
OpenSSL::SSL
OpenSSL::Crypto
CURL::libcurl
fmt::fmt
)
target_include_directories(${PROJECT_NAME} PRIVATE ${HEADER_FOLDER})

install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)

44 changes: 11 additions & 33 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,23 @@
#

# This prevents tests running on dependencies
option( DAW_ENABLE_TESTING "Build unit tests" OFF )
if( DAW_ENABLE_TESTING )
set( DAW_ENABLE_TESTING OFF )
endif( )
option(DAW_ENABLE_TESTING "Build unit tests" OFF)
if (DAW_ENABLE_TESTING)
set(DAW_ENABLE_TESTING OFF)
endif ()

include( FetchContent )
set( FETCHCONTENT_UPDATES_DISCONNECTED ON )
include(FetchContent)

FetchContent_Declare(
daw_header_libraries
GIT_REPOSITORY https://github.com/beached/header_libraries.git
daw_parse_json
GIT_REPOSITORY https://github.com/beached/parse_json.git
GIT_TAG v1.1.0
)

FetchContent_Declare(
daw_utf_range
GIT_REPOSITORY https://github.com/beached/utf_range.git
daw_libtemp_file
GIT_REPOSITORY https://github.com/beached/libtemp_file.git
)

FetchContent_Declare(
daw_parse_json
GIT_REPOSITORY https://github.com/beached/parse_json.git
)

FetchContent_Declare(
daw_libtemp_file
GIT_REPOSITORY https://github.com/beached/libtemp_file.git
)

FetchContent_Declare(
fmtlib
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
)

option( ENABLE_DATE_TESTING "" OFF )
option( USE_SYSTEM_TZ_DB "" ON )
FetchContent_Declare(
date
GIT_REPOSITORY https://github.com/howardhinnant/date.git
)

FetchContent_MakeAvailable(daw_header_libraries daw_utf_range daw_parse_json daw_libtemp_file date fmtlib )
FetchContent_MakeAvailable(daw_parse_json daw_libtemp_file)

3 changes: 3 additions & 0 deletions src/json_to_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ namespace daw::json_to_cpp {
name = find_replace( name, "\\u", "0x" );
// JSON member names are strings. That is it, so empty looks
// like it is valid, as is all digits, or C++ keywords.
if( auto pos = name.find( '@' ); pos != std::string::npos ) {
name[pos] = '_';
}
if( name.empty( ) or
not( std::isalpha( name.front( ) ) or name.front( ) == '_' ) or
keywords.count( { name.data( ), name.size( ) } ) > 0 ) {
Expand Down

0 comments on commit ecc30d1

Please sign in to comment.