Commit ce695165 authored by Romain Pokrzywka's avatar Romain Pokrzywka Committed by Ralf Habacker

refactor the cmake build to match with autotools: only export client symbols...

refactor the cmake build to match with autotools: only export client symbols in dbus-1 and use and internal library for the rest. Currently this library is statically linked to the apps but it can be made dynamic if wanted
parent cffb66be
......@@ -499,24 +499,6 @@ add_definitions(-DHAVE_CONFIG_H=1)
add_definitions(${DBUS_BUS_CFLAGS} -DDBUS_API_SUBJECT_TO_CHANGE)
option(splitlib "split library into dbus-lib-client, dbus-lib-generic, and dbus-lib-util, no installing possible" OFF)
if(splitlib AND MSVC)
# does not work with GCC/ld
set(DBUS_1 dbus-lib-client dbus-lib-generic dbus-lib-util)
message(STATUS "")
message(STATUS "dbus library is splitted into dbus-lib-client, dbus-lib-generic, and dbus-lib-util")
message(STATUS "installing is not possible")
message(STATUS "disable splitting: -Dsplitlib=0")
message(STATUS "")
else(splitlib AND MSVC)
message(STATUS "")
message(STATUS "for better code reading the dbus library could be splitted into three libraries:")
message(STATUS "dbus-lib-client, dbus-lib-generic, and dbus-lib-util (installing is then not possible)")
message(STATUS "enable splitting: -Dsplitlib=1")
message(STATUS "")
set(DBUS_1 dbus-1)
endif(splitlib AND MSVC)
if (DBUS_BUILD_TESTS)
# set variables used for the .in files (substituted by configure_file) in test/data:
set(TEST_VALID_SERVICE_DIR ${CMAKE_BINARY_DIR}/test/data/valid-service-files)
......
......@@ -76,19 +76,14 @@ set (BUS_SOURCES
)
include_directories(${XML_INCLUDE_DIR})
SET (LIBS ${XML_LIBRARY})
if(splitlib AND MSVC)
add_library(bus-lib STATIC ${BUS_SOURCES})
add_executable(dbus-daemon ${BUS_DIR}/main.c)
target_link_libraries(dbus-daemon ${DBUS_1} ${LIBS} bus-lib)
else(splitlib AND MSVC)
add_executable(dbus-daemon ${BUS_SOURCES} ${BUS_DIR}/main.c)
target_link_libraries(dbus-daemon ${DBUS_1} ${LIBS})
endif(splitlib AND MSVC)
if(WIN32)
set_target_properties(dbus-daemon PROPERTIES DEBUG_POSTFIX d)
endif(WIN32)
set(DBUS_LIBRARIES dbus-1 dbus-internal)
add_executable(dbus-daemon ${BUS_SOURCES} ${BUS_DIR}/main.c)
target_link_libraries(dbus-daemon ${DBUS_LIBRARIES} ${XML_LIBRARY})
if(WIN32 AND NOT DBUS_DISABLE_EXECUTABLE_DEBUG_POSTFIX)
set_target_properties(dbus-daemon PROPERTIES DEBUG_POSTFIX "d")
endif(WIN32 AND NOT DBUS_DISABLE_EXECUTABLE_DEBUG_POSTFIX)
install_targets(/bin dbus-daemon)
install_files(/etc FILES ${config_DATA})
......@@ -102,7 +97,7 @@ if (DBUS_SERVICE)
)
add_executable(dbus-service ${dbus_service_SOURCES} )
target_link_libraries(dbus-service ${DBUS_1} ${LIBS})
target_link_libraries(dbus-service ${DBUS_LIBRARIES} ${XML_LIBRARY})
install_targets(/bin dbus-service )
if(WIN32)
set_target_properties(dbus-service PROPERTIES DEBUG_POSTFIX d)
......@@ -124,14 +119,8 @@ endif (DBUS_SERVICE)
#noinst_PROGRAMS=$(TESTS)
if (DBUS_BUILD_TESTS)
if(splitlib AND MSVC)
add_executable(bus-test ${BUS_DIR}/test-main.c)
target_link_libraries(bus-test ${DBUS_1} ${LIBS} bus-lib)
else(splitlib AND MSVC)
add_executable(bus-test ${BUS_SOURCES} ${BUS_DIR}/test-main.c)
target_link_libraries(bus-test ${DBUS_1} ${LIBS})
endif(splitlib AND MSVC)
#install_targets(/bin bus-test)
add_executable(bus-test ${BUS_SOURCES} ${BUS_DIR}/test-main.c)
target_link_libraries(bus-test ${DBUS_LIBRARIES} ${XML_LIBRARY})
add_test(bus-test ${EXECUTABLE_OUTPUT_PATH}/bus-test ${CMAKE_BINARY_DIR}/test/data)
endif (DBUS_BUILD_TESTS)
......@@ -163,15 +152,15 @@ set(LAUNCH_HELPER_SOURCES ${XML_SOURCES}
if(NOT WIN32)
# TODO PENDING(kdab) fix build on windows (activation-helper.c)
add_executable(dbus-daemon-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/activation-helper-bin.c )
target_link_libraries(dbus-daemon-launch-helper ${DBUS_1} ${LIBS} )
target_link_libraries(dbus-daemon-launch-helper ${DBUS_LIBRARIES} ${XML_LIBRARY} )
add_executable(dbus-daemon-launch-helper-test ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/activation-helper-bin.c)
set_target_properties(dbus-daemon-launch-helper-test PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST")
target_link_libraries(dbus-daemon-launch-helper-test ${DBUS_1} ${LIBS} )
target_link_libraries(dbus-daemon-launch-helper-test ${DBUS_LIBRARIES} ${XML_LIBRARY} )
add_executable(bus-test-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/test-launch-helper.c)
set_target_properties(bus-test-launch-helper PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST -DACTIVATION_LAUNCHER_DO_OOM")
target_link_libraries(bus-test-launch-helper ${DBUS_1} ${LIBS} )
target_link_libraries(bus-test-launch-helper ${DBUS_LIBRARIES} ${XML_LIBRARY} )
add_test(bus-test-launch-helper ${EXECUTABLE_OUTPUT_PATH}/bus-test-launch-helper )
endif(NOT WIN32)
......
......@@ -189,22 +189,20 @@ if (WIN32)
${DBUS_DIR}/dbus-sysdeps-win.c
${DBUS_DIR}/dbus-pipe-win.c
${DBUS_DIR}/dbus-sysdeps-thread-win.c
${DBUS_DIR}/dbus-spawn-win.c
)
set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS}
${DBUS_DIR}/dbus-sockets-win.h
${DBUS_DIR}/dbus-sysdeps-win.h
)
set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES}
${DBUS_DIR}/dbus-spawn-win.c
${DBUS_DIR}/dbus-sysdeps-util-win.c
)
set (LIBS ${LIBS} ws2_32 advapi32 netapi32)
else (WIN32)
set (DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES}
${DBUS_DIR}/dbus-pipe-unix.c
${DBUS_DIR}/dbus-sysdeps-unix.c
${DBUS_DIR}/dbus-sysdeps-pthread.c
${DBUS_DIR}/dbus-spawn.c
${DBUS_DIR}/dbus-userdb.c
)
set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS}
......@@ -214,6 +212,7 @@ else (WIN32)
${DBUS_DIR}/dbus-userdb.h
)
set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES}
${DBUS_DIR}/dbus-spawn.c
${DBUS_DIR}/dbus-userdb-util.c
${DBUS_DIR}/dbus-sysdeps-util-unix.c
)
......@@ -242,57 +241,58 @@ if (MSVC)
set_source_files_properties(versioninfo.rc COMPILE_FLAGS "-D__LINE__=1")
endif (MSVC)
if(MSVC AND splitlib)
set(DBUS_LIB_TYPE STATIC)
elseif(MSVC AND splitlib)
set(DBUS_LIB_TYPE SHARED)
endif(MSVC AND splitlib)
if(splitlib AND MSVC)
# code for the client library and daemon/tests
add_library(dbus-lib-generic ${DBUS_LIB_TYPE} ${DBUS_SHARED_SOURCES} ${DBUS_SHARED_HEADERS})
# code only for daemon/tests
add_library(dbus-lib-util ${DBUS_LIB_TYPE} ${DBUS_UTIL_SOURCES} ${DBUS_UTIL_HEADERS})
# code for the client library
add_library(dbus-lib-client ${DBUS_LIB_TYPE} ${DBUS_LIB_SOURCES} ${DBUS_LIB_HEADERS})
target_link_libraries(dbus-lib-generic ${LIBS})
target_link_libraries(dbus-lib-util ${LIBS})
target_link_libraries(dbus-lib-client ${LIBS})
if(MSVC_IDE)
project_source_group(${GROUP_CODE} DBUS_LIB_SOURCES DBUS_LIB_HEADERS)
project_source_group(${GROUP_CODE} DBUS_SHARED_SOURCES DBUS_SHARED_HEADERS)
project_source_group(${GROUP_CODE} DBUS_UTIL_SOURCES DBUS_UTIL_SOURCES)
endif(MSVC_IDE)
else(splitlib AND MSVC)
# all code into one library
if(MSVC_IDE)
project_source_group(${GROUP_CODE} DBUS_LIB_SOURCES DBUS_LIB_HEADERS)
project_source_group(${GROUP_CODE} DBUS_SHARED_SOURCES DBUS_SHARED_HEADERS)
project_source_group(${GROUP_CODE} DBUS_UTIL_SOURCES DBUS_UTIL_SOURCES)
endif(MSVC_IDE)
### Client library
if(WIN32)
file(READ "${DBUS_DIR}/dbus-1-clientsymbols.def.in" DBUS_CLIENT_EXPORTS)
if (DBUS_BUILD_TESTS)
file(READ "${DBUS_DIR}/dbus-1-testsymbols.def.in" DBUS_TEST_EXPORTS)
endif(DBUS_BUILD_TESTS)
set(DBUS_LIB_DEF "${CMAKE_BINARY_DIR}/dbus-1.def")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/dbus-1.def.cmake" ${DBUS_LIB_DEF})
if(MSVC)
file(READ "${DBUS_DIR}/dbus-1-clientsymbols.def.in" DBUS_CLIENT_EXPORTS)
file(READ "${DBUS_DIR}/dbus-1-utilsymbols.def.in" DBUS_UTIL_EXPORTS)
if (DBUS_BUILD_TESTS)
file(READ "${DBUS_DIR}/dbus-1-testsymbols.def.in" DBUS_TEST_EXPORTS)
endif(DBUS_BUILD_TESTS)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/dbus-1.def.cmake" "${CMAKE_BINARY_DIR}/dbus-1.def")
list(APPEND libdbus_SOURCES ${CMAKE_BINARY_DIR}/dbus-1.def)
list(APPEND DBUS_LIB_SOURCES ${DBUS_LIB_DEF})
endif(MSVC)
add_library(dbus-1 ${DBUS_LIB_TYPE} ${libdbus_SOURCES} ${libdbus_HEADERS} )
target_link_libraries(dbus-1 ${LIBS})
if(MSVC_IDE)
project_source_group(${GROUP_CODE} libdbus_SOURCES libdbus_HEADERS)
endif(MSVC_IDE)
endif(splitlib AND MSVC)
endif(WIN32)
add_library(dbus-1 SHARED
${DBUS_LIB_SOURCES}
${DBUS_SHARED_SOURCES}
${DBUS_LIB_HEADERS}
${DBUS_SHARED_HEADERS})
if(WIN32)
target_link_libraries(dbus-1 ws2_32 advapi32 netapi32)
endif(WIN32)
install_targets(/lib dbus-1 )
install_files(/include/dbus FILES ${dbusinclude_HEADERS})
if(WIN32 and NOT MSVC)
install_files(/lib FILES ${DBUS_LIB_DEF})
endif(WIN32 and NOT MSVC)
### Internal library, used for the daemon, tools and tests, compiled statically.
if(WIN32)
set(DBUS_CLIENT_EXPORTS )
set(DBUS_TEST_EXPORTS )
file(READ "${DBUS_DIR}/dbus-1-utilsymbols.def.in" DBUS_UTIL_EXPORTS)
set(DBUS_INTERNAL_DEF "${CMAKE_BINARY_DIR}/dbus-internal.def")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/dbus-1.def.cmake" ${DBUS_INTERNAL_DEF})
if(MSVC)
list(APPEND DBUS_UTIL_SOURCES ${DBUS_INTERNAL_DEF})
endif(MSVC)
endif(WIN32)
if(NOT splitlib)
install_targets(/lib dbus-1 )
install_files(/include/dbus FILES ${dbusinclude_HEADERS})
endif(NOT splitlib)
add_library(dbus-internal STATIC
${DBUS_UTIL_SOURCES}
${DBUS_UTIL_HEADERS})
target_link_libraries(dbus-internal dbus-1)
#ADD_EXECUTABLE(dbus-example dbus-example.c)
#target_link_libraries(${CMAKE_SOURCE_DIR}/../dbus/dbus-example dbus-1)
......@@ -311,7 +311,7 @@ endif(NOT splitlib)
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} ${LIBS})
target_link_libraries(dbus-test dbus-1 dbus-internal)
add_test(dbus-test ${EXECUTABLE_OUTPUT_PATH}/dbus-test ${CMAKE_SOURCE_DIR}/../test/data)
#install_targets(/bin dbus-test)
ENDIF (DBUS_BUILD_TESTS)
......
project(tools)
set(DBUS_LIBRARIES dbus-1 dbus-internal)
set (dbus_send_SOURCES
../../tools/dbus-print-message.c
../../tools/dbus-print-message.h
......@@ -42,7 +44,7 @@ set (dbus_viewer_SOURCES
)
add_executable(dbus-send ${dbus_send_SOURCES})
target_link_libraries(dbus-send ${DBUS_1})
target_link_libraries(dbus-send ${DBUS_LIBRARIES})
install_targets(/bin dbus-send )
add_executable(dbus-launch ${dbus_launch_SOURCES})
......@@ -53,7 +55,7 @@ endif (DBUS_BUILD_X11)
install_targets(/bin dbus-launch )
add_executable(dbus-monitor ${dbus_monitor_SOURCES})
target_link_libraries(dbus-monitor ${DBUS_1})
target_link_libraries(dbus-monitor ${DBUS_LIBRARIES})
install_targets(/bin dbus-monitor )
if(WIN32)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment