summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandar Donchev <Aleksander.Donchev@partner.bmw.de>2014-02-12 13:57:34 (GMT)
committerChristian Linke <christian.linke@bmw.de>2014-03-28 15:48:02 (GMT)
commit0717ec147195b11fdf23f8326211b97b6ac9b283 (patch)
tree5d50dabaf8086ac17802fc6c8c4872b783065095
parent0360f3d41beb1f66bfbfddf16a9727f4368b75f5 (diff)
downloadaudiomanager-0717ec147195b11fdf23f8326211b97b6ac9b283.tar.gz
* Support for automatically generation of common-api sources. Cmake macros adopted to support the common-api generator.
Signed-off-by: Christian Linke <christian.linke@bmw.de>
-rw-r--r--AudioManagerDaemon/CMakeLists.txt12
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CMakeLists.txt8
-rwxr-xr-xCMakeLists.txt2
-rw-r--r--PluginCommandInterfaceCAPI/CMakeLists.txt15
-rw-r--r--PluginCommandInterfaceCAPI/test/CMakeLists.txt27
-rw-r--r--PluginRoutingInterfaceCAPI/CMakeLists.txt16
-rw-r--r--PluginRoutingInterfaceCAPI/test/CMakeLists.txt24
-rwxr-xr-xcmake/CommonAPIGenerator.cmake167
-rw-r--r--cmake/FindCommonAPI.cmake77
-rw-r--r--cmake/FindCommonAPI_DBus.cmake60
10 files changed, 258 insertions, 150 deletions
diff --git a/AudioManagerDaemon/CMakeLists.txt b/AudioManagerDaemon/CMakeLists.txt
index 92eea26..2ee16f5 100644
--- a/AudioManagerDaemon/CMakeLists.txt
+++ b/AudioManagerDaemon/CMakeLists.txt
@@ -46,7 +46,6 @@ FIND_PACKAGE(NSM REQUIRED)
IF(WITH_CAPI_WRAPPER)
FIND_PACKAGE(CommonAPI REQUIRED)
- FIND_PACKAGE(CommonAPI_DBus REQUIRED)
ENDIF(WITH_CAPI_WRAPPER)
SET(AUDIOMAN_SRCS_CXX
@@ -156,6 +155,17 @@ INCLUDE_DIRECTORIES(
)
IF(WITH_CAPI_WRAPPER)
+
+# Find the common-api sources.
+# The sources can be placed in the build directory (DESTINATION) or in the source tree (ALT_DESTINATION).
+# The ALT_DESTINATION is used as fall back if the DESTINATION directory dosen't contain the sources or you just don't want to use the generator.
+INCLUDE(CommonAPIGenerator)
+COMMON_API_GENERATE_SOUCRES(TARGET COMMON_API
+ FIDLS fidls/NodeStateManager.fdepl # a list with fidls
+ DESTINATION src-gen # a relative path to the build directory or an absolute path
+ ALT_DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/src-gen # an alternative relative/absolute path with common-api sources, usually in the source tree
+ DBUS)
+
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
${COMMON_API_INCLUDE_DIRS}
${COMMON_API_DBUS_INCLUDE_DIRS}
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CMakeLists.txt b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CMakeLists.txt
index 862f3fc..d317b62 100644
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CMakeLists.txt
@@ -27,14 +27,8 @@ set(EXECUTABLE_OUTPUT_PATH ${TEST_EXECUTABLE_OUTPUT_PATH})
FIND_PACKAGE(Threads)
FIND_PACKAGE(PkgConfig)
-pkg_check_modules(SQLITE REQUIRED sqlite3)
-
FIND_PACKAGE(CommonAPI REQUIRED)
-FIND_PACKAGE(CommonAPI_DBus REQUIRED)
-
-
-#grab the parent source gen folder, instead of making a copy for the tests
-FILE(GLOB_RECURSE COMMON_API_GEN_SOURCES "../../src-gen/*.cpp")
+pkg_check_modules(SQLITE REQUIRED sqlite3)
IF(WITH_DLT)
pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 24baa47..3e70e4f 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,6 +94,8 @@ OPTION ( WITH_NSM
OPTION ( WITH_DATABASE_STORAGE
"build with sqlite as in memory storage" OFF)
+
+SET (WITH_COMMON_API_GEN ON CACHE INTERNAL "hide this!" FORCE)
IF (WITH_ENABLED_IPC STREQUAL "DBUS")
SET (WITH_DBUS_WRAPPER ON CACHE INTERNAL "hide this!" FORCE)
diff --git a/PluginCommandInterfaceCAPI/CMakeLists.txt b/PluginCommandInterfaceCAPI/CMakeLists.txt
index c30c009..50224d4 100644
--- a/PluginCommandInterfaceCAPI/CMakeLists.txt
+++ b/PluginCommandInterfaceCAPI/CMakeLists.txt
@@ -45,7 +45,16 @@ set(COMMAND_INTERFACE_DBUS_CONF ${COMMAND_INTERFACE_DBUS_CONF} PARENT_SCOPE)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake ${CMAKE_CURRENT_SOURCE_DIR}/include/configCommandCAPI.h )
FIND_PACKAGE(CommonAPI REQUIRED)
-FIND_PACKAGE(CommonAPI_DBus REQUIRED)
+
+# Find the common-api sources.
+# The sources can be placed in the build directory (DESTINATION) or in the source tree (ALT_DESTINATION).
+# The ALT_DESTINATION is used as fall back if the DESTINATION directory dosen't contain the sources or you just don't want to use the generator.
+INCLUDE(CommonAPIGenerator)
+COMMON_API_GENERATE_SOUCRES(TARGET COMMON_API_COMMAND_INTERFACE
+ FIDLS fidl/CommandInterface.fidl # a list with fidls
+ DESTINATION src-gen # a relative path to the build directory or an absolute path
+ ALT_DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/src-gen # an alternative relative/absolute path with common-api sources, usually in the source tree
+ DBUS)
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}
@@ -55,12 +64,12 @@ INCLUDE_DIRECTORIES(
${DLT_INCLUDE_DIRS}
${COMMON_API_INCLUDE_DIRS}
${COMMON_API_DBUS_INCLUDE_DIRS}
- ${COMMON_API_GEN_INCLUDE_DIR}
+ ${COMMON_API_COMMAND_INTERFACE_GEN_INCLUDE_DIR}
${INCLUDE_FOLDER}
)
# all source files go here
-file(GLOB PLUGINCAPI_SRCS_CXX "src/*.cpp" ${COMMON_API_GEN_SOURCES})
+file(GLOB PLUGINCAPI_SRCS_CXX "src/*.cpp" ${COMMON_API_COMMAND_INTERFACE_GEN_SOURCES})
add_library(PluginCommandInterfaceCAPI MODULE ${PLUGINCAPI_SRCS_CXX})
diff --git a/PluginCommandInterfaceCAPI/test/CMakeLists.txt b/PluginCommandInterfaceCAPI/test/CMakeLists.txt
index 8dc6bfa..79d0c53 100644
--- a/PluginCommandInterfaceCAPI/test/CMakeLists.txt
+++ b/PluginCommandInterfaceCAPI/test/CMakeLists.txt
@@ -30,8 +30,7 @@ set(EXECUTABLE_OUTPUT_PATH ${TEST_EXECUTABLE_OUTPUT_PATH})
FIND_PACKAGE(Threads)
FIND_PACKAGE(PkgConfig)
FIND_PACKAGE(PythonLibs REQUIRED)
-pkg_check_modules(PC_COMMON REQUIRED CommonAPI)
-pkg_check_modules(PC_COMMON_DBUS REQUIRED CommonAPI-DBus)
+FIND_PACKAGE(CommonAPI REQUIRED)
IF(WITH_DLT)
pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0)
@@ -44,8 +43,9 @@ INCLUDE_DIRECTORIES(
${AUDIO_INCLUDE_FOLDER}
${CMAKE_SOURCE_DIR}
${DLT_INCLUDE_DIRS}
- ${PC_COMMON_INCLUDE_DIRS}
- ${PC_COMMON_DBUS_INCLUDE_DIRS}
+ ${COMMON_API_INCLUDE_DIRS}
+ ${COMMON_API_DBUS_INCLUDE_DIRS}
+ ${COMMON_API_COMMAND_INTERFACE_GEN_INCLUDE_DIR}
${INCLUDE_FOLDER}
${PYTHON_INCLUDE_DIRS}
${GOOGLE_TEST_INCLUDE_DIR}
@@ -56,25 +56,22 @@ INCLUDE_DIRECTORIES(
link_directories(
${LINK_DIRECTORIES}
- ${PC_COMMON_LIBRARY_DIRS}
- ${PC_COMMON_DBUS_LIBRARY_DIRS}
+ ${COMMON_API_LIBRARY_DIRS}
+ ${COMMON_API_DBUS_LIBRARY_DIRS}
)
file(GLOB CAPI_PLUGIN_INTERFACE_SRCS_CXX
"../../AudioManagerDaemon/src/CAmCommonAPIWrapper.cpp"
"../../AudioManagerDaemon/src/CAmSocketHandler.cpp"
- "../../AudioManagerDaemon/src/CAmDltWrapper.cpp"
- "../src/*.cpp"
+ "../../AudioManagerDaemon/src/CAmDltWrapper.cpp"
"CAmCommandSenderCAPITest.cpp"
"CAmTestCAPIWrapper.cpp"
"CAmCommandSenderCommon.cpp"
+ "../src/*.cpp"
+ ${COMMON_API_COMMAND_INTERFACE_GEN_SOURCES}
)
-file(GLOB_RECURSE CAPI_PLUGIN_INTERFACE_GEN_SRCS_CXX
- "../src-gen/*.cpp"
-)
-
-ADD_EXECUTABLE(AmCommandSenderCAPITest ${CAPI_PLUGIN_INTERFACE_SRCS_CXX} ${CAPI_PLUGIN_INTERFACE_GEN_SRCS_CXX})
+ADD_EXECUTABLE(AmCommandSenderCAPITest ${CAPI_PLUGIN_INTERFACE_SRCS_CXX})
TARGET_LINK_LIBRARIES(AmCommandSenderCAPITest
${DLT_LIBRARIES}
@@ -82,8 +79,8 @@ TARGET_LINK_LIBRARIES(AmCommandSenderCAPITest
${CMAKE_THREAD_LIBS_INIT}
${PYTHON_LIBRARY}
${PC_GSTREAMER_LIBRARIES}
- ${PC_COMMON_LIBRARIES}
- ${PC_COMMON_DBUS_LIBRARIES}
+ ${COMMON_API_LIBRARIES}
+ ${COMMON_API_DBUS_LIBRARIES}
gtest
gmock
)
diff --git a/PluginRoutingInterfaceCAPI/CMakeLists.txt b/PluginRoutingInterfaceCAPI/CMakeLists.txt
index e304049..c7b9594 100644
--- a/PluginRoutingInterfaceCAPI/CMakeLists.txt
+++ b/PluginRoutingInterfaceCAPI/CMakeLists.txt
@@ -43,7 +43,16 @@ set(ROUTING_INTERFACE_DBUS_CONF ${ROUTING_INTERFACE_DBUS_CONF} PARENT_SCOPE)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake ${CMAKE_CURRENT_SOURCE_DIR}/include/configRoutingCAPI.h )
FIND_PACKAGE(CommonAPI REQUIRED)
-FIND_PACKAGE(CommonAPI_DBus REQUIRED)
+
+# Find the common-api sources.
+# The sources can be placed in the build directory (DESTINATION) or in the source tree (ALT_DESTINATION).
+# The ALT_DESTINATION is used as fall back if the DESTINATION directory dosen't contain the sources or you just don't want to use the generator.
+INCLUDE(CommonAPIGenerator)
+COMMON_API_GENERATE_SOUCRES(TARGET COMMON_API_ROUTING_INTERFACE
+ FIDLS fidl/RoutingInterface.fidl # a list with fidls
+ DESTINATION src-gen # a relative path to the build directory or an absolute path
+ ALT_DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/src-gen # an alternative relative/absolute path with common-api sources, usually in the source tree
+ DBUS)
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}
@@ -52,13 +61,12 @@ INCLUDE_DIRECTORIES(
${PROJECT_INCLUDE_FOLDER}
${COMMON_API_INCLUDE_DIRS}
${COMMON_API_DBUS_INCLUDE_DIRS}
- ${COMMON_API_GEN_INCLUDE_DIR}
+ ${COMMON_API_ROUTING_INTERFACE_GEN_INCLUDE_DIR}
${INCLUDE_FOLDER}
)
# all source files go here
-file(GLOB PLUGINCAPI_SRCS_CXX "src/*.cpp" ${COMMON_API_GEN_SOURCES})
-
+file(GLOB PLUGINCAPI_SRCS_CXX "src/*.cpp" ${COMMON_API_ROUTING_INTERFACE_GEN_SOURCES})
add_library(PluginRoutingInterfaceCAPI MODULE ${PLUGINCAPI_SRCS_CXX})
diff --git a/PluginRoutingInterfaceCAPI/test/CMakeLists.txt b/PluginRoutingInterfaceCAPI/test/CMakeLists.txt
index 86bbde6..9803dc5 100644
--- a/PluginRoutingInterfaceCAPI/test/CMakeLists.txt
+++ b/PluginRoutingInterfaceCAPI/test/CMakeLists.txt
@@ -30,8 +30,8 @@ set(EXECUTABLE_OUTPUT_PATH ${TEST_EXECUTABLE_OUTPUT_PATH})
FIND_PACKAGE(Threads)
FIND_PACKAGE(PkgConfig)
FIND_PACKAGE(PythonLibs REQUIRED)
-pkg_check_modules(PC_COMMON REQUIRED CommonAPI)
-pkg_check_modules(PC_COMMON_DBUS REQUIRED CommonAPI-DBus)
+FIND_PACKAGE(CommonAPI REQUIRED)
+
IF(WITH_DLT)
pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0)
@@ -44,8 +44,9 @@ INCLUDE_DIRECTORIES(
${AUDIO_INCLUDE_FOLDER}
${CMAKE_SOURCE_DIR}
${DLT_INCLUDE_DIRS}
- ${PC_COMMON_INCLUDE_DIRS}
- ${PC_COMMON_DBUS_INCLUDE_DIRS}
+ ${COMMON_API_INCLUDE_DIRS}
+ ${COMMON_API_DBUS_INCLUDE_DIRS}
+ ${COMMON_API_GEN_INCLUDE_DIR}
${INCLUDE_FOLDER}
${PYTHON_INCLUDE_DIRS}
${GOOGLE_TEST_INCLUDE_DIR}
@@ -56,8 +57,8 @@ INCLUDE_DIRECTORIES(
link_directories(
${LINK_DIRECTORIES}
- ${PC_COMMON_LIBRARY_DIRS}
- ${PC_COMMON_DBUS_LIBRARY_DIRS}
+ ${COMMON_API_LIBRARY_DIRS}
+ ${COMMON_API_DBUS_LIBRARY_DIRS}
)
file(GLOB CAPI_PLUGIN_INTERFACE_SRCS_CXX
@@ -70,10 +71,7 @@ file(GLOB CAPI_PLUGIN_INTERFACE_SRCS_CXX
"CAmCommandSenderCommon.cpp"
"CAmRoutingSenderService.cpp"
"IAmRoutingSenderBackdoor.cpp"
-)
-
-file(GLOB_RECURSE CAPI_PLUGIN_INTERFACE_GEN_SRCS_CXX
- "../src-gen/*.cpp"
+ ${COMMON_API_ROUTING_INTERFACE_GEN_SOURCES}
)
set (CAPI_SENDER_INTERFACE "org.genivi.audiomanager.routingsender")
@@ -93,7 +91,7 @@ set (CAPI_ROUTING_INSTANCE_H "\"${CAPI_ROUTING_INSTANCE}\"")
set (CAPI_ROUTING_PATH_H "\"${CAPI_ROUTING_PATH}\"")
-ADD_EXECUTABLE(AmRoutingInterfaceCAPITests ${CAPI_PLUGIN_INTERFACE_SRCS_CXX} ${CAPI_PLUGIN_INTERFACE_GEN_SRCS_CXX})
+ADD_EXECUTABLE(AmRoutingInterfaceCAPITests ${CAPI_PLUGIN_INTERFACE_SRCS_CXX})
TARGET_LINK_LIBRARIES(AmRoutingInterfaceCAPITests
${DLT_LIBRARIES}
@@ -101,8 +99,8 @@ TARGET_LINK_LIBRARIES(AmRoutingInterfaceCAPITests
${CMAKE_THREAD_LIBS_INIT}
${PYTHON_LIBRARY}
${PC_GSTREAMER_LIBRARIES}
- ${PC_COMMON_LIBRARIES}
- ${PC_COMMON_DBUS_LIBRARIES}
+ ${COMMON_API_LIBRARIES}
+ ${COMMON_API_DBUS_LIBRARIES}
gtest
gmock
)
diff --git a/cmake/CommonAPIGenerator.cmake b/cmake/CommonAPIGenerator.cmake
new file mode 100755
index 0000000..1deba53
--- /dev/null
+++ b/cmake/CommonAPIGenerator.cmake
@@ -0,0 +1,167 @@
+#
+# Find common-api sources
+#
+# This module defines these variables:
+#
+# ${PARAMS_TARGET}_GEN_HEADERS
+# A list with generated headers
+# ${PARAMS_TARGET}_GEN_SOURCES
+# A list with generated sources
+# ${PARAMS_TARGET}_GEN_INCLUDE_DIR
+# A list with include directories
+
+include(CMakeParseArguments)
+
+IF(COMMON_API_FOUND AND COMMON_API_DBUS_FOUND)
+ # get lists with headers and sources after they has been generated
+ macro(SEARCH_FOR_COMMON_API_GEN_FILES GEN_DESTINATION)
+
+ #searching for generated headers
+ execute_process(COMMAND find ${GEN_DESTINATION} -name *.h
+ RESULT_VARIABLE EXIT_CODE
+ OUTPUT_VARIABLE _CAPI_HEADERS
+ ERROR_VARIABLE CAPI_HEADERS_ERROR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE)
+
+ IF(CAPI_HEADERS_ERROR)
+ MESSAGE(FATAL_ERROR "Can't find common-api generated headers!")
+ ENDIF()
+ string(REPLACE "\n" ";" CAPI_HEADERS ${_CAPI_HEADERS})
+
+ FOREACH(INCLUDE_ITER ${CAPI_HEADERS})
+ GET_FILENAME_COMPONENT(TEMP_PATH ${INCLUDE_ITER} PATH)
+ SET(CAPI_INCLUDES ${CAPI_INCLUDES} ${TEMP_PATH})
+ ENDFOREACH(INCLUDE_ITER ${CAPI_HEADERS})
+ LIST(REMOVE_DUPLICATES CAPI_INCLUDES)
+
+ #searching for generated sources
+ execute_process(COMMAND find ${GEN_DESTINATION} -name *.cpp
+ RESULT_VARIABLE EXIT_CODE
+ OUTPUT_VARIABLE _CAPI_SOURCES
+ ERROR_VARIABLE CAPI_SOURCES_ERROR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE)
+ IF(CAPI_SOURCES_ERROR)
+ MESSAGE(FATAL_ERROR "Can't find common-api generated sources!")
+ ENDIF()
+ string(REPLACE "\n" ";" CAPI_SOURCES ${_CAPI_SOURCES})
+ LIST(REMOVE_DUPLICATES CAPI_SOURCES)
+
+ set(${PARAMS_TARGET}_GEN_HEADERS ${CAPI_HEADERS} PARENT_SCOPE)
+ set(${PARAMS_TARGET}_GEN_SOURCES ${CAPI_SOURCES} PARENT_SCOPE)
+
+ #add base path src-gen
+ SET(${PARAMS_TARGET}_GEN_INCLUDE_DIR ${CAPI_INCLUDES} ${GEN_DESTINATION} PARENT_SCOPE)
+ endmacro()
+
+ # generate common-api sources and retreive a list with them
+ macro(GENERATE_FILES)
+ # searching for common-api-generator executable ...
+ FIND_PATH(COMMONAPI_GENERATOR_JAR
+ NAMES
+ "common-api-generator.jar"
+ PATH_SUFFIXES
+ CommonAPI-${COMMON_API_VERSION}
+ PATHS
+ "/usr/share"
+ "/usr/local/share")
+ if(COMMONAPI_GENERATOR_JAR)
+ # load java runtime ...
+ find_package(Java COMPONENTS Runtime REQUIRED QUIET)
+ function(mktmpdir OUTVAR)
+ while(NOT TEMP_DESTINATION OR EXISTS ${TEMP_DESTINATION})
+ string(RANDOM LENGTH 16 TEMP_DESTINATION)
+ set(TEMP_DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/${TEMP_DESTINATION}")
+ endwhile()
+
+ file(MAKE_DIRECTORY ${TEMP_DESTINATION})
+
+ set(${OUTVAR} ${TEMP_DESTINATION} PARENT_SCOPE)
+ endfunction()
+ # execute the generate command ...
+ execute_process(COMMAND ${Java_JAVA_EXECUTABLE} -jar "${COMMONAPI_GENERATOR_JAR}/common-api-generator.jar" -dest ${PARAMS_DESTINATION} ${ARGS} ${FIDLS}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ RESULT_VARIABLE EXIT_CODE
+ OUTPUT_VARIABLE GENERATOR_OUTPUT
+ ERROR_VARIABLE GENERATOR_OUTPUT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE)
+ if(EXIT_CODE)
+ message(FATAL_ERROR "Failed to generate files from FIDL:\n ${GENERATOR_OUTPUT}")
+ endif()
+ SET(TEMP_GEN_DST ${PARAMS_DESTINATION})
+ else()
+ # if the generator is not found, try to find the sources in the alternative folder
+ SET(TEMP_GEN_DST ${PARAMS_ALT_DESTINATION})
+ message(STATUS "Couldn't find a common-api generator...skiping generation!")
+ endif()
+ # get the lists with the sources and headers
+ message(STATUS "Looking for available common-api generated files...")
+ SEARCH_FOR_COMMON_API_GEN_FILES(${TEMP_GEN_DST})
+ endmacro()
+
+ function(COMMON_API_GENERATE_SOUCRES)
+ #parse the input parameters
+ set(options DBUS)
+ set(oneValueArgs TARGET DESTINATION ALT_DESTINATION HEADER_TEMPLATE)
+ set(multiValueArgs FIDLS FIDL_DEPENDS)
+
+ cmake_parse_arguments(PARAMS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if(NOT IS_ABSOLUTE ${PARAMS_DESTINATION})
+ set(PARAMS_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${PARAMS_DESTINATION})
+ endif()
+
+ if(NOT IS_ABSOLUTE ${PARAMS_ALT_DESTINATION})
+ set(PARAMS_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${PARAMS_ALT_DESTINATION})
+ endif()
+ # check the cmake option, whether to use the generator or not ...
+ IF(NOT WITH_COMMON_API_GEN)
+ message(STATUS "Looking for available common-api generated files...")
+ # check which of the given folders exists and get it as destination
+ IF(EXISTS ${PARAMS_DESTINATION})
+ SEARCH_FOR_COMMON_API_GEN_FILES(${PARAMS_DESTINATION})
+ ELSE()
+ SEARCH_FOR_COMMON_API_GEN_FILES(${PARAMS_ALT_DESTINATION})
+ ENDIF()
+ ELSE()
+ message(STATUS "Will generate common-api files...")
+ if(NOT PARAMS_FIDLS)
+ message(FATAL_ERROR "FIDLS must be specified")
+ endif()
+
+ if(NOT PARAMS_TARGET)
+ message(FATAL_ERROR "TARGET must be specified")
+ endif()
+
+ if(PARAMS_DBUS)
+ list(APPEND ARGS -dbus)
+ endif()
+
+ if(PARAMS_HEADER_TEMPLATE)
+ list(APPEND ARGS -pref ${PARAMS_HEADER_TEMPLATE})
+ endif()
+
+ foreach(FIDL ${PARAMS_FIDLS})
+ get_filename_component(FIDL_PATH ${FIDL} ABSOLUTE)
+
+ # Run configure_file on the .fidl - this forces cmake to reexecute its
+ # configure phase if the input file changes.
+ string(MD5 ${FIDL_PATH} FIDL_CHECKSUM)
+ configure_file(${FIDL_PATH} ${CMAKE_CURRENT_BINARY_DIR}/${FIDL_CHECKSUM}.fidl.done)
+
+ list(APPEND FIDLS ${FIDL_PATH})
+ endforeach()
+
+ message(STATUS "Determining list of generated files for ${PARAMS_FIDLS}")
+
+ foreach(FIDL_DEPEND ${PARAMS_FIDL_DEPENDS})
+ string(MD5 ${FIDL_PATH} FIDL_CHECKSUM)
+ configure_file(${FIDL_PATH} ${CMAKE_CURRENT_BINARY_DIR}/${FIDL_CHECKSUM}.fidl.done)
+ endforeach()
+ GENERATE_FILES()
+ ENDIF()
+ endfunction()
+
+ENDIF(COMMON_API_FOUND AND COMMON_API_DBUS_FOUND)
diff --git a/cmake/FindCommonAPI.cmake b/cmake/FindCommonAPI.cmake
index 3f156a5..958b729 100644
--- a/cmake/FindCommonAPI.cmake
+++ b/cmake/FindCommonAPI.cmake
@@ -7,9 +7,7 @@
include(UsePkgConfig)
pkg_check_modules(COMMON_API CommonAPI)
-
IF(COMMON_API_FOUND)
-
FIND_PATH(COMMON_API_INCLUDE_DIR
NAMES CommonAPI/Runtime.h CommonAPI/Proxy.h
PATH_SUFFIXES CommonAPI-${COMMON_API_VERSION}
@@ -23,63 +21,48 @@ IF(COMMON_API_FOUND)
PATHS
"/usr/local/lib"
"/usr/lib"
- )
-
-ELSE(COMMON_API_FOUND)
-
- MESSAGE(STATUS "CommonAPI package not found, search directly, trying version 0.7 ...")
+ )
+ENDIF(COMMON_API_FOUND)
-
- FIND_PATH(COMMON_API_INCLUDE_DIR
- NAMES CommonAPI/Runtime.h CommonAPI/Proxy.h
- PATH_SUFFIXES CommonAPI-0.7
+pkg_check_modules(COMMON_API_DBUS CommonAPI-DBus)
+IF(COMMON_API_DBUS_FOUND)
+ FIND_PATH(COMMON_API_DBUS_INCLUDE_DIR
+ NAMES CommonAPI/DBus/DBusRuntime.h CommonAPI/DBus/DBusProxy.h
+ PATH_SUFFIXES CommonAPI-${COMMON_API_VERSION}
PATHS
+ ${COMMON_API_DBUS_INCLUDE_DIRS}
"/usr/local/include"
- "/usr/include"
- )
-
- FIND_LIBRARY(COMMON_API_LIBRARY
- NAMES CommonAPI
- PATHS
- "/usr/local/lib"
- "/usr/lib"
- )
-
-ENDIF(COMMON_API_FOUND)
+ "/usr/include")
+
+ FIND_LIBRARY(COMMON_API_DBUS_LIBRARY
+ NAMES CommonAPI-DBus murmurhash-internal
+ PATHS
+ "/usr/local/lib"
+ "/usr/lib"
+ )
+ENDIF(COMMON_API_DBUS_FOUND)
+
SET(COMMON_API_LIBRARIES ${COMMON_API_LIBRARY})
IF(COMMON_API_INCLUDE_DIR AND COMMON_API_LIBRARY)
- message(STATUS "Found CommonAPI")
+ message(STATUS "Found CommonAPI ${COMMON_API_VERSION}")
ELSE(COMMON_API_LIBRARIES AND COMMON_API_LIBRARY)
message(STATUS " CommonAPI not found.")
ENDIF(COMMON_API_INCLUDE_DIR AND COMMON_API_LIBRARY)
-#searching for generated headers
-FILE(GLOB_RECURSE COMMON_API_GEN_HEADER_DIRECTORIES "src-gen/*.h")
-FOREACH(INCLUDE_ITER ${COMMON_API_GEN_HEADER_DIRECTORIES})
- GET_FILENAME_COMPONENT(TEMP_PATH ${INCLUDE_ITER} PATH)
- SET(COMMON_API_GEN_INCLUDE_DIR ${COMMON_API_GEN_INCLUDE_DIR} ${TEMP_PATH})
-ENDFOREACH(INCLUDE_ITER ${COMMON_API_GEN_HEADER_DIRECTORIES})
-LIST(REMOVE_DUPLICATES COMMON_API_GEN_INCLUDE_DIR)
+SET(COMMON_API_DBUS_LIBRARIES ${COMMON_API_DBUS_LIBRARY})
-#add base path src-gen
-SET(COMMON_API_GEN_INCLUDE_DIR ${COMMON_API_GEN_INCLUDE_DIR} "src-gen/")
-
-IF (COMMON_API_GEN_INCLUDE_DIR)
- message(STATUS "Found generated headers !")
-ELSE (COMMON_API_GEN_INCLUDE_DIR)
- message(STATUS "Did not find generated headers")
-ENDIF(COMMON_API_GEN_INCLUDE_DIR)
-
-#searching for generated sources
-FILE(GLOB_RECURSE COMMON_API_GEN_SOURCES "src-gen/*.cpp")
-
-IF (COMMON_API_GEN_SOURCES)
- message(STATUS "Found generated sources !")
-ELSE (COMMON_API_GEN_SOURCES)
- message(STATUS "Did not find generated sources !")
-ENDIF(COMMON_API_GEN_SOURCES)
+IF(COMMON_API_DBUS_INCLUDE_DIR AND COMMON_API_DBUS_LIBRARY)
+ message(STATUS "Found CommonAPI_DBUS")
+ELSE(COMMON_API_DBUS_INCLUDE_DIR AND COMMON_API_DBUS_LIBRARY)
+ message(STATUS " CommonAPI_DBUS not found.")
+ENDIF(COMMON_API_DBUS_INCLUDE_DIR AND COMMON_API_DBUS_LIBRARY)
+
+MARK_AS_ADVANCED(
+ COMMON_API_DBUS_LIBRARIES
+ COMMON_API_DBUS_INCLUDE_DIR
+)
MARK_AS_ADVANCED(
COMMON_API_LIBRARIES
diff --git a/cmake/FindCommonAPI_DBus.cmake b/cmake/FindCommonAPI_DBus.cmake
deleted file mode 100644
index 9ba9e06..0000000
--- a/cmake/FindCommonAPI_DBus.cmake
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Copyright (C) 2012, BMW AG
-#
-# \author Christian Linke
-#
-
-include(UsePkgConfig)
-
-pkg_check_modules(COMMON_API_DBUS CommonAPI-DBus)
-
-IF(COMMON_API_DBUS_FOUND)
-
- FIND_PATH(COMMON_API_DBUS_INCLUDE_DIR
- NAMES CommonAPI/DBus/DBusRuntime.h CommonAPI/DBus/DBusProxy.h
- PATH_SUFFIXES CommonAPI-${COMMON_API_VERSION}
- PATHS
- ${COMMON_API_DBUS_INCLUDE_DIRS}
- "/usr/local/include"
- "/usr/include")
-
- FIND_LIBRARY(COMMON_API_DBUS_LIBRARY
- NAMES CommonAPI-DBus murmurhash-internal
- PATHS
- "/usr/local/lib"
- "/usr/lib"
- )
-
-ELSE(COMMON_API_DBUS_FOUND)
-
- MESSAGE(STATUS "CommonAPI_DBUS package not found, search directly, trying version 0.7 ...")
-
-
- FIND_PATH(COMMON_API_DBUS_INCLUDE_DIR
- NAMES CommonAPI/DBus/DBusRuntime.h CommonAPI/DBus/DBusProxy.h
- PATH_SUFFIXES CommonAPI-0.7
- PATHS
- "/usr/local/include"
- "/usr/include")
-
- FIND_LIBRARY(COMMON_API_DBUS_LIBRARY
- NAMES CommonAPI-DBus
- PATHS
- "/usr/local/lib"
- "/usr/lib"
- NO_SYSTEM_ENVIRONMENT_PATH)
-ENDIF(COMMON_API_DBUS_FOUND)
-
-
-SET(COMMON_API_DBUS_LIBRARIES ${COMMON_API_DBUS_LIBRARY})
-
-IF(COMMON_API_DBUS_INCLUDE_DIR AND COMMON_API_DBUS_LIBRARY)
- message(STATUS "Found CommonAPI_DBUS")
-ELSE(COMMON_API_DBUS_INCLUDE_DIR AND COMMON_API_DBUS_LIBRARY)
- message(STATUS " CommonAPI_DBUS not found.")
-ENDIF(COMMON_API_DBUS_INCLUDE_DIR AND COMMON_API_DBUS_LIBRARY)
-
-MARK_AS_ADVANCED(
- COMMON_API_DBUS_LIBRARIES
- COMMON_API_DBUS_INCLUDE_DIR
-)