Switch to cmake for build system for better ROOT integration

This commit is contained in:
Gordon McCann 2022-06-22 15:03:49 -04:00
parent bcba081e7d
commit acc1ebe2fa
7 changed files with 139 additions and 220 deletions

22
CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_POSITION_INDEPENDENT_CODE On)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_BUILD_TYPE "Release")
message("Building release")
else()
message("Building debug")
endif()
project(SPS_SABRE_EventBuilder)
find_package(ROOT REQUIRED COMPONENTS Gui)
message("ROOT libs " ${ROOT_LIBRARIES})
set(EVB_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(EVB_LIBRARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib)
add_subdirectory(src)

View File

@ -1,217 +0,0 @@
workspace "EVB"
architecture "x64"
configurations {
"Release",
"Debug"
}
ROOTIncludeDir = "/home/gordon/cern/root-6.22.02/root-install/include"
ROOTLibDir = "/home/gordon/cern/root-6.22.02/root-install/lib"
project "SPSDict"
kind "SharedLib"
language "C++"
cppdialect "c++11"
targetdir "./lib/"
objdir "./objs/"
prebuildcommands {
"rootcint -f src/spsdict/sps_dict.cxx src/spsdict/DataStructs.h src/spsdict/LinkDef_sps.h",
"{COPY} src/spsdict/*.pcm ./lib/"
}
postbuildcommands {
"{COPY} src/spsdict/DataStructs.h ./include/"
}
files {
"src/spsdict/DataStructs.h",
"src/spsdict/*.cpp",
"src/spsdict/*.cxx"
}
includedirs {
"./",
"src/spsdict",
}
sysincludedirs {
ROOTIncludeDir
}
libdirs {
ROOTLibDir
}
links {
"Gui", "Core", "Imt", "RIO", "Net", "Hist",
"Graf", "Graf3d", "Gpad", "ROOTDataFrame", "ROOTVecOps",
"Tree", "TreePlayer", "Rint", "Postscript", "Matrix",
"Physics", "MathCore", "Thread", "MultiProc", "m", "dl"
}
filter "system:macosx or linux"
linkoptions {
"-pthread",
"-rdynamic"
}
filter "configurations:Debug"
symbols "On"
filter "configurations:Release"
optimize "On"
project "EventBuilderCore"
kind "StaticLib"
language "C++"
cppdialect "c++11"
targetdir "./lib/"
objdir "./objs/"
pchheader "EventBuilder.h"
pchsource "./src/EventBuilder.cpp"
files {
"src/spsdict/DataStructs.h",
"src/evb/*.cpp",
"src/evb/*.h"
}
defines "ETC_DIR_PATH=\"./etc/\""
includedirs {
"./",
"src/",
"vendor/spdlog/include",
"src/evb",
"src/spsdict",
"src/guidict"
}
sysincludedirs {
ROOTIncludeDir
}
libdirs {
ROOTLibDir,
}
links {
"SPSDict", "Gui", "Core", "Imt", "RIO", "Net", "Hist",
"Graf", "Graf3d", "Gpad", "ROOTDataFrame", "ROOTVecOps",
"Tree", "TreePlayer", "Rint", "Postscript", "Matrix",
"Physics", "MathCore", "Thread", "MultiProc", "m", "dl"
}
filter "system:macosx or linux"
linkoptions {
"-pthread",
"-rdynamic"
}
filter "configurations:Debug"
symbols "On"
filter "configurations:Release"
optimize "On"
project "EventBuilderGui"
kind "ConsoleApp"
language "C++"
cppdialect "c++11"
targetdir "./bin/"
objdir "./objs/"
prebuildcommands {
"rootcint -f src/guidict/gui_dict.cxx src/guidict/EVBMainFrame.h src/guidict/FileViewFrame.h src/guidict/LinkDef_Gui.h",
"{COPY} src/guidict/*.pcm ./bin/"
}
files {
"src/guidict/FileViewFrame.h",
"src/guidict/EVBMainFrame.h",
"src/guidict/*.cpp",
"src/guidict/gui_dict.cxx",
"src/gui_main.cpp"
}
includedirs {
"./",
"vendor/spdlog/include",
"src/evb",
"src/spsdict",
"src/guidict"
}
sysincludedirs {
ROOTIncludeDir
}
libdirs {
ROOTLibDir,
}
links {
"EventBuilderCore", "SPSDict", "Gui", "Core", "Imt", "RIO", "Net", "Hist",
"Graf", "Graf3d", "Gpad", "ROOTDataFrame", "ROOTVecOps",
"Tree", "TreePlayer", "Rint", "Postscript", "Matrix",
"Physics", "MathCore", "Thread", "MultiProc", "m", "dl"
}
filter "system:macosx or linux"
linkoptions {
"-pthread",
"-rdynamic"
}
filter "configurations:Debug"
symbols "On"
filter "configurations:Release"
optimize "On"
project "EventBuilder"
kind "ConsoleApp"
language "C++"
cppdialect "c++11"
targetdir "./bin/"
objdir "./objs/"
files {
"src/main.cpp"
}
includedirs {
"src/",
"vendor/spdlog/include",
"src/evb",
"src/spsdict",
"src/guidict"
}
sysincludedirs {
ROOTIncludeDir
}
libdirs {
ROOTLibDir,
}
links {
"EventBuilderCore", "SPSDict", "Gui", "Core", "Imt", "RIO", "Net", "Hist",
"Graf", "Graf3d", "Gpad", "ROOTDataFrame", "ROOTVecOps",
"Tree", "TreePlayer", "Rint", "Postscript", "Matrix",
"Physics", "MathCore", "Thread", "MultiProc", "m", "dl"
}
filter "system:macosx or linux"
linkoptions {
"-pthread",
"-rdynamic"
}
filter "configurations:Debug"
symbols "On"
filter "configurations:Release"
optimize "On"

3
src/.gitignore vendored
View File

@ -1,3 +0,0 @@
###ignore the root dictionary generated file###
*.cxx
!.gitignore

25
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,25 @@
add_subdirectory(spsdict)
add_subdirectory(guidict)
add_subdirectory(evb)
add_executable(EventBuilder)
target_include_directories(EventBuilder SYSTEM PUBLIC ../vendor/spdlog/include ${ROOT_INCLUDE_DIRS} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(EventBuilder PRIVATE main.cpp)
target_link_libraries(EventBuilder
SPSDict
EventBuilderCore
${ROOT_LIBRARIES}
)
set_target_properties(EventBuilder PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${EVB_BINARY_DIR})
add_executable(EventBuilderGui)
target_include_directories(EventBuilderGui SYSTEM PUBLIC ../vendor/spdlog/include ${ROOT_INCLUDE_DIRS} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(EventBuilderGui PRIVATE gui_main.cpp)
target_link_libraries(EventBuilderGui
SPSDict
GuiDict
EventBuilderCore
${ROOT_LIBRARIES}
)
set_target_properties(EventBuilderGui PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${EVB_BINARY_DIR})

52
src/evb/CMakeLists.txt Normal file
View File

@ -0,0 +1,52 @@
add_library(EventBuilderCore STATIC)
target_include_directories(EventBuilderCore SYSTEM PUBLIC ../../vendor/spdlog/include ${ROOT_INCLUDE_DIRS}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../
)
target_precompile_headers(EventBuilderCore PRIVATE ../EventBuilder.h)
target_sources(EventBuilderCore PRIVATE
ChannelMap.cpp
CompassRun.h
FlagHandler.cpp
MassLookup.h
SFPAnalyzer.h
Stopwatch.cpp
ChannelMap.h
CutHandler.cpp
FlagHandler.h
OrderChecker.cpp
SFPPlotter.cpp
Stopwatch.h
CutHandler.h
FP_kinematics.cpp
OrderChecker.h
SFPPlotter.h
CompassFile.cpp
EVBApp.cpp
FP_kinematics.h
ProgressCallback.h
ShiftMap.cpp
CompassFile.h
EVBApp.h
Logger.cpp
RunCollector.cpp
ShiftMap.h
CompassHit.h
FastSort.cpp
Logger.h
RunCollector.h
SlowSort.cpp
CompassRun.cpp
FastSort.h
MassLookup.cpp
SFPAnalyzer.cpp
SlowSort.h
)
target_link_libraries(EventBuilderCore PUBLIC
SPSDict
${ROOT_LIBRARIES}
)
set_target_properties(EventBuilderCore PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${EVB_LIBRARY_DIR})

View File

@ -0,0 +1,23 @@
add_library(GuiDict SHARED)
target_include_directories(GuiDict SYSTEM PUBLIC ../../vendor/spdlog/include/ ${ROOT_INCLUDE_DIRS} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
ROOT_GENERATE_DICTIONARY(guidict EVBMainFrame.h FileViewFrame.h LINKDEF LinkDef_Gui.h MODULE GuiDict)
target_sources(GuiDict PRIVATE
FileViewFrame.h
FileViewFrame.cpp
EVBMainFrame.h
EVBMainFrame.cpp
)
target_link_libraries(GuiDict
EventBuilderCore
SPSDict
${ROOT_LIBRARIES}
)
set_target_properties(GuiDict PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${EVB_LIBRARY_DIR})
add_custom_command(TARGET GuiDict POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/libGuiDict_rdict.pcm
${EVB_LIBRARY_DIR}/libGuiDict_rdict.pcm
)

View File

@ -0,0 +1,17 @@
add_library(SPSDict SHARED)
target_include_directories(SPSDict SYSTEM PUBLIC ${ROOT_INCLUDE_DIRS} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
ROOT_GENERATE_DICTIONARY(spsdict DataStructs.h LINKDEF LinkDef_sps.h MODULE SPSDict)
target_sources(SPSDict PRIVATE
DataStructs.h
DataStructs.cpp
)
target_link_libraries(SPSDict ${ROOT_LIBRARIES})
set_target_properties(SPSDict PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${EVB_LIBRARY_DIR})
add_custom_command(TARGET SPSDict POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/libSPSDict_rdict.pcm
${EVB_LIBRARY_DIR}/libSPSDict_rdict.pcm
)