1c5f01b2fSopenharmony_ciset(JSON_TEST_DATA_URL     https://github.com/nlohmann/json_test_data)
2c5f01b2fSopenharmony_ciset(JSON_TEST_DATA_VERSION 3.1.0)
3c5f01b2fSopenharmony_ci
4c5f01b2fSopenharmony_ci# if variable is set, use test data from given directory rather than downloading them
5c5f01b2fSopenharmony_ciif(JSON_TestDataDirectory)
6c5f01b2fSopenharmony_ci    message(STATUS "Using test data in ${JSON_TestDataDirectory}.")
7c5f01b2fSopenharmony_ci    add_custom_target(download_test_data)
8c5f01b2fSopenharmony_ci    file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${JSON_TestDataDirectory}\"\n")
9c5f01b2fSopenharmony_cielse()
10c5f01b2fSopenharmony_ci    find_package(Git)
11c5f01b2fSopenharmony_ci    # target to download test data
12c5f01b2fSopenharmony_ci    add_custom_target(download_test_data
13c5f01b2fSopenharmony_ci        COMMAND test -d json_test_data || ${GIT_EXECUTABLE} clone -c advice.detachedHead=false --branch v${JSON_TEST_DATA_VERSION} ${JSON_TEST_DATA_URL}.git --quiet --depth 1
14c5f01b2fSopenharmony_ci        COMMENT "Downloading test data from ${JSON_TEST_DATA_URL} (v${JSON_TEST_DATA_VERSION})"
15c5f01b2fSopenharmony_ci        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
16c5f01b2fSopenharmony_ci    )
17c5f01b2fSopenharmony_ci    # create a header with the path to the downloaded test data
18c5f01b2fSopenharmony_ci    file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${CMAKE_BINARY_DIR}/json_test_data\"\n")
19c5f01b2fSopenharmony_ciendif()
20c5f01b2fSopenharmony_ci
21c5f01b2fSopenharmony_ci# determine the operating system (for debug and support purposes)
22c5f01b2fSopenharmony_cifind_program(UNAME_COMMAND uname)
23c5f01b2fSopenharmony_cifind_program(VER_COMMAND ver)
24c5f01b2fSopenharmony_cifind_program(LSB_RELEASE_COMMAND lsb_release)
25c5f01b2fSopenharmony_cifind_program(SW_VERS_COMMAND sw_vers)
26c5f01b2fSopenharmony_ciset(OS_VERSION_STRINGS "${CMAKE_SYSTEM}")
27c5f01b2fSopenharmony_ciif (VER_COMMAND)
28c5f01b2fSopenharmony_ci    execute_process(COMMAND ${VER_COMMAND} OUTPUT_VARIABLE VER_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE)
29c5f01b2fSopenharmony_ci    set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${VER_COMMAND_RESULT}")
30c5f01b2fSopenharmony_ciendif()
31c5f01b2fSopenharmony_ciif (SW_VERS_COMMAND)
32c5f01b2fSopenharmony_ci    execute_process(COMMAND ${SW_VERS_COMMAND} OUTPUT_VARIABLE SW_VERS_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
33c5f01b2fSopenharmony_ci    string(REGEX REPLACE "[ ]*\n" "; " SW_VERS_COMMAND_RESULT "${SW_VERS_COMMAND_RESULT}")
34c5f01b2fSopenharmony_ci    set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${SW_VERS_COMMAND_RESULT}")
35c5f01b2fSopenharmony_ciendif()
36c5f01b2fSopenharmony_ciif (LSB_RELEASE_COMMAND)
37c5f01b2fSopenharmony_ci    execute_process(COMMAND ${LSB_RELEASE_COMMAND} -a OUTPUT_VARIABLE LSB_RELEASE_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
38c5f01b2fSopenharmony_ci    string(REGEX REPLACE "[ ]*\n" "; " LSB_RELEASE_COMMAND_RESULT "${LSB_RELEASE_COMMAND_RESULT}")
39c5f01b2fSopenharmony_ci    set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${LSB_RELEASE_COMMAND_RESULT}")
40c5f01b2fSopenharmony_ciendif()
41c5f01b2fSopenharmony_ciif (UNAME_COMMAND)
42c5f01b2fSopenharmony_ci    execute_process(COMMAND ${UNAME_COMMAND} -a OUTPUT_VARIABLE UNAME_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
43c5f01b2fSopenharmony_ci    set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${UNAME_COMMAND_RESULT}")
44c5f01b2fSopenharmony_ciendif()
45c5f01b2fSopenharmony_ci
46c5f01b2fSopenharmony_cimessage(STATUS "Operating system: ${OS_VERSION_STRINGS}")
47c5f01b2fSopenharmony_ci
48c5f01b2fSopenharmony_ci# determine the compiler (for debug and support purposes)
49c5f01b2fSopenharmony_ciif (MSVC)
50c5f01b2fSopenharmony_ci    execute_process(COMMAND ${CMAKE_CXX_COMPILER} OUTPUT_VARIABLE CXX_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_VARIABLE CXX_VERSION_RESULT ERROR_STRIP_TRAILING_WHITESPACE)
51c5f01b2fSopenharmony_ci    set(CXX_VERSION_RESULT "${CXX_VERSION_RESULT}; MSVC_VERSION=${MSVC_VERSION}; MSVC_TOOLSET_VERSION=${MSVC_TOOLSET_VERSION}")
52c5f01b2fSopenharmony_cielse()
53c5f01b2fSopenharmony_ci    execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE CXX_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE)
54c5f01b2fSopenharmony_ciendif()
55c5f01b2fSopenharmony_cistring(REGEX REPLACE "[ ]*\n" "; " CXX_VERSION_RESULT "${CXX_VERSION_RESULT}")
56c5f01b2fSopenharmony_cimessage(STATUS "Compiler: ${CXX_VERSION_RESULT}")
57