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

Switching to cmake

This commit is contained in:
Gordon McCann 2022-06-20 21:10:10 -04:00
parent 3a4c00e20d
commit c4ad76487b
5 changed files with 218 additions and 1 deletions

18
CMakeLists.txt Normal file
View File

@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_BUILD_TYPE "Debug")
message("Building debug")
else()
message("Building release")
endif()
project(Specter)
set(SPECTER_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(SPECTER_LIBRARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib)
add_subdirectory(Specter)
add_subdirectory(SpecProject)

View File

@ -0,0 +1,49 @@
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/
./src
)
target_sources(SpecProject PRIVATE
./src/main.cpp
./src/MassMap.cpp
./src/MassMap.h
./src/SPSAnalysisStage.cpp
./src/SPSAnalysisStage.h
./src/SPSInputLayer.cpp
./src/SPSInputLayer.h
)
set(THREADS_PREFER_PTHREAD_FLAG On)
find_package(Threads REQUIRED)
target_link_libraries(SpecProject PRIVATE Specter Threads::Threads glad glfw imgui)
if(APPLE)
target_link_libraries(SpecProject PRIVATE "-framework Cocoa" "-framework CoreVideo" "-framework IOKit" "-framework OpenGL" "-framework Carbon" ${CMAKE_DL_LIBS})
target_compile_definitions(SpecProject PRIVATE SPEC_APPLE)
elseif(UNIX)
target_link_libraries(SpecProject PRIVATE libGL.so libX11.so ${CMAKE_DL_LIBS})
target_compile_definitions(SpecProject PRIVATE SPEC_LINUX)
elseif(MSVC)
target_link_libraries(SpecProject PRIVATE opengl32.lib)
target_compile_definitions(SpecProject PRIVATE SPEC_WINDOWS)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_definitions(SpecProject PRIVATE SPEC_RELEASE)
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(SpecProject PRIVATE SPEC_DEBUG)
endif()
set_target_properties(SpecProject PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${SPECTER_BINARY_DIR})
add_custom_command(TARGET SpecProject POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Assets ${SPECTER_BINARY_DIR}/Assets)

139
Specter/src/CMakeLists.txt Normal file
View File

@ -0,0 +1,139 @@
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
./
)
target_precompile_headers(Specter PRIVATE specpch.h)
#Specter sources
target_sources(Specter PRIVATE
Specter/Core/Application.h
Specter/Core/Application.cpp
Specter/Core/Cut.cpp
Specter/Core/Graph.cpp
Specter/Core/Histogram.cpp
Specter/Core/Layer.cpp
Specter/Core/LayerStack.cpp
Specter/Core/Logger.cpp
Specter/Core/Parameter.cpp
Specter/Core/SpecCore.h
Specter/Core/SpectrumManager.h
Specter/Core/SpectrumSerializer.h
Specter/Core/Window.h
Specter/Core/Cut.h
Specter/Core/Graph.h
Specter/Core/Histogram.h
Specter/Core/Layer.h
Specter/Core/LayerStack.h
Specter/Core/Logger.h
Specter/Core/Parameter.h
Specter/Core/SpectrumManager.cpp
Specter/Core/SpectrumSerializer.cpp
Specter/Core/Timestep.h
Specter/Events/AppEvent.h
Specter/Events/Event.h
Specter/Events/KeyEvent.h
Specter/Events/MouseEvent.h
Specter/Events/PhysicsEvent.h
Specter/Renderer/GraphicsContext.h
Specter/Renderer/RenderCommand.cpp
Specter/Renderer/RenderCommand.h
Specter/Renderer/RendererAPI.cpp
Specter/Renderer/RendererAPI.h
Specter/ImGui/ImGuiBuild.cpp
Specter/ImGui/ImGuiExtensions.cpp
Specter/ImGui/ImGuiLayer.cpp
Specter/ImGui/ImGuiLayer.h
Specter/Physics/AnalysisStack.cpp
Specter/Physics/AnalysisStage.cpp
Specter/Physics/DataSource.h
Specter/Physics/PhysicsEventBuilder.h
Specter/Physics/PhysicsLayer.h
Specter/Physics/ShiftMap.h
Specter/Physics/AnalysisStack.h
Specter/Physics/AnalysisStage.h
Specter/Physics/DataSource.cpp
Specter/Physics/PhysicsEventBuilder.cpp
Specter/Physics/PhysicsLayer.cpp
Specter/Physics/ShiftMap.cpp
Specter/Physics/SpecData.h
Specter/Physics/Caen/CompassFile.cpp
Specter/Physics/Caen/CompassFile.h
Specter/Physics/Caen/CompassHit.cpp
Specter/Physics/Caen/CompassHit.h
Specter/Physics/Caen/CompassOnlineSource.cpp
Specter/Physics/Caen/CompassOnlineSource.h
Specter/Physics/Caen/CompassRun.cpp
Specter/Physics/Caen/CompassRun.h
Specter/Editor/EditorLayer.cpp
Specter/Editor/EditorLayer.h
Specter/Editor/FileDialog.cpp
Specter/Editor/FileDialog.h
Specter/Editor/SourceDialog.cpp
Specter/Editor/SourceDialog.h
Specter/Editor/SpectrumDialog.cpp
Specter/Editor/SpectrumDialog.h
Specter/Editor/SpectrumPanel.cpp
Specter/Editor/SpectrumPanel.h
Specter/Utils/Instrumentor.h
Specter/Utils/TCPClient.cpp
Specter/Utils/TCPClient.h
Specter/Utils/TestServerLayer.cpp
Specter/Utils/TestServerLayer.h
Specter/Utils/Timer.h
Platform/OpenGL/OpenGLContext.cpp
Platform/OpenGL/OpenGLContext.h
Platform/OpenGL/OpenGLRendererAPI.cpp
Platform/OpenGL/OpenGLRendererAPI.h
Platform/OpenGL/OpenGLWindow.cpp
Platform/OpenGL/OpenGLWindow.h
)
#ImPlot sources
target_sources(Specter PRIVATE
../vendor/implot/implot.cpp
../vendor/implot/implot.h
../vendor/implot/implot_demo.cpp
../vendor/implot/implot_internal.h
../vendor/implot/implot_items.cpp
../vendor/implot/backends/implot_backend.h
../vendor/implot/backends/implot_impl_opengl3.cpp
../vendor/implot/backends/implot_impl_opengl3.h
)
#Link our accompanying dependencies
target_link_libraries(Specter PUBLIC imgui glfw glad)
#Link OS graphics implementations
set(THREADS_PREFER_PTHREAD_FLAG On)
find_package(Threads REQUIRED)
if(APPLE)
target_link_libraries(Specter PRIVATE "-framework Cocoa" "-framework CoreVideo" "-framework IOKit" "-framework OpenGL" "-framework Carbon" ${CMAKE_DL_LIBS} Threads::Threads)
target_compile_definitions(Specter PRIVATE SPEC_APPLE)
elseif(UNIX)
target_link_libraries(Specter PRIVATE libGL.so libX11.so ${CMAKE_DL_LIBS} Threads::Threads)
target_compile_definitions(Specter PRIVATE SPEC_LINUX)
elseif(MSVC)
target_link_libraries(Specter PRIVATE opengl32.lib Threads::Threads)
target_compile_definitions(Specter PRIVATE SPEC_WINDOWS)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_definitions(Specter PRIVATE SPEC_RELEASE)
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(Specter PRIVATE SPEC_DEBUG)
endif()
#Some extra defs
target_compile_definitions(Specter PRIVATE GLFW_INCLUDE_NONE IMGUI_IMPL_OPENGL_LOADER_GLAD IMPLOT_BACKEND_ENABLE_OPENGL3)
set_target_properties(Specter PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${SPECTER_LIBRARY_DIR})

11
Specter/vendor/glad/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,11 @@
project(Glad)
add_library(glad STATIC)
target_include_directories(glad SYSTEM PUBLIC include)
target_sources(glad
PRIVATE src/glad.c
PRIVATE include/glad/glad.h
PRIVATE include/KHR/khrplatform.h
)

@ -1 +1 @@
Subproject commit cbe4e3cd7c9789b514eeaf9a65d8f674d984be3e
Subproject commit 7759495989c3efa248020e2ad8ecf4424555adf9