diff --git a/README.md b/README.md index 8ed051d..53db6d1 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,7 @@ Specter is a cross-platform Dear ImGui/ImPlot based data visualization tool desi spectra, applying cuts and gates graphically to spectra, and has a customizable analysis system. Specter is focused on providing a clean, pretty UI with good performance required by demainding experimental setups. The only external dependencies are OpenGL development headers, as OpenGL is the rendering API, and the -C++20 standard library. All other dependencies are included as git submodules in the vendor directory. The current state of the library is such that the only readily developed -data source type is for CAEN's CoMPASS DAQ for use with their digitizer modules. There are tentative plans to extend the sources to other DAQ frameworks. +C++20 standard library. All other dependencies are included as git submodules in the vendor directory. This project would not be possible with out the amazing online tutorials of [@TheCherno](https://github.com/TheCherno) and in particular his Hazel tutorials, which much of the application model and basically all of the renderer is based off of ([Hazel](https://github.com/TheCherno/Hazel)). I highly recommend checking out his work to anyone who is interested in projects like this, or just learning more about C++. @@ -20,11 +19,12 @@ Specter should be cloned from github using `git clone --recursive https://github Specter uses CMake as its build system. If you are unfamiliar with CMake, building Specter is very straightforward. From within the Specter repository run the following commands: - `mkdir build` -- `cd build && cmake .. && make -j 4 && cd ..` +- `cd build && cmake .. && make -j 4 && make install` -By default, only the static library Specter is built. If you want to build the example project (SpecProject) as well, replace the previous CMake command with: +This builds and installs the Specter library. By default, Specter is installed into the local repository in the lib directory. If you want to install Specter along global resource paths, you will need to modify +the Specter CMakeLists.txt. -- `cd build && cmake -DBUILD_SPECPROJECT=On .. && make -j 4 && cd ..` +See the SpecProject README for information on how to build the example project (and link Specter to a user made project). Note: On Linux distributions, typically Mesa OpenGL and X-window related header files are not installed by default. These can be installed using whatever package manager your distribution uses. For example, on Debian family distributions the necessary files can be installed using `sudo apt install libgl1 libgl1-mesa-dev libglu1-mesa libglu1-mesa-dev xorg-dev mesa-utils` which should fill out all of the @@ -32,10 +32,8 @@ dependencies. If this doesn't seem to work, check your distribution related docu ## Using Specter Specter is simply a library framework for making a GUI data analysis program. In the Specter repository there is an example of a project using Specter (SpecProject) designed around the SESPS analysis pipeline at -Florida State University. This can be used as a template from which more complex projects can be built. Typically, one would install Specter, and then create a separate project for the actual program. To link Specter -and all the necessary include paths and library paths, add the Specter repository as a subdirectory to your CMake project and add Specter as a library to link to your project executable. - -If one wants to build the example project, set the CMake option BUILD_SPECPROJECT to On when running CMake for Specter. Otherwise, only the Specter library will be built. +Florida State University. This can be used as a template from which more complex projects can be built. Typically, one would install Specter, and then create a separate project for the actual program. To link Specter using +CMake, one can use the `find_package()` command. If the standard install is run, you will also need to pass the `PATHS ` argument to the `find_package()` command. See SpecProject README and CMakeLists for more details. Note that your project will need to copy the Assets folder (located in SpecProject) to the runtime location of your project executable. diff --git a/SpecProject/CMakeLists.txt b/SpecProject/CMakeLists.txt index abf8173..a2e1374 100644 --- a/SpecProject/CMakeLists.txt +++ b/SpecProject/CMakeLists.txt @@ -1,15 +1,24 @@ +cmake_minimum_required(VERSION 3.16) + +set(CMAKE_CXX_STANDARD 20) + +if(NOT CMAKE_BUILD_TYPE STREQUAL "Release") + set(CMAKE_BUILD_TYPE "Debug") + message("Building debug") +else() + message("Building release") +endif() + +project(SpecProject) + +set(SPECPROJECT_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../bin) + +#Use this to find Specter and its libraries. Specify the path to the Specter/lib dir after the PATHS keyword +find_package(Specter REQUIRED PATHS ../lib) + add_executable(SpecProject) -target_include_directories(SpecProject - SYSTEM PUBLIC ../Specter/vendor/asio/asio/include - PUBLIC ../Specter/vendor/imgui - ../Specter/vendor/implot - ../Specter/vendor/glad/include - ../Specter/vendor/glfw/include - ../Specter/vendor/glm - ../Specter/vendor/IconFontCppHeaders - ../Specter/vendor/spdlog/include - ../Specter/src/ +target_include_directories(SpecProject PUBLIC ./src ) @@ -23,12 +32,14 @@ target_sources(SpecProject PRIVATE ./src/SPSInputLayer.h ) -target_link_libraries(SpecProject PRIVATE Specter) +target_link_libraries(SpecProject PRIVATE Specter::Specter) -set_target_properties(SpecProject PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${SPECTER_BINARY_DIR}) +set_target_properties(SpecProject PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${SPECPROJECT_BINARY_DIR}) -add_custom_command(TARGET SpecProject - POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink - ${CMAKE_CURRENT_SOURCE_DIR}/Assets - ${SPECTER_BINARY_DIR}/Assets -) +if(NOT EXISTS "${SPECPROJECT_BINARY_DIR}/Assets") + add_custom_command(TARGET SpecProject + POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink + ${CMAKE_CURRENT_SOURCE_DIR}/Assets + ${SPECPROJECT_BINARY_DIR}/Assets + ) +endif() diff --git a/SpecProject/README.md b/SpecProject/README.md new file mode 100644 index 0000000..60e0f06 --- /dev/null +++ b/SpecProject/README.md @@ -0,0 +1,11 @@ +# Example Project: SpecProject +SpecProject is an example project for use with Specter. It contains examples for making an analysis pipeline, extending the UI, and creating the executable entry point. +It also has an example CMakeLists.txt which demonstrates how to link a custom project to Specter. + +## Building SpecProject +In this directory (the SpecProject directory) run the following commands: + +- `mkdir build` +- `cd build && cmake .. && make -j 4` + +This will build the SpecProject executable and install it to the Specter/bin directory. The executable should be run from the Specter/bin directory. \ No newline at end of file diff --git a/Specter/CMakeLists.txt b/Specter/CMakeLists.txt index 6876431..e0ece52 100644 --- a/Specter/CMakeLists.txt +++ b/Specter/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory(vendor/glad) +set(GLFW_INSTALL Off CACHE BOOL "Generate installation target" ) add_subdirectory(vendor/glfw) add_subdirectory(vendor/imgui) diff --git a/Specter/cmake/SpecterConfig.cmake.in b/Specter/cmake/SpecterConfig.cmake.in new file mode 100644 index 0000000..32218be --- /dev/null +++ b/Specter/cmake/SpecterConfig.cmake.in @@ -0,0 +1,9 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +find_dependency(Threads) + +include("${CMAKE_CURRENT_LIST_DIR}/SpecterTargets.cmake") + +check_required_components(Specter) \ No newline at end of file diff --git a/Specter/src/CMakeLists.txt b/Specter/src/CMakeLists.txt index cbb8298..98132a0 100644 --- a/Specter/src/CMakeLists.txt +++ b/Specter/src/CMakeLists.txt @@ -1,16 +1,24 @@ add_library(Specter STATIC) target_include_directories(Specter - SYSTEM PUBLIC ../vendor/asio/asio/include - PUBLIC ../vendor/imgui - ../vendor/implot - ../vendor/glad/include - ../vendor/glfw/include - ../vendor/glm - ../vendor/IconFontCppHeaders - ../vendor/spdlog/include - ../vendor/yaml-cpp/inlcude/yaml-cpp/ - ./ + SYSTEM PUBLIC $ $ + PUBLIC $ $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ ) target_precompile_headers(Specter PRIVATE specpch.h) @@ -156,4 +164,24 @@ endif() #Some extra defs target_compile_definitions(Specter PRIVATE GLFW_INCLUDE_NONE YAML_CPP_STATIC_DEFINE IMGUI_IMPL_OPENGL_LOADER_GLAD IMPLOT_BACKEND_ENABLE_OPENGL3) -set_target_properties(Specter PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${SPECTER_LIBRARY_DIR}) \ No newline at end of file +#set_target_properties(Specter PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${SPECTER_LIBRARY_DIR}) + +install(TARGETS Specter imgui glfw glad yaml-cpp DaqGrimoire + EXPORT SpecterTargets + LIBRARY DESTINATION lib/ + ARCHIVE DESTINATION lib/ + RUNTIME DESTINATION bin/ +) + +install(EXPORT SpecterTargets + FILE SpecterTargets.cmake + NAMESPACE Specter:: + DESTINATION lib/cmake/Specter +) + +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/SpecterConfig.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/SpecterConfig.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Specter +) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SpecterConfig.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Specter) \ No newline at end of file