From 0d5a0ca1a56612729b592758372bc56b5f6ae5fe Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Mon, 11 Mar 2019 19:02:10 +0100 Subject: Added cmake rules to build libtty from termrec submodule --- .gitmodules | 3 +++ CMakeLists.txt | 1 + bastion/CMakeLists.txt | 6 ++---- external/CMakeLists.txt | 19 +++++++++++++++++++ external/termrec | 1 + 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 .gitmodules create mode 100644 external/CMakeLists.txt create mode 160000 external/termrec diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c3f6d12 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "external/termrec"] + path = external/termrec + url = https://github.com/kilobyte/termrec diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fe7708..38bc5f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,3 +14,4 @@ option(SESSION_RECORDING "whether or not recording feature based on lib termrec add_subdirectory(bastion) add_subdirectory(common) +add_subdirectory(external) diff --git a/bastion/CMakeLists.txt b/bastion/CMakeLists.txt index 0f826d2..6c87709 100644 --- a/bastion/CMakeLists.txt +++ b/bastion/CMakeLists.txt @@ -1,10 +1,8 @@ -include_directories("${bastion_SOURCE_DIR}/termrec/libtty/") +include_directories("${bastion_SOURCE_DIR}/external/termrec/libtty") include_directories("${bastion_SOURCE_DIR}/") file(GLOB_RECURSE SOURCES *.c) add_executable(bastion ${SOURCES}) -add_library(libtty.a STATIC IMPORTED) -set_property(TARGET libtty.a PROPERTY IMPORTED_LOCATION "${bastion_SOURCE_DIR}/libtty.a") -target_link_libraries(bastion libtty.a common) +target_link_libraries(bastion libtty common) target_link_libraries(bastion bz2 curl lzma mysqlclient pthread ssh z) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt new file mode 100644 index 0000000..7697b9b --- /dev/null +++ b/external/CMakeLists.txt @@ -0,0 +1,19 @@ +# Build libtty from the termrec project +if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/termrec/) + message("Unable to find termrec, running git submodule update --init") + execute_process(COMMAND git submodule update --init -- termrec WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +endif() +if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/termrec/configure) + message("Unable to find configure file for termrec, running autogen.sh") + execute_process(COMMAND ./autogen.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/termrec) +endif() +if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/termrec/config.h) + message("Unable to find config.h file for termrec, running configure script") + execute_process(COMMAND ./configure WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/termrec) +endif() +file(GLOB_RECURSE LIBTTY_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/termrec/libtty/*.c) +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/termrec/") +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/termrec/libtty") +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/termrec/sys") +ADD_LIBRARY(libtty STATIC ${LIBTTY_SOURCES}) +SET_TARGET_PROPERTIES(libtty PROPERTIES COMPILE_FLAGS "-Wno-all -Wno-error -Wno-extra -Wno-pedantic") diff --git a/external/termrec b/external/termrec new file mode 160000 index 0000000..28567db --- /dev/null +++ b/external/termrec @@ -0,0 +1 @@ +Subproject commit 28567dbccfce08da038d7897355430b82bf20785 -- cgit v1.2.3