From 40969e9cfd251ebd373df219c67409865464b042 Mon Sep 17 00:00:00 2001 From: Sebastien Wertz Date: Wed, 26 Jan 2022 15:16:41 +0100 Subject: [PATCH 1/8] remove build directory for clean OOS builds --- build/README.md | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 build/README.md diff --git a/build/README.md b/build/README.md deleted file mode 100644 index 16be330..0000000 --- a/build/README.md +++ /dev/null @@ -1,10 +0,0 @@ -Directory where to build the project. - -From here, execute the following: - -``` -cmake ../ -make -``` - -This will create a library and a set of test binaries. From 40628744da858b5ad88bdbedf8471d244972b771 Mon Sep 17 00:00:00 2001 From: Sebastien Wertz Date: Wed, 26 Jan 2022 15:16:54 +0100 Subject: [PATCH 2/8] update build instructions for modern cmake --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5367930..d1466eb 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,9 @@ Status of the supported boards: The project is built through cmake: ``` -cd build -cmake .. -make -[make install] +cmake -S . -B build +cmake --build build +[cmake --build build --target install] ``` ## Usage From fd5e9766a65ae985cf76abe3c38de5f71810e08b Mon Sep 17 00:00:00 2001 From: Sebastien Wertz Date: Wed, 26 Jan 2022 17:24:48 +0100 Subject: [PATCH 3/8] update README: add requirements, notes for CentOS7 --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d1466eb..4517de0 100644 --- a/README.md +++ b/README.md @@ -26,13 +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: ``` cmake -S . -B build -cmake --build 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: From b60782adbf7009f711e48ca47e3b930ad8efa500 Mon Sep 17 00:00:00 2001 From: Sebastien Wertz Date: Wed, 26 Jan 2022 17:25:17 +0100 Subject: [PATCH 4/8] cmake: bump version requirement --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b161166..d14b1d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 From a86de9e7798283af8a681a11243daaf47c03c187 Mon Sep 17 00:00:00 2001 From: Sebastien Wertz Date: Wed, 26 Jan 2022 17:26:55 +0100 Subject: [PATCH 5/8] cmake: better way of requiring c++17 --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d14b1d2..c0b8fdf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,15 +7,13 @@ 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}) @@ -70,6 +68,8 @@ add_library(VeheMencE SHARED ${VEHEMENCE_SOURCES}) target_include_directories(VeheMencE PRIVATE ${CMAKE_SOURCE_DIR}/include) target_link_libraries(VeheMencE ${CAEN_LIBRARY} ${Boost_LIBRARIES}) +target_compile_features(VeheMencE PUBLIC cxx_std_17) + # Examples add_subdirectory (examples) From 637da905f645a9a02d60c97397574c4083ee3714 Mon Sep 17 00:00:00 2001 From: Sebastien Wertz Date: Wed, 26 Jan 2022 17:27:40 +0100 Subject: [PATCH 6/8] cmake: handle boost stacktrace like other components --- CMakeLists.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0b8fdf..77b6ff6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,21 +21,18 @@ 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) From bceea3dba6b89d46e91758fd5afefd9b29fa1051 Mon Sep 17 00:00:00 2001 From: Sebastien Wertz Date: Wed, 26 Jan 2022 17:28:06 +0100 Subject: [PATCH 7/8] cmake: link to libdl missing --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77b6ff6..43d50a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,8 @@ 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) From 693db6777260b03c7ebec9a73ad07e322a30ec26 Mon Sep 17 00:00:00 2001 From: Sebastien Wertz Date: Tue, 8 Feb 2022 14:12:04 +0100 Subject: [PATCH 8/8] fix variable type in CommonDef --- include/CommonDef.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/CommonDef.h b/include/CommonDef.h index be0c521..7ba26e1 100644 --- a/include/CommonDef.h +++ b/include/CommonDef.h @@ -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() {} @@ -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 {