You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by GitBox <gi...@apache.org> on 2021/10/28 20:51:01 UTC

[GitHub] [datasketches-cpp] will-lauer commented on a change in pull request #245: Updating cmake config to support publication and package building

will-lauer commented on a change in pull request #245:
URL: https://github.com/apache/datasketches-cpp/pull/245#discussion_r738766207



##########
File path: README.md
##########
@@ -40,3 +38,62 @@ Building and running unit tests using cmake for Windows from the command line:
 	$ cmake --build build --config Release
 	$ cmake --build build --config Release --target RUN_TESTS
 ```
+
+To install a local distribution (OSX and Linux), use the following command. The
+CMAKE_INSTALL_PREFIX variable controls the destination. If not specified, it 
+defaults to installing in /usr (/usr/include, /usr/lib, etc). In the command below,
+the installation will be in /tmp/install/DataSketches (/tmp/install/DataSketches/include,
+/tmp/install/DataSketches/lib, etc)
+
+```
+	$ cmake -S . -B build/Release -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/install/DataSketches
+	$ cmake --build build/Release -t install
+```
+
+To generate an installable package using cmake's built in cpack packaging tool,
+use the following command. The type of packaging is controlled by the CPACK_GENERATOR
+variable (semi-colon separated list). Cmake usually supports packaging types such as RPM,
+DEB, STGZ, TGZ, TZ, ZIP, etc.
+
+```
+	$ cmake3 -S . -B build/Release -DCMAKE_BUILD_TYPE=Release -DCPACK_GENERATOR="RPM;STGZ;TGZ" 
+	$ cmake3 --build build/Release -t package
+```
+
+The DataSketches project can be included in other projects' CMakeLists.txt files in one of two ways.
+If DataSketches has been installed on the host (using an RPM, DEB, "make install" into /usr/local, or some 
+way, then CMake's `find_package` command can be used like this:
+
+```
+	find_package(DataSketches 3.2 REQUIRED)
+	target_link_library(my_dependent_target PUBLIC ${DATASKETCHES_LIB})
+```
+
+If you don't have DataSketches installed locally, dependent projects can pull it directly
+from GitHub using CMake's `ExternalProject` module. The code would look something like this:
+
+```
+	cmake_policy(SET CMP0097 NEW)
+	include(ExternalProject)
+	ExternalProject_Add(datasketches
+	    GIT_REPOSITORY https://github.com/apache/datasketches-cpp.git
+	    GIT_TAG 3.2.0
+	    GIT_SHALLOW true
+	    GIT_SUBMODULES ""
+	    INSTALL_DIR /tmp/datasketches-prefix
+	   	CMAKE_ARGS -DBUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=/tmp/datasketches-prefix
+
+		# Override the install command to add DESTDIR
+		# This is necessary to work around an oddity in the RPM (but not other) package
+		# generation, as CMake otherwise picks up the Datasketch files when building
+		# an RPM for a dependent package. (RPM scans the directory for files in addition to installing
+		# those files referenced in an "install" rule in the cmake file)
+	    INSTALL_COMMAND env DESTDIR= ${CMAKE_COMMAND} --build . --target install
+	)
+	ExternalProject_Get_property(datasketches INSTALL_DIR)
+	set(datasketches_INSTALL_DIR ${INSTALL_DIR})
+	message("Source dir of datasketches = ${datasketches_INSTALL_DIR}")
+	target_include_directories(my_dependent_target 
+								PRIVATE ${datasketches_INSTALL_DIR}/include/DataSketches)

Review comment:
       Looks like this spacing is because I use 4-space tabs in my editor. The file is a bit of a mix between tabs and spaces (and some of that is my fault), with tab seeming to be the default. It looks like git is showing the data using 8-space tabs, which makes it line up differently than in my editor.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org