Skip to content

Commit

Permalink
Merge pull request #7 from abmorris/master
Browse files Browse the repository at this point in the history
CMake: allow optional ROOT libraries and more conventional installation with instructions in the README
  • Loading branch information
cofitzpa authored Feb 8, 2018
2 parents d8032b1 + 6864228 commit e574cc8
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 273 deletions.
39 changes: 27 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,31 @@ endif()

project(SMPT)

#set(CMAKE_CXX_FLAGS "-std=c++11")

# Load Macro to locate ROOT and needed libraries
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
find_package(ROOT REQUIRED Core RIO Net Hist Graf Graf3d Gpad Tree Rint
set(ROOT_REQUIRED_COMPONENTS Core RIO Net Hist Graf Graf3d Gpad Tree Rint
Postscript Matrix Physics MathCore Thread Gui TreePlayer Minuit TMVA)
#set(ROOT_OPTIONAL_COMPONENTS Proof)
find_package(ROOT REQUIRED ${ROOT_REQUIRED_COMPONENTS}
OPTIONAL_COMPONENTS ${ROOT_OPTIONAL_COMPONENTS})

# Set preprocessor flags for optional components
foreach(opt ${ROOT_OPTIONAL_COMPONENTS})
if(ROOT_${opt}_LIBRARY)
add_definitions(-Duse_${opt})
endif()
endforeach()

#Check the compiler and set the compile and link flags
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ROOT_CXX_FLAGS}")

# Locate Boost
find_package(Boost REQUIRED system)

# Check the compiler and set the compile and link flags
#set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY lib)


include_directories(${ROOT_INCLUDE_DIRS} ${SMPT_SOURCE_DIR}/include)

# Build one shared lib with all sources
Expand All @@ -32,16 +43,20 @@ ${SMPT_SOURCE_DIR}/src/cropcutensemble.cc
${SMPT_SOURCE_DIR}/src/cropdatastore.cc
)


# List executables and link each of them to the local and ROOT libraries
set(EXELIST thresholdeffs bwdiv crop stackergen rangefinder sepper mergevars updatedatastore stacker varstocuts eff corr cuttester columnmaker multicolumnmaker tuplesampler tuplescrambler cutapplier)

foreach(exe ${EXELIST})
add_executable(${exe} ${SMPT_SOURCE_DIR}/src/${exe}.cc)
target_link_libraries (${exe} cropsimpletools ${ROOT_LIBRARIES})
target_link_libraries (${exe} cropsimpletools ${ROOT_LIBRARIES})
endforeach()


# Configure install destination
install(TARGETS cropsimpletools ${EXELIST}
RUNTIME DESTINATION ${SMPT_SOURCE_DIR}/bin
LIBRARY DESTINATION ${SMPT_SOURCE_DIR}/lib
ARCHIVE DESTINATION ${SMPT_SOURCE_DIR}/lib/static)
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/static)

# Provide easy (but dumb) way to uninstall
add_custom_target(uninstall xargs rm -v < install_manifest.txt)

25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,28 @@ The most recent version of simpletools, including the above documentation will a

Bug reports, feature requests, comments and patches are always welcome. \
[email protected]

## Installation

Building and installing are done with CMake.
If you want to install simpletools system-wide, run:

cmake .
make
sudo make install

If you don't have administrator privileges and/or want to install locally, use `-DCMAKE_INSTALL_PREFIX` to change the destination, *e.g.*:

cmake . -DCMAKE_INSTALL_PREFIX=~/.local/
make
make install

### Uninstallation

After running `make install`, a file called `install_manifest.txt` will be created, which lists the destinations of all installed binaries and libraries.
To uninstall, you can run:

make uninstall

which will delete every file listed in `install_manifest.txt`.

Loading

0 comments on commit e574cc8

Please sign in to comment.