CMake

samples/CMakeLists.txt
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#[[
CMake file for building samples.
]]
cmake_minimum_required(VERSION 3.1)

set(CEPTON_SDK_SAMPLES_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}")
get_filename_component(CEPTON_SDK_SOURCE_DIR
                       "${CEPTON_SDK_SAMPLES_SOURCE_DIR}/../" ABSOLUTE)
list(APPEND CMAKE_MODULE_PATH "${CEPTON_SDK_SOURCE_DIR}/cmake")

include("CeptonVersion")
project(
  cepton_sdk_samples
  VERSION ${CEPTON_VERSION}
  LANGUAGES C CXX)

include("CeptonCommon")

if(GCC OR CLANG)
  add_flags(-Wall -Wextra -pedantic)
  add_linker_flags(-pthread)
endif()

# cepton_sdk
add_subdirectory("${CEPTON_SDK_SOURCE_DIR}"
                 "${PROJECT_BINARY_DIR}/third_party/cepton_sdk")

set(CEPTON_SDK_SAMPLE_SOURCES
    "${CEPTON_SDK_SAMPLES_SOURCE_DIR}/advanced/frame_accumulator.cpp"
    "${CEPTON_SDK_SAMPLES_SOURCE_DIR}/advanced/frame_detector.cpp"
    "${CEPTON_SDK_SAMPLES_SOURCE_DIR}/advanced/process_multi.cpp"
    "${CEPTON_SDK_SAMPLES_SOURCE_DIR}/advanced/process_single.cpp"
    "${CEPTON_SDK_SAMPLES_SOURCE_DIR}/basic.cpp"
    "${CEPTON_SDK_SAMPLES_SOURCE_DIR}/callback.cpp"
    "${CEPTON_SDK_SAMPLES_SOURCE_DIR}/error.cpp")
foreach(path ${CEPTON_SDK_SAMPLE_SOURCES})
  get_filename_component(name "${path}" NAME_WE)
  add_executable(cepton_sdk_sample_${name} "${path}")
  target_include_directories(cepton_sdk_sample_${name}
                             PRIVATE "${CEPTON_SDK_SAMPLES_SOURCE_DIR}")
  target_link_libraries(cepton_sdk_sample_${name} cepton_sdk::cepton_sdk)
endforeach()

if(GCC OR CLANG)
  set(CEPTON_SDK_POSIX_SAMPLE_SOURCES
      "${CEPTON_SDK_SAMPLES_SOURCE_DIR}/posix/direct_networking.c")
  foreach(path ${CEPTON_SDK_POSIX_SAMPLE_SOURCES})
    get_filename_component(name "${path}" NAME_WE)
    add_executable(cepton_sdk_sample_${name} "${path}")
    target_include_directories(cepton_sdk_sample_${name}
                                PRIVATE "${CEPTON_SDK_SAMPLES_SOURCE_DIR}")
    target_link_libraries(cepton_sdk_sample_${name} cepton_sdk::cepton_sdk)
  endforeach()
endif()