mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
* commands code generation (#803) * commands code generation for only frames command * fix cmake file and add Caller files * working exptime, fully extended commands file and its variants * start adding template commands * add INT_CMD_VEC_ID template * add list command, generate multiple bins, format code * reach 208 commands using the cpp macros * add tests for command parser * start adding tests for commands parser * fix typo to use commands.yaml * add more tests for command_parser * add all template functions (up to 218 commands) * finish template functions and add more CmdProxy.cpp functions (250+) * 257 commands * 300 commands the rest are very special commands * add special commands without generation * separate special functions from generated c++ file * implementing one command for put and get (buggy) * add infer action in a separate file * generate header for special commands from yaml * allow only 0 or 1 for bool inputs * group all commands in gen_commands.py * add help to gen_commands.py * add autocomplete bash script * autocompletion: add support for module levels and help * remove debugging line * add autocompletion, help to commands, change int [0,1] to bool * copy tests for Caller.cpp. Tests pass * update with the new developer branch changes * fix errors after merging (there is problems with tests) * fixed port/stopport in yaml (intput typo), added '_caller' to the test dac and test on chip dac command in global test for cmdcaller * undo previous test simulator debug change * add documentation for the generated code * reducing the comment to be replaced in length so formatting does not split into 2 lines * removed formatting specific style of C++11 in gen_commands.py to keep with the top level clang format of the project * regeneratign code for commands * automation generated * Redirect deprecated commands (#872) * working implementation, need to fix dac * fixed deprecation redirect for dac command * Detector specific autocomplete (#873) * working implementation, need to fix dac * fixed deprecation redirect for dac command * detector specific completion for dac * added autocomplete using detector specific * fixed error when autocompleting partial words * Generate commands/fix commands (#875) * fix vm_a, im_a etc have deg Celsius suffix, also help missing or changed in some places * dac: require det id for all, arg0 to be printed at output, help for onchip dac and dac, onchipdac: spacing * getscan detid and blocking trigger help * udp_Dstlist det_id fixed, but rx_id invalid * cmdApp in line with cmdLineApp (missing version, receiver_id, not creating det object in help action * added set_command to differentiate between check_det_id and require_det_id (mixed up), args: -1 needs to check for at least one argument * reordering * reordering and checked till integer_command_hex * fixed a lot more commands * fix caller tests for eiger * changes to tests after Bechir left * changing .cmd to .cmdcall for the caller commands * fixed tests for caller, still warning for setexptime about cast input * autocomplete ran * add moench test * regenerating autocomplete and commands * fixing other things from merge conflicts (renaming slsDetectorDefs to defs in commands.yaml) * formatting * added code injection to help (#876) * updated 3 commands to have get output that can be put into put (#877) * updated some commands to have get output that can be put into put * fix tests for clkdiv * adding help to free (#878) * removing old commands and renaming them, (also making it work for parameters command as it was still calling cmdproxy) (#879) * More helpful error messages for unsupported actions (#880) * removing old commands and renaming them, (also making it work for parameters command as it was still calling cmdproxy) * Added specific help for unsupported actions * fixed a vetofile get special exception message. more specific warning for special exception message instead of no function warning * added condition checking true in exceptions for special message --------- Co-authored-by: Bechir Brahem <bachbrahem@gmail.com> Co-authored-by: Erik Frojdh <erik.frojdh@gmail.com> Co-authored-by: Dhanya Thattil <dhanya.thattil@psi.ch>
349 lines
12 KiB
CMake
349 lines
12 KiB
CMake
# SPDX-License-Identifier: LGPL-3.0-or-other
|
|
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
cmake_minimum_required(VERSION 3.14)
|
|
project(slsDetectorPackage)
|
|
set(PROJECT_VERSION 7.0.0)
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
|
|
|
cmake_policy(SET CMP0074 NEW)
|
|
|
|
if (${CMAKE_VERSION} VERSION_GREATER "3.24")
|
|
cmake_policy(SET CMP0135 NEW) #Fetch content download timestamp
|
|
endif()
|
|
include(cmake/project_version.cmake)
|
|
include(cmake/SlsAddFlag.cmake)
|
|
|
|
|
|
|
|
# Using FetchContent to get libzmq
|
|
include(FetchContent)
|
|
option(SLS_FETCH_ZMQ_FROM_GITHUB "Fetch zmq from github" OFF)
|
|
option(SLS_FETCH_PYBIND11_FROM_GITHUB "Fetch pybind11 from github" OFF)
|
|
|
|
if(SLS_FETCH_ZMQ_FROM_GITHUB)
|
|
# Opt in to pull down a zmq version from github instead of
|
|
# using the bundled verison
|
|
FetchContent_Declare(
|
|
libzmq
|
|
GIT_REPOSITORY https://github.com/zeromq/libzmq.git
|
|
GIT_TAG v4.3.4
|
|
)
|
|
else()
|
|
# Standard behaviour use libzmq included in this repo (libs/libzmq)
|
|
FetchContent_Declare(
|
|
libzmq
|
|
URL ${CMAKE_SOURCE_DIR}/libs/libzmq/libzmq-4.3.4.tar.gz
|
|
URL_HASH MD5=cc20b769ac10afa352e5ed2769bb23b3
|
|
)
|
|
endif()
|
|
|
|
# Disable unwanted options from libzmq
|
|
set(BUILD_TESTS OFF CACHE BOOL "Switch off libzmq test build")
|
|
set(BUILD_SHARED OFF CACHE BOOL "Switch off libzmq shared libs")
|
|
set(WITH_PERF_TOOL OFF CACHE BOOL "")
|
|
set(ENABLE_CPACK OFF CACHE BOOL "")
|
|
set(ENABLE_CLANG OFF CACHE BOOL "")
|
|
set(ENABLE_CURVE OFF CACHE BOOL "")
|
|
set(ENABLE_DRAFTS OFF CACHE BOOL "")
|
|
|
|
# Using GetProperties and Populate to be able to exclude zmq
|
|
# from install (not possible with FetchContent_MakeAvailable(libzmq))
|
|
FetchContent_GetProperties(libzmq)
|
|
if(NOT libzmq_POPULATED)
|
|
FetchContent_Populate(libzmq)
|
|
add_subdirectory(${libzmq_SOURCE_DIR} ${libzmq_BINARY_DIR} EXCLUDE_FROM_ALL)
|
|
endif()
|
|
|
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
# If conda build, always set lib dir to 'lib'
|
|
if($ENV{CONDA_BUILD})
|
|
set(CMAKE_INSTALL_LIBDIR "lib")
|
|
endif()
|
|
|
|
# Set lower / upper case project names
|
|
string(TOUPPER "${PROJECT_NAME}" PROJECT_NAME_UPPER)
|
|
string(TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER)
|
|
|
|
# Set targets export name (used by slsDetectorPackage and dependencies)
|
|
set(TARGETS_EXPORT_NAME "${PROJECT_NAME_LOWER}-targets")
|
|
set(namespace "sls::")
|
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
|
|
|
|
|
# Check if project is being used directly or via add_subdirectory
|
|
set(SLS_MASTER_PROJECT OFF)
|
|
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
|
set(SLS_MASTER_PROJECT ON)
|
|
endif()
|
|
|
|
|
|
|
|
option(SLS_USE_HDF5 "HDF5 File format" OFF)
|
|
option(SLS_BUILD_SHARED_LIBRARIES "Build shared libaries" ON)
|
|
option(SLS_USE_TEXTCLIENT "Text Client" ON)
|
|
option(SLS_USE_DETECTOR "Detector libs" ON)
|
|
option(SLS_USE_RECEIVER "Receiver" ON)
|
|
option(SLS_USE_RECEIVER_BINARIES "Receiver binaries" ON)
|
|
option(SLS_USE_GUI "GUI" OFF)
|
|
option(SLS_USE_SIMULATOR "Simulator" OFF)
|
|
option(SLS_USE_TESTS "TESTS" OFF)
|
|
option(SLS_USE_INTEGRATION_TESTS "Integration Tests" OFF)
|
|
option(SLS_USE_SANITIZER "Sanitizers for debugging" OFF)
|
|
option(SLS_USE_PYTHON "Python bindings" OFF)
|
|
option(SLS_INSTALL_PYTHONEXT "Install the python extension in the install tree under CMAKE_INSTALL_PREFIX/python/" OFF)
|
|
option(SLS_USE_CTBGUI "ctb GUI" OFF)
|
|
option(SLS_BUILD_DOCS "docs" OFF)
|
|
option(SLS_BUILD_EXAMPLES "examples" OFF)
|
|
option(SLS_TUNE_LOCAL "tune to local machine" OFF)
|
|
option(SLS_DEVEL_HEADERS "install headers for devel" OFF)
|
|
option(SLS_USE_MOENCH "compile zmq and post processing for Moench" OFF)
|
|
option(SLS_USE_JUNGFRAU "compile post processing for Jungfrau" OFF)
|
|
|
|
#Convenience option to switch off defaults when building Moench binaries only
|
|
option(SLS_BUILD_ONLY_MOENCH "compile only Moench" OFF)
|
|
if(SLS_BUILD_ONLY_MOENCH)
|
|
message(STATUS "Build MOENCH binaries only!")
|
|
set(SLS_BUILD_SHARED_LIBRARIES OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
|
|
set(SLS_USE_TEXTCLIENT OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
|
|
set(SLS_USE_DETECTOR OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
|
|
set(SLS_USE_RECEIVER OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
|
|
set(SLS_USE_RECEIVER_BINARIES OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
|
|
set(SLS_USE_MOENCH ON CACHE BOOL "Enable" FORCE)
|
|
endif()
|
|
|
|
#Convenience option to switch off defaults when building Jungfrau binaries only
|
|
option(SLS_BUILD_ONLY_JUNGFRAU "compile only Jungfrau" OFF)
|
|
if(SLS_BUILD_ONLY_JUNGFRAU)
|
|
message(STATUS "Build JUNGFRAU binaries only!")
|
|
set(SLS_BUILD_SHARED_LIBRARIES OFF CACHE BOOL "Disabled for JUNGFRAU_ONLY" FORCE)
|
|
set(SLS_USE_TEXTCLIENT OFF CACHE BOOL "Disabled for JUNGFRAU_ONLY" FORCE)
|
|
set(SLS_USE_DETECTOR OFF CACHE BOOL "Disabled for JUNGFRAU_ONLY" FORCE)
|
|
set(SLS_USE_RECEIVER OFF CACHE BOOL "Disabled for JUNGFRAU_ONLY" FORCE)
|
|
set(SLS_USE_RECEIVER_BINARIES OFF CACHE BOOL "Disabled for JUNGFRAU_ONLY" FORCE)
|
|
set(SLS_USE_JUNGFRAU ON CACHE BOOL "Enable" FORCE)
|
|
endif()
|
|
|
|
|
|
option(SLS_EXT_BUILD "external build of part of the project" OFF)
|
|
if(SLS_EXT_BUILD)
|
|
message(STATUS "External build using already installed libraries")
|
|
set(SLS_BUILD_SHARED_LIBRARIES OFF CACHE BOOL "Should already exist" FORCE)
|
|
set(SLS_USE_TEXTCLIENT OFF CACHE BOOL "Should already exist" FORCE)
|
|
set(SLS_USE_DETECTOR OFF CACHE BOOL "Should already exist" FORCE)
|
|
set(SLS_USE_RECEIVER OFF CACHE BOOL "Should already exist" FORCE)
|
|
set(SLS_USE_RECEIVER_BINARIES OFF CACHE BOOL "Should already exist" FORCE)
|
|
set(SLS_MASTER_PROJECT OFF CACHE BOOL "No master proj in case of extbuild" FORCE)
|
|
endif()
|
|
|
|
#Maybe have an option guarding this?
|
|
set(SLS_INTERNAL_RAPIDJSON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/rapidjson)
|
|
|
|
set(SLS_INTERNAL_QWT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/qwt-6.1.5)
|
|
|
|
set(ClangFormat_EXCLUDE_PATTERNS "build/"
|
|
"libs/"
|
|
"slsDetectorCalibration/"
|
|
"ctbGui/"
|
|
"manual/"
|
|
"python/"
|
|
"sample/"
|
|
${CMAKE_BINARY_DIR})
|
|
find_package(ClangFormat)
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
message(STATUS "No build type selected, default to Release")
|
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE)
|
|
endif()
|
|
|
|
|
|
#Enable LTO if available
|
|
include(CheckIPOSupported)
|
|
check_ipo_supported(RESULT SLS_LTO_AVAILABLE)
|
|
if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE)
|
|
message(STATUS "Building with link time optimization")
|
|
else()
|
|
message(STATUS "Building without link time optimization")
|
|
endif()
|
|
|
|
|
|
if(SLS_EXT_BUILD)
|
|
# Find ourself in case of external build
|
|
find_package(slsDetectorPackage ${PROJECT_VERSION} REQUIRED)
|
|
endif()
|
|
|
|
|
|
|
|
# slsProjectOptions and slsProjectWarnings are used
|
|
# to control options for the libraries
|
|
if(NOT TARGET slsProjectOptions)
|
|
add_library(slsProjectOptions INTERFACE)
|
|
target_compile_features(slsProjectOptions INTERFACE cxx_std_11)
|
|
endif()
|
|
|
|
if (NOT TARGET slsProjectWarnings)
|
|
add_library(slsProjectWarnings INTERFACE)
|
|
target_compile_options(slsProjectWarnings INTERFACE
|
|
-Wall
|
|
-Wextra
|
|
-Wno-unused-parameter
|
|
# -Wold-style-cast
|
|
-Wnon-virtual-dtor
|
|
-Woverloaded-virtual
|
|
-Wdouble-promotion
|
|
-Wformat=2
|
|
-Wredundant-decls
|
|
# -Wconversion
|
|
-Wvla
|
|
-Wdouble-promotion
|
|
-Werror=return-type
|
|
)
|
|
# Add or disable warnings depending on if the compiler supports them
|
|
# The function checks internally and sets HAS_warning-name
|
|
sls_enable_cxx_warning("-Wnull-dereference")
|
|
sls_enable_cxx_warning("-Wduplicated-cond")
|
|
sls_disable_cxx_warning("-Wclass-memaccess")
|
|
|
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
target_compile_options(slsProjectWarnings INTERFACE
|
|
-Wno-missing-field-initializers)
|
|
endif()
|
|
|
|
|
|
endif()
|
|
|
|
|
|
if (NOT TARGET slsProjectCSettings)
|
|
#Settings for C code
|
|
add_library(slsProjectCSettings INTERFACE)
|
|
target_compile_options(slsProjectCSettings INTERFACE
|
|
-std=gnu99 #fixed
|
|
-Wall
|
|
-Wextra
|
|
-Wno-unused-parameter
|
|
-Wdouble-promotion
|
|
-Wformat=2
|
|
-Wredundant-decls
|
|
-Wdouble-promotion
|
|
-Werror=return-type
|
|
)
|
|
sls_disable_c_warning("-Wstringop-truncation")
|
|
endif()
|
|
|
|
|
|
if(SLS_USE_SANITIZER)
|
|
target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer)
|
|
target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined)
|
|
# target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread)
|
|
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
|
|
endif()
|
|
|
|
|
|
if(SLS_TUNE_LOCAL)
|
|
target_compile_options(slsProjectOptions INTERFACE -mtune=native -march=native)
|
|
endif()
|
|
|
|
|
|
if(SLS_MASTER_PROJECT)
|
|
install(TARGETS slsProjectOptions slsProjectWarnings
|
|
EXPORT "${TARGETS_EXPORT_NAME}"
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
)
|
|
endif()
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
set(CMAKE_INSTALL_RPATH $ORIGIN)
|
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
|
|
|
if (SLS_USE_TESTS)
|
|
enable_testing()
|
|
add_subdirectory(tests)
|
|
endif(SLS_USE_TESTS)
|
|
|
|
|
|
if(NOT SLS_EXT_BUILD)
|
|
add_subdirectory(slsSupportLib)
|
|
endif()
|
|
|
|
if (SLS_USE_DETECTOR OR SLS_USE_TEXTCLIENT)
|
|
add_subdirectory(slsDetectorSoftware)
|
|
endif ()
|
|
|
|
if (SLS_USE_RECEIVER)
|
|
add_subdirectory(slsReceiverSoftware)
|
|
endif (SLS_USE_RECEIVER)
|
|
|
|
if (SLS_USE_GUI)
|
|
add_subdirectory(libs/qwt)
|
|
add_subdirectory(slsDetectorGui)
|
|
endif (SLS_USE_GUI)
|
|
|
|
if (SLS_USE_SIMULATOR)
|
|
add_subdirectory(slsDetectorServers)
|
|
endif (SLS_USE_SIMULATOR)
|
|
|
|
if (SLS_USE_INTEGRATION_TESTS)
|
|
add_subdirectory(integrationTests)
|
|
endif (SLS_USE_INTEGRATION_TESTS)
|
|
|
|
if (SLS_USE_PYTHON)
|
|
find_package (Python 3.6 COMPONENTS Interpreter Development)
|
|
if(SLS_FETCH_PYBIND11_FROM_GITHUB)
|
|
FetchContent_Declare(
|
|
pybind11
|
|
GIT_REPOSITORY https://github.com/pybind/pybind11
|
|
GIT_TAG v2.11.0
|
|
)
|
|
|
|
else()
|
|
FetchContent_Declare(
|
|
pybind11
|
|
URL ${CMAKE_SOURCE_DIR}/libs/pybind11/v2.11.0.tar.gz
|
|
URL_HASH MD5=90c4946e87c64d8d8fc0ae4edf35d780
|
|
)
|
|
endif()
|
|
FetchContent_MakeAvailable(pybind11)
|
|
|
|
add_subdirectory(python)
|
|
endif(SLS_USE_PYTHON)
|
|
|
|
if (SLS_USE_CTBGUI)
|
|
add_subdirectory(ctbGui)
|
|
endif(SLS_USE_CTBGUI)
|
|
|
|
configure_file( .clang-tidy
|
|
${CMAKE_BINARY_DIR}/.clang-tidy
|
|
)
|
|
|
|
if (SLS_BUILD_EXAMPLES)
|
|
add_subdirectory(sample)
|
|
endif(SLS_BUILD_EXAMPLES)
|
|
|
|
if(SLS_BUILD_DOCS)
|
|
add_subdirectory(docs)
|
|
endif(SLS_BUILD_DOCS)
|
|
|
|
if(SLS_USE_MOENCH)
|
|
add_subdirectory(slsDetectorCalibration/tiffio)
|
|
add_subdirectory(slsDetectorCalibration/moenchExecutables)
|
|
endif(SLS_USE_MOENCH)
|
|
|
|
if(SLS_USE_JUNGFRAU)
|
|
add_subdirectory(slsDetectorCalibration/tiffio)
|
|
add_subdirectory(slsDetectorCalibration/jungfrauExecutables)
|
|
endif(SLS_USE_JUNGFRAU)
|
|
|
|
if(SLS_MASTER_PROJECT)
|
|
set(CMAKE_INSTALL_DIR "share/cmake/${PROJECT_NAME}")
|
|
set(PROJECT_LIBRARIES slsSupportShared slsDetectorShared slsReceiverShared)
|
|
include(cmake/package_config.cmake)
|
|
endif()
|