Tweaked makefile recipes to use variables for CP, MV, MKDIR, etc. Added Cmake artifacts to distclean rule

pull/91/head
Jeffrey Walton 2015-12-26 06:45:59 -05:00
parent ca7394540b
commit 79882d4c7d
4 changed files with 206 additions and 200 deletions

View File

@ -1,185 +1,185 @@
cmake_minimum_required(VERSION 3.2 FATAL_ERROR) cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(cryptopp VERSION 5.6.3) project(cryptopp VERSION 5.6.3)
include(GNUInstallDirs) include(GNUInstallDirs)
include(TestBigEndian) include(TestBigEndian)
include(CheckCXXSymbolExists) include(CheckCXXSymbolExists)
#============================================================================ #============================================================================
# Settable options # Settable options
#============================================================================ #============================================================================
option(BUILD_TESTING "Build library tests" ON) option(BUILD_TESTING "Build library tests" ON)
option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" OFF) option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" OFF)
option(DISABLE_ASM "Disable ASM" OFF) option(DISABLE_ASM "Disable ASM" OFF)
option(DISABLE_SSSE3 "Disable SSSE3" OFF) option(DISABLE_SSSE3 "Disable SSSE3" OFF)
option(DISABLE_AESNI "Disable AES-NI" OFF) option(DISABLE_AESNI "Disable AES-NI" OFF)
#============================================================================ #============================================================================
# Internal compiler options # Internal compiler options
#============================================================================ #============================================================================
set(LIB_VER ${cryptopp_VERSION_MAJOR}${cryptopp_VERSION_MINOR}${cryptopp_VERSION_PATCH}) set(LIB_VER ${cryptopp_VERSION_MAJOR}${cryptopp_VERSION_MINOR}${cryptopp_VERSION_PATCH})
if(CMAKE_CXX_COMPILER_ID MATCHES "Intel") if(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_definitions(-wd68 -wd186 -wd279 -wd327 -wd161 -wd3180) add_definitions(-wd68 -wd186 -wd279 -wd327 -wd161 -wd3180)
endif() endif()
# Endianess # Endianess
TEST_BIG_ENDIAN(IS_BIG_ENDIAN) TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
if(IS_BIG_ENDIAN) if(IS_BIG_ENDIAN)
add_definitions(-DIS_BIG_ENDIAN) add_definitions(-DIS_BIG_ENDIAN)
endif() endif()
if(DISABLE_ASM) if(DISABLE_ASM)
add_definitions(-DCRYPTOPP_DISABLE_ASM) add_definitions(-DCRYPTOPP_DISABLE_ASM)
endif() endif()
if(DISABLE_SSSE3) if(DISABLE_SSSE3)
add_definitions(-DCRYPTOPP_DISABLE_SSSE3) add_definitions(-DCRYPTOPP_DISABLE_SSSE3)
endif() endif()
if(DISABLE_AESNI) if(DISABLE_AESNI)
add_definitions(-DCRYPTOPP_DISABLE_AESNI) add_definitions(-DCRYPTOPP_DISABLE_AESNI)
endif() endif()
#============================================================================ #============================================================================
# Sources & headers # Sources & headers
#============================================================================ #============================================================================
# Library headers # Library headers
file(GLOB cryptopp_HEADERS *.h) file(GLOB cryptopp_HEADERS *.h)
# Test sources # Test sources
file(GLOB cryptopp_SOURCES_TEST bench.cpp bench2.cpp test.cpp validat1.cpp validat2.cpp validat3.cpp adhoc.cpp datatest.cpp regtest.cpp fipsalgt.cpp dlltest.cpp fipstest.cpp) file(GLOB cryptopp_SOURCES_TEST bench.cpp bench2.cpp test.cpp validat1.cpp validat2.cpp validat3.cpp adhoc.cpp datatest.cpp regtest.cpp fipsalgt.cpp dlltest.cpp fipstest.cpp)
# Library sources # Library sources
file(GLOB cryptopp_SOURCES *.cpp) file(GLOB cryptopp_SOURCES *.cpp)
list(REMOVE_ITEM cryptopp_SOURCES list(REMOVE_ITEM cryptopp_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/cryptlib.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cryptlib.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cpu.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cpu.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pch.cpp ${CMAKE_CURRENT_SOURCE_DIR}/pch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/simple.cpp ${CMAKE_CURRENT_SOURCE_DIR}/simple.cpp
${CMAKE_CURRENT_SOURCE_DIR}/winpipes.cpp ${CMAKE_CURRENT_SOURCE_DIR}/winpipes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cryptlib_bds.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cryptlib_bds.cpp
${cryptopp_SOURCES_TEST} ${cryptopp_SOURCES_TEST}
) )
set(cryptopp_SOURCES set(cryptopp_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/cryptlib.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cryptlib.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cpu.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cpu.cpp
${cryptopp_SOURCES} ${cryptopp_SOURCES}
) )
if(MINGW) if(MINGW)
list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/winpipes.cpp) list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/winpipes.cpp)
endif() endif()
#============================================================================ #============================================================================
# Compile targets # Compile targets
#============================================================================ #============================================================================
add_library(cryptopp-object OBJECT ${cryptopp_SOURCES}) add_library(cryptopp-object OBJECT ${cryptopp_SOURCES})
if(CMAKE_SIZEOF_VOID_P EQUAL 8) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
# Enables -fPIC on all 64-bit platforms # Enables -fPIC on all 64-bit platforms
set_target_properties(cryptopp-object PROPERTIES POSITION_INDEPENDENT_CODE TRUE) set_target_properties(cryptopp-object PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
endif() endif()
add_library(cryptopp-static STATIC $<TARGET_OBJECTS:cryptopp-object>) add_library(cryptopp-static STATIC $<TARGET_OBJECTS:cryptopp-object>)
add_library(cryptopp-shared SHARED $<TARGET_OBJECTS:cryptopp-object>) add_library(cryptopp-shared SHARED $<TARGET_OBJECTS:cryptopp-object>)
target_include_directories(cryptopp-shared PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include/cryptopp>) target_include_directories(cryptopp-shared PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include/cryptopp>)
target_include_directories(cryptopp-static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include/cryptopp>) target_include_directories(cryptopp-static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include/cryptopp>)
if(NOT MSVC) if(NOT MSVC)
set(COMPAT_VERSION ${cryptopp_VERSION_MAJOR}.${cryptopp_VERSION_MINOR}) set(COMPAT_VERSION ${cryptopp_VERSION_MAJOR}.${cryptopp_VERSION_MINOR})
set_target_properties(cryptopp-static set_target_properties(cryptopp-static
PROPERTIES PROPERTIES
OUTPUT_NAME cryptopp) OUTPUT_NAME cryptopp)
set_target_properties(cryptopp-shared set_target_properties(cryptopp-shared
PROPERTIES PROPERTIES
SOVERSION ${COMPAT_VERSION} SOVERSION ${COMPAT_VERSION}
OUTPUT_NAME cryptopp) OUTPUT_NAME cryptopp)
endif() endif()
#============================================================================ #============================================================================
# Third-party libraries # Third-party libraries
#============================================================================ #============================================================================
if(WIN32) if(WIN32)
target_link_libraries(cryptopp-static ws2_32) target_link_libraries(cryptopp-static ws2_32)
target_link_libraries(cryptopp-shared ws2_32) target_link_libraries(cryptopp-shared ws2_32)
endif() endif()
find_package(Threads) find_package(Threads)
target_link_libraries(cryptopp-static ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(cryptopp-static ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(cryptopp-shared ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(cryptopp-shared ${CMAKE_THREAD_LIBS_INIT})
#============================================================================ #============================================================================
# Tests # Tests
#============================================================================ #============================================================================
enable_testing() enable_testing()
if(BUILD_TESTING) if(BUILD_TESTING)
add_library(cryptest-object OBJECT ${cryptopp_SOURCES_TEST}) add_library(cryptest-object OBJECT ${cryptopp_SOURCES_TEST})
add_executable(cryptest $<TARGET_OBJECTS:cryptest-object>) add_executable(cryptest $<TARGET_OBJECTS:cryptest-object>)
target_link_libraries(cryptest cryptopp-static) target_link_libraries(cryptest cryptopp-static)
file(COPY ${CMAKE_SOURCE_DIR}/TestData DESTINATION ${PROJECT_BINARY_DIR}) file(COPY ${CMAKE_SOURCE_DIR}/TestData DESTINATION ${PROJECT_BINARY_DIR})
file(COPY ${CMAKE_SOURCE_DIR}/TestVectors DESTINATION ${PROJECT_BINARY_DIR}) file(COPY ${CMAKE_SOURCE_DIR}/TestVectors DESTINATION ${PROJECT_BINARY_DIR})
add_test(NAME cryptest COMMAND $<TARGET_FILE:cryptest> v) add_test(NAME cryptest COMMAND $<TARGET_FILE:cryptest> v)
endif() endif()
#============================================================================ #============================================================================
# Doxygen documentation # Doxygen documentation
#============================================================================ #============================================================================
if(BUILD_DOCUMENTATION) if(BUILD_DOCUMENTATION)
find_package(Doxygen REQUIRED) find_package(Doxygen REQUIRED)
set(in_source_DOCS_DIR "${CMAKE_SOURCE_DIR}/html-docs") set(in_source_DOCS_DIR "${CMAKE_SOURCE_DIR}/html-docs")
set(out_source_DOCS_DIR "${PROJECT_BINARY_DIR}/html-docs") set(out_source_DOCS_DIR "${PROJECT_BINARY_DIR}/html-docs")
add_custom_target(docs ALL add_custom_target(docs ALL
COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
SOURCES ${CMAKE_SOURCE_DIR}/Doxyfile SOURCES ${CMAKE_SOURCE_DIR}/Doxyfile
) )
if(NOT ${in_source_DOCS_DIR} STREQUAL ${out_source_DOCS_DIR}) if(NOT ${in_source_DOCS_DIR} STREQUAL ${out_source_DOCS_DIR})
add_custom_command( add_custom_command(
TARGET docs POST_BUILD TARGET docs POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${in_source_DOCS_DIR}" "${out_source_DOCS_DIR}" COMMAND ${CMAKE_COMMAND} -E copy_directory "${in_source_DOCS_DIR}" "${out_source_DOCS_DIR}"
COMMAND ${CMAKE_COMMAND} -E remove_directory "${in_source_DOCS_DIR}" COMMAND ${CMAKE_COMMAND} -E remove_directory "${in_source_DOCS_DIR}"
) )
endif() endif()
endif() endif()
#============================================================================ #============================================================================
# Install # Install
#============================================================================ #============================================================================
set(export_name "cryptopp-targets") set(export_name "cryptopp-targets")
# Runtime package # Runtime package
install(TARGETS cryptopp-shared EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(TARGETS cryptopp-shared EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR})
# Development package # Development package
install(TARGETS cryptopp-static EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(TARGETS cryptopp-static EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${cryptopp_HEADERS} DESTINATION include/cryptopp) install(FILES ${cryptopp_HEADERS} DESTINATION include/cryptopp)
# CMake Package # CMake Package
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
write_basic_package_version_file("${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake" COMPATIBILITY SameMajorVersion) write_basic_package_version_file("${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake" COMPATIBILITY SameMajorVersion)
install(FILES cryptopp-config.cmake ${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake DESTINATION "lib/cmake/cryptopp") install(FILES cryptopp-config.cmake ${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake DESTINATION "lib/cmake/cryptopp")
install(EXPORT ${export_name} DESTINATION "lib/cmake/cryptopp") install(EXPORT ${export_name} DESTINATION "lib/cmake/cryptopp")
# Tests # Tests
if(BUILD_TESTING) if(BUILD_TESTING)
install(TARGETS cryptest DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS cryptest DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${CMAKE_SOURCE_DIR}/TestData DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cryptopp) install(DIRECTORY ${CMAKE_SOURCE_DIR}/TestData DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cryptopp)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/TestVectors DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cryptopp) install(DIRECTORY ${CMAKE_SOURCE_DIR}/TestVectors DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cryptopp)
endif() endif()
# Documentation # Documentation
if(BUILD_DOCUMENTATION) if(BUILD_DOCUMENTATION)
install(DIRECTORY "${out_source_DOCS_DIR}" DESTINATION ${CMAKE_INSTALL_DOCDIR}) install(DIRECTORY "${out_source_DOCS_DIR}" DESTINATION ${CMAKE_INSTALL_DOCDIR})
endif() endif()

View File

@ -138,7 +138,7 @@ ALWAYS_DETAILED_SEC = NO
# operators of the base classes will not be shown. # operators of the base classes will not be shown.
# The default value is: NO. # The default value is: NO.
INLINE_INHERITED_MEMB = YES INLINE_INHERITED_MEMB = NO
# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path # If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
# before files name in the file list and in the header files. If set to NO the # before files name in the file list and in the header files. If set to NO the

View File

@ -16,6 +16,7 @@ ARFLAGS ?= -cr # ar needs the dash on OpenBSD
RANLIB ?= ranlib RANLIB ?= ranlib
CP ?= cp CP ?= cp
MV ?= mv
CHMOD ?= chmod CHMOD ?= chmod
MKDIR ?= mkdir MKDIR ?= mkdir
EGREP ?= egrep EGREP ?= egrep
@ -339,7 +340,7 @@ endif
docs html: docs html:
-$(RM) -r $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/ html-docs/ -$(RM) -r $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/ html-docs/
doxygen Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING doxygen Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING
mv $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/ $(MV) $(DOXYGEN_DIRECTORY)/ $(DOCUMENT_DIRECTORY)/
-$(RM) CryptoPPRef.zip -$(RM) CryptoPPRef.zip
zip -9 CryptoPPRef.zip -x ".*" -x "*/.*" -r $(DOCUMENT_DIRECTORY)/ zip -9 CryptoPPRef.zip -x ".*" -x "*/.*" -r $(DOCUMENT_DIRECTORY)/
@ -363,7 +364,12 @@ endif
.PHONY: distclean .PHONY: distclean
distclean: clean distclean: clean
-$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps benchmarks.html cryptest.txt cryptest-*.txt *.o *.ii *.s *~ -$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps benchmarks.html cryptest.txt cryptest-*.txt
-$(RM) CMakeCache.txt Makefile CTestTestfile.cmake cmake_install.cmake cryptopp-config-version.cmake
-$(RM) *.o *.ii *.s *~
ifneq ($(wildcard CMakeFiles/),)
-$(RM) -r CMakeFiles/
endif
ifneq ($(wildcard cryptopp$(LIB_VER)\.*),) ifneq ($(wildcard cryptopp$(LIB_VER)\.*),)
-$(RM) cryptopp$(LIB_VER)\.* -$(RM) cryptopp$(LIB_VER)\.*
endif endif
@ -461,7 +467,7 @@ dlltest.exe: cryptopp.dll $(DLLTESTOBJS)
$(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS) $(CXX) -o $@ $(CXXFLAGS) $(DLLTESTOBJS) -L. -lcryptopp.dll $(LDFLAGS) $(LDLIBS)
# This recipe prepares the distro files # This recipe prepares the distro files
TEXT_FILES := *.h *.cpp adhoc.cpp.proto License.txt Readme.txt Install.txt Filelist.txt config.recommend Doxyfile cryptest* cryptlib* dlltest* cryptdll* *.sln *.vcproj *.dsw *.dsp cryptopp.rc TestVectors/*.txt TestData/*.dat TEXT_FILES := *.h *.cpp adhoc.cpp.proto License.txt Readme.txt Install.txt Filelist.txt CMakeLists.txt config.recommend Doxyfile cryptest* cryptlib* dlltest* cryptdll* *.sln *.vcproj *.dsw *.dsp cryptopp.rc TestVectors/*.txt TestData/*.dat
EXEC_FILES := GNUmakefile GNUmakefile-cross TestData/ TestVectors/ EXEC_FILES := GNUmakefile GNUmakefile-cross TestData/ TestVectors/
ifeq ($(wildcard Filelist.txt),Filelist.txt) ifeq ($(wildcard Filelist.txt),Filelist.txt)
@ -470,11 +476,11 @@ endif
.PHONY: convert .PHONY: convert
convert: convert:
-chmod 0700 TestVectors/ TestData/ -$(CHMOD) 0700 TestVectors/ TestData/
-chmod 0600 $(TEXT_FILES) *.asm *.S *.zip -$(CHMOD) 0600 $(TEXT_FILES) *.asm *.S *.zip *.cmake
-chmod 0700 $(EXEC_FILES) *.sh *.cmd -$(CHMOD) 0700 $(EXEC_FILES) *.sh *.cmd
-chmod 0700 *.cmd *.sh GNUmakefile GNUmakefile-cross -$(CHMOD) 0700 *.cmd *.sh GNUmakefile GNUmakefile-cross
-unix2dos --keepdate --quiet $(TEXT_FILES) *.asm *.cmd -unix2dos --keepdate --quiet $(TEXT_FILES) *.asm *.cmd *.cmake
-dos2unix --keepdate --quiet GNUmakefile GNUmakefile-cross *.S *.sh -dos2unix --keepdate --quiet GNUmakefile GNUmakefile-cross *.S *.sh
ifneq ($(IS_DARWIN),0) ifneq ($(IS_DARWIN),0)
-xattr -c * -xattr -c *
@ -487,15 +493,15 @@ zip dist: | distclean convert
.PHONY: iso .PHONY: iso
iso: | zip iso: | zip
ifneq ($(IS_DARWIN),0) ifneq ($(IS_DARWIN),0)
mkdir -p $(PWD)/cryptopp$(LIB_VER) $(MKDIR) -p $(PWD)/cryptopp$(LIB_VER)
cp cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER) $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
hdiutil makehybrid -iso -joliet -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER) hdiutil makehybrid -iso -joliet -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
-rm -rf $(PWD)/cryptopp$(LIB_VER) -$(RM) -r $(PWD)/cryptopp$(LIB_VER)
else ifneq ($(IS_LINUX),0) else ifneq ($(IS_LINUX),0)
mkdir -p $(PWD)/cryptopp$(LIB_VER) $(MKDIR) -p $(PWD)/cryptopp$(LIB_VER)
cp cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER) $(CP) cryptopp$(LIB_VER).zip $(PWD)/cryptopp$(LIB_VER)
genisoimage -q -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER) genisoimage -q -o cryptopp$(LIB_VER).iso $(PWD)/cryptopp$(LIB_VER)
-rm -rf $(PWD)/cryptopp$(LIB_VER) -$(RM) -r $(PWD)/cryptopp$(LIB_VER)
endif endif
.PHONY: bench benchmark benchmarks .PHONY: bench benchmark benchmarks

View File

@ -1 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/cryptopp-targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/cryptopp-targets.cmake")