Merge pull request #3177 from Carbenium/build-deps

Cleanup build system of external dependecies
This commit is contained in:
Isaac Connor 2021-02-27 23:07:59 -05:00 committed by GitHub
commit ae3d1eca54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 2390 additions and 2444 deletions

View File

@ -833,13 +833,7 @@ configure_file(zmlinkcontent.sh.in "${CMAKE_CURRENT_BINARY_DIR}/zmlinkcontent.sh
include(Pod2Man)
# Process subdirectories
# build a bcrypt static library
set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(src/libbcrypt EXCLUDE_FROM_ALL)
set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}")
add_subdirectory(dep)
add_subdirectory(src)
add_subdirectory(scripts)
add_subdirectory(db)

View File

@ -16,11 +16,17 @@ else()
cxx_std_11)
endif()
# Interface to set warning levels on targets
# It gets populated in the compiler specific script
# Interface to set warning levels on targets.
# It gets populated in the compiler specific script.
add_library(zm-warning-interface INTERFACE)
# An interface used by all other interfaces
# Interface which disables all warnings on the target.
add_library(zm-no-warning-interface INTERFACE)
target_compile_options(zm-no-warning-interface
INTERFACE
-w)
# An interface used by all other interfaces.
add_library(zm-default-interface INTERFACE)
target_link_libraries(zm-default-interface
INTERFACE
@ -34,3 +40,11 @@ target_link_libraries(zm-core-interface
INTERFACE
zm-default-interface
zm-warning-interface)
# An interface which provides the flags and definitions
# used by the external dependency targets.
add_library(zm-dependency-interface INTERFACE)
target_link_libraries(zm-dependency-interface
INTERFACE
zm-default-interface
zm-no-warning-interface)

2
dep/CMakeLists.txt Normal file
View File

@ -0,0 +1,2 @@
add_subdirectory(jwt-cpp)
add_subdirectory(libbcrypt)

View File

@ -0,0 +1,6 @@
add_library(jwt-cpp INTERFACE)
add_library(jwt-cpp::jwt-cpp ALIAS jwt-cpp)
target_include_directories(jwt-cpp
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include/jwt-cpp)

View File

@ -0,0 +1,25 @@
enable_language(ASM)
set(BCRYPT_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/bcrypt.c
${CMAKE_CURRENT_SOURCE_DIR}/src/crypt_blowfish.c
${CMAKE_CURRENT_SOURCE_DIR}/src/crypt_gensalt.c
${CMAKE_CURRENT_SOURCE_DIR}/src/wrapper.c
${CMAKE_CURRENT_SOURCE_DIR}/src/x86.S)
add_library(bcrypt STATIC ${BCRYPT_SOURCES})
add_library(libbcrypt::bcrypt ALIAS bcrypt)
target_include_directories(bcrypt
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include/bcrypt)
target_link_libraries(bcrypt
PRIVATE
zm-dependency-interface)
if(BSD)
target_compile_definitions(bcrypt
PRIVATE
__SKIP_GNU)
endif()

View File

@ -78,19 +78,16 @@ target_include_directories(zm
${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(zm
PUBLIC
libbcrypt::bcrypt
jwt-cpp::jwt-cpp
PRIVATE
zm-core-interface)
link_directories(libbcrypt)
add_executable(zmc zmc.cpp)
add_executable(zmu zmu.cpp)
add_executable(zms zms.cpp)
# JWT is a header only library.
include_directories(libbcrypt/include/bcrypt)
include_directories(jwt-cpp/include/jwt-cpp)
target_link_libraries(zmc
PRIVATE
zm-core-interface
@ -105,8 +102,7 @@ target_link_libraries(zmu
zm
${ZM_EXTRA_LIBS}
${ZM_BIN_LIBS}
${CMAKE_DL_LIBS}
bcrypt)
${CMAKE_DL_LIBS})
target_link_libraries(zms
PRIVATE
@ -114,8 +110,7 @@ target_link_libraries(zms
zm
${ZM_EXTRA_LIBS}
${ZM_BIN_LIBS}
${CMAKE_DL_LIBS}
bcrypt)
${CMAKE_DL_LIBS})
# Generate man files for the binaries destined for the bin folder
if(BUILD_MAN)

View File

@ -1,90 +0,0 @@
###################################################################################
#
# Copyright (c) 2014, webvariants GmbH, http://www.webvariants.de
#
# This file is released under the terms of the MIT license. You can find the
# complete text in the attached LICENSE file or online at:
#
# http://www.opensource.org/licenses/mit-license.php
#
# @author: Tino Rusch (tino.rusch@webvariants.de)
#
###################################################################################
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(bcrypt)
enable_language(ASM)
set(MYLIB_VERSION_MAJOR 1)
set(MYLIB_VERSION_MINOR 0)
set(MYLIB_VERSION_PATCH 0)
set(MYLIB_VERSION_STRING ${MYLIB_VERSION_MAJOR}.${MYLIB_VERSION_MINOR}.${MYLIB_VERSION_PATCH})
# just doing cmake . will build a shared or static lib and honor existing environment setting
# to force build static, cmake . -DBUILD_SHARED_LIBS=Off
# to force build shared, cmake . -DBUILD_SHARED_LIBS=On
if (NOT BUILD_SHARED_LIBS)
message ("Building a static library")
else ()
message ("Building a shared library")
endif ()
set( CMAKE_COLOR_MAKEFILE ON )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall --std=c++11 -O3" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3" )
set( CMAKE_ASM_FLAGS "${CXXFLAGS} -x assembler-with-cpp")
set( SRCFILES
${CMAKE_CURRENT_SOURCE_DIR}/src/bcrypt.c
${CMAKE_CURRENT_SOURCE_DIR}/src/crypt_blowfish.c
${CMAKE_CURRENT_SOURCE_DIR}/src/crypt_gensalt.c
${CMAKE_CURRENT_SOURCE_DIR}/src/wrapper.c
${CMAKE_CURRENT_SOURCE_DIR}/src/x86.S
)
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include/bcrypt)
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include)
add_library(
${PROJECT_NAME}
${SRCFILES}
)
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${MYLIB_VERSION_STRING} SOVERSION ${MYLIB_VERSION_MAJOR})
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER include/bcrypt/BCrypt.hpp)
target_include_directories(${PROJECT_NAME} PRIVATE include)
target_include_directories(${PROJECT_NAME} PRIVATE src)
add_executable( ${PROJECT_NAME}_test ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)
target_link_libraries( ${PROJECT_NAME}_test ${PROJECT_NAME})
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/bcrypt)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h")
SET(CPACK_GENERATOR "DEB")
SET(CPACK_SET_DESTDIR ON)
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Manuel Romei")
SET(CPACK_PACKAGE_VERSION "1.0.0")
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "0")
SET(CPACK_PACKAGE_VERSION_PATCH "0")
INCLUDE(CPack)