Skip to content

Commit

Permalink
tidy up cmake for plotting and bring it more in line with other MaCh3…
Browse files Browse the repository at this point in the history
… libraries. Also now include it as part of MaCh3::All target
  • Loading branch information
ewanwm committed Aug 29, 2024
1 parent 770b3b5 commit 844a307
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 28 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ if( MaCh3_PYTHON_ENABLED )
## EM: make a module target out of all the python*Module.cpp files (currently just one...)
pybind11_add_module(
pyMaCh3 MODULE
pythonMaCh3.cpp
pyMaCh3.cpp
plotting/plottingUtils/pythonPlottingModule.cpp
)
## EM: only works with code compiled with -fPIC enabled.. I think this flag can things slightly slower
Expand All @@ -237,7 +237,7 @@ endif()
#This is to export the target properties of MaCh3
#Anything that links to "MaCh3" will get all of these target properties
add_library(MaCh3 INTERFACE)
target_link_libraries(MaCh3 INTERFACE MCMC OscClass SamplePDF Covariance Splines Manager MaCh3CompilerOptions)
target_link_libraries(MaCh3 INTERFACE MCMC OscClass SamplePDF Covariance Splines Manager MaCh3CompilerOptions Plotting)
set_target_properties(MaCh3 PROPERTIES EXPORT_NAME All)

install(TARGETS MaCh3
Expand Down
16 changes: 9 additions & 7 deletions cmake/Modules/MaCh3Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ endif()

######################### python binding ##########################

set(PYBIND11_FINDPYTHON ON)
if( MaCh3_PYTHON_ENABLED )
set(PYBIND11_FINDPYTHON ON)

CPMFindPackage(
NAME pybind11
VERSION 2.13.5
GITHUB_REPOSITORY "pybind/pybind11"
GIT_TAG v2.13.5
)
CPMFindPackage(
NAME pybind11
VERSION 2.13.5
GITHUB_REPOSITORY "pybind/pybind11"
GIT_TAG v2.13.5
)
endif()
2 changes: 1 addition & 1 deletion plotting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ foreach(app
PlotLLH
)
add_executable( ${app} ${app}.cpp )
target_link_libraries( ${app} Plotting )
target_link_libraries( ${app} MaCh3::Plotting )

endforeach(app)
2 changes: 1 addition & 1 deletion plotting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ from pyMaCh3 import plotting
A very basic example that will plot LLH scans is:

```
from pymach3 import plotting
from pyMaCh3 import plotting
import matplotlib.backends.backend_pdf
from matplotlib import pyplot as plt
import sys
Expand Down
45 changes: 28 additions & 17 deletions plotting/plottingUtils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
set( HEADERS
plottingManager.h
inputManager.h
styleManager.h
plottingUtils.h
)

## build the base level library targets
foreach(lib
inputManager
styleManager
plottingUtils
)
add_library( ${lib} ${lib}.cpp )
target_link_libraries( ${lib} ${ROOT_LIBRARIES} MaCh3::Manager )
add_library( Plotting SHARED
plottingManager.cpp
inputManager.cpp
styleManager.cpp
plottingUtils.cpp
)

set_property( TARGET ${lib} PROPERTY POSITION_INDEPENDENT_CODE ON )
set_target_properties( Plotting PROPERTIES
PUBLIC_HEADER "${HEADERS}"
EXPORT_NAME Plotting
)

endforeach(lib)
target_link_libraries( Plotting ${ROOT_LIBRARIES} MaCh3::Manager )

## to be compiled into python module needs to be compiled as position independent library
if( MaCh3_PYTHON_ENABLED )

## build the higher level plottingManager
add_library( plottingManager plottingManager.cpp plottingManager.h )
set_property( TARGET plottingManager PROPERTY POSITION_INDEPENDENT_CODE ON )
target_link_libraries( plottingManager inputManager styleManager )
set_property( TARGET Plotting PROPERTY POSITION_INDEPENDENT_CODE ON )

endif()

## chuck it all together into the Plotting library
add_library( Plotting INTERFACE )
target_link_libraries( Plotting INTERFACE inputManager plottingManager styleManager plottingUtils )
install(TARGETS Plotting
EXPORT MaCh3-targets
LIBRARY DESTINATION lib/
PUBLIC_HEADER DESTINATION include/plotting
)

add_library(MaCh3::Plotting ALIAS Plotting)

0 comments on commit 844a307

Please sign in to comment.