summaryrefslogtreecommitdiff
path: root/src/3rd_party/dbus-cmake/CMakeLists.txt
blob: 37528ab6f510c6c8926dcc46ecb137dea7aecca8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Copyright (c) 2014, Ford Motor Company
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with the
# distribution.
#
# Neither the name of the Ford Motor Company nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

set(DBUS_SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../dbus-1.7.8)
set(DBUS_BUILD_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../dbus-build)

set(DBUS_BUILD_DIRECTORY ${DBUS_BUILD_DIRECTORY} PARENT_SCOPE)

set(DBUS_INCLUDE_DIR ${3RD_PARTY_INSTALL_PREFIX}/include)
set(DBUS_INCLUDE_DIR_ARCH ${3RD_PARTY_INSTALL_PREFIX_ARCH}/include)
set(DBUS_INCLUDE_DIRS ${DBUS_INCLUDE_DIR} ${DBUS_INCLUDE_DIR_ARCH})

set(DBUS_INCLUDE_DIRS ${DBUS_INCLUDE_DIRS} PARENT_SCOPE)


file(MAKE_DIRECTORY
  ${DBUS_BUILD_DIRECTORY}
)

set(COMMON_CONFIGURE_FLAGS
  "--enable-tests=no"
  "CFLAGS=-I${EXPAT_INCLUDE_DIRECTORY}"
  "LDFLAGS=-L${EXPAT_LIBS_DIRECTORY}"
)

if(CROSS_HOST)
  set(EXTRA_CONFIGURE_FLAGS
    "--host=${CROSS_HOST}"
  )
else()
  set(EXTRA_CONFIGURE_FLAGS "")
endif()

if (CMAKE_SYSTEM_NAME STREQUAL "QNX")
  set(CONFIGURE_FLAGS "--host=${CMAKE_SYSTEM_PROCESSOR}-nto-qnx" ${COMMON_CONFIGURE_FLAGS})
else ()
  set(CONFIGURE_FLAGS ${COMMON_CONFIGURE_FLAGS} ${EXTRA_CONFIGURE_FLAGS})
endif ()

if(CROSS_HOST)
  add_custom_command(OUTPUT ${DBUS_BUILD_DIRECTORY}/Makefile
    COMMAND ${DBUS_SOURCE_DIRECTORY}/configure ${CONFIGURE_FLAGS}
    DEPENDS expat
    WORKING_DIRECTORY ${DBUS_BUILD_DIRECTORY}
  )
else()
  add_custom_command(OUTPUT ${DBUS_BUILD_DIRECTORY}/Makefile
    COMMAND CC=${CMAKE_C_COMPILER} ${DBUS_SOURCE_DIRECTORY}/configure ${CONFIGURE_FLAGS}
    DEPENDS expat
    WORKING_DIRECTORY ${DBUS_BUILD_DIRECTORY}
  )
endif()

add_custom_target(dbus ALL make
  COMMAND /bin/bash -c \"
          cd ${CMAKE_CURRENT_SOURCE_DIR}\;
          git log . 1>/dev/null 2>&1\;
          if [ \\$$? == 0 ]; then
          grep \\".commit_hash\\" ${DBUS_BUILD_DIRECTORY}/dbus/.libs/libdbus-1.so 1>/dev/null 2>&1\;
          if [ ! \\\$$? == 0 ]\; then
            cd ${CMAKE_CURRENT_SOURCE_DIR} &&
            git log --pretty=\\"format:%H\\" -1 ${DBUS_SOURCE_DIRECTORY} > /tmp/commit_hash 2>/dev/null &&
            echo \\"Adding .commit_hash section\\" &&
            ${objcopy} --add-section .commit_hash=/tmp/commit_hash ${DBUS_BUILD_DIRECTORY}/dbus/.libs/libdbus-1.so ${DBUS_BUILD_DIRECTORY}/dbus/.libs/libdbus-1.so 1>/dev/null 2>&1\;
          fi;
        fi\"
  DEPENDS ${DBUS_BUILD_DIRECTORY}/Makefile
  WORKING_DIRECTORY ${DBUS_BUILD_DIRECTORY}
)

install(
  FILES ${DBUS_BUILD_DIRECTORY}/dbus/dbus-arch-deps.h
  DESTINATION ${DBUS_INCLUDE_DIR_ARCH}/dbus
)

install(
  DIRECTORY ${DBUS_SOURCE_DIRECTORY}/dbus/
  DESTINATION ${DBUS_INCLUDE_DIR}/dbus
  FILES_MATCHING PATTERN *.h
)

install(
  DIRECTORY ${DBUS_BUILD_DIRECTORY}/dbus/.libs/
  DESTINATION ${3RD_PARTY_INSTALL_PREFIX_ARCH}/lib
  USE_SOURCE_PERMISSIONS
  FILES_MATCHING PATTERN libdbus-1.so*
)