115 lines
2.9 KiB
CMake
115 lines
2.9 KiB
CMake
cmake_minimum_required(VERSION 3.0)
|
|
project(m_epics_ca)
|
|
|
|
add_compile_options(
|
|
-Wall
|
|
-Wformat=2
|
|
-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()
|
|
|
|
# Add the MIDAS libs
|
|
set(LIBS
|
|
${LIBS}
|
|
${EPICSSYS}/lib/$ENV{EPICS_HOST_ARCH}/libca.so
|
|
$ENV{MIDASSYS}/lib/libmfe.a
|
|
$ENV{MIDASSYS}/lib/libmidas.a
|
|
$ENV{MIDASSYS}/lib/libmscb.a
|
|
)
|
|
|
|
################################################################################
|
|
## Driver Library
|
|
################################################################################
|
|
|
|
add_library(
|
|
m_epics_ca
|
|
INTERFACE
|
|
)
|
|
|
|
target_sources(m_epics_ca INTERFACE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/bus/m_epics_ca.h
|
|
${CMAKE_CURRENT_SOURCE_DIR}/bus/m_epics_ca.tpp
|
|
)
|
|
|
|
target_include_directories(m_epics_ca INTERFACE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/bus
|
|
)
|
|
|
|
################################################################################
|
|
## Test executable
|
|
################################################################################
|
|
|
|
add_executable(
|
|
m_epics_ca_test
|
|
test/m_epics_ca_test.cxx
|
|
)
|
|
|
|
set_property(
|
|
TARGET
|
|
m_epics_ca_test
|
|
PROPERTY
|
|
CXX_STANDARD 17
|
|
)
|
|
|
|
target_include_directories(
|
|
m_epics_ca_test
|
|
PUBLIC
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
PRIVATE
|
|
m_epics_ca
|
|
$ENV{MIDASSYS}/drivers
|
|
$ENV{MIDASSYS}/include
|
|
# This is redundant if MIDASSYS =/ Midas repo, but needed if MIDAS has been
|
|
# installed in the repo directory, since the CMake file of MIDAS doesn't
|
|
# copy the headers into $ENV{MIDASSYS}/include in the latter case.
|
|
$ENV{MIDASSYS}/include/mscb
|
|
${EPICSSYS}/include
|
|
${EPICSSYS}/include/os/Linux
|
|
${EPICSSYS}/include/os/Darwin
|
|
${EPICSSYS}/include/compiler/gcc
|
|
${EPICSSYS}/include/compiler/clang
|
|
)
|
|
|
|
target_link_libraries(
|
|
m_epics_ca_test
|
|
m_epics_ca
|
|
${LIBS}
|
|
)
|
|
|
|
# Custom target to run the test immediately after building
|
|
add_custom_command(TARGET m_epics_ca_test
|
|
POST_BUILD
|
|
COMMAND m_epics_ca_test
|
|
COMMENT "Running m_epics_ca_test after build..."
|
|
)
|
|
|
|
add_custom_target(run_m_epics_ca_test
|
|
COMMAND m_epics_ca_test
|
|
DEPENDS m_epics_ca_test
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
COMMENT "Running m_epics_ca_test..."
|
|
) |