Make the windows binaries and build match the linux one with cmake buildsystem.
authorunknown <Administrator@.(none)>
Mon, 22 Mar 2010 09:38:38 +0000 (10:38 +0100)
committerRalf Habacker <ralf.habacker@freenet.de>
Mon, 22 Mar 2010 09:41:06 +0000 (10:41 +0100)
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
cmake/bus/CMakeLists.txt
cmake/dbus/CMakeLists.txt
cmake/test/CMakeLists.txt
dbus/dbus-macros.h

index 80db3de..0d4da13 100644 (file)
@@ -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 ###############
 
index 23dd05b..1cfd147 100644 (file)
@@ -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)
 
index db46113..57c499f 100644 (file)
@@ -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)
index 93d677d..393c494 100644 (file)
@@ -1,5 +1,7 @@
 project(test)
 
+add_definitions(${DBUS_INTERNAL_CLIENT_DEFINITIONS})
+
 add_subdirectory( name-test )
 
 set (test-service_SOURCES
index 3102a95..d1e40ec 100644 (file)
  */
 
 #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)