-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
98 lines (79 loc) · 2.53 KB
/
Copy pathCMakeLists.txt
File metadata and controls
98 lines (79 loc) · 2.53 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
cmake_minimum_required(VERSION 3.16)
project(OpenSRX
VERSION 0.1.2
DESCRIPTION "C++ library for interfacing with Keyence SR series barcode readers"
LANGUAGES CXX
)
include(FetchContent)
include(GNUInstallDirs)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(BUILD_STATIC_LIB "Build a static library instead of a shared library" OFF)
option(BUILD_EXAMPLES "Build example binaries" ON)
option(BUILD_TESTS "Build test targets" ON)
find_package(Threads REQUIRED)
FetchContent_Declare(
asio
URL https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-30-2.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
FetchContent_Declare(
spdlog
URL https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
FetchContent_Declare(
fineftp
URL https://github.com/eclipse-ecal/fineftp-server/archive/refs/tags/v1.6.0.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
FetchContent_GetProperties(asio)
if(NOT asio_POPULATED)
if(POLICY CMP0169)
cmake_policy(SET CMP0169 OLD)
endif()
FetchContent_Populate(asio)
endif()
FetchContent_MakeAvailable(spdlog)
# Set asio_INCLUDE_DIR so fineftp's Findasio.cmake finds our already-fetched Asio headers.
set(asio_INCLUDE_DIR "${asio_SOURCE_DIR}/asio/include" CACHE PATH "" FORCE)
set(FINEFTP_SERVER_BUILD_TESTS OFF CACHE BOOL "" FORCE)
FetchContent_GetProperties(fineftp)
if(NOT fineftp_POPULATED)
FetchContent_Populate(fineftp)
# Build fineftp as static so it's linked into libOpenSRX.so
set(_saved_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(${fineftp_SOURCE_DIR} ${fineftp_BINARY_DIR} EXCLUDE_FROM_ALL)
set(BUILD_SHARED_LIBS ${_saved_BUILD_SHARED_LIBS})
endif()
add_library(asio_headers INTERFACE)
add_library(asio::asio ALIAS asio_headers)
target_include_directories(asio_headers
INTERFACE
${asio_SOURCE_DIR}/asio/include
)
target_compile_definitions(asio_headers
INTERFACE
ASIO_STANDALONE
)
target_link_libraries(asio_headers
INTERFACE
Threads::Threads
)
set(OPENSRX_GENERATED_INCLUDE_DIR "${PROJECT_BINARY_DIR}/generated/include")
file(MAKE_DIRECTORY "${OPENSRX_GENERATED_INCLUDE_DIR}/OpenSRX")
configure_file(
"${PROJECT_SOURCE_DIR}/include/OpenSRX/Version.hpp.in"
"${OPENSRX_GENERATED_INCLUDE_DIR}/OpenSRX/Version.hpp"
@ONLY
)
add_subdirectory(src)
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()