tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

CMakeLists.txt (6283B)


      1 # Copyright 2022 The Chromium Authors.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 cmake_minimum_required(VERSION 3.22)
      5 
      6 project(chrome_enterprise_connector_local_analysis)
      7 
      8 # Ensure a C++14 compiler is used.
      9 set(CMAKE_CXX_STANDARD 14)
     10 
     11 # Determine the operating system being targeted.
     12 if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
     13  set(WIN TRUE)
     14  set(MAC FALSE)
     15  set(LINUX FALSE)
     16 elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     17  set(WIN FALSE)
     18  set(MAC TRUE)
     19  set(LINUX FALSE)
     20 else()
     21  set(WIN FALSE)
     22  set(MAC FALSE)
     23  set(LINUX TRUE)
     24 endif()
     25 
     26 # Set the path to the protoc protobuf compiler.
     27 if(WIN)
     28  set(PROTOC ${PROJECT_BINARY_DIR}/vcpkg/installed/x64-windows/tools/protobuf/protoc.exe)
     29 elseif(MAC)
     30  set(PROTOC ${PROJECT_BINARY_DIR}/vcpkg/installed/x64-osx/tools/protobuf/protoc)
     31 elseif(LINUX)
     32  set(PROTOC ${PROJECT_BINARY_DIR}/vcpkg/installed/x64-linux/tools/protobuf/protoc)
     33 endif()
     34 
     35 # Calls the protoc compiler using the arguments specific to this project.
     36 # protobuf_generate_cpp is not flexible enough for our needs.
     37 add_custom_command(
     38  OUTPUT ${PROJECT_BINARY_DIR}/gen/content_analysis/sdk/analysis.pb.cc
     39  COMMAND
     40    ${PROTOC}
     41    --cpp_out=${PROJECT_BINARY_DIR}/gen
     42    --proto_path=${PROJECT_SOURCE_DIR}/proto
     43    ${PROJECT_SOURCE_DIR}/proto/content_analysis/sdk/analysis.proto
     44  DEPENDS ./proto/content_analysis/sdk/analysis.proto
     45  WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
     46 )
     47 # Define proto target. Compile this target exclusively by calling:
     48 # `cmake --build <build_dir> --target proto`
     49 add_custom_target(proto
     50  ALL
     51  DEPENDS
     52  ${PROJECT_BINARY_DIR}/gen/content_analysis/sdk/analysis.pb.cc
     53 )
     54 
     55 # The include directory contains the header files needed by the demo code.
     56 # The gen directory contains generated protobuf headers describing the request
     57 # and response objects used to communicate with Google Chrome.
     58 set(AGENT_INCLUDES
     59  ./agent/include
     60  .
     61  ${PROJECT_BINARY_DIR}/gen
     62 )
     63 set(BROWSER_INCLUDES
     64  ./browser/include
     65  .
     66  ${PROJECT_BINARY_DIR}/gen
     67 )
     68 
     69 # The SDK contains platform specific code for each of the supported platforms.
     70 # ${PLATFORM_AGENT_CODE} holds the list of source files needed for the current
     71 # platform being built.
     72 if(WIN)
     73  set(PLATFORM_AGENT_CODE
     74    ./agent/src/agent_utils_win.cc
     75    ./agent/src/agent_utils_win.h
     76    ./agent/src/agent_win.cc
     77    ./agent/src/agent_win.h
     78    ./agent/src/event_win.cc
     79    ./agent/src/event_win.h
     80    ./agent/src/scoped_print_handle_win.cc
     81    ./agent/src/scoped_print_handle_win.h
     82    ./common/utils_win.cc
     83    ./common/utils_win.h
     84  )
     85  set(PLATFORM_TEST_CODE
     86    ./agent/src/agent_win_unittest.cc
     87    ./agent/src/event_win_unittest.cc
     88  )
     89 elseif(MAC)
     90  set(PLATFORM_AGENT_CODE
     91    ./agent/src/agent_mac.cc
     92    ./agent/src/agent_mac.h
     93    ./agent/src/event_mac.cc
     94    ./agent/src/event_mac.h
     95    ./agent/src/scoped_print_handle_mac.cc
     96    ./agent/src/scoped_print_handle_mac.h
     97  )
     98  set(PLATFORM_TEST_CODE
     99    ./agent/src/event_mac_unittest.cc
    100  )
    101 elseif(LINUX)
    102  set(PLATFORM_AGENT_CODE
    103    ./agent/src/agent_posix.cc
    104    ./agent/src/agent_posix.h
    105    ./agent/src/event_posix.cc
    106    ./agent/src/event_posix.h
    107    ./agent/src/scoped_print_handle_posix.cc
    108    ./agent/src/scoped_print_handle_posix.h
    109  )
    110  set(PLATFORM_TEST_CODE
    111    ./agent/src/event_posix_unittest.cc
    112  )
    113 endif()
    114 
    115 # The SDK contains platform specific code for each of the supported platforms.
    116 # ${PLATFORM_BROWSER_CODE} holds the list of source files needed for the current
    117 # platform being built.
    118 if(WIN)
    119  set(PLATFORM_BROWSER_CODE
    120    ./browser/src/client_win.cc
    121    ./browser/src/client_win.h
    122    ./common/utils_win.cc
    123    ./common/utils_win.h
    124  )
    125 elseif(MAC)
    126  set(PLATFORM_BROWSER_CODE
    127    ./browser/src/client_mac.cc
    128    ./browser/src/client_mac.h
    129  )
    130 elseif(LINUX)
    131  set(PLATFORM_BROWSER_CODE
    132    ./browser/src/client_posix.cc
    133    ./browser/src/client_posix.h
    134  )
    135 endif()
    136 
    137 # Makes available the package definitions in vcpkg.
    138 include("${PROJECT_BINARY_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
    139 find_package(Protobuf CONFIG REQUIRED)
    140 # Unit tests
    141 enable_testing()
    142 find_package(GTest CONFIG REQUIRED)
    143 include(GoogleTest)
    144 
    145 add_executable(unit_tests
    146  ${PLATFORM_TEST_CODE}
    147 )
    148 set_property(TARGET unit_tests PROPERTY CXX_STANDARD 20)
    149 target_include_directories(unit_tests
    150  PRIVATE
    151  ${AGENT_INCLUDES}
    152  ${BROWSER_INCLUDES}
    153 )
    154 target_link_libraries(unit_tests
    155  PUBLIC 
    156  cac_agent
    157  cac_browser
    158  GTest::gtest GTest::gtest_main
    159 )
    160 
    161 gtest_discover_tests(unit_tests) 
    162 
    163 # Builds the content analysis connector agent linker library.  This library
    164 # is linked into the agent in order to listen for and process content analysis
    165 # requests from Google Chrome.
    166 add_library(cac_agent
    167  ./agent/include/content_analysis/sdk/analysis_agent.h
    168  ./agent/include/content_analysis/sdk/result_codes.h
    169  ./agent/src/agent_base.cc
    170  ./agent/src/agent_base.h
    171  ./agent/src/event_base.cc
    172  ./agent/src/event_base.h
    173  ./agent/src/scoped_print_handle_base.cc
    174  ./agent/src/scoped_print_handle_base.h
    175  ${PLATFORM_AGENT_CODE}
    176  ${PROJECT_BINARY_DIR}/gen/content_analysis/sdk/analysis.pb.cc
    177 )
    178 target_link_libraries(cac_agent
    179  PUBLIC
    180  protobuf::libprotoc
    181  protobuf::libprotobuf
    182  protobuf::libprotobuf-lite)
    183 target_include_directories(cac_agent PRIVATE ${AGENT_INCLUDES})
    184 # Builds the content analysis connector browser linker library.  This library
    185 # is linked into the client in order to send content analysis requests to the
    186 # agent.
    187 add_library(cac_browser
    188  ./browser/include/content_analysis/sdk/analysis_client.h
    189  ./browser/src/client_base.cc
    190  ./browser/src/client_base.h
    191  ${PLATFORM_BROWSER_CODE}
    192  ${PROJECT_BINARY_DIR}/gen/content_analysis/sdk/analysis.pb.cc
    193 )
    194 target_include_directories(cac_browser PRIVATE ${BROWSER_INCLUDES})
    195 target_link_libraries(cac_browser
    196  PUBLIC
    197  protobuf::libprotoc
    198  protobuf::libprotobuf
    199  protobuf::libprotobuf-lite)
    200 
    201 # The demo agent executable.
    202 add_executable(agent
    203  ./demo/agent.cc
    204  ./demo/handler.h
    205 )
    206 target_compile_features(agent PRIVATE cxx_std_17)
    207 target_include_directories(agent PRIVATE ${AGENT_INCLUDES})
    208 target_link_libraries(agent PRIVATE cac_agent)
    209 
    210 # The demo client executable.
    211 add_executable(browser ./demo/client.cc)
    212 target_include_directories(browser PRIVATE ${BROWSER_INCLUDES})
    213 target_link_libraries(browser PRIVATE cac_browser)