aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2019-03-14 19:10:41 +0100
committerJulien Dessaux2019-03-14 19:10:41 +0100
commit5002e404851cfdcdf0d20240319e5a5230780f6f (patch)
treeb3a0842b2fe44f0496c45ec8a2a459b316ec3cda
parentUse proper directories configuration from cmake (diff)
downloadbastion-5002e404851cfdcdf0d20240319e5a5230780f6f.tar.gz
bastion-5002e404851cfdcdf0d20240319e5a5230780f6f.tar.bz2
bastion-5002e404851cfdcdf0d20240319e5a5230780f6f.zip
Add cmake installation rules along with cpack entries. Made cmake_build_type clever.
-rw-r--r--CMakeLists.txt31
-rw-r--r--README.md2
-rw-r--r--bastion/CMakeLists.txt2
3 files changed, 31 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c8b30ab..a131f0b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,9 +1,17 @@
cmake_minimum_required(VERSION 3.0)
-project(bastion LANGUAGES C VERSION 0.1.0)
+project(bastion LANGUAGES C VERSION 0.1.1)
set(CMAKE_VERBOSE_MAKEFILE FALSE)
-set(CMAKE_BUILD_TYPE Release)
-set(CMAKE_INSTALL_PREFIX /usr/local)
+if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
+ set(default_build_type Debug)
+else()
+ set(default_build_type Release)
+endif()
+if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+ message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
+ set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
+ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
+endif()
set(CMAKE_C_FLAGS "-Wall -Werror -Wextra -pedantic")
set(CMAKE_C_FLAGS_DEBUG "-g -ggdb -pg -fsanitize=address")
@@ -20,3 +28,20 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}")
add_subdirectory(bastion)
add_subdirectory(common)
add_subdirectory(external)
+
+include (InstallRequiredSystemLibraries)
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
+set(CPACK_PACKAGE_CONTACT "Julien Dessaux <julien.dessaux@adyxax.org>")
+set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
+set(CPACK_DEBIAN_PACKAGE_SECTION "net")
+set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libssh-4")
+set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
+set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
+find_program(DPKG_CMD dpkg)
+if(EXISTS ${DPKG_CMD})
+ execute_process(COMMAND "${DPKG_CMD}" --print-architecture
+ OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif()
+include (CPack)
diff --git a/README.md b/README.md
index 0447444..3b817cd 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ make install
You can customise the build with the following cmake flags :
-- `CMAKE_BUILD_TYPE` : Debug|Release|RelWithDebInfo|MinSizeRel, defaults to Release
+- `CMAKE_BUILD_TYPE` : Debug|Release|RelWithDebInfo|MinSizeRel, defaults to Release if using a tarball, and Debug if using the git tree
- `CMAKE_INSTALL_PREFIX` : path, defaults to `/usr/local`
- `SESSION_RECORDING` : ON|OFF, defaults to ON
diff --git a/bastion/CMakeLists.txt b/bastion/CMakeLists.txt
index 858797a..8176078 100644
--- a/bastion/CMakeLists.txt
+++ b/bastion/CMakeLists.txt
@@ -9,3 +9,5 @@ if (${SESSION_RECORDING})
target_link_libraries(bastion libtty)
endif()
target_link_libraries(bastion bz2 lzma mysqlclient ssh z)
+
+install (TARGETS bastion DESTINATION bin)