1
0
Fork 0
mirror of https://github.com/gwm17/Specter.git synced 2024-11-22 10:18:50 -05:00

Overhaul CMake system for Specter. Specter is now installed to local lib directory, packaged. Can be found using find_package. Update SpecProject to reflect this, requires separate build.

This commit is contained in:
Gordon McCann 2022-11-11 09:04:24 -05:00
parent 0cfeeabe54
commit 24fc3fa163
6 changed files with 95 additions and 37 deletions

View File

@ -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. 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 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 C++20 standard library. All other dependencies are included as git submodules in the vendor directory.
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.
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 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++. 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: 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` - `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. 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 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 ## 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 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 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
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. CMake, one can use the `find_package()` command. If the standard install is run, you will also need to pass the `PATHS <your_path_to_Specter>` argument to the `find_package()` command. See SpecProject README and CMakeLists for more details.
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.
Note that your project will need to copy the Assets folder (located in SpecProject) to the runtime location of your project executable. Note that your project will need to copy the Assets folder (located in SpecProject) to the runtime location of your project executable.

View File

@ -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) add_executable(SpecProject)
target_include_directories(SpecProject target_include_directories(SpecProject PUBLIC
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/
./src ./src
) )
@ -23,12 +32,14 @@ target_sources(SpecProject PRIVATE
./src/SPSInputLayer.h ./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 if(NOT EXISTS "${SPECPROJECT_BINARY_DIR}/Assets")
POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink add_custom_command(TARGET SpecProject
${CMAKE_CURRENT_SOURCE_DIR}/Assets POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink
${SPECTER_BINARY_DIR}/Assets ${CMAKE_CURRENT_SOURCE_DIR}/Assets
) ${SPECPROJECT_BINARY_DIR}/Assets
)
endif()

11
SpecProject/README.md Normal file
View File

@ -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.

View File

@ -1,4 +1,5 @@
add_subdirectory(vendor/glad) add_subdirectory(vendor/glad)
set(GLFW_INSTALL Off CACHE BOOL "Generate installation target" )
add_subdirectory(vendor/glfw) add_subdirectory(vendor/glfw)
add_subdirectory(vendor/imgui) add_subdirectory(vendor/imgui)

View File

@ -0,0 +1,9 @@
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(Threads)
include("${CMAKE_CURRENT_LIST_DIR}/SpecterTargets.cmake")
check_required_components(Specter)

View File

@ -1,16 +1,24 @@
add_library(Specter STATIC) add_library(Specter STATIC)
target_include_directories(Specter target_include_directories(Specter
SYSTEM PUBLIC ../vendor/asio/asio/include SYSTEM PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../vendor/asio/asio/include> $<INSTALL_INTERFACE:Specter/vendor/asio/asio/include>
PUBLIC ../vendor/imgui PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../vendor/imgui> $<INSTALL_INTERFACE:Specter/vendor/imgui>
../vendor/implot $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../vendor/implot>
../vendor/glad/include $<INSTALL_INTERFACE:Specter/vendor/implot>
../vendor/glfw/include $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../vendor/glad/include>
../vendor/glm $<INSTALL_INTERFACE:Specter/vendor/glad/include>
../vendor/IconFontCppHeaders $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../vendor/glfw/include>
../vendor/spdlog/include $<INSTALL_INTERFACE:Specter/vendor/glfw/include>
../vendor/yaml-cpp/inlcude/yaml-cpp/ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../vendor/glm>
./ $<INSTALL_INTERFACE:Specter/vendor/glm>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../vendor/IconFontCppHeaders>
$<INSTALL_INTERFACE:Specter/vendor/IconFontCppHeaders>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../vendor/spdlog/include>
$<INSTALL_INTERFACE:Specter/vendor/spdlog/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../vendor/yaml-cpp/include/yaml-cpp/>
$<INSTALL_INTERFACE:Specter/vendor/yaml-cpp/include/yaml-cpp/>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/./>
$<INSTALL_INTERFACE:Specter/src/>
) )
target_precompile_headers(Specter PRIVATE specpch.h) target_precompile_headers(Specter PRIVATE specpch.h)
@ -156,4 +164,24 @@ endif()
#Some extra defs #Some extra defs
target_compile_definitions(Specter PRIVATE GLFW_INCLUDE_NONE YAML_CPP_STATIC_DEFINE IMGUI_IMPL_OPENGL_LOADER_GLAD IMPLOT_BACKEND_ENABLE_OPENGL3) 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}) #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)