diff --git a/examples/build/cmake/CMakeLists.txt b/examples/build/cmake/CMakeLists.txt index 5f4b95b8a..c1c6fd7da 100755 --- a/examples/build/cmake/CMakeLists.txt +++ b/examples/build/cmake/CMakeLists.txt @@ -19,9 +19,16 @@ include_directories (../../include file(GLOB_RECURSE Example_sources ../../src/*.cpp) -add_executable (jsoncons_examples ${Example_sources}) - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") - # special link option on Linux because llvm stl rely on GNU stl - target_link_libraries (jsoncons_examples -Wl,-lstdc++) -endif() +# Loop through each example file and create an executable for each +foreach(example_file ${Example_sources}) + # Extract the filename without path and extension + get_filename_component(example_name ${example_file} NAME_WE) + + # Create an executable with the example name and file + add_executable(${example_name} ${example_file}) + + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + # special link option on Linux because llvm stl rely on GNU stl + target_link_libraries(${example_name} -Wl,-lstdc++) + endif() +endforeach() diff --git a/examples/src/serialization_examples.cpp b/examples_boost/serialization_examples.cpp similarity index 98% rename from examples/src/serialization_examples.cpp rename to examples_boost/serialization_examples.cpp index 49f3ecca5..fdcf1a90c 100644 --- a/examples/src/serialization_examples.cpp +++ b/examples_boost/serialization_examples.cpp @@ -5,8 +5,10 @@ #include #include #include +#include using namespace jsoncons; +namespace boost_mp = boost::multiprecision; void serialization_example1() { @@ -409,7 +411,8 @@ void bignum_access_examples() // If your compiler supports extended integral types #if (defined(__GNUC__) || defined(__clang__)) && defined(JSONCONS_HAS_INT128) __int128 i = j.as<__int128>(); - std::cout << "(4) " << i << "\n\n"; + boost_mp::int128_t boost_i = static_cast(i); + std::cout << "(4) " << boost_i << "\n\n"; #endif } @@ -485,7 +488,9 @@ int main() decimal_precision_examples(); bignum_access_examples(); chinese_char(); - chinese_uchar8_t(); + #ifdef __cpp_char8_t + chinese_uchar8_t(); + #endif std::cout << std::endl; }