Newer
Older
PROJECT(ChimeraTK-ApplicationCore)
include(cmake/add_dependency.cmake)
Martin Christoph Hierholzer
committed
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
set(${PROJECT_NAME}_MAJOR_VERSION 01)
set(${PROJECT_NAME}_MINOR_VERSION 04)
set(${PROJECT_NAME}_PATCH_VERSION 00)
Martin Christoph Hierholzer
committed
include(cmake/set_version_numbers.cmake)
Martin Christoph Hierholzer
committed
# Find the ControlSystemAdapter
Martin Killenberg
committed
add_dependency(ChimeraTK-ControlSystemAdapter 01.03 REQUIRED)
Martin Christoph Hierholzer
committed
# Find the XML parser library libxml++
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
# optional dependency: BOOST unit test framework needed for tests
Martin Christoph Hierholzer
committed
FIND_PACKAGE(Boost COMPONENTS unit_test_framework)
Martin Christoph Hierholzer
committed
IF(Boost_UNIT_TEST_FRAMEWORK_FOUND)
Martin Christoph Hierholzer
committed
ELSE()
Martin Christoph Hierholzer
committed
message(" The following packages were not found, so testing will be disabled:")
Martin Christoph Hierholzer
committed
message(" * BOOST unit_test_framework")
ENDIF()
Martin Christoph Hierholzer
committed
# Find BOOST filesystem
# Note: we need to search this after looking for the unit_test_framework, since we must not link against the
# unit_test_framework library (use header-only)
FIND_PACKAGE(Boost COMPONENTS filesystem REQUIRED)
Martin Christoph Hierholzer
committed
# optional dependency: the ControlSystemAdapter-DoocsAdapter is needed for the example
add_dependency(ChimeraTK-ControlSystemAdapter-DoocsAdapter 00.10)
Martin Christoph Hierholzer
committed
IF(ChimeraTK-ControlSystemAdapter-DoocsAdapter_FOUND)
Martin Christoph Hierholzer
committed
set(DEMO_IS_ENABLED "true")
ENABLE_TESTING()
ELSE()
message(" The following packages were not found, so the example will be disabled:")
Martin Christoph Hierholzer
committed
IF(NOT ChimeraTK-ControlSystemAdapter-DoocsAdapter_FOUND)
message(" * ChimeraTK-ControlSystemAdapter-DoocsAdapter")
Martin Christoph Hierholzer
committed
ENDIF()
Martin Christoph Hierholzer
committed
ENDIF()
# requierd dependency: HDF5 library needed for the MicroDAQ system (TODO make optional!)
FIND_PACKAGE(HDF5 COMPONENTS CXX REQUIRED)
include_directories(SYSTEM ${HDF5_INCLUDE_DIRS})
link_directories(${HDF5_LIBRARY_DIRS})
IF(HDF5_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MICRO_DAQ")
ELSE()
message(" HDF5 was not found, so the MicroDAQ system will not be built.")
set(HDF5_LIBRARIES "")
ENDIF()
Martin Christoph Hierholzer
committed
# Moderate version of the compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -Wextra -Wuninitialized ")
Martin Christoph Hierholzer
committed
# use -DCMAKE_BUILD_TYPE=Debug in your cmake command to turn on the coverage option
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 --coverage -fno-inline -fno-inline-small-functions -fno-default-inline")
# linker flags
Martin Christoph Hierholzer
committed
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-dynamic ${ChimeraTK-ControlSystemAdapter_LINK_FLAGS}")
set(${PROJECT_NAME}_INCLUDE_DIRS ${${PROJECT_NAME}_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include/ ${CMAKE_SOURCE_DIR}/Modules/include/)
aux_source_directory(${CMAKE_SOURCE_DIR}/src library_sources)
# add generic modules
include_directories(${CMAKE_SOURCE_DIR}/Modules/include)
aux_source_directory(${CMAKE_SOURCE_DIR}/Modules/src library_sources)
MACRO( COPY_MAPPING_FILES )
foreach( FILE_TO_COPY test.xlmap test.dmap )
configure_file( tests/${FILE_TO_COPY} ${PROJECT_BINARY_DIR}/${FILE_TO_COPY} copyonly)
endforeach( FILE_TO_COPY )
ENDMACRO( COPY_MAPPING_FILES )
Martin Christoph Hierholzer
committed
# Create the executables for automated unit testing.
include_directories(${CMAKE_SOURCE_DIR}/tests/include)
aux_source_directory(${CMAKE_SOURCE_DIR}/tests/executables_src testExecutables)
foreach( testExecutableSrcFile ${testExecutables})
#NAME_WE means the base name without path and (longest) extension
get_filename_component(executableName ${testExecutableSrcFile} NAME_WE)
add_executable(${executableName} ${testExecutableSrcFile} )
Martin Christoph Hierholzer
committed
# do not link against the boost unit test library, the tests are not written for it!
target_link_libraries(${executableName} ${PROJECT_NAME} ${ChimeraTK-ControlSystemAdapter_LIBRARIES} ${HDF5_LIBRARIES})
Martin Christoph Hierholzer
committed
set_target_properties(${executableName} PROPERTIES LINK_FLAGS "-Wl,-rpath,${PROJECT_BINARY_DIR} ${Boost_LINK_FLAGS} ${ChimeraTK-ControlSystemAdapter_LINK_FLAGS}")
add_test(${executableName} ${executableName})
Martin Christoph Hierholzer
committed
# enable code coverate report
include(cmake/enable_code_coverage_report.cmake)
Martin Christoph Hierholzer
committed
# copy config files
FILE( COPY ${CMAKE_SOURCE_DIR}/tests/test.map DESTINATION ${PROJECT_BINARY_DIR})
Martin Christoph Hierholzer
committed
FILE( COPY ${CMAKE_SOURCE_DIR}/tests/test2.map DESTINATION ${PROJECT_BINARY_DIR})
Martin Christoph Hierholzer
committed
FILE( COPY ${CMAKE_SOURCE_DIR}/tests/test3.map DESTINATION ${PROJECT_BINARY_DIR})
Martin Christoph Hierholzer
committed
FILE( COPY ${CMAKE_SOURCE_DIR}/tests/test.dmap DESTINATION ${PROJECT_BINARY_DIR})
Martin Christoph Hierholzer
committed
FILE( COPY ${CMAKE_SOURCE_DIR}/tests/validConfig.xml DESTINATION ${PROJECT_BINARY_DIR})
FILE( COPY ${CMAKE_SOURCE_DIR}/xmlschema/application.xsd DESTINATION ${PROJECT_BINARY_DIR})
Martin Christoph Hierholzer
committed
Martin Christoph Hierholzer
committed
# build example
Martin Christoph Hierholzer
committed
if(DEMO_IS_ENABLED)
Martin Christoph Hierholzer
committed
Martin Christoph Hierholzer
committed
add_executable(demoApp example/demoApp.cc example/TimerDummyDevice.cc example/DemoDummyDevice.cc)
Martin Christoph Hierholzer
committed
set_target_properties(demoApp PROPERTIES COMPILE_FLAGS "${ChimeraTK-ControlSystemAdapter_CXX_FLAGS}")
set_target_properties(demoApp PROPERTIES LINK_FLAGS "${ChimeraTK-ControlSystemAdapter_LINK_FLAGS} ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LINK_FLAGS}")
Martin Christoph Hierholzer
committed
target_link_libraries(demoApp ${PROJECT_NAME}
${Boost_LIBRARIES}
Martin Christoph Hierholzer
committed
${ChimeraTK-ControlSystemAdapter_LIBRARIES}
Martin Christoph Hierholzer
committed
${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LIBRARIES}
Martin Christoph Hierholzer
committed
${LibXML++_LIBRARIES}
${glib_LIBRARIES}
${HDF5_LIBRARIES})
Martin Christoph Hierholzer
committed
Martin Christoph Hierholzer
committed
add_executable(demoApp-xmlGenerator example/demoApp.cc)
Martin Christoph Hierholzer
committed
set_target_properties(demoApp-xmlGenerator PROPERTIES COMPILE_FLAGS "${ChimeraTK-ControlSystemAdapter_CXX_FLAGS} -DGENERATE_XML")
set_target_properties(demoApp-xmlGenerator PROPERTIES LINK_FLAGS "${ChimeraTK-ControlSystemAdapter_LINK_FLAGS}")
Martin Christoph Hierholzer
committed
target_link_libraries(demoApp-xmlGenerator ${PROJECT_NAME}
${Boost_LIBRARIES}
Martin Christoph Hierholzer
committed
${ChimeraTK-ControlSystemAdapter_LIBRARIES}
${LibXML++_LIBRARIES}
${glib_LIBRARIES}
${HDF5_LIBRARIES})
Martin Christoph Hierholzer
committed
# add_custom_target(demoApp-xml ALL DEPENDS demoApp-xmlGenerator
# COMMAND ${PROJECT_BINARY_DIR}/demoApp-xmlGenerator
# WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
Martin Christoph Hierholzer
committed
Martin Christoph Hierholzer
committed
# copy config files
Martin Christoph Hierholzer
committed
FILE( COPY ${CMAKE_SOURCE_DIR}/example/dummy.dmap DESTINATION ${PROJECT_BINARY_DIR})
Martin Christoph Hierholzer
committed
FILE( COPY ${CMAKE_SOURCE_DIR}/example/DemoDummy.map DESTINATION ${PROJECT_BINARY_DIR})
FILE( COPY ${CMAKE_SOURCE_DIR}/example/demoApp.conf DESTINATION ${PROJECT_BINARY_DIR})
Martin Christoph Hierholzer
committed
# second example
add_executable(demoApp2 example2/demoApp2.cc)
Martin Christoph Hierholzer
committed
set_target_properties(demoApp2 PROPERTIES COMPILE_FLAGS "${ChimeraTK-ControlSystemAdapter_CXX_FLAGS}")
set_target_properties(demoApp2 PROPERTIES LINK_FLAGS "${ChimeraTK-ControlSystemAdapter_LINK_FLAGS} ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LINK_FLAGS}")
target_link_libraries(demoApp2 ${PROJECT_NAME}
${Boost_LIBRARIES}
${ChimeraTK-ControlSystemAdapter_LIBRARIES}
${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LIBRARIES}
${LibXML++_LIBRARIES}
${glib_LIBRARIES}
${HDF5_LIBRARIES})
# copy config files for 2nd example
FILE( COPY ${CMAKE_SOURCE_DIR}/example2/example2.dmap DESTINATION ${PROJECT_BINARY_DIR})
FILE( COPY ${CMAKE_SOURCE_DIR}/example2/demoApp2.conf DESTINATION ${PROJECT_BINARY_DIR})
FILE( COPY ${CMAKE_SOURCE_DIR}/example2/oven.map DESTINATION ${PROJECT_BINARY_DIR})
Martin Christoph Hierholzer
committed
# second example with automation etc.
add_executable(demoApp2a example2a/demoApp2a.cc)
set_target_properties(demoApp2a PROPERTIES COMPILE_FLAGS "${ChimeraTK-ControlSystemAdapter_CXX_FLAGS}")
set_target_properties(demoApp2a PROPERTIES LINK_FLAGS "${ChimeraTK-ControlSystemAdapter_LINK_FLAGS} ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LINK_FLAGS}")
target_link_libraries(demoApp2a ${PROJECT_NAME}
${Boost_LIBRARIES}
${ChimeraTK-ControlSystemAdapter_LIBRARIES}
${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LIBRARIES}
${LibXML++_LIBRARIES}
${glib_LIBRARIES}
${HDF5_LIBRARIES})
# copy config files for 2nd example with automation
FILE( COPY ${CMAKE_SOURCE_DIR}/example2a/demoApp2a.conf DESTINATION ${PROJECT_BINARY_DIR})
FILE( COPY ${CMAKE_SOURCE_DIR}/example2a/demoApp2a.xml DESTINATION ${PROJECT_BINARY_DIR})
# 3rd example with automation etc.
add_executable(demoApp3 example3/demoApp3.cc)
set_target_properties(demoApp3 PROPERTIES COMPILE_FLAGS "${ChimeraTK-ControlSystemAdapter_CXX_FLAGS}")
set_target_properties(demoApp3 PROPERTIES LINK_FLAGS "${ChimeraTK-ControlSystemAdapter_LINK_FLAGS} ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LINK_FLAGS}")
target_link_libraries(demoApp3 ${PROJECT_NAME}
${Boost_LIBRARIES}
${ChimeraTK-ControlSystemAdapter_LIBRARIES}
${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LIBRARIES}
${LibXML++_LIBRARIES}
${glib_LIBRARIES}
${HDF5_LIBRARIES})
# copy config files for 2nd example with automation
FILE( COPY ${CMAKE_SOURCE_DIR}/example3/demoApp3.conf DESTINATION ${PROJECT_BINARY_DIR})
Martin Christoph Hierholzer
committed
#add_executable(exceptionTestApp exception_test/exceptionTestApp.cc exception_test/ExceptionDevice.cc example/TimerDummyDevice.cc)
#set_target_properties(exceptionTestApp PROPERTIES COMPILE_FLAGS "${ChimeraTK-ControlSystemAdapter_CXX_FLAGS}")
#set_target_properties(exceptionTestApp PROPERTIES LINK_FLAGS "${ChimeraTK-ControlSystemAdapter_LINK_FLAGS} ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LINK_FLAGS}")
#target_link_libraries(exceptionTestApp ${PROJECT_NAME}
# ${Boost_LIBRARIES}
# ${ChimeraTK-ControlSystemAdapter_LIBRARIES}
# ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LIBRARIES}
# ${LibXML++_LIBRARIES}
# ${glib_LIBRARIES}
# ${HDF5_LIBRARIES})
#FILE( COPY ${CMAKE_SOURCE_DIR}/exception_test/exceptionTestApp.conf DESTINATION ${PROJECT_BINARY_DIR})
Martin Christoph Hierholzer
committed
Martin Christoph Hierholzer
committed
endif(DEMO_IS_ENABLED)
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 Christoph Hierholzer
committed
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${ChimeraTK-ControlSystemAdapter_LINK_FLAGS}")
target_link_libraries(${PROJECT_NAME} ${ChimeraTK-ControlSystemAdapter_LIBRARIES}
${Boost_LIBRARIES}
Martin Christoph Hierholzer
committed
pthread
Martin Christoph Hierholzer
committed
${LibXML++_LIBRARIES}
${glib_LIBRARIES}
${HDF5_LIBRARIES})
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
include(cmake/enable_doxygen_documentation.cmake)
Martin Christoph Hierholzer
committed
# Install the library and the executables
install( TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib )
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/ChimeraTK/ApplicationCore
Martin Christoph Hierholzer
committed
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn"
EXCLUDE PATTERN "${PROJECT_NAME}" EXCLUDE)
set(${PROJECT_NAME}_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include")
Martin Christoph Hierholzer
committed
set(${PROJECT_NAME}_LIBRARIES "${PROJECT_NAME} ${ChimeraTK-ControlSystemAdapter_LIBRARIES} ${HDF5_LIBRARIES}")
set(${PROJECT_NAME}_LIBRARY_DIRS "${CMAKE_INSTALL_PREFIX}/lib")
Martin Christoph Hierholzer
committed
set(${PROJECT_NAME}_CXX_FLAGS "${ChimeraTK-ControlSystemAdapter_CXX_FLAGS}")
set(${PROJECT_NAME}_LINK_FLAGS "${ChimeraTK-ControlSystemAdapter_LINK_FLAGS}")
include(${CMAKE_SOURCE_DIR}/cmake/create_cmake_config_files.cmake)