-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
157 lines (121 loc) · 3.72 KB
/
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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
cmake_minimum_required(VERSION 3.13.4)
# Allows for setting MSVC static runtime
cmake_policy(SET CMP0091 NEW)
project(udaq
VERSION "0.0.1"
DESCRIPTION "Cross-pltform Data Acquisition Sequencer"
LANGUAGES C CXX)
set(NAMESPACE udaq)
##
## Build options
##
# Set this to OFF to build static libraries
option (BUILD_SHARED_LIBS "Build shared libraries" ON)
option (BUILD_TESTS "Build tests and related tools" OFF)
if (BUILD_SHARED_LIBS)
set(USE_STATIC_LIBS_DEFAULT OFF)
else()
set(USE_STATIC_LIBS_DEFAULT ON)
endif()
option (USE_STATIC_LIBS "Use external static libs if possible" ${USE_STATIC_LIBS_DEFAULT})
if(MSVC)
# Note: will require SDL2 to be compiled with FORCE_STATIC_VCRT=ON
# We only use this on MSVC
option(USE_STATIC_RUNTIME "Statically link against the C++ runtime" OFF)
endif()
option (LABVIEW_SUPPORT "Build with LabVIEW support" OFF)
##
## CMake module paths
##
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/external/sanitizers-cmake/cmake")
##
## Compile support
##
# Export compile database for IDEs, needed for QtCreator
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
##
## Import functions
##
include(setup_ide_folders)
include(get_standard_library_name)
# Check for name of standard library, use by common
include(CheckCXXSourceCompiles)
get_standard_library_name(STANDARD_LIBRARY)
##
## Packages
##
find_package(Sanitizers REQUIRED)
find_package(Threads REQUIRED)
find_package(fmt REQUIRED)
find_package(LibUV REQUIRED)
find_package(wampcc REQUIRED)
if (TARGET wampcc::wampcc_static AND USE_STATIC_LIBS)
set_target_properties(wampcc::wampcc_static PROPERTIES IMPORTED_GLOBAL TRUE)
add_library(wampcc ALIAS wampcc::wampcc_static)
else()
set_target_properties(wampcc::wampcc_shared PROPERTIES IMPORTED_GLOBAL TRUE)
add_library(wampcc ALIAS wampcc::wampcc_shared)
endif()
# Use boost statially if making a static library
if(NOT BUILD_SHARED_LIBS)
set(Boost_USE_STATIC_LIBS ON)
endif()
if (USE_STATIC_RUNTIME)
set(Boost_USE_STATIC_RUNTIME ON)
endif()
# Configure Boost in Windows
if(MSVC)
# Target Windows 7 and higher
add_compile_definitions(_WIN32_WINNT=_WIN32_WINNT_WIN7)
# Boost tries to use auto linking (i.e. #pragma lib in headers) to tell
# the compiler what to link to. This does not work properly on
# Widnows/MSVC.
add_compile_definitions(BOOST_ALL_NO_LIB)
endif()
##
## Targets/Sources
##
add_subdirectory(external/cli11)
add_subdirectory(external_cmake_wrappers/uv)
add_subdirectory(external_cmake_wrappers/wise_enum)
add_subdirectory(helpers/visa)
add_subdirectory(common)
add_subdirectory(imgui)
add_subdirectory(devices/safibra)
add_subdirectory(wrappers/c)
if(LABVIEW_SUPPORT)
add_subdirectory(wrappers/labview-c)
endif()
add_subdirectory(udaq)
add_subdirectory(gui)
if(BUILD_TESTS)
add_subdirectory(tools/scpi-simulator)
add_subdirectory(tools/safibra-simulator)
add_subdirectory(tests/find-resource)
add_subdirectory(tests/idn)
add_subdirectory(tests/device-wrapper)
#add_subdirectory(test)
endif()
# Generate target list
get_property(TARGETS GLOBAL PROPERTY ${PROJECT_NAME}_TARGETS)
##
## Compile options
##
foreach(t ${TARGETS})
# Enable extra errors for all projects
target_compile_options(${t}
PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:-Wall>
$<$<CXX_COMPILER_ID:MSVC>:/permissive->)
# Link against MSVC statically if enabled
if (USE_STATIC_RUNTIME AND MSVC)
set_property(TARGET ${t} PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
add_sanitizers(${t})
endforeach()
foreach(t ${TARGETS})
target_compile_features(${t} PRIVATE cxx_std_17)
endforeach()