build: Cleanup CMakeLists.txt of libbcrypt
Remove unnecessary cruft and make sure it uses our compile options as dictated by zm-dependency-interface. An additional step towards a warning-free compile. Define __SKIP_GNU on BSD since they have their own bcrypt implementation.
This commit is contained in:
parent
6b7b23970b
commit
866bcc9518
|
@ -833,13 +833,6 @@ 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(src)
|
||||
add_subdirectory(scripts)
|
||||
add_subdirectory(db)
|
||||
|
|
|
@ -71,6 +71,7 @@ set(ZM_BIN_SRC_FILES
|
|||
zm_storage.cpp)
|
||||
|
||||
add_subdirectory(jwt-cpp)
|
||||
add_subdirectory(libbcrypt)
|
||||
|
||||
# A fix for cmake recompiling the source files for every target.
|
||||
add_library(zm STATIC ${ZM_BIN_SRC_FILES})
|
||||
|
@ -81,18 +82,15 @@ target_include_directories(zm
|
|||
|
||||
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)
|
||||
|
||||
include_directories(libbcrypt/include/bcrypt)
|
||||
|
||||
target_link_libraries(zmc
|
||||
PRIVATE
|
||||
zm-core-interface
|
||||
|
@ -107,8 +105,7 @@ target_link_libraries(zmu
|
|||
zm
|
||||
${ZM_EXTRA_LIBS}
|
||||
${ZM_BIN_LIBS}
|
||||
${CMAKE_DL_LIBS}
|
||||
bcrypt)
|
||||
${CMAKE_DL_LIBS})
|
||||
|
||||
target_link_libraries(zms
|
||||
PRIVATE
|
||||
|
@ -116,8 +113,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)
|
||||
|
|
|
@ -1,90 +1,25 @@
|
|||
###################################################################################
|
||||
#
|
||||
# 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})
|
||||
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)
|
||||
|
||||
# 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
|
||||
add_library(bcrypt STATIC ${BCRYPT_SOURCES})
|
||||
add_library(libbcrypt::bcrypt ALIAS bcrypt)
|
||||
|
||||
if (NOT BUILD_SHARED_LIBS)
|
||||
message ("Building a static library")
|
||||
else ()
|
||||
message ("Building a shared library")
|
||||
endif ()
|
||||
target_include_directories(bcrypt
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/bcrypt)
|
||||
|
||||
target_link_libraries(bcrypt
|
||||
PRIVATE
|
||||
zm-dependency-interface)
|
||||
|
||||
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)
|
||||
if(BSD)
|
||||
target_compile_definitions(bcrypt
|
||||
PRIVATE
|
||||
__SKIP_GNU)
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue