[PATCH 2/3] Make the windows binaries and build match the linux one for cmake buildsystem.
Ralf Habacker
ralf.habacker at freenet.de
Mon Mar 22 02:38:38 PDT 2010
This is performed by including the files from the client lib in the internal one
and by removing the linking to dbus-1 for targets using the internal library.
---
cmake/CMakeLists.txt | 8 +++++++-
cmake/bus/CMakeLists.txt | 3 +++
cmake/dbus/CMakeLists.txt | 18 ++++++++++++++----
cmake/test/CMakeLists.txt | 2 ++
dbus/dbus-macros.h | 4 +++-
5 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 80db3de..0d4da13 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -495,7 +495,13 @@ if (DBUS_BUILD_TESTS)
endif (DBUS_BUILD_TESTS)
set(DBUS_LIBRARIES dbus-1)
-set(DBUS_INTERNAL_LIBRARIES dbus-1 dbus-internal)
+set(DBUS_INTERNAL_LIBRARIES dbus-internal)
+
+# settings for building and using static internal lib
+# important note: DBUS_INTERNAL_xxxxx_DEFINITIONS must *not* be set when building dbus-1 library
+set (DBUS_INTERNAL_ADD_LIBRARY_OPTIONS STATIC)
+set (DBUS_INTERNAL_LIBRARY_DEFINITIONS "-DDBUS_STATIC_BUILD")
+set (DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_STATIC_BUILD")
########### subdirs ###############
diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt
index 23dd05b..1cfd147 100644
--- a/cmake/bus/CMakeLists.txt
+++ b/cmake/bus/CMakeLists.txt
@@ -80,6 +80,7 @@ include_directories(${XML_INCLUDE_DIR})
add_executable(dbus-daemon ${BUS_SOURCES} ${BUS_DIR}/main.c)
target_link_libraries(dbus-daemon ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY})
set_target_properties(dbus-daemon PROPERTIES OUTPUT_NAME ${DBUS_DAEMON_NAME})
+set_target_properties(dbus-daemon PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
install_targets(/bin dbus-daemon)
install_files(/etc FILES ${config_DATA})
@@ -94,12 +95,14 @@ if (DBUS_SERVICE)
add_executable(dbus-service ${dbus_service_SOURCES} )
target_link_libraries(dbus-service ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY})
+ set_target_properties(dbus-service PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
install_targets(/bin dbus-service )
endif (DBUS_SERVICE)
if (DBUS_BUILD_TESTS)
add_executable(bus-test ${BUS_SOURCES} ${BUS_DIR}/test-main.c)
target_link_libraries(bus-test ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY})
+ set_target_properties(bus-test PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
add_test(bus-test ${EXECUTABLE_OUTPUT_PATH}/bus-test ${CMAKE_BINARY_DIR}/test/data)
endif (DBUS_BUILD_TESTS)
diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt
index db46113..57c499f 100644
--- a/cmake/dbus/CMakeLists.txt
+++ b/cmake/dbus/CMakeLists.txt
@@ -264,16 +264,26 @@ install_files(/include/dbus FILES ${dbusinclude_HEADERS})
### Internal library, used for the daemon, tools and tests, compiled statically.
-add_library(dbus-internal STATIC
+add_library(dbus-internal ${DBUS_INTERNAL_ADD_LIBRARY_OPTIONS}
+ ${DBUS_LIB_SOURCES}
+ ${DBUS_LIB_HEADERS}
+ ${DBUS_SHARED_SOURCES}
+ ${DBUS_SHARED_HEADERS}
${DBUS_UTIL_SOURCES}
- ${DBUS_UTIL_HEADERS})
-target_link_libraries(dbus-internal dbus-1)
+ ${DBUS_UTIL_HEADERS}
+)
+target_link_libraries(dbus-internal)
+set_target_properties(dbus-internal PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_LIBRARY_DEFINITIONS})
+if(WIN32)
+ target_link_libraries(dbus-internal ws2_32 advapi32 netapi32)
+endif(WIN32)
if (DBUS_BUILD_TESTS)
set (TESTS_ENVIRONMENT "DBUS_TEST_DATA=${CMAKE_SOURCE_DIR}/test/data DBUS_TEST_HOMEDIR=${CMAKE_BUILD_DIR}/dbus")
ADD_EXECUTABLE(dbus-test ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c)
- target_link_libraries(dbus-test dbus-1 dbus-internal)
+ target_link_libraries(dbus-test ${DBUS_INTERNAL_LIBRARIES})
add_test(dbus-test ${EXECUTABLE_OUTPUT_PATH}/dbus-test ${CMAKE_SOURCE_DIR}/../test/data)
+ set_target_properties(dbus-test PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
ENDIF (DBUS_BUILD_TESTS)
if (UNIX)
diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt
index 93d677d..393c494 100644
--- a/cmake/test/CMakeLists.txt
+++ b/cmake/test/CMakeLists.txt
@@ -1,5 +1,7 @@
project(test)
+add_definitions(${DBUS_INTERNAL_CLIENT_DEFINITIONS})
+
add_subdirectory( name-test )
set (test-service_SOURCES
diff --git a/dbus/dbus-macros.h b/dbus/dbus-macros.h
index 3102a95..d1e40ec 100644
--- a/dbus/dbus-macros.h
+++ b/dbus/dbus-macros.h
@@ -158,7 +158,9 @@
*/
#if defined(_WIN32)
-# if defined(dbus_1_EXPORTS)
+# if defined(DBUS_STATIC_BUILD)
+# define DBUS_EXPORT
+# elif defined(dbus_1_EXPORTS)
# define DBUS_EXPORT __declspec(dllexport)
# else
# define DBUS_EXPORT __declspec(dllimport)
--
1.6.4.msysgit.0
--------------000806040900020000040804
Content-Type: text/plain;
name="0003-Additional-fixes-for-2154acb3492d5ba19da36562e840901.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename*0="0003-Additional-fixes-for-2154acb3492d5ba19da36562e840901.pa";
filename*1="tch"
More information about the dbus
mailing list