Commit f410ea77 authored by legoc's avatar legoc
Browse files

First version of FindCameo.cmake and cameo apps

parent cd32cf62
......@@ -25,6 +25,17 @@ endif()
option(NOMAD "Compile Nomad library and programs" OFF)
option(CAMEO "Compile Cameo programs" OFF)
# Add current directory for find package
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
if(CAMEO)
find_package(Cameo REQUIRED)
endif(CAMEO)
message("Cameo found " ${Cameo_FOUND})
message("Cameo include " ${Cameo_INCLUDE_DIRS})
message("Cameo lib " ${Cameo_LIBRARIES})
#------------------------------------------------------------
# Libraries
#------------------------------------------------------------
......
# Find Cameo Headers/Libs
# Variables
# CAMEO_ROOT - set this to a location where Cameo may be found
#
# Cameo_FOUND - True of Cameo found
# Cameo_INCLUDE_DIRS - Location of Cameo includes
# Cameo_LIBRARIES - Cameo libraries
include(FindPackageHandleStandardArgs)
if (NOT CAMEO_ROOT)
set(CAMEO_ROOT "$ENV{CAMEO_ROOT}")
endif()
if (NOT CAMEO_ROOT)
find_path(_Cameo_ROOT NAMES include/cameo/cameo.h)
else()
set(_Cameo_ROOT "${CAMEO_ROOT}")
endif()
find_path(Cameo_INCLUDE_DIRS NAMES cameo/cameo.h HINTS ${_Cameo_ROOT}/include)
if (Cameo_INCLUDE_DIRS)
set(_Cameo_H ${Cameo_INCLUDE_DIRS}/cameo/cameo.h)
function(_cameover_EXTRACT _Cameo_VER_COMPONENT _Cameo_VER_OUTPUT)
set(CMAKE_MATCH_1 "0")
set(_Cameo_expr "^[ \\t]*#define[ \\t]+${_Cameo_VER_COMPONENT}[ \\t]+([0-9]+)$")
file(STRINGS "${_Cameo_H}" _Cameo_ver REGEX "${_Cameo_expr}")
string(REGEX MATCH "${_Cameo_expr}" Cameo_ver "${_Cameo_ver}")
set(${_Cameo_VER_OUTPUT} "${CMAKE_MATCH_1}" PARENT_SCOPE)
endfunction()
#define CAMEO_API_VERSION_MAJOR 1
#define CAMEO_API_VERSION_MINOR 0
#define CAMEO_API_VERSION_REVISION 2
_cameover_EXTRACT("CAMEO_API_VERSION_MAJOR" Cameo_VERSION_MAJOR)
_cameover_EXTRACT("CAMEO_API_VERSION_MINOR" Cameo_VERSION_MINOR)
_cameover_EXTRACT("CAMEO_API_VERSION_REVISION" Cameo_VERSION_PATCH)
message(STATUS "Cameo version: ${Cameo_VERSION_MAJOR}.${Cameo_VERSION_MINOR}.${Cameo_VERSION_PATCH}")
# We should provide version to find_package_handle_standard_args in the same format as it was requested,
# otherwise it can't check whether version matches exactly.
if (NOT ${CMAKE_CXX_PLATFORM_ID} STREQUAL "Windows")
find_library(Cameo_LIBRARIES NAMES cameo HINTS ${_Cameo_ROOT}/lib)
else()
#find_library(
# ZeroMQ_LIBRARY_RELEASE
# NAMES
# libzmq
# "libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-${ZeroMQ_VERSION_MAJOR}_${ZeroMQ_VERSION_MINOR}_${ZeroMQ_VERSION_PATCH}"
# HINTS
# ${_ZeroMQ_ROOT}/lib
# )
#find_library(
# ZeroMQ_LIBRARY_DEBUG
# NAMES
# libzmq_d
# "libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-gd-${ZeroMQ_VERSION_MAJOR}_${ZeroMQ_VERSION_MINOR}_${ZeroMQ_VERSION_PATCH}"
# HINTS
# ${_ZeroMQ_ROOT}/lib)
# On Windows we have to use corresponding version (i.e. Release or Debug) of ZeroMQ because of `errno` CRT global variable
# See more at http://www.drdobbs.com/avoiding-the-visual-c-runtime-library/184416623
#set(ZeroMQ_LIBRARIES optimized "${ZeroMQ_LIBRARY_RELEASE}" debug "${ZeroMQ_LIBRARY_DEBUG}")
message("Windows platform not supported yet")
endif()
endif()
find_package_handle_standard_args(Cameo FOUND_VAR Cameo_FOUND
REQUIRED_VARS Cameo_INCLUDE_DIRS Cameo_LIBRARIES
VERSION_VAR Cameo_VERSION
)
if (Cameo_FOUND)
mark_as_advanced(Cameo_INCLUDE_DIRS Cameo_LIBRARIES Cameo_VERSION
Cameo_VERSION_MAJOR Cameo_VERSION_MINOR Cameo_VERSION_PATCH)
endif()
include_directories(${Cameo_INCLUDE_DIRS})
#------------------------------------------------------------
# Programs
#------------------------------------------------------------
......@@ -8,7 +10,7 @@ add_executable(lstcameohisto128
)
target_link_libraries(lstcameohisto128 PUBLIC
lstdppnomad128 lstdpp128
lstdppnomad128 lstdpp128 ${Cameo_LIBRARIES}
)
......@@ -18,7 +20,7 @@ add_executable(lstcameocoincidence128
)
target_link_libraries(lstcameocoincidence128 PUBLIC
lstdppnomad128 lstdpp128
lstdppnomad128 lstdpp128 ${Cameo_LIBRARIES}
)
#------------------------------------------------------------
......
......@@ -152,10 +152,17 @@ int main(int argc, char * argv[]) {
time_t t1 = time(0);
time_t last = time(0);
string data;
while (subscriber->receiveBinary(data)) {
int32_t blockSize = data.size() / sizeof(int32_t);
int32_t * block = const_cast<int32_t *>(reinterpret_cast<const int32_t *>(data.c_str()));
// string data;
// while (subscriber->receiveBinary(data)) {
while (true) {
std::optional<string> data = subscriber->receiveBinary();
if (!data.has_value()) {
break;
}
int32_t blockSize = data.value().size() / sizeof(int32_t);
int32_t * block = const_cast<int32_t *>(reinterpret_cast<const int32_t *>(data.value().c_str()));
// processing block
algorithm.process(block, blockSize, blocks);
......
......@@ -135,11 +135,17 @@ int main(int argc, char * argv[]) {
time_t t1 = time(0);
time_t last = time(0);
string data;
while (subscriber->receiveBinary(data)) {
// string data;
// while (subscriber->receiveBinary(data)) {
int32_t blockSize = data.size() / sizeof(int32_t);
int32_t * block = const_cast<int32_t *>(reinterpret_cast<const int32_t *>(data.c_str()));
while (true) {
std::optional<string> data = subscriber->receiveBinary();
if (!data.has_value()) {
break;
}
int32_t blockSize = data.value().size() / sizeof(int32_t);
int32_t * block = const_cast<int32_t *>(reinterpret_cast<const int32_t *>(data.value().c_str()));
// processing block
algorithm.process(block, blockSize, blocks);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment