Add cmake installation rules along with cpack entries. Made cmake_build_type clever.
This commit is contained in:
parent
3933311d47
commit
5002e40485
3 changed files with 31 additions and 4 deletions
|
@ -1,9 +1,17 @@
|
||||||
cmake_minimum_required(VERSION 3.0)
|
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_VERBOSE_MAKEFILE FALSE)
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||||
set(CMAKE_INSTALL_PREFIX /usr/local)
|
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 "-Wall -Werror -Wextra -pedantic")
|
||||||
set(CMAKE_C_FLAGS_DEBUG "-g -ggdb -pg -fsanitize=address")
|
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(bastion)
|
||||||
add_subdirectory(common)
|
add_subdirectory(common)
|
||||||
add_subdirectory(external)
|
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)
|
||||||
|
|
|
@ -41,7 +41,7 @@ make install
|
||||||
|
|
||||||
You can customise the build with the following cmake flags :
|
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`
|
- `CMAKE_INSTALL_PREFIX` : path, defaults to `/usr/local`
|
||||||
- `SESSION_RECORDING` : ON|OFF, defaults to ON
|
- `SESSION_RECORDING` : ON|OFF, defaults to ON
|
||||||
|
|
||||||
|
|
|
@ -9,3 +9,5 @@ if (${SESSION_RECORDING})
|
||||||
target_link_libraries(bastion libtty)
|
target_link_libraries(bastion libtty)
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(bastion bz2 lzma mysqlclient ssh z)
|
target_link_libraries(bastion bz2 lzma mysqlclient ssh z)
|
||||||
|
|
||||||
|
install (TARGETS bastion DESTINATION bin)
|
||||||
|
|
Reference in a new issue