if(NOT COUCHBASE_CXX_CLIENT_GIT_REVISION)
  find_program(GIT git)
  if(GIT)
    execute_process(
      COMMAND git rev-parse HEAD
      WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
      OUTPUT_STRIP_TRAILING_WHITESPACE
      OUTPUT_VARIABLE COUCHBASE_CXX_CLIENT_GIT_REVISION)
  else()
    set(COUCHBASE_CXX_CLIENT_GIT_REVISION "unknown")
  endif()
endif()

string(TIMESTAMP COUCHBASE_CXX_CLIENT_BUILD_TIMESTAMP "%Y-%m-%d %H:%M:%S" UTC)
configure_file(${PROJECT_SOURCE_DIR}/cmake/build_version.hxx.in
               ${PROJECT_BINARY_DIR}/generated/couchbase/build_version.hxx @ONLY)
configure_file(${PROJECT_SOURCE_DIR}/cmake/build_config.hxx.in
               ${PROJECT_BINARY_DIR}/generated/couchbase/build_config.hxx @ONLY)

file(
  GENERATE
  OUTPUT ${PROJECT_BINARY_DIR}/generated/couchbase/build_info.hxx
  CONTENT
    "
#pragma once

#define COUCHBASE_CXX_CLIENT_COMPILE_DEFINITIONS \"$<TARGET_PROPERTY:couchbase_cxx_client,COMPILE_DEFINITIONS>\"
#define COUCHBASE_CXX_CLIENT_COMPILE_FEATURES \"$<TARGET_PROPERTY:couchbase_cxx_client,COMPILE_FEATURES>\"
#define COUCHBASE_CXX_CLIENT_COMPILE_FLAGS \"$<TARGET_PROPERTY:couchbase_cxx_client,COMPILE_FLAGS>\"
#define COUCHBASE_CXX_CLIENT_COMPILE_OPTIONS \"$<TARGET_PROPERTY:couchbase_cxx_client,COMPILE_OPTIONS>\"
#define COUCHBASE_CXX_CLIENT_LINK_DEPENDS \"$<TARGET_PROPERTY:couchbase_cxx_client,LINK_DEPENDS>\"
#define COUCHBASE_CXX_CLIENT_LINK_FLAGS \"$<TARGET_PROPERTY:couchbase_cxx_client,LINK_FLAGS>\"
#define COUCHBASE_CXX_CLIENT_LINK_LIBRARIES \"$<TARGET_PROPERTY:couchbase_cxx_client,LINK_LIBRARIES>\"
#define COUCHBASE_CXX_CLIENT_LINK_OPTIONS \"$<TARGET_PROPERTY:couchbase_cxx_client,LINK_OPTIONS>\"
#define COUCHBASE_CXX_CLIENT_POST_LINKED_OPENSSL \"${COUCHBASE_CXX_CLIENT_POST_LINKED_OPENSSL}\"

#define OPENSSL_CRYPTO_LIBRARIES \"${OPENSSL_CRYPTO_LIBRARIES}\"
#define OPENSSL_SSL_LIBRARIES \"${OPENSSL_SSL_LIBRARIES}\"
#define OPENSSL_INCLUDE_DIR \"${OPENSSL_INCLUDE_DIR}\"

#define CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\"
#define CMAKE_VERSION \"${CMAKE_VERSION}\"

#define COUCHBASE_CXX_CLIENT_DEBUG_BUILD $<STREQUAL:$<UPPER_CASE:\"${CMAKE_BUILD_TYPE}\">,\"DEBUG\">
")
