Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit c59fe7f

Browse files
bourtembIgor Khokhriakov
authored andcommitted
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.
1 parent ee6d32b commit c59fe7f

File tree

5 files changed

+49
-31
lines changed

5 files changed

+49
-31
lines changed

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.0)
22
project(libtango)
33
include(CTest)
44

@@ -20,7 +20,8 @@ include(configure/CMakeLists.txt)
2020
include_directories(cppapi/client)
2121
include_directories(cppapi/client/helpers)
2222
include_directories(cppapi/server)
23-
include_directories(cppapi/server/idl)
23+
#required for idl/tango.h
24+
include_directories(${CMAKE_CURRENT_BINARY_DIR}/cppapi/server)
2425
include_directories(log4tango/include)
2526
#required for generated config.h
2627
include_directories(${CMAKE_CURRENT_BINARY_DIR}/log4tango/include)
@@ -54,3 +55,10 @@ configure_file(tango.pc.cmake tango.pc @ONLY)
5455

5556
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tango.pc"
5657
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig")
58+
59+
# This is a convenient target to be able to test the installation part from CLion IDE
60+
# Just select the install_libtango target and build (not execute) this target
61+
# This will do the equivalent of make install from CLion
62+
add_custom_target(install_${PROJECT_NAME}
63+
$(MAKE) install
64+
COMMENT "Installing ${PROJECT_NAME}")

cppapi/client/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@ add_subdirectory(helpers)
6060

6161
add_library(client_objects OBJECT ${SOURCES})
6262
target_compile_options(client_objects PRIVATE -fPIC)
63+
add_dependencies(client_objects idl_objects)
6364

64-
install(FILES ${HEADERS} DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
65+
install(FILES ${HEADERS} DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}")

cppapi/server/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,6 @@ add_subdirectory(jpeg_mmx)
137137

138138
add_library(server_objects OBJECT ${SOURCES})
139139
target_compile_options(server_objects PRIVATE -fPIC)
140+
add_dependencies(server_objects idl_objects)
140141

141-
install(FILES ${HEADERS} DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
142+
install(FILES ${HEADERS} DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}")

cppapi/server/idl/CMakeLists.txt

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,15 @@
1-
message("Generate tango.h, tangoSK.cpp and tangoDybSK.cpp from idl")
2-
3-
message("Using OMNIIDL_PATH=${OMNIIDL_PATH}")
4-
message("Using IDL=${IDL_PKG_INCLUDE_DIRS}")
5-
6-
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
7-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
8-
RESULT_VARIABLE FAILED)
9-
10-
if(${FAILED})
11-
message(SEND_ERROR " Failed to generate source files from idl. rv=${FAILED}")
12-
endif()
13-
14-
FILE(GLOB ENHANCEMENTS Enhance*)
15-
16-
foreach(ENHANCEMENT ${ENHANCEMENTS})
17-
message("Applying enhancement ${ENHANCEMENT}")
18-
execute_process(COMMAND sed -i -f ${ENHANCEMENT} tango.h
19-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
20-
RESULT_VARIABLE FAILED)
21-
22-
#non-zero
23-
if(${FAILED})
24-
message(SEND_ERROR " Failed to apply ${ENHANCEMENT}. rv=${FAILED}")
25-
endif()
26-
endforeach(ENHANCEMENT)
1+
add_custom_command(
2+
OUTPUT tango.h tangoSK.cpp tangoDynSK.cpp
3+
COMMAND ${CMAKE_COMMAND} -DOMNIIDL_PATH=${OMNIIDL_PATH} -DIDL_PKG_INCLUDE_DIRS=${IDL_PKG_INCLUDE_DIRS}
4+
-DCMAKE_INSTALL_FULL_INCLUDEDIR=${CMAKE_INSTALL_FULL_INCLUDEDIR} -DPATCHES_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/generate/CMakeLists.txt
5+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
6+
)
277

288
set(SOURCES tangoSK.cpp
299
tangoDynSK.cpp)
3010

3111
add_library(idl_objects OBJECT ${SOURCES} tango.h)
3212
target_compile_options(idl_objects PRIVATE -fPIC)
3313

34-
install(FILES tango.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/idl")
14+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tango.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/idl")
15+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
message("Generate tango.h, tangoSK.cpp and tangoDybSK.cpp from idl")
2+
message("Using OMNIIDL_PATH=${OMNIIDL_PATH}")
3+
message("Using IDL=${IDL_PKG_INCLUDE_DIRS}")
4+
5+
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
6+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
7+
RESULT_VARIABLE FAILED)
8+
9+
if(${FAILED})
10+
message(SEND_ERROR " Failed to generate source files from idl. rv=${FAILED}")
11+
endif()
12+
13+
message("Using PATCHES_SOURCE_DIR=${PATCHES_SOURCE_DIR}")
14+
15+
FILE(GLOB ENHANCEMENTS ${PATCHES_SOURCE_DIR}/Enhance*)
16+
17+
foreach(ENHANCEMENT ${ENHANCEMENTS})
18+
message("Applying enhancement ${ENHANCEMENT}")
19+
execute_process(COMMAND sed -i -f ${ENHANCEMENT} tango.h
20+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
21+
RESULT_VARIABLE FAILED)
22+
#non-zero
23+
if(${FAILED})
24+
message(SEND_ERROR " Failed to apply ${ENHANCEMENT}. rv=${FAILED}")
25+
endif()
26+
endforeach(ENHANCEMENT)
27+

0 commit comments

Comments
 (0)