Skip to content
Snippets Groups Projects
CMakeLists.txt 4.96 KiB
Newer Older
  • Learn to ignore specific revisions
  • if (fmt_FOUND)
      get_target_property(FMT_INCLUDE_DIR fmt::fmt INTERFACE_INCLUDE_DIRECTORIES)
    endif()
    
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
    
      add_definitions(-DNOGDI -DNOMINMAX)
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    endif()
    
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    add_definitions(-DBOOST_FILESYSTEM_NO_DEPRECATED)
    
    
    include_directories(
      ${CMAKE_CURRENT_BINARY_DIR}
      ${CMAKE_SOURCE_DIR}/src
      ${VENDOR_INSTALL_DIR}/include
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
      ${Boost_INCLUDE_DIRS}
    
    file(GLOB PROTO_SRC ${CMAKE_SOURCE_DIR}/proto/cpp/vereign/client_library/*.cc)
    list(APPEND PROTO_SRC
      ${CMAKE_SOURCE_DIR}/proto/cpp/google/api/annotations.pb.cc
      ${CMAKE_SOURCE_DIR}/proto/cpp/google/api/http.pb.cc
    
      ${CMAKE_SOURCE_DIR}/proto/cpp/code.vereign.com/code/viam-apis/versions/api/api.pb.cc
    
      ${CMAKE_SOURCE_DIR}/proto/cpp/code.vereign.com/code/viam-apis/audit-log-agent/api/api.pb.cc
      ${CMAKE_SOURCE_DIR}/proto/cpp/code.vereign.com/code/viam-apis/entities-management-agent/api/api.pb.cc
      ${CMAKE_SOURCE_DIR}/proto/cpp/code.vereign.com/code/viam-apis/hyperledger-agent/api/api.pb.cc
      ${CMAKE_SOURCE_DIR}/proto/cpp/code.vereign.com/code/viam-apis/image-storage-agent/api/api.pb.cc
      ${CMAKE_SOURCE_DIR}/proto/cpp/code.vereign.com/code/viam-apis/restful-api/api/api.pb.cc
      ${CMAKE_SOURCE_DIR}/proto/cpp/code.vereign.com/code/viam-apis/signing-service-agent/api/api.pb.cc
      ${CMAKE_SOURCE_DIR}/proto/cpp/code.vereign.com/code/viam-apis/passport-generation-agent/api/api.pb.cc
    
    add_library(vereignproto STATIC ${PROTO_SRC})
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    set_property(TARGET vereignproto PROPERTY POSITION_INDEPENDENT_CODE ON)
    
    
    target_link_libraries(
      vereignproto
      protobuf::libprotobuf
      OpenSSL::SSL
      OpenSSL::Crypto
      $<$<CXX_COMPILER_ID:MSVC>:CRYPT32.LIB>
    )
    
    if (VEREIGN_USE_PRECOMPILED_HEADERS)
      file(GLOB PROTO_HEADERS ${CMAKE_SOURCE_DIR}/proto/cpp/vereign/client_library/*pb.h)
      target_precompile_headers(vereignproto PUBLIC ${PROTO_HEADERS})
    endif()
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
      vereign/core/rand.cc
      vereign/core/temp.cc
      vereign/core/fs.cc
    
      vereign/core/string.cc
    
      vereign/restapi/detail/http_reader.cc
      vereign/restapi/client.cc
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    
      # vereign/grpc/gen/gen.cc
    
      vereign/grpc/json/encoder.cc
    
      vereign/grpc/service_registry.cc
    
      vereign/sqlite/statement.cc
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
      vereign/sqlite/connection.cc
    
      vereign/bytes/view_dump.cc
      vereign/bytes/buffer.cc
    
      vereign/encoding/binary.cc
      vereign/encoding/base64.cc
      vereign/encoding/hex.cc
    
      vereign/crypto/aes.cc
      vereign/crypto/rsa.cc
      vereign/crypto/bio.cc
      vereign/crypto/digest.cc
    
    
      vereign/kvstore/lock.cc
    
      vereign/kvstore/detail/base_crypto_storage.cc
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
      vereign/kvstore/sqlite_storage.cc
      vereign/kvstore/crypto_storage.cc
    
      vereign/identity/provider.cc
    
      vereign/service/gen/passport_service.cc
      vereign/service/passport_service.cc
      vereign/service/identity_service.cc
    
      # FIXME: remove this
      vereign/service/gen/identity_service.cc
      vereign/service/gen/passport_service.cc
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    
    if (LINUX)
      list(APPEND VEREIGNLIB_SRC
        vereign/kvstore/detail/linux_crypto_storage.cc
      )
    
    elseif (WIN32)
      list(APPEND VEREIGNLIB_SRC
    
        vereign/ncrypt/errors.cc
        vereign/ncrypt/unique_ptr.cc
        vereign/ncrypt/rsa.cc
    
        vereign/kvstore/detail/win_crypto_storage.cc
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    endif()
    
    # file(GLOB GENERATED_SERVICES_SRC vereign/service/gen/*.cc)
    # list(APPEND VEREIGNLIB_SRC ${GENERATED_SERVICES_SRC})
    
    
    add_library(vereignlib STATIC ${VEREIGNLIB_SRC})
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    set_property(TARGET vereignlib PROPERTY POSITION_INDEPENDENT_CODE ON)
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    target_link_libraries(vereignlib PRIVATE
      nlohmann_json::nlohmann_json
    )
    
    target_link_libraries(vereignlib PUBLIC
    
      fmt::fmt
    
      gRPC::grpc++_reflection
      gRPC::grpc++
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
      Boost::filesystem
    
      $<$<CXX_COMPILER_ID:MSVC>:Boost::date_time>
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
      SQLite::SQLite3
    
      $<$<CXX_COMPILER_ID:MSVC>:ncrypt.lib>
      $<$<CXX_COMPILER_ID:MSVC>:cryptui.lib>
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    add_library(vereign SHARED
      vereign/vereign.cc
    )
    target_include_directories(vereign
      PRIVATE ${CMAKE_SOURCE_DIR}/include
    )
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    target_link_libraries(vereign PRIVATE
      vereignlib
    )
    if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
      # Set the DLLEXPORT variable to export symbols
      target_compile_definitions(vereign PRIVATE WIN_EXPORT)
    endif()
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    
    
    set(csandbox_sources
      csandbox.cc
    )
    
    #add_library(csandboxlib STATIC ${csandboxlib_src})
    #target_link_libraries(csandboxlib ${LIBS})
    
    add_executable(csandbox ${csandbox_sources})
    
    target_link_libraries(csandbox
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
      PRIVATE vereignlib
      $<$<CXX_COMPILER_ID:MSVC>:Boost::date_time>
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
      Boost::filesystem
      # Boost::file
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
      # Boost::thread
      # vereign
    
      # fmt::fmt
      # Boost::regex
      # Threads::Threads
      # OpenSSL::SSL
      # $<$<CXX_COMPILER_ID:MSVC>:CRYPT32.LIB>
    
    if (VEREIGN_USE_TIME_TRACE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
      target_compile_options(csandbox
        PRIVATE "-ftime-trace"
      )
    endif()
    
    
    # Generates the gRPC and Vereign services source code.
    add_custom_target(
      vcl-gen
    
      COMMAND vcl-gen generate -v --templates-path=templates --output-path src
    
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
    )