127 lines
2.6 KiB
CMake
127 lines
2.6 KiB
CMake
cmake_minimum_required(VERSION 3.03)
|
|
|
|
project(ePowerSwitchFrontend VERSION 1.0)
|
|
|
|
add_subdirectory(submodule/mepicsca)
|
|
|
|
add_compile_options(
|
|
-Wall
|
|
-Wformat=2
|
|
-g
|
|
-Wno-format-nonliteral
|
|
-Wno-strict-aliasing
|
|
-Wuninitialized
|
|
-Wno-unused-function
|
|
)
|
|
|
|
# Check if the required environment variables MIDASSYS and EPICSSYS are available
|
|
if (NOT DEFINED ENV{MIDASSYS})
|
|
message(SEND_ERROR "MIDASSYS environment variable not defined.")
|
|
endif()
|
|
if (NOT DEFINED ENV{EPICSSYS})
|
|
message(SEND_ERROR "EPICSSYS environment variable not defined.")
|
|
endif()
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(MIDASSYS $ENV{MIDASSYS})
|
|
set(EPICSSYS $ENV{EPICSSYS})
|
|
|
|
# Select the correct EPICS library depending on the OS (currently Linus or Darwin are available)
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
|
|
link_directories(${EPICSSYS}/lib/linux-x86_64)
|
|
set(LIBS ${LIBS} -lpthread -lutil -lrt -lbsd -ldl)
|
|
endif()
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES Darwin)
|
|
link_directories(${EPICSSYS}/lib/darwin-aarch64)
|
|
set(LIBS ${LIBS} -lutil -lca)
|
|
endif()
|
|
|
|
set(LIBS
|
|
${LIBS}
|
|
${EPICSSYS}/lib/$ENV{EPICS_HOST_ARCH}/libca.so
|
|
${EPICSSYS}/lib/$ENV{EPICS_HOST_ARCH}/libCom.so # For alarm.h
|
|
)
|
|
|
|
find_package(Midas REQUIRED)
|
|
|
|
################################################################################
|
|
## Device Library
|
|
################################################################################
|
|
|
|
add_library(
|
|
power_switch
|
|
src/device/power_switch.cpp
|
|
src/utils/outlet.cpp
|
|
)
|
|
|
|
set_property(
|
|
TARGET
|
|
power_switch
|
|
PROPERTY
|
|
CXX_STANDARD 17
|
|
)
|
|
|
|
target_link_libraries(
|
|
power_switch
|
|
PRIVATE
|
|
midas::mfe
|
|
m_epics_ca
|
|
${LIBS}
|
|
)
|
|
|
|
target_include_directories(
|
|
power_switch
|
|
PUBLIC
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
PRIVATE
|
|
${EPICSSYS}/include
|
|
${EPICSSYS}/include/os/Linux
|
|
${EPICSSYS}/include/os/Darwin
|
|
${EPICSSYS}/include/compiler/gcc
|
|
${EPICSSYS}/include/compiler/clang
|
|
)
|
|
|
|
|
|
|
|
################################################################################
|
|
## Frontend
|
|
################################################################################
|
|
|
|
add_executable(power_switch_scfe
|
|
src/frontend/power_switch_scfe.cpp
|
|
)
|
|
|
|
set_property(
|
|
TARGET
|
|
power_switch_scfe
|
|
PROPERTY
|
|
CXX_STANDARD 17
|
|
)
|
|
|
|
|
|
target_include_directories(
|
|
power_switch_scfe
|
|
PUBLIC
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
PRIVATE
|
|
${EPICSSYS}/include
|
|
${EPICSSYS}/include/os/Linux
|
|
${EPICSSYS}/include/os/Darwin
|
|
${EPICSSYS}/include/compiler/gcc
|
|
${EPICSSYS}/include/compiler/clang
|
|
)
|
|
|
|
target_link_libraries(
|
|
power_switch_scfe
|
|
PRIVATE
|
|
power_switch
|
|
midas::mfe
|
|
m_epics_ca
|
|
${LIBS}
|
|
)
|
|
install(
|
|
TARGETS
|
|
power_switch_scfe
|
|
RUNTIME DESTINATION bin
|
|
)
|