Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build instructions for CentOS7, tweaks to CMake script #20

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 2.6)
cmake_minimum_required (VERSION 3.11)
project (VeheMencE)

# Don't put the lib prefix in front of the livrary, so that it nicely loads in python
Expand All @@ -7,37 +7,32 @@ set(CMAKE_SHARED_LIBRARY_PREFIX "")
# Control the verbosity of the build
set(CMAKE_VERBOSE_MAKEFILE OFF)

# no gnu++
set(CMAKE_CXX_EXTENSIONS OFF)

# Python version
set(PYTHON_MIN_VERSION "2.7" CACHE STRING "Minimum Python version to look for")
set(Boost_PYTHON_VERSION_TAG "python27" CACHE STRING "Suffix for boost::python shared library (X in libboost_pythonX.py)")

# Use C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Python headers and configure the build
find_package(PythonLibs ${PYTHON_MIN_VERSION} REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
message("-- Using python version: ${PYTHONLIBS_VERSION_STRING}")

# Find boost headers and configure the build
set(Boost_NO_BOOST_CMAKE ON)
set(_Boost_STACKTRACE_BASIC_HEADERS "boost/stacktrace.hpp")
set(_Boost_STACKTRACE_BACKTRACE_HEADERS "boost/stacktrace.hpp")
set(_Boost_STACKTRACE_ADDR2LINE_HEADERS "boost/stacktrace.hpp")
set(_Boost_STACKTRACE_NOOP_HEADERS "boost/stacktrace.hpp")
find_package(Boost 1.54 REQUIRED COMPONENTS ${Boost_PYTHON_VERSION_TAG} stacktrace_basic stacktrace_noop thread log log_setup)
include_directories(${Boost_INCLUDE_DIRS})
message("-- Using Boost version: ${Boost_VERSION}" )
add_definitions(-DBOOST_STACKTRACE_LINK -DBOOST_LOG_DYN_LINK)
# make sure dynamic libraries are used - fixes linking errors
add_definitions(-DBOOST_LOG_DYN_LINK)

# Find CAENLIB library and headers
set(CAEN_LIBRARY "CAENVME")
find_library(CAENLIB ${CAEN_LIBRARY})
find_file(CAENLIBHEADERS CAENVMElib.h)
if(NOT (CAENLIB AND CAENLIBHEADERS))
message(FATAL_ERROR "CAEN library not found")
message(FATAL_ERROR "CAEN library not found")
endif()
get_filename_component(CAENLIB_INCLUDE_DIR ${CAENLIBHEADERS} DIRECTORY)
get_filename_component(CAENLIB_LIBRARY_PATH ${CAENLIB} DIRECTORY)
Expand Down Expand Up @@ -68,7 +63,10 @@ set(VEHEMENCE_SOURCES
# Build and link the shared library
add_library(VeheMencE SHARED ${VEHEMENCE_SOURCES})
target_include_directories(VeheMencE PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(VeheMencE ${CAEN_LIBRARY} ${Boost_LIBRARIES})
target_link_libraries(VeheMencE ${CAEN_LIBRARY} ${Boost_LIBRARIES}
${CMAKE_DL_LIBS})

target_compile_features(VeheMencE PUBLIC cxx_std_17)

# Examples
add_subdirectory (examples)
Expand Down
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,30 @@ Status of the supported boards:

## Installation

### Requirements

- CMake >= 3.11
- C++17-compatible compiler
- python >= 2.7
- boost >= 1.54, components: python, stacktrace, thread, log, log
- CAENVMELib: can be downloaded from [here](https://www.caen.it/products/caenvmelib-library/), requires creating a CAEN account (free)

### Build

The project is built through cmake:
```
cd build
cmake ..
make
[make install]
cmake -S . -B build
cmake --build build -j 4
[cmake --build build --target install]
```

### Notes for CentOS7 and similar dinosaurs

- Install modern CMake from EPEL (activate EPEL: `yum -y install epel-release`); `yum -y install cmake3.x86_64`. Note that you'll need to run with `cmake3` instead of `cmake`.
- Install boost-1.69: `yum install -y boost169-python2-devel.x86_64 boost169-stacktrace.x86_64 boost169-thread.x86_64 boost169-log.x86_64`
- Install [devtoolset](https://www.softwarecollections.org/en/scls/rhscl/devtoolset-8/) to have a newer compiler (tested with version 8); enable it using `scl enable devtoolset-8 $SHELL`
- Configure the build using `cmake3 -S . -B build -DBOOST_LIBRARYDIR=/usr/lib64/boost169 -DBOOST_INCLUDEDIR=/usr/include/boost169`

## Usage

Examples of the use of the library in C++ are provided in the example directory. The typical usage consists in:
Expand Down
10 changes: 0 additions & 10 deletions build/README.md

This file was deleted.

6 changes: 3 additions & 3 deletions include/CommonDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void throw_with_trace(const E& e) {
class CAENVMEexception: public std::exception
{
public:
explicit CAENVMEexception(const CAENVME_API& errorcode) : errorcode_(errorcode) { }
explicit CAENVMEexception(const CVErrorCodes& errorcode) : errorcode_(errorcode) { }

~CAENVMEexception() {}

Expand All @@ -59,10 +59,10 @@ class CAENVMEexception: public std::exception
}

private:
CAENVME_API errorcode_;
CVErrorCodes errorcode_;
};

#define checkCAENVMEexception(x) {CAENVME_API status_cve = (x); if (status_cve) throw_with_trace(CAENVMEexception(status_cve));}
#define checkCAENVMEexception(x) {CVErrorCodes status_cve = (x); if (status_cve) throw_with_trace(CAENVMEexception(status_cve));}

class CAENETexception: public std::exception
{
Expand Down