File tree Expand file tree Collapse file tree 6 files changed +72
-22
lines changed Expand file tree Collapse file tree 6 files changed +72
-22
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -10,16 +10,46 @@ Dependency|Version
10
10
cmake| 3.2+
11
11
GCC| GCC ` 4.7+ `
12
12
13
- ### Build
13
+ #### Build
14
14
15
+ > @obsoleted
15
16
Use CMake ` add_subdirectory ` ;
16
- [ CMakeLists.txt example] ( ../../CMakeLists.txt )
17
+ [ CMakeLists.txt example] ( ../../src/CPP/ CMakeLists.txt )
17
18
18
19
```
19
20
$ mkdir build
20
21
$ cd build
21
22
$ cmake .. && make
22
23
```
24
+ #### Integrate in your own project
25
+
26
+ > Use cmake FetchContent
27
+
28
+ [ CMakeLists.txt example] ( ../../src/CPP/CMakeLists.txt )
29
+
30
+ ``` shell
31
+ include(FetchContent)
32
+ FetchContent_Declare(
33
+ pinpoint
34
+ GIT_REPOSITORY https://github.com/pinpoint-c-agent/pinpoint-c-agent.git
35
+ # GIT_TAG 74bc39d813d664cb56b78b1506d91932c8131396
36
+ # not recommended, please use hash key like `74bc39d813d664cb56b78b1506d91932c8131396`
37
+ GIT_TAG origin/dev
38
+ )
39
+
40
+ FetchContent_GetProperties(pinpoint)
41
+ if (NOT pinpoint_POPULATED)
42
+ FetchContent_Populate(pinpoint)
43
+ add_subdirectory(${pinpoint_SOURCE_DIR} /common ${pinpoint_BINARY_DIR} )
44
+ endif ()
45
+
46
+ FetchContent_MakeAvailable(pinpoint)
47
+
48
+ add_executable(app test_pinpoint.cpp)
49
+ target_link_libraries(app PRIVATE pinpoint_common_static rt)
50
+ ` ` `
51
+
52
+
23
53
# ## Run
24
54
25
55
` ` `
Original file line number Diff line number Diff line change 1
1
cmake_minimum_required (VERSION 3.13 )
2
- project (common VERSION 0.4.24 DESCRIPTION "pinpoint common library" )
2
+ project (pinpoint VERSION 0.4.24 DESCRIPTION "pinpoint common library" )
3
3
4
4
set (CMAKE_CXX_STANDARD 11 )
5
5
@@ -45,18 +45,26 @@ link_directories(${CMAKE_BINARY_DIR}/lib)
45
45
add_subdirectory (jsoncpp )
46
46
add_subdirectory (src )
47
47
48
+ add_library (pinpoint_common_static STATIC $< TARGET_OBJECTS:pinpoint_common_obj> $< TARGET_OBJECTS:jsoncppObj> )
49
+
50
+ target_include_directories (pinpoint_common_static PUBLIC
51
+ $< INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR} >
52
+ $< BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR} /include>
53
+ $< BUILD_INTERFACE:${PROJECT_BINARY_DIR} /include>
54
+ )
55
+
48
56
if (UNIX AND NOT APPLE )
49
57
include (GNUInstallDirs )
50
58
add_library (pinpoint_common_shared SHARED $< TARGET_OBJECTS:pinpoint_common_obj> $< TARGET_OBJECTS:jsoncppObj> )
51
59
install (DIRECTORY include / DESTINATION include /pinpoint_common
52
60
FILES_MATCHING PATTERN "*.h" )
53
61
54
- set_target_properties (pinpoint_common_shared pinpoint_common PROPERTIES
62
+ set_target_properties (pinpoint_common_shared pinpoint_common_static PROPERTIES
55
63
VERSION ${PROJECT_VERSION}
56
64
SOVERSION 1
57
65
PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR} /include/common.h" )
58
66
59
- install (TARGETS pinpoint_common_shared pinpoint_common ${INSTALL_EXPORT}
67
+ install (TARGETS pinpoint_common_shared pinpoint_common_static ${INSTALL_EXPORT}
60
68
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
61
69
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
62
70
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Original file line number Diff line number Diff line change @@ -4,4 +4,4 @@ foreach(dir ${src_dir})
4
4
endforeach ()
5
5
6
6
add_library (pinpoint_common_obj OBJECT ${SRC_FILES} )
7
- add_library (pinpoint_common STATIC $< TARGET_OBJECTS:pinpoint_common_obj> $< TARGET_OBJECTS:jsoncppObj> )
7
+ # add_library(pinpoint_common STATIC $<TARGET_OBJECTS:pinpoint_common_obj> $<TARGET_OBJECTS:jsoncppObj>)
Original file line number Diff line number Diff line change @@ -6,14 +6,14 @@ target_compile_definitions(TestCommon PRIVATE "-DUTEST -DCOMMON_DEBUG")
6
6
# message("${CMAKE_BINARY_DIR}/lib")
7
7
if (WITH_CODECOVERAGE AND LINUX_ )
8
8
# message("enable -lgcov")
9
- target_link_libraries (TestCommon pinpoint_common gtest_main rt gcov )
9
+ target_link_libraries (TestCommon pinpoint_common_static gtest_main rt gcov )
10
10
elseif (APPLE )
11
- target_link_libraries (TestCommon pinpoint_common gtest_main )
11
+ target_link_libraries (TestCommon pinpoint_common_static gtest_main )
12
12
elseif (MSVC )
13
13
message ( FATAL_ERROR "pinpoint-c-agent not support windows, if you need create an issue https://github.com/pinpoint-apm/pinpoint-c-agent/issues" )
14
14
else ()
15
15
message ("------------------------------" )
16
- target_link_libraries (TestCommon pinpoint_common gtest_main rt )
16
+ target_link_libraries (TestCommon pinpoint_common_static gtest_main rt )
17
17
endif ()
18
18
19
19
add_test (TestCommon TestCommon )
Original file line number Diff line number Diff line change
1
+ cmake_minimum_required (VERSION 3.13 )
2
+ project (common )
3
+ set (CMAKE_CXX_STANDARD 11 )
4
+
5
+ include (FetchContent )
6
+ FetchContent_Declare (
7
+ pinpoint
8
+ GIT_REPOSITORY https://github.com/pinpoint-c-agent/pinpoint-c-agent.git
9
+ # GIT_TAG 74bc39d813d664cb56b78b1506d91932c8131396
10
+ # not recommended, please use hash key like `74bc39d813d664cb56b78b1506d91932c8131396`
11
+ GIT_TAG origin/dev
12
+ )
13
+
14
+ FetchContent_GetProperties (pinpoint )
15
+ if (NOT pinpoint_POPULATED )
16
+ FetchContent_Populate (pinpoint )
17
+ add_subdirectory (${pinpoint_SOURCE_DIR} /common ${pinpoint_BINARY_DIR} )
18
+ endif ()
19
+
20
+ FetchContent_MakeAvailable (pinpoint )
21
+
22
+ add_executable (test_pinpoint_cpp test_pinpoint.cpp )
23
+ add_executable (test_pinpoint_c test_pinpoint.c )
24
+ target_link_libraries (test_pinpoint_cpp PRIVATE pinpoint_common_static rt )
25
+ target_link_libraries (test_pinpoint_c pinpoint_common_static rt )
You can’t perform that action at this time.
0 commit comments