Skip to content
Snippets Groups Projects
Commit eb96dd05 authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

changed build environment so the example is built by the CMake script as well

parent 998d249e
No related branches found
No related tags found
No related merge requests found
PROJECT(ChimeraTK-ControlSystemDeviceConnector)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
set(${PROJECT_NAME}_MAJOR_VERSION 00)
set(${PROJECT_NAME}_MINOR_VERSION 01)
......@@ -9,45 +9,64 @@ set(${PROJECT_NAME}_PATCH_VERSION 00)
set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_VERSION})
set(${PROJECT_NAME}_SOVERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION})
#This library depends on deviceaccess, which is likely to change often.
#We add a build version to the version number to be able to install
#the same software version of the library linked against different versions
#of deviceacces (or other dependencies)
# This library depends on deviceaccess, which is likely to change often.
# We add a build version to the version number to be able to install
# the same software version of the library linked against different versions
# of deviceacces (or other dependencies)
set(${PROJECT_NAME}_BUILDVERSION $ENV{${PROJECT_NAME}_BUILDVERSION})
if( ${PROJECT_NAME}_BUILDVERSION )
set(${PROJECT_NAME}_SOVERSION "${${PROJECT_NAME}_SOVERSION}${${PROJECT_NAME}_BUILDVERSION}")
endif( ${PROJECT_NAME}_BUILDVERSION )
message("${PROJECT_NAME}_SOVERSION ${${PROJECT_NAME}_SOVERSION}")
#We need the build name to be part of the libraries full version name
# We need the build name to be part of the libraries full version name
set(${PROJECT_NAME}_FULL_LIBRARY_VERSION ${${PROJECT_NAME}_SOVERSION}.${${PROJECT_NAME}_PATCH_VERSION})
#put the min version of deviceaccess into a variable. We need it for the debian packaging scripts
# put the min version of deviceaccess into a variable. We need it for the debian packaging scripts
set(mtca4u-deviceaccess_MIN_VERSION 00.12)
FIND_PACKAGE(mtca4u-deviceaccess ${mtca4u-deviceaccess_MIN_VERSION} REQUIRED)
include_directories(SYSTEM ${mtca4u-deviceaccess_INCLUDE_DIRS})
#put the min version of deviceaccess into a variable. We need it for the debian packaging scripts
# put the min version of deviceaccess into a variable. We need it for the debian packaging scripts
set(ControlSystemAdapter_MIN_VERSION 00.00)
FIND_PACKAGE(ControlSystemAdapter ${ControlSystemAdapter_MIN_VERSION} REQUIRED)
include_directories(SYSTEM ${ControlSystemAdapter_INCLUDE_DIRS})
#Moderate version of the compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -Wextra -ansi -Wuninitialized ${mtca4u-deviceaccess_CXX_FLAGS} -O3")
# optional dependency: if finding the DOOCS server library, the example and tests will be built
# put the min version of deviceaccess into a variable. We need it for the debian packaging scripts
set(DOOCS_MIN_VERSION 18.10.5)
FIND_PACKAGE(DOOCS ${DOOCS_MIN_VERSION} COMPONENTS server)
include_directories(SYSTEM ${DOOCS_INCLUDE_DIRS})
link_directories(${DOOCS_LIBRARY_DIRS})
#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")
# optional dependency: the DoocsServerTestHelper is also needed for the tests
FIND_PACKAGE(mtca4u-doocsServerTestHelper)
include_directories(SYSTEM ${mtca4u-doocsServerTestHelper_INCLUDE_DIRS})
link_directories(${mtca4u-doocsServerTestHelper_LIBRARY_DIRS})
# linker flags
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-dynamic ${mtca4u-deviceaccess_LINK_FLAGS}")
# optional dependency: the ControlSystemAdapter-DoocsAdapter needed for tests and example
FIND_PACKAGE(ControlSystemAdapter-DoocsAdapter)
include_directories(SYSTEM ${ControlSystemAdapter-DoocsAdapter_INCLUDE_DIRS})
link_directories(${ControlSystemAdapter-DoocsAdapter_LIBRARY_DIRS})
#BOOST unit test framework
# optional dependency: BOOST unit test framework needed for tests
FIND_PACKAGE(Boost COMPONENTS unit_test_framework)
IF(Boost_UNIT_TEST_FRAMEWORK_FOUND)
IF(Boost_UNIT_TEST_FRAMEWORK_FOUND AND DOOCS_FOUND AND mtca4u-doocsServerTestHelper_FOUND)
set(TESTING_IS_ENABLED "true")
ENABLE_TESTING()
ELSE(Boost_UNIT_TEST_FRAMEWORK_FOUND)
message("Boost unit_test_framework not found, disabling testing")
ENDIF(Boost_UNIT_TEST_FRAMEWORK_FOUND)
ELSE()
message(" One of the following packages was not found, so testing will be disabled:")
message(" * BOOST unit_test_framework")
message(" * DOOCS server lib")
message(" * mtca4u-doocsServerTestHelper")
ENDIF()
# Moderate version of the compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -Wextra -ansi -Wuninitialized ${mtca4u-deviceaccess_CXX_FLAGS} -O3")
# 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
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-dynamic ${mtca4u-deviceaccess_LINK_FLAGS}")
include_directories(${CMAKE_SOURCE_DIR}/include)
set(${PROJECT_NAME}_INCLUDE_DIRS ${${PROJECT_NAME}_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include/)
......@@ -59,11 +78,8 @@ MACRO( COPY_MAPPING_FILES )
endforeach( FILE_TO_COPY )
ENDMACRO( COPY_MAPPING_FILES )
#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.
# Create the executables for automated unit testing.
if(TESTING_IS_ENABLED)
# COPY_MAPPING_FILES()
aux_source_directory(${CMAKE_SOURCE_DIR}/tests/executables_src testExecutables)
foreach( testExecutableSrcFile ${testExecutables})
......@@ -87,15 +103,28 @@ if(TESTING_IS_ENABLED)
endif(TESTING_IS_ENABLED)
# build example
if(TESTING_IS_ENABLED)
add_executable(InstaCoSADevExample_server example/InstaCoSADevExample_server.cc)
set_target_properties(InstaCoSADevExample_server PROPERTIES COMPILE_FLAGS "${mtca4u-deviceaccess_CXX_FLAGS} ${DOOCS_CXX_FLAGS}")
set_target_properties(InstaCoSADevExample_server PROPERTIES LINK_FLAGS ${DOOCS_LINK_FLAGS})
target_link_libraries(InstaCoSADevExample_server ${PROJECT_NAME} ${mtca4u-deviceaccess_LIBRARIES} ${ControlSystemAdapter-DoocsAdapter_LIBRARIES} ${DOOCS_LIBRARIES})
# copy config file
FILE( COPY ${CMAKE_SOURCE_DIR}/example/InstaCoSADevExample_server.conf DESTINATION ${PROJECT_BINARY_DIR})
FILE( COPY ${CMAKE_SOURCE_DIR}/example/dummy.dmap DESTINATION ${PROJECT_BINARY_DIR})
FILE( COPY ${CMAKE_SOURCE_DIR}/example/dummy.xlmap DESTINATION ${PROJECT_BINARY_DIR})
endif(TESTING_IS_ENABLED)
# C++ library
add_library(${PROJECT_NAME} SHARED ${library_sources} )
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${${PROJECT_NAME}_FULL_LIBRARY_VERSION} SOVERSION ${${PROJECT_NAME}_SOVERSION})
target_link_libraries(${PROJECT_NAME} ${mtca4u-deviceaccess_LIBRARIES})
# do not remove runtime path of the library when installing
set_property(TARGET ${PROJECT_NAME} PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
#configure a header file which contains the version information for use in C++
#configure_file(cmake/version.h.in "${PROJECT_BINARY_DIR}/version.h" @ONLY)
# do not remove runtime path of the library when installing
set_property(TARGET ${PROJECT_NAME} PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
# add a target to generate API documentation with Doxygen
find_package(Doxygen)
......@@ -108,25 +137,17 @@ if(DOXYGEN_FOUND)
)
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/ DESTINATION share/doc/${PROJECT_NAME}-${${PROJECT_NAME}_SOVERSION})
else(DOXYGEN_FOUND)
message("Doxygen not found, documentation will not be build.")
message("Doxygen not found, documentation will not be built.")
endif(DOXYGEN_FOUND)
# Install the library and the executables
install( TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib )
#Install the library and the executables
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
)
#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.
# 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/mtca4u/InstaCoSADev
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
PATTERN "${PROJECT_NAME}" EXCLUDE
)
FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "${PROJECT_NAME}" EXCLUDE )
set(${PROJECT_NAME}_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include")
set(${PROJECT_NAME}_LIBRARIES "${PROJECT_NAME}")
......
#include <DoocsAdapter.h>
#include <ControlSystemAdapter-DoocsAdapter/DoocsAdapter.h>
// Include all the control applications you want in this server
#include "IndependentControlCore.h"
......
#define the dependeny locations here
DOOCSROOT = /export/doocs
# to define DOOCSROOT as an absolute path
include $(DOOCSROOT)/$(DOOCSARCH)/DEFINEDOOCSROOT
# to define the arch dependend things
include $(DOOCSROOT)/$(DOOCSARCH)/CONFIG
#include /usr/share/mtca4u/ControlSystemAdapter.CONFIG
include /space/mhier/builddirs/u14/ControlSystemAdapter/ControlSystemAdapter.CONFIG
CPPFLAGS += $(ControlSystemAdapter_INCLUDE_FLAGS)
LDFLAGS += $(ControlSystemAdapter_LIB_FLAGS) $(ControlSystemAdapter_RUNPATH_FLAGS)
CPPFLAGS += `mtca4uInstaCoSADev-config --cppflags`
LDFLAGS += `mtca4uInstaCoSADev-config --ldflags`
CPPFLAGS += `mtca4u-deviceaccess-config --cppflags`
LDFLAGS += `mtca4u-deviceaccess-config --ldflags`
OBJDIR = $(DOOCSROOT)/$(DOOCSARCH)/obj/server/test/InstaCoSADevExample
SRCDIR = $(PWD)
ADAPTER_OBJDIR = $(DOOCSROOT)/$(DOOCSARCH)/obj/library/common/DoocsAdapter
SOURCEOBJ = $(OBJDIR)/InstaCoSADevExample_server.o
SOURCEHFILES =
ALLPROGS = $(OBJDIR)/InstaCoSADevExample_server
CPPFLAGS += -I/space/mhier/builddirs/u14/DOOCS_Adapter/include
#include ../CPP_DEBUG_FLAGS.CONFIG
BOOST_MPL_FLAGS=-DFUSION_MAX_VECTOR_SIZE=30 -DBOOST_MPL_LIMIT_VECTOR_SIZE=30 -DFUSION_MAX_DEQUE_SIZE=30 -DFUSION_MAX_MAP_SIZE=30 -DBOOST_FUSION_DONT_USE_PREPROCESSED_FILES -DBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
CPPFLAGS += $(BOOST_MPL_FLAGS) -std=c++11
CPPFLAGS += -Wall -Wextra -Wshadow -pedantic -Wuninitialized $(CPP_DEBUG_FLAGS)
CPPFLAGS += -I../include -I../example -Iinclude -isystem/local/lib/include
LDFLAGS += -lboost_thread -lboost_system
#link the adapter with runpath, so it is found at execution time
LDFLAGS += -L$(ADAPTER_OBJDIR) -lDoocsAdapter -Wl,-rpath=$(ADAPTER_OBJDIR),--enable-new-dtags
all: $(ALLPROGS)
$(OBJDIR)/.depend depend:
@if [ ! -f $(OBJDIR) ] ; then \
echo ---------- create dir $(OBJDIR) --------------; \
mkdir -p $(OBJDIR) ; \
fi
for i in $(SRCDIR)/*.cc ;do $(CCDEP) $$i ;done > $(OBJDIR)/.depend_temp
cat $(OBJDIR)/.depend_temp | sed -e "/:/s/^/\$$\(OBJDIR\)\//g" > $(OBJDIR)/.depend
chmod g+w $(OBJDIR)/.depend*
include $(OBJDIR)/.depend
$(OBJDIR)/InstaCoSADevExample_server: $(SOURCEOBJ)
$(LINK.cc) \
-o $(OBJDIR)/InstaCoSADevExample_server $(SOURCEOBJ) \
-lEqServer -lDOOCSapi \
$(LDFLAGS) $(LDLIBS)
@chmod g+w $(OBJDIR)/InstaCoSADevExample_server
@echo "---------------- $(OBJDIR)/InstaCoSADevExample_server done---------------"
static $(OBJDIR)/static_InstaCoSADevExample_server: $(SOURCEOBJ)
$(LINK.cc.static) $(LDFLAGS) -o $(OBJDIR)/static_InstaCoSADevExample_server $(SOURCEOBJ) \
-lEqServer -lDOOCSapi \
$(LDLIBS)
@chmod g+w $(OBJDIR)/static_InstaCoSADevExample_server
@echo "----------------$(OBJDIR)/static_InstaCoSADevExample_server done---------------"
clean:
rm -f $(SOURCEOBJ) $(OBJDIR)/*.o $(OBJDIR)/cosade_server $(OBJDIR)/.depend* *.gcda *.gcno
test: $(OBJDIR)/CTestTestfile.cmake
(cd $(OBJDIR); ctest)
$(OBJDIR)/CTestTestfile.cmake: CTestTestfile.cmake.in
cat $< | sed "{s|@__OBJDIR__@|$(OBJDIR)|}" > $@
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment