@@ -25,18 +25,18 @@ Installing the latest cmake on OSX: brew install cmake
25
25
Building and running unit tests using cmake for OSX and Linux:
26
26
27
27
```
28
- $ cmake -S . -B build/Release -DCMAKE_BUILD_TYPE=Release
29
- $ cmake --build build/Release -t test
28
+ $ cmake -S . -B build/Release -DCMAKE_BUILD_TYPE=Release
29
+ $ cmake --build build/Release -t test
30
30
```
31
31
32
32
Building and running unit tests using cmake for Windows from the command line:
33
33
34
34
```
35
- $ cd build
36
- $ cmake ..
37
- $ cd ..
38
- $ cmake --build build --config Release
39
- $ cmake --build build --config Release --target RUN_TESTS
35
+ $ cd build
36
+ $ cmake ..
37
+ $ cd ..
38
+ $ cmake --build build --config Release
39
+ $ cmake --build build --config Release --target RUN_TESTS
40
40
```
41
41
42
42
To install a local distribution (OSX and Linux), use the following command. The
@@ -46,8 +46,8 @@ the installation will be in /tmp/install/DataSketches (/tmp/install/DataSketches
46
46
/tmp/install/DataSketches/lib, etc)
47
47
48
48
```
49
- $ cmake -S . -B build/Release -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/install/DataSketches
50
- $ cmake --build build/Release -t install
49
+ $ cmake -S . -B build/Release -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/install/DataSketches
50
+ $ cmake --build build/Release -t install
51
51
```
52
52
53
53
To generate an installable package using cmake's built in cpack packaging tool,
@@ -56,44 +56,54 @@ variable (semi-colon separated list). Cmake usually supports packaging types suc
56
56
DEB, STGZ, TGZ, TZ, ZIP, etc.
57
57
58
58
```
59
- $ cmake3 -S . -B build/Release -DCMAKE_BUILD_TYPE=Release -DCPACK_GENERATOR="RPM;STGZ;TGZ"
60
- $ cmake3 --build build/Release -t package
59
+ $ cmake3 -S . -B build/Release -DCMAKE_BUILD_TYPE=Release -DCPACK_GENERATOR="RPM;STGZ;TGZ"
60
+ $ cmake3 --build build/Release -t package
61
61
```
62
62
63
63
The DataSketches project can be included in other projects' CMakeLists.txt files in one of two ways.
64
64
If DataSketches has been installed on the host (using an RPM, DEB, "make install" into /usr/local, or some
65
65
way, then CMake's ` find_package ` command can be used like this:
66
66
67
67
```
68
- find_package(DataSketches 3.2 REQUIRED)
69
- target_link_library(my_dependent_target PUBLIC ${DATASKETCHES_LIB})
68
+ find_package(DataSketches 3.2 REQUIRED)
69
+ target_link_library(my_dependent_target PUBLIC ${DATASKETCHES_LIB})
70
70
```
71
71
72
+ When used with find_package, DataSketches exports several variables, including
73
+
74
+ - ` DATASKETCHES_VERSION ` : The version number of the datasketches package that was imported.
75
+ - ` DATASKETCHES_INCLUDE_DIR ` : The directory that should be added to access DataSketches include files.
76
+ Because cmake automatically includes the interface directories for included target libraries when
77
+ using ` target_link_library ` , under normal circumstances there will be no need to include this directly.
78
+ - ` DATASKETCHES_LIB ` : The name of the DataSketches target to include as a dependency. Projects pulling
79
+ in DataSketches should reference this with ` target_link_library ` in order to set up all the correct dependencies
80
+ and include paths.
81
+
72
82
If you don't have DataSketches installed locally, dependent projects can pull it directly
73
83
from GitHub using CMake's ` ExternalProject ` module. The code would look something like this:
74
84
75
85
```
76
- cmake_policy(SET CMP0097 NEW)
77
- include(ExternalProject)
78
- ExternalProject_Add(datasketches
79
- GIT_REPOSITORY https://github.com/apache/datasketches-cpp.git
80
- GIT_TAG 3.2.0
81
- GIT_SHALLOW true
82
- GIT_SUBMODULES ""
83
- INSTALL_DIR /tmp/datasketches-prefix
84
- CMAKE_ARGS -DBUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=/tmp/datasketches-prefix
85
-
86
- # Override the install command to add DESTDIR
87
- # This is necessary to work around an oddity in the RPM (but not other) package
88
- # generation, as CMake otherwise picks up the Datasketch files when building
89
- # an RPM for a dependent package. (RPM scans the directory for files in addition to installing
90
- # those files referenced in an "install" rule in the cmake file)
91
- INSTALL_COMMAND env DESTDIR= ${CMAKE_COMMAND} --build . --target install
92
- )
93
- ExternalProject_Get_property(datasketches INSTALL_DIR)
94
- set(datasketches_INSTALL_DIR ${INSTALL_DIR})
95
- message("Source dir of datasketches = ${datasketches_INSTALL_DIR}")
96
- target_include_directories(my_dependent_target
97
- PRIVATE ${datasketches_INSTALL_DIR}/include/DataSketches)
98
- add_dependencies(my_dependent_target datasketches)
86
+ cmake_policy(SET CMP0097 NEW)
87
+ include(ExternalProject)
88
+ ExternalProject_Add(datasketches
89
+ GIT_REPOSITORY https://github.com/apache/datasketches-cpp.git
90
+ GIT_TAG 3.2.0
91
+ GIT_SHALLOW true
92
+ GIT_SUBMODULES ""
93
+ INSTALL_DIR /tmp/datasketches-prefix
94
+ CMAKE_ARGS -DBUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=/tmp/datasketches-prefix
95
+
96
+ # Override the install command to add DESTDIR
97
+ # This is necessary to work around an oddity in the RPM (but not other) package
98
+ # generation, as CMake otherwise picks up the Datasketch files when building
99
+ # an RPM for a dependent package. (RPM scans the directory for files in addition to installing
100
+ # those files referenced in an "install" rule in the cmake file)
101
+ INSTALL_COMMAND env DESTDIR= ${CMAKE_COMMAND} --build . --target install
102
+ )
103
+ ExternalProject_Get_property(datasketches INSTALL_DIR)
104
+ set(datasketches_INSTALL_DIR ${INSTALL_DIR})
105
+ message("Source dir of datasketches = ${datasketches_INSTALL_DIR}")
106
+ target_include_directories(my_dependent_target
107
+ PRIVATE ${datasketches_INSTALL_DIR}/include/DataSketches)
108
+ add_dependencies(my_dependent_target datasketches)
99
109
```
0 commit comments