Skip to content

Commit 4ff7427

Browse files
committed
build: add option to disable mph
1 parent 025d2c7 commit 4ff7427

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

CMakeLists.txt

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
1414

1515
option(WITH_TESTING "Whether to enable tests" ON)
1616
option(WITH_EXAMPLES "Whether to enable examples" ON)
17+
option(WITH_MPH "Whether to use mph" ON)
1718
option(INSTALL_RESOURCE_DETECTORS "Whether to install Resource Detectors" ON)
1819

19-
include(FetchContent)
20-
2120
find_package(opentelemetry-cpp CONFIG REQUIRED)
2221

23-
FetchContent_Declare(
24-
qlibs_mph
25-
GIT_REPOSITORY https://github.com/qlibs/mph
26-
GIT_TAG v5.0.4
27-
)
22+
if(WITH_MPH)
23+
include(FetchContent)
24+
FetchContent_Declare(
25+
qlibs_mph
26+
GIT_REPOSITORY https://github.com/qlibs/mph
27+
GIT_TAG v5.0.4
28+
)
2829

29-
FetchContent_MakeAvailable(qlibs_mph)
30+
FetchContent_MakeAvailable(qlibs_mph)
31+
endif()
3032

3133
add_library(utils OBJECT)
3234
target_sources(
@@ -38,13 +40,14 @@ target_sources(
3840
src/string_utils.cpp
3941
)
4042

41-
target_link_libraries(
42-
utils
43-
PUBLIC opentelemetry-cpp::resources
44-
PRIVATE qlibs_mph
45-
)
43+
target_link_libraries(utils PUBLIC opentelemetry-cpp::resources)
4644

47-
target_include_directories(utils PUBLIC ${qlibs_mph_SOURCE_DIR})
45+
if(WITH_MPH)
46+
target_link_libraries(utils PRIVATE qlibs_mph)
47+
target_include_directories(utils PUBLIC ${qlibs_mph_SOURCE_DIR})
48+
else()
49+
target_compile_definitions(utils PRIVATE DISABLE_MPH)
50+
endif()
4851

4952
add_library(helpers STATIC $<TARGET_OBJECTS:utils>)
5053
target_include_directories(helpers PUBLIC ${CMAKE_SOURCE_DIR}/src)

src/os_utils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#include <string_view>
44
#include <utility>
55

6-
#if (defined(__clang__) && __clang_major__ < 15) || (defined(__GNUC__) && __GNUC__ < 12) || defined(__MINGW32__)
6+
#if !defined(DISABLE_MPH) && \
7+
((defined(__clang__) && __clang_major__ < 15) || (defined(__GNUC__) && __GNUC__ < 12) || defined(__MINGW32__))
78
# define DISABLE_MPH
89
#endif
910

0 commit comments

Comments
 (0)