Provided compatibility with CMake 2.8.7

pull/96/head
Alexander Shishenko 2015-12-29 07:44:17 +03:00
parent 51d674c7d8
commit 033e6e7467
No known key found for this signature in database
GPG Key ID: 5165F41B94E12C76
7 changed files with 94 additions and 27 deletions

View File

@ -1,15 +1,16 @@
cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR) cmake_minimum_required(VERSION 2.8.7 FATAL_ERROR)
project(cryptopp) project(cryptopp)
set(cryptopp_VERSION 5.6.3)
set(cryptopp_VERSION_MAJOR 5)
set(cryptopp_VERSION_MINOR 6)
set(cryptopp_VERSION_PATCH 3)
include(GNUInstallDirs) include(GNUInstallDirs)
include(TestBigEndian) include(TestBigEndian)
include(CheckCXXSymbolExists) include(CheckCXXSymbolExists)
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
#============================================================================ #============================================================================
# Settable options # Settable options
#============================================================================ #============================================================================
@ -26,7 +27,10 @@ set(CRYPTOPP_DATA_DIR "" CACHE PATH "Crypto++ test data directory")
# Internal compiler options # Internal compiler options
#============================================================================ #============================================================================
set(LIB_VER ${cryptopp_VERSION_MAJOR}${cryptopp_VERSION_MINOR}${cryptopp_VERSION_PATCH}) string(REPLACE "." ";" cryptopp_VERSION_LIST ${cryptopp_VERSION})
list(GET cryptopp_VERSION_LIST 0 cryptopp_VERSION_MAJOR)
list(GET cryptopp_VERSION_LIST 1 cryptopp_VERSION_MINOR)
list(GET cryptopp_VERSION_LIST 2 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)
@ -38,6 +42,14 @@ if(IS_BIG_ENDIAN)
add_definitions(-DIS_BIG_ENDIAN) add_definitions(-DIS_BIG_ENDIAN)
endif() endif()
# Position independent code
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
# Enables -fPIC on all 64-bit platforms
set(cryptopp_POSITION_INDEPENDENT_CODE TRUE)
else()
set(cryptopp_POSITION_INDEPENDENT_CODE FALSE)
endif()
if(DISABLE_ASM) if(DISABLE_ASM)
add_definitions(-DCRYPTOPP_DISABLE_ASM) add_definitions(-DCRYPTOPP_DISABLE_ASM)
endif() endif()
@ -85,19 +97,12 @@ endif()
#============================================================================ #============================================================================
# Compile targets # Compile targets
#============================================================================ #============================================================================
add_library(cryptopp-object OBJECT ${cryptopp_SOURCES}) if(${CMAKE_VERSION} VERSION_GREATER 2.8.8)
include("cmake/cryptopp-compile-targets-2.8.8.cmake")
if(CMAKE_SIZEOF_VOID_P EQUAL 8) else()
# Enables -fPIC on all 64-bit platforms include("cmake/cryptopp-compile-targets.cmake")
set_target_properties(cryptopp-object PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
endif() endif()
add_library(cryptopp-static STATIC $<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-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})
@ -127,9 +132,7 @@ target_link_libraries(cryptopp-shared ${CMAKE_THREAD_LIBS_INIT})
#============================================================================ #============================================================================
enable_testing() enable_testing()
if(BUILD_TESTING) if(BUILD_TESTING)
add_library(cryptest-object OBJECT ${cryptopp_SOURCES_TEST}) add_executable(cryptest ${cryptopp_SOURCES_TEST})
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})
@ -175,9 +178,9 @@ install(TARGETS cryptopp-static EXPORT ${export_name} DESTINATION ${CMAKE_INSTAL
install(FILES ${cryptopp_HEADERS} DESTINATION include/cryptopp) install(FILES ${cryptopp_HEADERS} DESTINATION include/cryptopp)
# CMake Package # CMake Package
include(CMakePackageConfigHelpers) set(CVF_VERSION "${cryptopp_VERSION}")
write_basic_package_version_file("${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake" VERSION ${cryptopp_VERSION_MAJOR}.${cryptopp_VERSION_MINOR}.${cryptopp_VERSION_PATCH} COMPATIBILITY SameMajorVersion) configure_file(cmake/cryptopp-config-version.in ${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake)
install(FILES cryptopp-config.cmake ${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake DESTINATION "lib/cmake/cryptopp") install(FILES cmake/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
@ -187,7 +190,6 @@ if(BUILD_TESTING)
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})

View File

@ -304,7 +304,10 @@ Readme.txt
Install.txt Install.txt
Filelist.txt Filelist.txt
CMakeLists.txt CMakeLists.txt
cryptopp-config.cmake cmake/cryptopp-compile-targets.cmake
cmake/cryptopp-compile-targets-2.8.8.cmake
cmake/cryptopp-config.cmake
cmake/cryptopp-config-version.in
TestData/3desval.dat TestData/3desval.dat
TestData/3wayval.dat TestData/3wayval.dat
TestData/camellia.dat TestData/camellia.dat

View File

@ -403,11 +403,14 @@ endif
.PHONY: distclean .PHONY: distclean
distclean: clean distclean: clean
-$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps benchmarks.html cryptest.txt cryptest-*.txt -$(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) CMakeCache.txt install_manifest.txt Makefile *.cmake
-$(RM) *.o *.ii *.s *~ -$(RM) *.o *.ii *.s *~
ifneq ($(wildcard CMakeFiles/),) ifneq ($(wildcard CMakeFiles/),)
-$(RM) -r CMakeFiles/ -$(RM) -r CMakeFiles/
endif endif
ifneq ($(wildcard Testing/),)
-$(RM) -r Testing/
endif
ifneq ($(wildcard cryptopp$(LIB_VER)\.*),) ifneq ($(wildcard cryptopp$(LIB_VER)\.*),)
-$(RM) cryptopp$(LIB_VER)\.* -$(RM) cryptopp$(LIB_VER)\.*
endif endif
@ -506,7 +509,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 CMakeLists.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 cmake/* 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)

View File

@ -0,0 +1,9 @@
add_library(cryptopp-object OBJECT ${cryptopp_SOURCES})
set_target_properties(cryptopp-object PROPERTIES POSITION_INDEPENDENT_CODE ${cryptopp_POSITION_INDEPENDENT_CODE})
add_library(cryptopp-static STATIC $<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-static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include/cryptopp>)

View File

@ -0,0 +1,5 @@
add_library(cryptopp-static STATIC ${cryptopp_SOURCES})
add_library(cryptopp-shared SHARED ${cryptopp_SOURCES})
set_target_properties(cryptopp-static PROPERTIES POSITION_INDEPENDENT_CODE ${cryptopp_POSITION_INDEPENDENT_CODE})
set_target_properties(cryptopp-shared PROPERTIES POSITION_INDEPENDENT_CODE ${cryptopp_POSITION_INDEPENDENT_CODE})

View File

@ -0,0 +1,45 @@
# This is a basic version file for the Config-mode of find_package().
# It is used by write_basic_package_version_file() as input file for configure_file()
# to create a version-file which can be installed along a config.cmake file.
#
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
# the requested version string are exactly the same and it sets
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
# but only if the requested major version is the same as the current one.
# The variable CVF_VERSION must be set before calling configure_file().
set(PACKAGE_VERSION "@CVF_VERSION@")
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.")
set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
else()
set(CVF_VERSION_MAJOR "@CVF_VERSION@")
endif()
if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR)
set(PACKAGE_VERSION_COMPATIBLE TRUE)
else()
set(PACKAGE_VERSION_COMPATIBLE FALSE)
endif()
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
return()
endif()
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@")
math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()