-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
106 lines (91 loc) · 2.79 KB
/
Copy pathCMakeLists.txt
File metadata and controls
106 lines (91 loc) · 2.79 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# root `${workspaceFolder}/CMakeLists.txt` file
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(freeimpala LANGUAGES C CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(-Wall -Wextra -pthread)
# — Fix for conda compiler include paths —
# Add system include directory for conda-based compilers
add_compile_options(-I/usr/include)
# — Fetch header-only libs —
include(FetchContent)
FetchContent_Declare(
argparse
GIT_REPOSITORY https://github.com/p-ranav/argparse.git
GIT_TAG v3.2
)
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.10.0
)
FetchContent_MakeAvailable(argparse spdlog)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
)
# — Find MPI —
find_package(MPI COMPONENTS CXX QUIET)
if(MPI_CXX_FOUND)
message(STATUS "MPI found")
else()
message(WARNING "MPI not found; MPI targets will be skipped")
endif()
# — Find LibTorch —
find_package(Torch QUIET)
if(Torch_FOUND)
message(STATUS "LibTorch found")
else()
message(WARNING "LibTorch not found; libtorch_bench will be skipped")
endif()
# — Find Paho MQTT C —
find_path(PAHO_MQTT_C_INCLUDE_DIR
NAMES MQTTClient.h
HINTS
/usr/include
/usr/local/include
/opt/homebrew/include
)
# Detect system architecture for library search
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64")
set(ARCH_LIB_DIR "aarch64-linux-gnu")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64")
set(ARCH_LIB_DIR "x86_64-linux-gnu")
else()
set(ARCH_LIB_DIR "")
endif()
find_library(PAHO_MQTT3C_LIBRARY
NAMES paho-mqtt3c
HINTS
/usr/lib
/usr/lib/${ARCH_LIB_DIR} # Architecture-specific directory
/usr/lib/x86_64-linux-gnu
/usr/lib/aarch64-linux-gnu
/usr/local/lib
/opt/homebrew/lib
)
if(NOT PAHO_MQTT_C_INCLUDE_DIR OR NOT PAHO_MQTT3C_LIBRARY)
message(FATAL_ERROR "Cannot find Paho MQTT C; install via brew/apt/spack")
endif()
# diagnostic output
message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "Architecture lib dir: ${ARCH_LIB_DIR}")
message(STATUS "Paho MQTT C include dir: ${PAHO_MQTT_C_INCLUDE_DIR}")
message(STATUS "Paho MQTT C library: ${PAHO_MQTT3C_LIBRARY}")
# imported shared library target
add_library(PahoMqttC::paho-mqtt3c SHARED IMPORTED)
set_target_properties(PahoMqttC::paho-mqtt3c PROPERTIES
IMPORTED_LOCATION ${PAHO_MQTT3C_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${PAHO_MQTT_C_INCLUDE_DIR}
)
# — Add your binaries —
add_subdirectory(cmd/freeimpala)
add_subdirectory(cmd/mqtt_example)
if(MPI_CXX_FOUND)
add_subdirectory(cmd/freeimpala_mpi_sync)
add_subdirectory(cmd/freeimpala_mpi_async)
add_subdirectory(cmd/freeimpala_mpi_async_pool)
endif()
if(Torch_FOUND)
add_subdirectory(cmd/libtorch_bench)
endif()