summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeder Andersen2012-03-14 17:22:08 (EDT)
committer Eugene Tarassov2012-03-15 15:11:17 (EDT)
commite642148dae8dd3f93c1fe0949e8e2bf225fcdc36 (patch)
tree62d2f4903ba9e6132616d23cd46fb1b082c7b6d1
parentaeb7c770dbc636d77c43532a533b06b9af796888 (diff)
downloadorg.eclipse.tcf.agent-e642148dae8dd3f93c1fe0949e8e2bf225fcdc36.zip
org.eclipse.tcf.agent-e642148dae8dd3f93c1fe0949e8e2bf225fcdc36.tar.gz
org.eclipse.tcf.agent-e642148dae8dd3f93c1fe0949e8e2bf225fcdc36.tar.bz2
cmake: added support for building as external lib
This fixes current cmake build support, and further decouples the necessary logic so the TCF core can be sanely included in larger cmake-based projects.
-rw-r--r--agent/CMakeLists.txt132
-rw-r--r--cmake-tcf-lib.txt73
2 files changed, 110 insertions, 95 deletions
diff --git a/agent/CMakeLists.txt b/agent/CMakeLists.txt
index e6ca8dc..c5aeff0 100644
--- a/agent/CMakeLists.txt
+++ b/agent/CMakeLists.txt
@@ -1,99 +1,41 @@
+# -*- cmake -*-
+
cmake_minimum_required(VERSION 2.8)
set(CMAKE_COLOR_MAKEFILE OFF)
-if (WIN32)
-include_directories(system/Windows)
-include_directories(machine/x86_64)
-set(PLAT_SOURCES
- system/Windows/context-win32.c
- system/Windows/pthreads-win32.c
- system/Windows/windbgcache.c)
-endif (WIN32)
-
-include_directories(.)
-
-add_library(tcf STATIC
- framework/asyncreq.c
- framework/base64.c
- framework/cache.c
- framework/channel.c
- framework/channel_pipe.c
- framework/channel_tcp.c
- framework/context.c
- framework/cpudefs.c
- framework/errors.c
- framework/events.c
- framework/exceptions.c
- framework/inputbuf.c
- framework/ip_ifc.c
- framework/json.c
- framework/mdep.c
- framework/myalloc.c
- framework/outputbuf.c
- framework/peer.c
- framework/plugins.c
- framework/protocol.c
- framework/proxy.c
- framework/signames.c
- framework/streams.c
- framework/trace.c
- framework/waitpid.c
- services/breakpoints.c
- services/diagnostics.c
- services/discovery.c
- services/discovery_udp.c
- services/dwarfcache.c
- services/dwarfexpr.c
- services/dwarfframe.c
- services/dwarfio.c
- services/dwarfreloc.c
- services/expressions.c
- services/filesystem.c
- services/linenumbers.c
- services/linenumbers_elf.c
- services/linenumbers_proxy.c
- services/linenumbers_win32.c
- services/memorymap.c
- services/memoryservice.c
- services/pathmap.c
- services/processes.c
- services/registers.c
- services/runctrl.c
- services/stacktrace.c
- services/streamsservice.c
- services/symbols.c
- services/symbols_elf.c
- services/symbols_proxy.c
- services/symbols_win32.c
- services/sysmon.c
- services/tcf_elf.c
- services/terminals.c
- main/cmdline.c
- main/server.c
- main/services.c
- main/test.c
- ${PLAT_SOURCES}
- )
-
-add_executable(agent main/main.c)
-
-target_link_libraries(agent tcf)
-
-if(WIN32)
-if(MSVC)
-target_link_libraries(agent shell32.lib advapi32.lib Iphlpapi.lib WS2_32.lib version.lib)
-else(MSVC) # MinGW
-target_link_libraries(agent WS2_32 Iphlpapi)
-endif(MSVC)
-endif(WIN32)
-
-#./main/main_client.c
-#./main/main_log.c
-#./main/main_lua.c
-#./main/main_reg.c
-#./main/main_va.c
-#system/Darwin/context-darwin.c
-#system/FreeBSD/context-freebsd.c
-#system/GNU/Linux/context-linux.c
-#system/VxWorks/context-vxworks.c
+set(TCF_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
+set(TCF_LIB_NAME tcf-agent)
+
+if (NOT WIN32)
+ if(NOT TCF_OPSYS)
+ set(TCF_OPSYS "GNU/Linux")
+ endif()
+ if(NOT TCF_MACHINE)
+ set(TCF_MACHINE "x86_64")
+ endif()
+endif()
+
+if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ set(MULTI_THREADED_COMPILE_FLAGS "-pthreads")
+ set(MULTI_THREADED_LINK_LIBS pthread rt)
+elseif(APPLE)
+ set(MULTI_THREADED_COMPILE_FLAGS "-pthread -D_REENTRANT")
+ set(MULTI_THREADED_LINK_FLAGS "")
+ set(MULTI_THREADED_LINK_LIBS pthread)
+elseif(UNIX)
+ set(MULTI_THREADED_COMPILE_FLAGS "-pthread -D_REENTRANT")
+ set(MULTI_THREADED_LINK_FLAGS "")
+ set(MULTI_THREADED_LINK_LIBS pthread rt)
+ set(UUID_LIB_NAME uuid)
+elseif(WIN32)
+ set(SOCKET_LINK_LIBS ws2_32 iphlpapi)
+endif()
+
+include(../cmake-tcf-lib.txt)
+
+message(STATUS "operating system:" ${TCF_OPSYS})
+message(STATUS "machine:" ${TCF_MACHINE})
+
+add_executable(agent tcf/main/main.c)
+target_link_libraries(agent ${TCF_LIB_NAME})
diff --git a/cmake-tcf-lib.txt b/cmake-tcf-lib.txt
new file mode 100644
index 0000000..3c80c85
--- /dev/null
+++ b/cmake-tcf-lib.txt
@@ -0,0 +1,73 @@
+# -*- cmake -*-
+
+if (WIN32)
+if(NOT TCF_OPSYS)
+ set(TCF_OPSYS "Windows")
+endif()
+if(NOT TCF_MACHINE)
+ set(TCF_MACHINE "x86_64")
+endif()
+endif (WIN32)
+
+set(TCF_BASE_DIR ${TCF_DIR}/agent)
+
+# sources to build
+set(TCF_SRCS)
+
+# get all regular source files
+file(GLOB TCF_SRCS_REL RELATIVE ${TCF_BASE_DIR}
+ ${TCF_BASE_DIR}/system/${TCF_OPSYS}/tcf/*.c
+ ${TCF_BASE_DIR}/machine/${TCF_MACHINE}/tcf/*.c
+ ${TCF_BASE_DIR}/tcf/framework/*.c
+ ${TCF_BASE_DIR}/tcf/services/*.c
+ ${TCF_BASE_DIR}/tcf/main/*.c)
+
+# remove non-library files
+file(GLOB TCF_MAIN_REL RELATIVE ${TCF_BASE_DIR}
+ ${TCF_BASE_DIR}/tcf/main/main*.c)
+list(REMOVE_ITEM TCF_SRCS_REL ${TCF_MAIN_REL})
+
+if(DEFINED TCF_EXTRA_DIR)
+ # get extra all source files
+ file(GLOB TCF_EXTRA_SRCS_REL RELATIVE ${TCF_EXTRA_DIR}
+ ${TCF_EXTRA_DIR}/system/${TCF_OPSYS}/tcf/*.c
+ ${TCF_EXTRA_DIR}/machine/${TCF_MACHINE}/tcf/*.c
+ ${TCF_EXTRA_DIR}/tcf/framework/*.c
+ ${TCF_EXTRA_DIR}/tcf/services/*.c
+ ${TCF_EXTRA_DIR}/tcf/main/*.c)
+
+ # Override regular files with extra files
+ list(REMOVE_ITEM TCF_SRCS_REL ${TCF_EXTRA_SRCS_REL})
+
+ foreach(file ${TCF_EXTRA_SRCS_REL})
+ list(APPEND TCF_SRCS ${TCF_EXTRA_DIR}/${file})
+ endforeach(file)
+endif()
+
+foreach(file ${TCF_SRCS_REL})
+ list(APPEND TCF_SRCS ${TCF_BASE_DIR}/${file})
+endforeach(file)
+
+if(DEFINED TCF_EXTRA_DIR)
+ include_directories(${TCF_EXTRA_DIR} ${TCF_EXTRA_DIR}/system/${TCF_OPSYS} ${TCF_EXTRA_DIR}/machine/${TCF_MACHINE})
+endif()
+include_directories(${TCF_BASE_DIR} ${TCF_BASE_DIR}/system/${TCF_OPSYS} ${TCF_BASE_DIR}/machine/${TCF_MACHINE})
+
+set_source_files_properties(${TCF_SRCS} PROPERTIES
+ COMPILE_FLAGS "${MULTI_THREADED_COMPILE_FLAGS}")
+add_library(${TCF_LIB_NAME} ${TCF_LIB_TYPE} ${TCF_SRCS})
+target_link_libraries(${TCF_LIB_NAME}
+ ${UUID_LIB_NAME} ${MULTI_THREADED_LINK_LIBS} ${SOCKET_LINK_LIBS})
+
+if(SSL_LIB_NAME)
+ target_link_libraries(${TCF_LIB_NAME} ${SSL_LIB_NAME})
+else()
+ add_definitions("-DENABLE_SSL=0")
+endif()
+
+if(DEFINED TCF_PLUGIN_PATH)
+ add_definitions(-DPATH_Plugins=${TCF_PLUGIN_PATH})
+ if (UNIX)
+ target_link_libraries(${TCF_LIB_NAME} dl)
+ endif()
+endif()