From 5a7e1045d01f3ad82d16bc2349d962888f78a935 Mon Sep 17 00:00:00 2001 From: Reynald Bourtembourg Date: Wed, 7 Dec 2016 17:27:40 +0100 Subject: [PATCH] Generates files from IDL only at compile time if necessary. (Before it was done when executing cmake, leading to tango.h which could be patched several times and causing compilation errors). The files generated from the IDL are now generated in CMAKE_CURRENT_BINARY_DIR because they could depend on the version of omniORB used by the current config. CMake minimum required version is now 3.0 instead of 2.8. (CMake was failing with 2.8.11 version). Added install_libtango custom target to be able to test the installation part from CLion IDE. --- CMakeLists.txt | 12 ++++++-- cppapi/client/CMakeLists.txt | 3 +- cppapi/server/CMakeLists.txt | 3 +- cppapi/server/idl/CMakeLists.txt | 35 ++++++----------------- cppapi/server/idl/generate/CMakeLists.txt | 27 +++++++++++++++++ 5 files changed, 49 insertions(+), 31 deletions(-) create mode 100644 cppapi/server/idl/generate/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 45e7cc6a0..c2f904520 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.0) project(libtango) include(CTest) @@ -20,7 +20,8 @@ include(configure/CMakeLists.txt) include_directories(cppapi/client) include_directories(cppapi/client/helpers) include_directories(cppapi/server) -include_directories(cppapi/server/idl) +#required for idl/tango.h +include_directories(${CMAKE_CURRENT_BINARY_DIR}/cppapi/server) include_directories(log4tango/include) #required for generated config.h include_directories(${CMAKE_CURRENT_BINARY_DIR}/log4tango/include) @@ -54,3 +55,10 @@ configure_file(tango.pc.cmake tango.pc @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tango.pc" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig") + +# This is a convenient target to be able to test the installation part from CLion IDE +# Just select the install_libtango target and build (not execute) this target +# This will do the equivalent of make install from CLion +add_custom_target(install_${PROJECT_NAME} + $(MAKE) install + COMMENT "Installing ${PROJECT_NAME}") \ No newline at end of file diff --git a/cppapi/client/CMakeLists.txt b/cppapi/client/CMakeLists.txt index 24c892043..5f1581fae 100644 --- a/cppapi/client/CMakeLists.txt +++ b/cppapi/client/CMakeLists.txt @@ -60,5 +60,6 @@ add_subdirectory(helpers) add_library(client_objects OBJECT ${SOURCES}) target_compile_options(client_objects PRIVATE -fPIC) +add_dependencies(client_objects idl_objects) -install(FILES ${HEADERS} DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") \ No newline at end of file +install(FILES ${HEADERS} DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") diff --git a/cppapi/server/CMakeLists.txt b/cppapi/server/CMakeLists.txt index ec31e6640..19b0293d3 100644 --- a/cppapi/server/CMakeLists.txt +++ b/cppapi/server/CMakeLists.txt @@ -137,5 +137,6 @@ add_subdirectory(jpeg_mmx) add_library(server_objects OBJECT ${SOURCES}) target_compile_options(server_objects PRIVATE -fPIC) +add_dependencies(server_objects idl_objects) -install(FILES ${HEADERS} DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") \ No newline at end of file +install(FILES ${HEADERS} DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") diff --git a/cppapi/server/idl/CMakeLists.txt b/cppapi/server/idl/CMakeLists.txt index 6b400700a..2ac75729b 100644 --- a/cppapi/server/idl/CMakeLists.txt +++ b/cppapi/server/idl/CMakeLists.txt @@ -1,29 +1,9 @@ -message("Generate tango.h, tangoSK.cpp and tangoDybSK.cpp from idl") - -message("Using OMNIIDL_PATH=${OMNIIDL_PATH}") -message("Using IDL=${IDL_PKG_INCLUDE_DIRS}") - -execute_process(COMMAND ${OMNIIDL_PATH}omniidl -I${IDL_PKG_INCLUDE_DIRS} -bcxx -Wbh=.h -Wbs=SK.cpp -Wbd=DynSK.cpp -Wba ${IDL_PKG_INCLUDE_DIRS}/tango.idl - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE FAILED) - -if(${FAILED}) - message(SEND_ERROR " Failed to generate source files from idl. rv=${FAILED}") -endif() - -FILE(GLOB ENHANCEMENTS Enhance*) - -foreach(ENHANCEMENT ${ENHANCEMENTS}) - message("Applying enhancement ${ENHANCEMENT}") - execute_process(COMMAND sed -i -f ${ENHANCEMENT} tango.h - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE FAILED) - - #non-zero - if(${FAILED}) - message(SEND_ERROR " Failed to apply ${ENHANCEMENT}. rv=${FAILED}") - endif() -endforeach(ENHANCEMENT) +add_custom_command( + OUTPUT tango.h tangoSK.cpp tangoDynSK.cpp + COMMAND ${CMAKE_COMMAND} -DOMNIIDL_PATH=${OMNIIDL_PATH} -DIDL_PKG_INCLUDE_DIRS=${IDL_PKG_INCLUDE_DIRS} + -DCMAKE_INSTALL_FULL_INCLUDEDIR=${CMAKE_INSTALL_FULL_INCLUDEDIR} -DPATCHES_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/generate/CMakeLists.txt + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) set(SOURCES tangoSK.cpp tangoDynSK.cpp) @@ -31,4 +11,5 @@ set(SOURCES tangoSK.cpp add_library(idl_objects OBJECT ${SOURCES} tango.h) target_compile_options(idl_objects PRIVATE -fPIC) -install(FILES tango.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/idl") +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tango.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/idl") + diff --git a/cppapi/server/idl/generate/CMakeLists.txt b/cppapi/server/idl/generate/CMakeLists.txt new file mode 100644 index 000000000..c0ab4faa8 --- /dev/null +++ b/cppapi/server/idl/generate/CMakeLists.txt @@ -0,0 +1,27 @@ +message("Generate tango.h, tangoSK.cpp and tangoDybSK.cpp from idl") +message("Using OMNIIDL_PATH=${OMNIIDL_PATH}") +message("Using IDL=${IDL_PKG_INCLUDE_DIRS}") + +execute_process(COMMAND ${OMNIIDL_PATH}omniidl -I${IDL_PKG_INCLUDE_DIRS} -bcxx -Wbh=.h -Wbs=SK.cpp -Wbd=DynSK.cpp -Wba ${IDL_PKG_INCLUDE_DIRS}/tango.idl + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + RESULT_VARIABLE FAILED) + +if(${FAILED}) + message(SEND_ERROR " Failed to generate source files from idl. rv=${FAILED}") +endif() + +message("Using PATCHES_SOURCE_DIR=${PATCHES_SOURCE_DIR}") + +FILE(GLOB ENHANCEMENTS ${PATCHES_SOURCE_DIR}/Enhance*) + +foreach(ENHANCEMENT ${ENHANCEMENTS}) + message("Applying enhancement ${ENHANCEMENT}") + execute_process(COMMAND sed -i -f ${ENHANCEMENT} tango.h + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + RESULT_VARIABLE FAILED) + #non-zero + if(${FAILED}) + message(SEND_ERROR " Failed to apply ${ENHANCEMENT}. rv=${FAILED}") + endif() +endforeach(ENHANCEMENT) +