Newer
Older
Martin Christoph Hierholzer
committed
PROJECT(ChimeraTK-ControlSystemAdapter-DoocsAdapter)
Martin Christoph Hierholzer
committed
cmake_minimum_required(VERSION 2.8)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
set(${PROJECT_NAME}_MAJOR_VERSION 00)
set(${PROJECT_NAME}_MINOR_VERSION 16)
set(${PROJECT_NAME}_PATCH_VERSION 00)
include(cmake/set_version_numbers.cmake)
Martin Christoph Hierholzer
committed
include(cmake/set_default_build_to_release.cmake)
include(cmake/set_default_flags.cmake)
Martin Christoph Hierholzer
committed
# linker flags
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-dynamic")
include(cmake/add_dependency.cmake)
Martin Christoph Hierholzer
committed
add_dependency(ChimeraTK-ControlSystemAdapter 01.05 REQUIRED)
add_dependency(doocs-server-test-helper 01.03 REQUIRED)
add_dependency(DOOCS 20.03.0 COMPONENTS server REQUIRED)
Martin Christoph Hierholzer
committed
FIND_PACKAGE(Boost COMPONENTS thread REQUIRED)
# libXML++ is used for parsing/writing XML files
FIND_PACKAGE(PkgConfig REQUIRED)
set(LIBXML++_VERSION "libxml++-2.6")
PKG_CHECK_MODULES(LibXML++ REQUIRED ${LIBXML++_VERSION})
PKG_CHECK_MODULES(glib REQUIRED glib-2.0)
include_directories(SYSTEM "${LibXML++_INCLUDEDIR}/${LIBXML++_VERSION}" ${glib_INCLUDE_DIRS} ${LibXML++_INCLUDE_DIRS})
Martin Christoph Hierholzer
committed
#For some reason the system library has to be mentioned explicitly to the linker.
#This is strange because the thead library has it as a dependency.
FIND_PACKAGE(Boost COMPONENTS thread system unit_test_framework)
IF(Boost_UNIT_TEST_FRAMEWORK_FOUND)
set(TESTING_IS_ENABLED "true")
ENABLE_TESTING()
ELSE(Boost_UNIT_TEST_FRAMEWORK_FOUND)
message("Boost unit_test_framework, disabling testing")
ENDIF(Boost_UNIT_TEST_FRAMEWORK_FOUND)
include_directories(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/tests/include ${CMAKE_SOURCE_DIR}/example)
set(${PROJECT_NAME}_INCLUDE_DIRS ${${PROJECT_NAME}_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include/)
aux_source_directory(${CMAKE_SOURCE_DIR}/src library_sources)
# Create the executables for automated unit testing.
# Currently we assume that they are all tests contained in one file, so
# each file gives a new executable. This section has to be adapted if this should change.
if(TESTING_IS_ENABLED)
# loop over all sources files in execultables_src directory
aux_source_directory(${CMAKE_SOURCE_DIR}/tests/src testExecutables)
foreach( testExecutableSrcFile ${testExecutables} ${referenceExecutables})
# NAME_WE means the base name without path and (longest) extension
get_filename_component(excutableName ${testExecutableSrcFile} NAME_WE)
# each test includes a DOOCS server
add_executable(${excutableName} ${testExecutableSrcFile})
Martin Killenberg
committed
set_target_properties(${excutableName} PROPERTIES COMPILE_FLAGS "${ChimeraTK-ControlSystemAdapter_CXX_FLAGS} ${DOOCS_CXX_FLAGS} ${doocs-server-test-helper_CXX_FLAGS}")
set_target_properties(${excutableName} PROPERTIES LINK_FLAGS "-Wl,-rpath=${CMAKE_BINARY_DIR},--enable-new-dtags ${ChimeraTK-ControlSystemAdapter_LINKER_FLAGS} ${DOOCS_LINKER_FLAGS} ${doocs-server-test-helper_LINKER_FLAGS}")
Martin Killenberg
committed
target_link_libraries(${excutableName} ${PROJECT_NAME} ${doocs-server-test-helper_LIBRARIES})
Martin Christoph Hierholzer
committed
add_test(${excutableName} ${excutableName})
endforeach( testExecutableSrcFile )
Martin Killenberg
committed
file(GLOB XML_FILES variable ${CMAKE_SOURCE_DIR}/tests/variableTreeXml/*.xml ${CMAKE_SOURCE_DIR}/tests/variableTreeXml/intentionallyBroken/*.xml)
file(COPY ${XML_FILES} DESTINATION ${PROJECT_BINARY_DIR}/variableTreeXml)
file(GLOB TEST_XML_FILES variable ${CMAKE_SOURCE_DIR}/tests/*.xml)
file(COPY ${TEST_XML_FILES} DESTINATION ${PROJECT_BINARY_DIR})
Martin Killenberg
committed
Martin Killenberg
committed
file(GLOB TEST_CONF_FILES variable ${CMAKE_SOURCE_DIR}/tests/*.conf)
file(COPY ${TEST_CONF_FILES} DESTINATION ${PROJECT_BINARY_DIR})
Martin Christoph Hierholzer
committed
#The make coverage command is only available in debug mode
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
configure_file(cmake/Makefile.coverage.in ${PROJECT_BINARY_DIR}/Makefile.coverage @ONLY)
add_custom_target( coverage
make -f Makefile.coverage
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating test coverage documentation" VERBATIM )
Martin Christoph Hierholzer
committed
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
endif(TESTING_IS_ENABLED)
include(cmake/enable_doxygen_documentation.cmake)
Martin Christoph Hierholzer
committed
# C++ library
add_library(${PROJECT_NAME} SHARED ${library_sources} )
Martin Christoph Hierholzer
committed
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${${PROJECT_NAME}_FULL_LIBRARY_VERSION} SOVERSION ${${PROJECT_NAME}_SOVERSION})
Martin Killenberg
committed
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${ChimeraTK-ControlSystemAdapter_CXX_FLAGS} ${DOOCS_CXX_FLAGS}")
Martin Christoph Hierholzer
committed
target_link_libraries(${PROJECT_NAME} ${ChimeraTK-ControlSystemAdapter_LIBRARIES} ${DOOCS_LIBRARIES})
Martin Christoph Hierholzer
committed
Martin Christoph Hierholzer
committed
# do not remove runtime path of the library when installing
set_property(TARGET ${PROJECT_NAME} PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
Martin Christoph Hierholzer
committed
# build the reference test doocs server
add_executable(referenceTestDoocsServer ${CMAKE_SOURCE_DIR}/tests/referenceTestDoocsServer/referenceTestDoocsServer.cc)
Martin Killenberg
committed
set_target_properties(referenceTestDoocsServer PROPERTIES COMPILE_FLAGS "${ChimeraTK-ControlSystemAdapter_CXX_FLAGS} ${DOOCS_CXX_FLAGS}")
set_target_properties(referenceTestDoocsServer PROPERTIES LINK_FLAGS "${ChimeraTK-ControlSystemAdapter_LINKER_FLAGS} ${DOOCS_LINKER_FLAGS}")
target_link_libraries(referenceTestDoocsServer ${PROJECT_NAME} ${DOOCS_LIBRARIES} ${ChimeraTK-ControlSystemAdapter_LIBRARIES} ${Boost_LIBRARIES} )
FILE( COPY ${CMAKE_SOURCE_DIR}/tests/referenceTestDoocsServer/referenceTestDoocsServer.conf DESTINATION ${PROJECT_BINARY_DIR})
Martin Christoph Hierholzer
committed
#Install the library and the executables
install( TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
Martin Christoph Hierholzer
committed
#all include files go into include/PROJECT_NAME
#The exclusion of ${PROJECT_NAME} prevents the recursive installation of the files just being installed.
#The original headers are in include/*.h, the installed ones in include/PROJECT_NAME/*.h.
install( DIRECTORY ${${PROJECT_NAME}_INCLUDE_DIRS} DESTINATION include/${PROJECT_NAME}
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
PATTERN "${PROJECT_NAME}" EXCLUDE )
Martin Christoph Hierholzer
committed
# generate cmake config so other projects can find this library
Martin Killenberg
committed
set(${PROJECT_NAME}_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include ${ChimeraTK-ControlSystemAdapter_INCLUDE_DIRS}")
Martin Killenberg
committed
set(${PROJECT_NAME}_LIBRARIES "${ChimeraTK-ControlSystemAdapter_LIBRARIES} ${DOOCS_LIBRARIES}")
set(${PROJECT_NAME}_LIBRARY_DIRS "${CMAKE_INSTALL_PREFIX}/lib ${ChimeraTK-ControlSystemAdapter_LIBRARY_DIRS} ${DOOCS_LIBRARY_DIRS}")
Martin Killenberg
committed
set(${PROJECT_NAME}_CXX_FLAGS "${ChimeraTK-ControlSystemAdapter_CXX_FLAGS}")
set(${PROJECT_NAME}_LINKER_FLAGS "${ChimeraTK-ControlSystemAdapter_LINKER_FLAGS} ${DOOCS_LINKER_FLAGS}")
include(${CMAKE_SOURCE_DIR}/cmake/create_cmake_config_files.cmake)