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)
|
include(Pod2Man)
|
||||||
|
|
||||||
# Process subdirectories
|
# 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(src)
|
||||||
add_subdirectory(scripts)
|
add_subdirectory(scripts)
|
||||||
add_subdirectory(db)
|
add_subdirectory(db)
|
||||||
|
|
|
@ -71,6 +71,7 @@ set(ZM_BIN_SRC_FILES
|
||||||
zm_storage.cpp)
|
zm_storage.cpp)
|
||||||
|
|
||||||
add_subdirectory(jwt-cpp)
|
add_subdirectory(jwt-cpp)
|
||||||
|
add_subdirectory(libbcrypt)
|
||||||
|
|
||||||
# A fix for cmake recompiling the source files for every target.
|
# A fix for cmake recompiling the source files for every target.
|
||||||
add_library(zm STATIC ${ZM_BIN_SRC_FILES})
|
add_library(zm STATIC ${ZM_BIN_SRC_FILES})
|
||||||
|
@ -81,18 +82,15 @@ target_include_directories(zm
|
||||||
|
|
||||||
target_link_libraries(zm
|
target_link_libraries(zm
|
||||||
PUBLIC
|
PUBLIC
|
||||||
|
libbcrypt::bcrypt
|
||||||
jwt-cpp::jwt-cpp
|
jwt-cpp::jwt-cpp
|
||||||
PRIVATE
|
PRIVATE
|
||||||
zm-core-interface)
|
zm-core-interface)
|
||||||
|
|
||||||
link_directories(libbcrypt)
|
|
||||||
|
|
||||||
add_executable(zmc zmc.cpp)
|
add_executable(zmc zmc.cpp)
|
||||||
add_executable(zmu zmu.cpp)
|
add_executable(zmu zmu.cpp)
|
||||||
add_executable(zms zms.cpp)
|
add_executable(zms zms.cpp)
|
||||||
|
|
||||||
include_directories(libbcrypt/include/bcrypt)
|
|
||||||
|
|
||||||
target_link_libraries(zmc
|
target_link_libraries(zmc
|
||||||
PRIVATE
|
PRIVATE
|
||||||
zm-core-interface
|
zm-core-interface
|
||||||
|
@ -107,8 +105,7 @@ target_link_libraries(zmu
|
||||||
zm
|
zm
|
||||||
${ZM_EXTRA_LIBS}
|
${ZM_EXTRA_LIBS}
|
||||||
${ZM_BIN_LIBS}
|
${ZM_BIN_LIBS}
|
||||||
${CMAKE_DL_LIBS}
|
${CMAKE_DL_LIBS})
|
||||||
bcrypt)
|
|
||||||
|
|
||||||
target_link_libraries(zms
|
target_link_libraries(zms
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
@ -116,8 +113,7 @@ target_link_libraries(zms
|
||||||
zm
|
zm
|
||||||
${ZM_EXTRA_LIBS}
|
${ZM_EXTRA_LIBS}
|
||||||
${ZM_BIN_LIBS}
|
${ZM_BIN_LIBS}
|
||||||
${CMAKE_DL_LIBS}
|
${CMAKE_DL_LIBS})
|
||||||
bcrypt)
|
|
||||||
|
|
||||||
# Generate man files for the binaries destined for the bin folder
|
# Generate man files for the binaries destined for the bin folder
|
||||||
if(BUILD_MAN)
|
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)
|
enable_language(ASM)
|
||||||
|
|
||||||
set(MYLIB_VERSION_MAJOR 1)
|
set(BCRYPT_SOURCES
|
||||||
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/bcrypt.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/crypt_blowfish.c
|
${CMAKE_CURRENT_SOURCE_DIR}/src/crypt_blowfish.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/crypt_gensalt.c
|
${CMAKE_CURRENT_SOURCE_DIR}/src/crypt_gensalt.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/wrapper.c
|
${CMAKE_CURRENT_SOURCE_DIR}/src/wrapper.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/x86.S
|
${CMAKE_CURRENT_SOURCE_DIR}/src/x86.S)
|
||||||
)
|
|
||||||
|
|
||||||
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include/bcrypt)
|
add_library(bcrypt STATIC ${BCRYPT_SOURCES})
|
||||||
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
add_library(libbcrypt::bcrypt ALIAS bcrypt)
|
||||||
|
|
||||||
add_library(
|
target_include_directories(bcrypt
|
||||||
${PROJECT_NAME}
|
PUBLIC
|
||||||
${SRCFILES}
|
${CMAKE_CURRENT_SOURCE_DIR}/include/bcrypt)
|
||||||
)
|
|
||||||
|
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${MYLIB_VERSION_STRING} SOVERSION ${MYLIB_VERSION_MAJOR})
|
target_link_libraries(bcrypt
|
||||||
|
PRIVATE
|
||||||
|
zm-dependency-interface)
|
||||||
|
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER include/bcrypt/BCrypt.hpp)
|
if(BSD)
|
||||||
|
target_compile_definitions(bcrypt
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE include)
|
PRIVATE
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE src)
|
__SKIP_GNU)
|
||||||
|
endif()
|
||||||
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)
|
|
||||||
|
|
Loading…
Reference in New Issue