@@ -11,10 +11,37 @@ endif()
11
11
12
12
find_path (Datadog_INCLUDE_DIR datadog/profiling.h HINTS ${Datadog_ROOT} /include )
13
13
14
- find_library (
15
- Datadog_LIBRARY
16
- NAMES datadog_profiling
17
- HINTS ${Datadog_ROOT} /lib)
14
+ set (DD_LIB_NAME "datadog_profiling" )
15
+
16
+ if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
17
+ # Prefer static linking over dynamic unless specified
18
+ set (LINK_TYPE "static" )
19
+ if (DEFINED VCRUNTIME_LINK_TYPE)
20
+ string (TOLOWER ${VCRUNTIME_LINK_TYPE} LINK_TYPE)
21
+ endif ()
22
+
23
+ set (BUILD_TYPE "release" )
24
+ if (DEFINED CMAKE_BUILD_TYPE )
25
+ string (TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE )
26
+ endif ()
27
+
28
+ find_library (
29
+ Datadog_LIBRARY
30
+ # Windows artifacts publish the library as datadog_profiling_ffi
31
+ # in {build_type}/{link_type} directory
32
+ NAMES ${DD_LIB_NAME} datadog_profiling_ffi
33
+ HINTS ${Datadog_ROOT} /lib ${Datadog_ROOT} /${BUILD_TYPE} /${LINK_TYPE} )
34
+
35
+ # It could be either datadog_profiling or datadog_profiling_ffi, set it to the
36
+ # one that is found
37
+ get_filename_component (DD_LIB_NAME ${Datadog_LIBRARY} NAME_WE )
38
+ message (STATUS "Datadog library name: ${DD_LIB_NAME} " )
39
+ else ()
40
+ find_library (
41
+ Datadog_LIBRARY
42
+ NAMES ${DD_LIB_NAME}
43
+ HINTS ${Datadog_ROOT} /lib)
44
+ endif ()
18
45
19
46
find_package_handle_standard_args(Datadog DEFAULT_MSG Datadog_LIBRARY
20
47
Datadog_INCLUDE_DIR)
@@ -24,15 +51,15 @@ if(Datadog_FOUND)
24
51
set (Datadog_LIBRARIES ${Datadog_LIBRARY} "@Datadog_LIBRARIES@" )
25
52
mark_as_advanced (Datadog_ROOT Datadog_LIBRARY Datadog_INCLUDE_DIR)
26
53
27
- add_library (datadog_profiling INTERFACE )
28
- target_include_directories (datadog_profiling
54
+ add_library (${DD_LIB_NAME} INTERFACE )
55
+ target_include_directories (${DD_LIB_NAME}
29
56
INTERFACE ${Datadog_INCLUDE_DIRS} )
30
- target_link_libraries (datadog_profiling INTERFACE ${Datadog_LIBRARIES} )
31
- target_compile_features (datadog_profiling INTERFACE c_std_11)
57
+ target_link_libraries (${DD_LIB_NAME} INTERFACE ${Datadog_LIBRARIES} )
58
+ target_compile_features (${DD_LIB_NAME} INTERFACE c_std_11)
32
59
33
60
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
34
61
target_link_libraries (
35
- datadog_profiling
62
+ ${DD_LIB_NAME}
36
63
INTERFACE NtDll
37
64
UserEnv
38
65
Bcrypt
@@ -45,7 +72,7 @@ if(Datadog_FOUND)
45
72
PowrProf)
46
73
endif ()
47
74
48
- add_library (Datadog::Profiling ALIAS datadog_profiling )
75
+ add_library (Datadog::Profiling ALIAS ${DD_LIB_NAME} )
49
76
else ()
50
77
set (Datadog_ROOT
51
78
""
0 commit comments