CMake support for CTB Gui (#51)

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP builds...

* clean up

* root 6.18 support
This commit is contained in:
Erik Fröjdh 2019-08-22 21:21:04 +02:00 committed by Dhanya Thattil
parent 867bce8b38
commit 3ca52176b7
3 changed files with 107 additions and 24 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9) cmake_minimum_required(VERSION 3.11)
project(slsDetectorPackage) project(slsDetectorPackage)
set(PROJECT_VERSION 5.0.0) set(PROJECT_VERSION 5.0.0)
@ -42,7 +42,8 @@ option (SLS_USE_TESTS "TESTS" OFF)
option (SLS_USE_INTEGRATION_TESTS "Integration Tests" OFF) option (SLS_USE_INTEGRATION_TESTS "Integration Tests" OFF)
option(SLS_USE_SANITIZER "Sanitizers for debugging" OFF) option(SLS_USE_SANITIZER "Sanitizers for debugging" OFF)
option(SLS_USE_PYTHON "Python bindings" OFF) option(SLS_USE_PYTHON "Python bindings" OFF)
option(SLS_BUILD_DOCS "Documentations" OFF) option(SLS_USE_CTBGUI "ctb GUI" OFF)
option(SLS_BUILD_DOCS "docs" OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@ -176,6 +177,10 @@ if (SLS_USE_PYTHON)
add_subdirectory(python) add_subdirectory(python)
endif(SLS_USE_PYTHON) endif(SLS_USE_PYTHON)
if (SLS_USE_CTBGUI)
add_subdirectory(ctbGui)
endif(SLS_USE_CTBGUI)
configure_file( .clang-tidy configure_file( .clang-tidy
${CMAKE_BINARY_DIR}/.clang-tidy ${CMAKE_BINARY_DIR}/.clang-tidy
) )

78
ctbGui/CMakeLists.txt Normal file
View File

@ -0,0 +1,78 @@
find_package(ROOT CONFIG REQUIRED COMPONENTS Core Gui)
find_package(TIFF REQUIRED)
target_include_directories(ROOT::Core INTERFACE "${ROOT_INCLUDE_DIRS}")
add_library(ROOT::Flags_CXX IMPORTED INTERFACE)
separate_arguments(ROOT_CXX_FLAGS)
target_compile_options(ROOT::Flags_CXX INTERFACE ${ROOT_CXX_FLAGS})
separate_arguments(ROOT_DEFINITIONS)
target_compile_definitions(ROOT::Flags_CXX INTERFACE ${ROOT_DEFINITIONS})
# This fixes a bug in the linker flags
string(REPLACE "-L " "-L" ROOT_EXE_LINKER_FLAGS "${ROOT_EXE_LINKER_FLAGS}")
separate_arguments(ROOT_EXE_LINKER_FLAGS)
# Stuck into using old property method due to separate -L and -l arguments
# (A full path to -l is better!)
set_property(TARGET ROOT::Flags_CXX PROPERTY
INTERFACE_LINK_LIBRARIES ${ROOT_EXE_LINKER_FLAGS})
set_property(TARGET ROOT::Core PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${ROOT_INCLUDE_DIRS}")
add_executable(ctbGui
ctbGui.cpp
ctbMain.cpp
ctbDacs.cpp
ctbPowers.cpp
ctbSlowAdcs.cpp
ctbSignals.cpp
ctbAdcs.cpp
ctbPattern.cpp
ctbAcquisition.cpp
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/tiffIO.cpp
)
#TODO! Replace with target
target_include_directories(ctbGui PRIVATE
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/dataStructures
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/interpolations
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/
)
# Headders needed for ROOT dictionary generation
set( HEADERS
ctbMain.h
ctbDacs.h
ctbPattern.h
ctbSignals.h
ctbAdcs.h
ctbAcquisition.h
ctbPowers.h
ctbSlowAdcs.h
)
#set(ROOT_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
# ROOT dictionary generation
include("${ROOT_DIR}/modules/RootNewMacros.cmake")
root_generate_dictionary(ctbDict ${HEADERS} LINKDEF ctbLinkDef.h)
add_library(ctbRootLib SHARED ctbDict.cxx)
target_include_directories(ctbRootLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(ctbRootLib PUBLIC
ROOT::Core
${ROOT_LIBRARIES}
${ROOT_EXE_LINKER_FLAGS}
)
target_link_libraries(ctbGui PUBLIC
slsDetectorShared
ctbRootLib
${TIFF_LIBRARIES}
)
set_target_properties(ctbGui PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)

View File

@ -55,29 +55,29 @@
// CHECK(subFrameNumber == -1); // CHECK(subFrameNumber == -1);
// } // }
TEST_CASE("Parse header gotthard data", "[receiver]") { // TEST_CASE("Parse header gotthard data", "[receiver]") {
GotthardData data; // GotthardData data;
struct packet { // struct packet {
uint32_t frameNumber; // uint32_t frameNumber;
unsigned char data[GOTTHARD_PACKET_SIZE]; // unsigned char data[GOTTHARD_PACKET_SIZE];
} __attribute__((packed)); // } __attribute__((packed));
packet test_packet; // packet test_packet;
test_packet.frameNumber = 25698u; // test_packet.frameNumber = 25698u;
int index = 0; // int index = 0;
char *packetData = reinterpret_cast<char *>(&test_packet); // char *packetData = reinterpret_cast<char *>(&test_packet);
uint32_t dynamicRange{0}; // uint32_t dynamicRange{0};
bool oddStartingPacket{0}; // bool oddStartingPacket{0};
uint64_t frameNumber{0}; // uint64_t frameNumber{0};
uint32_t packetNumber{0}; // uint32_t packetNumber{0};
uint32_t subFrameNumber{0}; // uint32_t subFrameNumber{0};
uint64_t bunchId{0}; // uint64_t bunchId{0};
data.GetHeaderInfo(index, packetData, dynamicRange, oddStartingPacket, // data.GetHeaderInfo(index, packetData, dynamicRange, oddStartingPacket,
frameNumber, packetNumber, subFrameNumber, bunchId); // frameNumber, packetNumber, subFrameNumber, bunchId);
CHECK(frameNumber == test_packet.frameNumber/2); // CHECK(frameNumber == test_packet.frameNumber/2);
CHECK(subFrameNumber == -1); // CHECK(subFrameNumber == -1);
CHECK(bunchId == -1); // CHECK(bunchId == -1);
} // }