From b8730c897515098c67c25865380017db4b579673 Mon Sep 17 00:00:00 2001 From: Bryan Tan Date: Wed, 13 Dec 2023 23:15:30 -0800 Subject: [PATCH] Update README with additional CMake setup information --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 4d73c7a..011dae9 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,35 @@ To copy the header files into `/usr/local/include/sparta` and set up a cmake lib sudo make install ``` +### CMake Setup + +If you are using CMake for your project, you can also use SPARTA in the following ways: + +* A system-wide installation of SPARTA will contain a CMake configuration file that exports the library as `sparta::sparta`. This enables the use of `find_package` to locate SPARTA. For example: + + ```cmake + find_package(Boost REQUIRED COMPONENTS thread) # required by SPARTA + find_package(sparta REQUIRED) + add_library(MyAnalysisLibrary) + target_link_libraries(MyAnalysisLibrary PUBLIC sparta::sparta) + ``` + +* If you have cloned and "built" SPARTA locally, you can use a `find_package` call (such as the one above) and run CMake with the `-Dsparta_DIR=` to load the library: + + ```sh + # Assuming you are at the top-level of your project that uses SPARTA + mkdir build && cd build + cmake .. -Dsparta_DIR=path/to/your/sparta/build + ``` + +* SPARTA can be added as a subdirectory in your project: + + ```cmake + # assuming you have cloned SPARTA into a folder named sparta + add_subdirectory(sparta) + add_library(MyAnalysisLibrary) + target_link_libraries(MyAnalysisLibrary PUBLIC sparta::sparta) + ``` ## Issues