Haibo Huang | b0bee82 | 2021-02-24 15:40:15 -0800 | [diff] [blame^] | 1 | #vim: et ts =4 sts = 4 sw = 4 tw = 0 |
| 2 | set(EXAMPLES |
| 3 | readFromString |
| 4 | readFromStream |
| 5 | stringWrite |
| 6 | streamWrite |
| 7 | ) |
| 8 | add_definitions(-D_GLIBCXX_USE_CXX11_ABI) |
| 9 | |
| 10 | if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
| 11 | add_compile_options(-Wall -Wextra) |
| 12 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") |
| 13 | add_definitions( |
| 14 | -D_SCL_SECURE_NO_WARNINGS |
| 15 | -D_CRT_SECURE_NO_WARNINGS |
| 16 | -D_WIN32_WINNT=0x601 |
| 17 | -D_WINSOCK_DEPRECATED_NO_WARNINGS |
| 18 | ) |
| 19 | endif() |
| 20 | |
| 21 | foreach(example ${EXAMPLES}) |
| 22 | add_executable(${example} ${example}/${example}.cpp) |
| 23 | target_include_directories(${example} PUBLIC ${CMAKE_SOURCE_DIR}/include) |
| 24 | target_link_libraries(${example} jsoncpp_lib) |
| 25 | endforeach() |
| 26 | |
| 27 | add_custom_target(examples ALL DEPENDS ${EXAMPLES}) |