|
| 1 | +cmake_minimum_required(VERSION 3.20) |
| 2 | + |
| 3 | +# set(VCPKG_LIBRARY_LINKAGE static) |
| 4 | +# set(VCPKG_TARGET_TRIPET x64-windows-static) |
| 5 | +# set(VCPKG_INSTALL_OPTIONS --allow-unsupported) |
| 6 | + |
| 7 | +message("VCPKG_ROOT: $ENV{VCPKG_ROOT}") |
| 8 | +message("CMAKE_TOOLCHAIN_FILE: $ENV{CMAKE_TOOLCHAIN_FILE}") |
| 9 | + |
| 10 | +list(APPEND CMAKE_PROJECT_TOP_LEVEL_INCLUDES "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") |
| 11 | +list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_PROJECT_TOP_LEVEL_INCLUDES) |
| 12 | + |
| 13 | +if(POLICY CMP0167) |
| 14 | + cmake_policy(SET CMP0167 NEW) |
| 15 | +endif() |
| 16 | + |
| 17 | +project(pulsescan_cpp LANGUAGES CXX) |
| 18 | + |
| 19 | +option(ENABLE_STACKTRACE "Enable Boost stacktrace logging" OFF) |
| 20 | + |
| 21 | +set(CMAKE_CXX_STANDARD 20) |
| 22 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 23 | +set(CMAKE_CXX_EXTENSIONS OFF) |
| 24 | +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 25 | + |
| 26 | +find_package(CLI11 CONFIG REQUIRED) |
| 27 | +find_package(Boost REQUIRED COMPONENTS asio) |
| 28 | +if(ENABLE_STACKTRACE) |
| 29 | + find_package(Boost REQUIRED COMPONENTS stacktrace_basic) |
| 30 | +endif() |
| 31 | + |
| 32 | + |
| 33 | +add_executable(pulsescan_cpp |
| 34 | + src/core/cli.cpp |
| 35 | + src/main.cpp |
| 36 | + src/core/logging.cpp |
| 37 | + src/net/icmp_packet.cpp |
| 38 | + src/core/resolve.cpp |
| 39 | + src/core/scan_runner.cpp |
| 40 | + src/net/scan_tcp.cpp |
| 41 | + src/net/scan_udp.cpp |
| 42 | +) |
| 43 | +set_target_properties(pulsescan_cpp PROPERTIES OUTPUT_NAME "pulsescan-cpp") |
| 44 | + |
| 45 | +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 46 | + target_sources(pulsescan_cpp PRIVATE src/net/icmp_ping.cpp) |
| 47 | + target_sources(pulsescan_cpp PRIVATE src/platform/sandbox_landlock.cpp) |
| 48 | +elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") |
| 49 | + target_sources(pulsescan_cpp PRIVATE src/net/icmp_ping.cpp) |
| 50 | + target_sources(pulsescan_cpp PRIVATE src/platform/sandbox_capsicum.cpp) |
| 51 | +else() |
| 52 | + target_sources(pulsescan_cpp PRIVATE src/net/icmp_ping_stub.cpp) |
| 53 | + target_sources(pulsescan_cpp PRIVATE src/platform/sandbox_none.cpp) |
| 54 | +endif() |
| 55 | +target_include_directories(pulsescan_cpp PRIVATE src) |
| 56 | + |
| 57 | +find_package(CURL REQUIRED) |
| 58 | +target_link_libraries(pulsescan_cpp PRIVATE CURL::libcurl) |
| 59 | + |
| 60 | +# this is heuristically generated, and may not be correct |
| 61 | +find_package(cpr CONFIG REQUIRED) |
| 62 | +target_link_libraries(pulsescan_cpp PRIVATE cpr::cpr) |
| 63 | + |
| 64 | +target_link_libraries(pulsescan_cpp PRIVATE Boost::asio CLI11::CLI11) |
| 65 | +if(ENABLE_STACKTRACE) |
| 66 | + target_link_libraries(pulsescan_cpp PRIVATE Boost::stacktrace_basic) |
| 67 | + target_compile_definitions(pulsescan_cpp PRIVATE ENABLE_STACKTRACE) |
| 68 | +endif() |
| 69 | + |
| 70 | +include(CTest) |
| 71 | +if(BUILD_TESTING) |
| 72 | + find_package(Catch2 CONFIG REQUIRED) |
| 73 | + include(Catch) |
| 74 | + |
| 75 | + add_executable(pulsescan_cpp_tests |
| 76 | + tests/test_network.cpp |
| 77 | + tests/test_parsing.cpp |
| 78 | + src/core/cli.cpp |
| 79 | + src/core/logging.cpp |
| 80 | + src/core/resolve.cpp |
| 81 | + src/net/icmp_packet.cpp |
| 82 | + ) |
| 83 | + target_include_directories(pulsescan_cpp_tests PRIVATE src) |
| 84 | + target_link_libraries(pulsescan_cpp_tests PRIVATE Boost::asio CLI11::CLI11 Catch2::Catch2WithMain) |
| 85 | + if(ENABLE_STACKTRACE) |
| 86 | + target_link_libraries(pulsescan_cpp_tests PRIVATE Boost::stacktrace_basic) |
| 87 | + target_compile_definitions(pulsescan_cpp_tests PRIVATE ENABLE_STACKTRACE) |
| 88 | + endif() |
| 89 | + catch_discover_tests(pulsescan_cpp_tests) |
| 90 | +endif() |
0 commit comments