未验证 提交 4d6d2db8 编写于 作者: W wuhuanzhou 提交者: GitHub

Windows system supports Ninja compilation (#31161)

上级 0fff9306
...@@ -22,6 +22,13 @@ SET(CRYPTOPP_TAG CRYPTOPP_8_2_0) ...@@ -22,6 +22,13 @@ SET(CRYPTOPP_TAG CRYPTOPP_8_2_0)
IF(WIN32) IF(WIN32)
SET(CRYPTOPP_LIBRARIES "${CRYPTOPP_INSTALL_DIR}/lib/cryptopp-static.lib" CACHE FILEPATH "cryptopp library." FORCE) SET(CRYPTOPP_LIBRARIES "${CRYPTOPP_INSTALL_DIR}/lib/cryptopp-static.lib" CACHE FILEPATH "cryptopp library." FORCE)
# There is a compilation parameter 'FI\"winapifamily.h\"' can't be used correctly
# with Ninja on Windows. The only difference between the patch file and original
# file is that the compilation parameters are changed to 'FIwinapifamily.h'. This
# patch command can be removed when upgrading to a higher version.
if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
set(CRYPTOPP_PATCH_COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PADDLE_SOURCE_DIR}/patches/cryptopp/CMakeLists.txt" "<SOURCE_DIR>/")
endif()
ELSE(WIN32) ELSE(WIN32)
SET(CRYPTOPP_LIBRARIES "${CRYPTOPP_INSTALL_DIR}/lib/libcryptopp.a" CACHE FILEPATH "cryptopp library." FORCE) SET(CRYPTOPP_LIBRARIES "${CRYPTOPP_INSTALL_DIR}/lib/libcryptopp.a" CACHE FILEPATH "cryptopp library." FORCE)
ENDIF(WIN32) ENDIF(WIN32)
...@@ -58,6 +65,7 @@ ExternalProject_Add( ...@@ -58,6 +65,7 @@ ExternalProject_Add(
COMMAND git clone ${GIT_URL}/noloader/cryptopp-cmake "<SOURCE_DIR>/cmake" COMMAND git clone ${GIT_URL}/noloader/cryptopp-cmake "<SOURCE_DIR>/cmake"
COMMAND cd "<SOURCE_DIR>/cmake" && git checkout tags/${CRYPTOPP_TAG} -b ${CRYPTOPP_TAG} COMMAND cd "<SOURCE_DIR>/cmake" && git checkout tags/${CRYPTOPP_TAG} -b ${CRYPTOPP_TAG}
COMMAND ${CMAKE_COMMAND} -E copy_directory "<SOURCE_DIR>/cmake/" "<SOURCE_DIR>/" COMMAND ${CMAKE_COMMAND} -E copy_directory "<SOURCE_DIR>/cmake/" "<SOURCE_DIR>/"
COMMAND ${CRYPTOPP_PATCH_COMMAND}
INSTALL_DIR ${CRYPTOPP_INSTALL_DIR} INSTALL_DIR ${CRYPTOPP_INSTALL_DIR}
CMAKE_ARGS ${CRYPTOPP_CMAKE_ARGS} CMAKE_ARGS ${CRYPTOPP_CMAKE_ARGS}
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CRYPTOPP_INSTALL_DIR} CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CRYPTOPP_INSTALL_DIR}
......
...@@ -250,5 +250,8 @@ IF(NOT PROTOBUF_FOUND) ...@@ -250,5 +250,8 @@ IF(NOT PROTOBUF_FOUND)
SET(PROTOBUF_PROTOC_EXECUTABLE ${extern_protobuf_PROTOC_EXECUTABLE} SET(PROTOBUF_PROTOC_EXECUTABLE ${extern_protobuf_PROTOC_EXECUTABLE}
CACHE FILEPATH "protobuf executable." FORCE) CACHE FILEPATH "protobuf executable." FORCE)
# `EXTERN_PROTOBUF_DEPEND` used in cmake function `proto_library` to ensure
# `protoc.exe` existed before calling it.
set(EXTERN_PROTOBUF_DEPEND extern_protobuf)
PROMPT_PROTOBUF_LIB(extern_protobuf) PROMPT_PROTOBUF_LIB(extern_protobuf)
ENDIF(NOT PROTOBUF_FOUND) ENDIF(NOT PROTOBUF_FOUND)
...@@ -260,8 +260,8 @@ function(merge_static_libs TARGET_NAME) ...@@ -260,8 +260,8 @@ function(merge_static_libs TARGET_NAME)
# msvc will put libarary in directory of "/Release/xxxlib" by default # msvc will put libarary in directory of "/Release/xxxlib" by default
# COMMAND cmake -E remove "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${TARGET_NAME}.lib" # COMMAND cmake -E remove "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${TARGET_NAME}.lib"
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
COMMAND cmake -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}" COMMAND cmake -E make_directory $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND lib /OUT:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib${TARGET_NAME}.lib ${libfiles} COMMAND lib /OUT:$<TARGET_FILE:${TARGET_NAME}> ${libfiles}
) )
endif(WIN32) endif(WIN32)
endfunction(merge_static_libs) endfunction(merge_static_libs)
...@@ -755,7 +755,8 @@ function(paddle_protobuf_generate_cpp SRCS HDRS) ...@@ -755,7 +755,8 @@ function(paddle_protobuf_generate_cpp SRCS HDRS)
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
-I${CMAKE_CURRENT_SOURCE_DIR} -I${CMAKE_CURRENT_SOURCE_DIR}
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}" ${ABS_FIL} --cpp_out "${CMAKE_CURRENT_BINARY_DIR}" ${ABS_FIL}
DEPENDS ${ABS_FIL} protoc # Set `EXTERN_PROTOBUF_DEPEND` only if need to compile `protoc.exe`.
DEPENDS ${ABS_FIL} ${EXTERN_PROTOBUF_DEPEND}
COMMENT "Running C++ protocol buffer compiler on ${FIL}" COMMENT "Running C++ protocol buffer compiler on ${FIL}"
VERBATIM ) VERBATIM )
endforeach() endforeach()
......
...@@ -164,11 +164,11 @@ copy_part_of_thrid_party(inference_lib_dist ${PADDLE_INFERENCE_INSTALL_DIR}) ...@@ -164,11 +164,11 @@ copy_part_of_thrid_party(inference_lib_dist ${PADDLE_INFERENCE_INSTALL_DIR})
set(src_dir "${PADDLE_SOURCE_DIR}/paddle/fluid") set(src_dir "${PADDLE_SOURCE_DIR}/paddle/fluid")
if(WIN32) if(WIN32)
if(WITH_STATIC_LIB) if(WITH_STATIC_LIB)
set(paddle_inference_lib ${PADDLE_BINARY_DIR}/paddle/fluid/inference/${CMAKE_BUILD_TYPE}/libpaddle_inference.lib set(paddle_inference_lib $<TARGET_FILE_DIR:paddle_inference>/libpaddle_inference.lib
${PADDLE_BINARY_DIR}/paddle/fluid/inference/${CMAKE_BUILD_TYPE}/paddle_inference.*) $<TARGET_FILE_DIR:paddle_inference>/paddle_inference.*)
else() else()
set(paddle_inference_lib ${PADDLE_BINARY_DIR}/paddle/fluid/inference/${CMAKE_BUILD_TYPE}/paddle_inference.dll set(paddle_inference_lib $<TARGET_FILE_DIR:paddle_inference_shared>/paddle_inference.dll
${PADDLE_BINARY_DIR}/paddle/fluid/inference/${CMAKE_BUILD_TYPE}/paddle_inference.lib) $<TARGET_FILE_DIR:paddle_inference_shared>/paddle_inference.lib)
endif() endif()
copy(inference_lib_dist copy(inference_lib_dist
SRCS ${src_dir}/inference/api/paddle_*.h ${paddle_inference_lib} SRCS ${src_dir}/inference/api/paddle_*.h ${paddle_inference_lib}
...@@ -200,7 +200,7 @@ copy_part_of_thrid_party(inference_lib_dist ${PADDLE_INFERENCE_C_INSTALL_DIR}) ...@@ -200,7 +200,7 @@ copy_part_of_thrid_party(inference_lib_dist ${PADDLE_INFERENCE_C_INSTALL_DIR})
set(src_dir "${PADDLE_SOURCE_DIR}/paddle/fluid") set(src_dir "${PADDLE_SOURCE_DIR}/paddle/fluid")
if(WIN32) if(WIN32)
set(paddle_inference_c_lib ${PADDLE_BINARY_DIR}/paddle/fluid/inference/capi/${CMAKE_BUILD_TYPE}/paddle_inference_c.*) set(paddle_inference_c_lib $<TARGET_FILE_DIR:paddle_inference_c>/paddle_inference_c.*)
else(WIN32) else(WIN32)
set(paddle_inference_c_lib ${PADDLE_BINARY_DIR}/paddle/fluid/inference/capi/libpaddle_inference_c.*) set(paddle_inference_c_lib ${PADDLE_BINARY_DIR}/paddle/fluid/inference/capi/libpaddle_inference_c.*)
endif(WIN32) endif(WIN32)
......
...@@ -222,7 +222,7 @@ if(WITH_MKLDNN) ...@@ -222,7 +222,7 @@ if(WITH_MKLDNN)
endif() endif()
include(external/protobuf) # find first, then download, build, install protobuf include(external/protobuf) # find first, then download, build, install protobuf
if(NOT PROTOBUF_FOUND OR WIN32) if(TARGET extern_protobuf)
list(APPEND third_party_deps extern_protobuf) list(APPEND third_party_deps extern_protobuf)
endif() endif()
...@@ -317,6 +317,7 @@ endif (WITH_LITE) ...@@ -317,6 +317,7 @@ endif (WITH_LITE)
if (WITH_CRYPTO) if (WITH_CRYPTO)
include(external/cryptopp) # download, build, install cryptopp include(external/cryptopp) # download, build, install cryptopp
list(APPEND third_party_deps extern_cryptopp)
add_definitions(-DPADDLE_WITH_CRYPTO) add_definitions(-DPADDLE_WITH_CRYPTO)
endif (WITH_CRYPTO) endif (WITH_CRYPTO)
......
...@@ -374,11 +374,16 @@ if (LINUX) ...@@ -374,11 +374,16 @@ if (LINUX)
endif() endif()
if (WIN32) if (WIN32)
if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
set(paddle_framework_lib_path ${CMAKE_CURRENT_BINARY_DIR})
else()
set(paddle_framework_lib_path ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
endif()
set(FLUID_FRAMEWORK_IMPORT_LIB set(FLUID_FRAMEWORK_IMPORT_LIB
${PADDLE_BINARY_DIR}/paddle/fluid/framework/${CMAKE_BUILD_TYPE}/paddle_framework.lib ${paddle_framework_lib_path}/paddle_framework.lib
CACHE INTERNAL "Fluid framework lib") CACHE INTERNAL "Fluid framework lib")
set(FLUID_FRAMEWORK_SHARED_LIB set(FLUID_FRAMEWORK_SHARED_LIB
${PADDLE_BINARY_DIR}/paddle/fluid/framework/${CMAKE_BUILD_TYPE}/paddle_framework.dll ${paddle_framework_lib_path}/paddle_framework.dll
CACHE INTERNAL "Fluid framework dll") CACHE INTERNAL "Fluid framework dll")
endif() endif()
...@@ -417,11 +422,16 @@ if (LINUX) ...@@ -417,11 +422,16 @@ if (LINUX)
endif() endif()
if (WIN32) if (WIN32)
if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
set(paddle_custom_op_lib_path ${CMAKE_CURRENT_BINARY_DIR})
else()
set(paddle_custom_op_lib_path ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
endif()
set(PADDLE_CUSTOM_OP_IMPORT_LIB set(PADDLE_CUSTOM_OP_IMPORT_LIB
${PADDLE_BINARY_DIR}/paddle/fluid/framework/${CMAKE_BUILD_TYPE}/paddle_custom_op.lib ${paddle_custom_op_lib_path}/paddle_custom_op.lib
CACHE INTERNAL "Paddle custom op import lib") CACHE INTERNAL "Paddle custom op import lib")
set(PADDLE_CUSTOM_OP_SHARED_LIB set(PADDLE_CUSTOM_OP_SHARED_LIB
${PADDLE_BINARY_DIR}/paddle/fluid/framework/${CMAKE_BUILD_TYPE}/paddle_custom_op.dll ${paddle_custom_op_lib_path}/paddle_custom_op.dll
CACHE INTERNAL "Paddle custom op dll") CACHE INTERNAL "Paddle custom op dll")
endif() endif()
......
...@@ -101,11 +101,16 @@ if(WITH_PYTHON) ...@@ -101,11 +101,16 @@ if(WITH_PYTHON)
set(tmp_impl_file ${impl_file}.tmp) set(tmp_impl_file ${impl_file}.tmp)
if(WIN32) if(WIN32)
if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
set(op_function_generator_path "${CMAKE_CURRENT_BINARY_DIR}")
else()
set(op_function_generator_path "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
endif()
file(WRITE ${CMAKE_BINARY_DIR}/paddle/fluid/pybind/op_function_generator_retry.bat "" file(WRITE ${CMAKE_BINARY_DIR}/paddle/fluid/pybind/op_function_generator_retry.bat ""
"set build_times=1\n" "set build_times=1\n"
":retry\n" ":retry\n"
"ECHO op_function_generator run %build_times% time\n" "ECHO op_function_generator run %build_times% time\n"
"${CMAKE_BINARY_DIR}/paddle/fluid/pybind/${CMAKE_BUILD_TYPE}/op_function_generator ${impl_file}\n" "${op_function_generator_path}/op_function_generator ${impl_file}\n"
"if %ERRORLEVEL% NEQ 0 (\n" "if %ERRORLEVEL% NEQ 0 (\n"
" set /a build_times=%build_times%+1\n" " set /a build_times=%build_times%+1\n"
" if %build_times% GTR 100 (\n" " if %build_times% GTR 100 (\n"
...@@ -123,19 +128,19 @@ if(WITH_PYTHON) ...@@ -123,19 +128,19 @@ if(WITH_PYTHON)
if(${CBLAS_PROVIDER} STREQUAL MKLML) if(${CBLAS_PROVIDER} STREQUAL MKLML)
add_custom_command(TARGET op_function_generator add_custom_command(TARGET op_function_generator
PRE_LINK PRE_LINK
COMMAND ${CMAKE_COMMAND} -E copy ${MKLML_SHARED_LIB} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE} COMMAND ${CMAKE_COMMAND} -E copy ${MKLML_SHARED_LIB} ${op_function_generator_path}
COMMAND ${CMAKE_COMMAND} -E copy ${MKLML_SHARED_IOMP_LIB} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE} COMMAND ${CMAKE_COMMAND} -E copy ${MKLML_SHARED_IOMP_LIB} ${op_function_generator_path}
) )
else(${CBLAS_PROVIDER} STREQUAL EXTERN_OPENBLAS) else(${CBLAS_PROVIDER} STREQUAL EXTERN_OPENBLAS)
add_custom_command(TARGET op_function_generator add_custom_command(TARGET op_function_generator
PRE_LINK PRE_LINK
COMMAND ${CMAKE_COMMAND} -E copy ${OPENBLAS_SHARED_LIB} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE} COMMAND ${CMAKE_COMMAND} -E copy ${OPENBLAS_SHARED_LIB} ${op_function_generator_path}
) )
endif() endif()
if(WITH_MKLDNN) if(WITH_MKLDNN)
add_custom_command(TARGET op_function_generator add_custom_command(TARGET op_function_generator
PRE_LINK PRE_LINK
COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_SHARED_LIB} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE} COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_SHARED_LIB} ${op_function_generator_path}
) )
endif() endif()
else(WIN32) else(WIN32)
......
...@@ -146,6 +146,15 @@ rem set CLCACHE_OBJECT_CACHE_TIMEOUT_MS=1000000 ...@@ -146,6 +146,15 @@ rem set CLCACHE_OBJECT_CACHE_TIMEOUT_MS=1000000
:: set maximum cache size to 20G :: set maximum cache size to 20G
rem clcache.exe -M 21474836480 rem clcache.exe -M 21474836480
:: install ninja if GENERATOR is Ninja
if %GENERATOR% == "Ninja" (
pip install ninja
if %errorlevel% NEQ 0 (
echo pip install ninja failed!
exit /b 7
)
)
rem ------show summary of current environment---------- rem ------show summary of current environment----------
cmake --version cmake --version
nvcc --version nvcc --version
...@@ -285,14 +294,14 @@ if "%WITH_GPU%"=="ON" ( ...@@ -285,14 +294,14 @@ if "%WITH_GPU%"=="ON" (
) )
:cmake_impl :cmake_impl
echo cmake .. -G %GENERATOR% -DWITH_AVX=%WITH_AVX% -DWITH_GPU=%WITH_GPU% -DWITH_MKL=%WITH_MKL% ^ echo cmake .. -G %GENERATOR% -DCMAKE_BUILD_TYPE=Release -DWITH_AVX=%WITH_AVX% -DWITH_GPU=%WITH_GPU% -DWITH_MKL=%WITH_MKL% ^
-DWITH_TESTING=%WITH_TESTING% -DWITH_PYTHON=%WITH_PYTHON% -DPYTHON_EXECUTABLE=%PYTHON_EXECUTABLE% -DON_INFER=%ON_INFER% ^ -DWITH_TESTING=%WITH_TESTING% -DWITH_PYTHON=%WITH_PYTHON% -DPYTHON_EXECUTABLE=%PYTHON_EXECUTABLE% -DON_INFER=%ON_INFER% ^
-DWITH_INFERENCE_API_TEST=%WITH_INFERENCE_API_TEST% -DTHIRD_PARTY_PATH=%THIRD_PARTY_PATH% ^ -DWITH_INFERENCE_API_TEST=%WITH_INFERENCE_API_TEST% -DTHIRD_PARTY_PATH=%THIRD_PARTY_PATH% ^
-DINFERENCE_DEMO_INSTALL_DIR=%INFERENCE_DEMO_INSTALL_DIR% -DWITH_STATIC_LIB=%WITH_STATIC_LIB% ^ -DINFERENCE_DEMO_INSTALL_DIR=%INFERENCE_DEMO_INSTALL_DIR% -DWITH_STATIC_LIB=%WITH_STATIC_LIB% ^
-DWITH_TENSORRT=%WITH_TENSORRT% -DTENSORRT_ROOT="%TENSORRT_ROOT%" -DMSVC_STATIC_CRT=%MSVC_STATIC_CRT% ^ -DWITH_TENSORRT=%WITH_TENSORRT% -DTENSORRT_ROOT="%TENSORRT_ROOT%" -DMSVC_STATIC_CRT=%MSVC_STATIC_CRT% ^
-DWITH_UNITY_BUILD=%WITH_UNITY_BUILD% -DCUDA_ARCH_NAME=%CUDA_ARCH_NAME% -DWITH_UNITY_BUILD=%WITH_UNITY_BUILD% -DCUDA_ARCH_NAME=%CUDA_ARCH_NAME%
cmake .. -G %GENERATOR% -DWITH_AVX=%WITH_AVX% -DWITH_GPU=%WITH_GPU% -DWITH_MKL=%WITH_MKL% ^ cmake .. -G %GENERATOR% -DCMAKE_BUILD_TYPE=Release -DWITH_AVX=%WITH_AVX% -DWITH_GPU=%WITH_GPU% -DWITH_MKL=%WITH_MKL% ^
-DWITH_TESTING=%WITH_TESTING% -DWITH_PYTHON=%WITH_PYTHON% -DPYTHON_EXECUTABLE=%PYTHON_EXECUTABLE% -DON_INFER=%ON_INFER% ^ -DWITH_TESTING=%WITH_TESTING% -DWITH_PYTHON=%WITH_PYTHON% -DPYTHON_EXECUTABLE=%PYTHON_EXECUTABLE% -DON_INFER=%ON_INFER% ^
-DWITH_INFERENCE_API_TEST=%WITH_INFERENCE_API_TEST% -DTHIRD_PARTY_PATH=%THIRD_PARTY_PATH% ^ -DWITH_INFERENCE_API_TEST=%WITH_INFERENCE_API_TEST% -DTHIRD_PARTY_PATH=%THIRD_PARTY_PATH% ^
-DINFERENCE_DEMO_INSTALL_DIR=%INFERENCE_DEMO_INSTALL_DIR% -DWITH_STATIC_LIB=%WITH_STATIC_LIB% ^ -DINFERENCE_DEMO_INSTALL_DIR=%INFERENCE_DEMO_INSTALL_DIR% -DWITH_STATIC_LIB=%WITH_STATIC_LIB% ^
...@@ -317,7 +326,11 @@ for /F %%# in ('wmic cpu get NumberOfLogicalProcessors^|findstr [0-9]') do set / ...@@ -317,7 +326,11 @@ for /F %%# in ('wmic cpu get NumberOfLogicalProcessors^|findstr [0-9]') do set /
set build_times=1 set build_times=1
:build_tp :build_tp
echo Build third_party the %build_times% time: echo Build third_party the %build_times% time:
msbuild /m /p:Configuration=Release /verbosity:quiet third_party.vcxproj if %GENERATOR% == "Ninja" (
ninja third_party
) else (
msbuild /m /p:Configuration=Release /verbosity:quiet third_party.vcxproj
)
if %ERRORLEVEL% NEQ 0 ( if %ERRORLEVEL% NEQ 0 (
set /a build_times=%build_times%+1 set /a build_times=%build_times%+1
if %build_times% GTR 2 ( if %build_times% GTR 2 (
...@@ -335,10 +348,14 @@ set build_times=1 ...@@ -335,10 +348,14 @@ set build_times=1
rem clcache.exe -z rem clcache.exe -z
echo Build Paddle the %build_times% time: echo Build Paddle the %build_times% time:
if "%WITH_CLCACHE%"=="OFF" ( if %GENERATOR% == "Ninja" (
msbuild /m:%PARALLEL_PROJECT_COUNT% /p:Configuration=Release /verbosity:%LOG_LEVEL% paddle.sln ninja -j %PARALLEL_PROJECT_COUNT%
) else ( ) else (
if "%WITH_CLCACHE%"=="OFF" (
msbuild /m:%PARALLEL_PROJECT_COUNT% /p:Configuration=Release /verbosity:%LOG_LEVEL% paddle.sln
) else (
msbuild /m:%PARALLEL_PROJECT_COUNT% /p:TrackFileAccess=false /p:CLToolExe=clcache.exe /p:CLToolPath=%PYTHON_ROOT%\Scripts /p:Configuration=Release /verbosity:%LOG_LEVEL% paddle.sln msbuild /m:%PARALLEL_PROJECT_COUNT% /p:TrackFileAccess=false /p:CLToolExe=clcache.exe /p:CLToolPath=%PYTHON_ROOT%\Scripts /p:Configuration=Release /verbosity:%LOG_LEVEL% paddle.sln
)
) )
if %ERRORLEVEL% NEQ 0 ( if %ERRORLEVEL% NEQ 0 (
......
# Please ensure your changes or patch meets minimum requirements.
# The minimum requirements are 2.8.6. It roughly equates to
# Ubuntu 14.05 LTS or Solaris 11.3. Please do not check in something
# for 3.5.0 or higher because it will break LTS operating systems
# and a number of developer boards used for testing. To test your
# changes, please set up a Ubuntu 14.05 LTS system.
# Should we be setting things like this? We are not a C project
# so nothing should be done with the C compiler. But there is
# no reliable way to tell CMake we are C++.
# Cannot set this... Breaks Linux PowerPC with Clang:
# SET(CMAKE_C_COMPILER ${CMAKE_CXX_COMPILER})
# # error "The CMAKE_C_COMPILER is set to a C++ compiler"
if(NOT DEFINED cryptocpp_DISPLAY_CMAKE_SUPPORT_WARNING)
set(cryptocpp_DISPLAY_CMAKE_SUPPORT_WARNING 1)
endif()
if(cryptocpp_DISPLAY_CMAKE_SUPPORT_WARNING)
message( STATUS
"*************************************************************************\n"
"The Crypto++ library does not officially support CMake. CMake support is a\n"
"community effort, and the library works with the folks using CMake to help\n"
"improve it. If you find an issue then please fix it or report it at\n"
"https://github.com/noloader/cryptopp-cmake.\n"
"-- *************************************************************************"
)
endif()
# Print useful information
message( STATUS "CMake version ${CMAKE_VERSION}" )
cmake_minimum_required(VERSION 2.8.6)
if (${CMAKE_VERSION} VERSION_LESS "3.0.0")
project(cryptopp)
set(cryptopp_VERSION_MAJOR 8)
set(cryptopp_VERSION_MINOR 2)
set(cryptopp_VERSION_PATCH 0)
else ()
cmake_policy(SET CMP0048 NEW)
project(cryptopp VERSION 8.2.0)
if (NOT ${CMAKE_VERSION} VERSION_LESS "3.1.0")
cmake_policy(SET CMP0054 NEW)
endif ()
endif ()
# Need to set SRC_DIR manually after removing the Python library code.
set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
# Make RelWithDebInfo the default (it does e.g. add '-O2 -g -DNDEBUG' for GNU)
# If not in multi-configuration environments, no explicit build type or CXX
# flags are set by the user and if we are the root CMakeLists.txt file.
if (NOT CMAKE_CONFIGURATION_TYPES AND
NOT CMAKE_NO_BUILD_TYPE AND
NOT CMAKE_BUILD_TYPE AND
NOT CMAKE_CXX_FLAGS AND
CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif ()
include(GNUInstallDirs)
include(CheckCXXCompilerFlag)
# We now carry around test programs. test_cxx.cxx is the default C++ one.
# Also see https://github.com/weidai11/cryptopp/issues/741.
set(TEST_PROG_DIR ${SRC_DIR}/TestPrograms)
set(TEST_CXX_FILE ${TEST_PROG_DIR}/test_cxx.cxx)
#============================================================================
# Settable options
#============================================================================
option(BUILD_STATIC "Build static library" ON)
option(BUILD_SHARED "Build shared library" ON)
option(BUILD_TESTING "Build library tests" ON)
option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" OFF)
option(USE_INTERMEDIATE_OBJECTS_TARGET "Use a common intermediate objects target for the static and shared library targets" ON)
# These are IA-32 options. TODO: Add ARM A-32, Aarch64 and Power8 options.
option(DISABLE_ASM "Disable ASM" OFF)
option(DISABLE_SSSE3 "Disable SSSE3" OFF)
option(DISABLE_SSE4 "Disable SSE4" OFF)
option(DISABLE_AESNI "Disable AES-NI" OFF)
option(DISABLE_SHA "Disable SHA" OFF)
option(DISABLE_AVX "Disable AVX" OFF)
option(DISABLE_AVX2 "Disable AVX2" OFF)
option(CRYPTOPP_NATIVE_ARCH "Enable native architecture" OFF)
set(CRYPTOPP_DATA_DIR "" CACHE PATH "Crypto++ test data directory")
#============================================================================
# Compiler options
#============================================================================
set(CRYPTOPP_COMPILE_DEFINITIONS)
set(CRYPTOPP_COMPILE_OPTIONS)
# Stop hiding the damn output...
# set(CMAKE_VERBOSE_MAKEFILE on)
# Always 1 ahead in Master. Also see http://groups.google.com/forum/#!topic/cryptopp-users/SFhqLDTQPG4
set(LIB_VER ${cryptopp_VERSION_MAJOR}${cryptopp_VERSION_MINOR}${cryptopp_VERSION_PATCH})
# Don't use RPATH's. The resulting binary could fail a security audit.
set(CMAKE_MACOSX_RPATH 0)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
list(APPEND CRYPTOPP_COMPILE_OPTIONS -wd68 -wd186 -wd279 -wd327 -wd161 -wd3180)
endif ()
# Also see http://github.com/weidai11/cryptopp/issues/395
if (DISABLE_ASM)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_ASM)
endif ()
if (DISABLE_SSSE3)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SSSE3)
endif ()
if (DISABLE_SSE4)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SSSE4)
endif ()
if (DISABLE_AESNI)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_AESNI)
endif ()
if (DISABLE_SHA)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SHA)
endif ()
if (DISABLE_ALTIVEC)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_ALTIVEC)
endif ()
if (DISABLE_POWER7)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_POWER7)
endif ()
if (DISABLE_POWER8)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_POWER8)
endif ()
if (DISABLE_POWER9)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_POWER9)
endif ()
if (NOT CRYPTOPP_DATA_DIR STREQUAL "")
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS "CRYPTOPP_DATA_DIR=${CRYPTOPP_DATA_DIR}")
endif ()
###############################################################################
# Try to find a Posix compatible grep and sed. Solaris, Digital Unix,
# Tru64, HP-UX and a few others need tweaking
if (EXISTS /usr/xpg4/bin/grep)
set(GREP_CMD /usr/xpg4/bin/grep)
elseif (EXISTS /usr/gnu/bin/grep)
set(GREP_CMD /usr/gnu/bin/grep)
elseif (EXISTS /usr/linux/bin/grep)
set(GREP_CMD /usr/linux/bin/grep)
else ()
set(GREP_CMD grep)
endif ()
if (EXISTS /usr/xpg4/bin/sed)
set(SED_CMD /usr/xpg4/bin/sed)
elseif (EXISTS /usr/gnu/bin/sed)
set(SED_CMD /usr/gnu/bin/sed)
elseif (EXISTS /usr/linux/bin/sed)
set(SED_CMD /usr/linux/bin/sed)
else ()
set(SED_CMD sed)
endif ()
###############################################################################
function(CheckCompileOption opt var)
if (MSVC)
# TODO: improve this...
CHECK_CXX_COMPILER_FLAG(${opt} ${var})
elseif (CMAKE_CXX_COMPILER_ID MATCHES "SunPro")
message(STATUS "Performing Test ${var}")
execute_process(
COMMAND sh -c "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS} ${opt} -c ${TEST_CXX_FILE} 2>&1"
COMMAND ${GREP_CMD} -i -c -E "illegal value ignored"
RESULT_VARIABLE COMMAND_RESULT
OUTPUT_VARIABLE COMMAND_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE)
# No dereference below. Thanks for the warning, CMake (not!).
if (COMMAND_RESULT AND NOT COMMAND_OUTPUT)
set(${var} 1 PARENT_SCOPE)
message(STATUS "Performing Test ${var} - Success")
else ()
set(${var} 0 PARENT_SCOPE)
message(STATUS "Performing Test ${var} - Failed")
endif ()
# Must use CMAKE_CXX_COMPILER here due to XLC 13.1 and LLVM front-end.
elseif (CMAKE_CXX_COMPILER MATCHES "xlC")
message(STATUS "Performing Test ${var}")
execute_process(
COMMAND sh -c "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS} ${opt} -c ${TEST_CXX_FILE} 2>&1"
COMMAND ${GREP_CMD} -i -c -E "Unrecognized value"
RESULT_VARIABLE COMMAND_RESULT
OUTPUT_VARIABLE COMMAND_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE)
# No dereference below. Thanks for the warning, CMake (not!).
if (COMMAND_RESULT AND NOT COMMAND_OUTPUT)
set(${var} 1 PARENT_SCOPE)
message(STATUS "Performing Test ${var} - Success")
else ()
set(${var} 0 PARENT_SCOPE)
message(STATUS "Performing Test ${var} - Failed")
endif ()
else ()
CHECK_CXX_COMPILER_FLAG(${opt} ${var})
endif ()
endfunction(CheckCompileOption)
function(CheckCompileLinkOption opt var prog)
if (MSVC)
# TODO: improve this...
CHECK_CXX_COMPILER_FLAG(${opt} ${var})
else ()
message(STATUS "Performing Test ${var}")
execute_process(
COMMAND sh -c "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS} ${opt} ${prog} 2>&1"
RESULT_VARIABLE COMMAND_RESULT
OUTPUT_VARIABLE COMMAND_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE)
# message(STATUS "RESULT_VARIABLE ${RESULT_VARIABLE}")
# message(STATUS "COMMAND_RESULT ${COMMAND_RESULT}")
# message(STATUS "OUTPUT_VARIABLE ${OUTPUT_VARIABLE}")
# message(STATUS "COMMAND_OUTPUT ${COMMAND_OUTPUT}")
# This test is strict. We require two things. First, the invocation
# of the compile command must return 0. Second, there must be no
# messages on the console. We are interested in diagnostics like
# warnings to decide when to reject an option. But we will probably
# capture chatty compiler that want to say, "Hooray, success". For
# chatty compilers we will need to find a quiet option and use it
# for the test. Microsoft compilers come to mind.
if ("${COMMAND_RESULT}" EQUAL 0 AND "${COMMAND_OUTPUT}" STREQUAL "")
set(${var} 1 PARENT_SCOPE)
message(STATUS "Performing Test ${var} - Success")
else ()
set(${var} 0 PARENT_SCOPE)
message(STATUS "Performing Test ${var} - Failed")
endif ()
endif ()
endfunction(CheckCompileLinkOption)
function(AddCompileOption opt)
if ("${COMMAND_OUTPUT}" NOT STREQUAL "")
list(APPEND CRYPTOPP_COMPILE_OPTIONS "${opt}")
endif ()
endfunction(AddCompileOption)
###############################################################################
function(DumpMachine output pattern)
if (MSVC)
# CMake does not provide a generic shell/terminal mechanism
# and Microsoft environments don't know what 'sh' is.
set(${output} 0 PARENT_SCOPE)
else ()
execute_process(
COMMAND sh -c "${CMAKE_CXX_COMPILER} -dumpmachine 2>&1"
COMMAND ${GREP_CMD} -i -c -E "${pattern}"
OUTPUT_VARIABLE ${output}
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(${output} "${${output}}" PARENT_SCOPE)
endif()
endfunction(DumpMachine)
# Thansk to Anonimal for MinGW; see http://github.com/weidai11/cryptopp/issues/466
DumpMachine(CRYPTOPP_AMD64 "amd64|x86_64")
DumpMachine(CRYPTOPP_I386 "i.86")
DumpMachine(CRYPTOPP_MINGW32 "\\<mingw32\\>")
DumpMachine(CRYPTOPP_MINGW64 "w64-mingw32|mingw64")
DumpMachine(CRYPTOPP_X32 "x32")
DumpMachine(CRYPTOPP_AARCH32 "Aarch32")
DumpMachine(CRYPTOPP_AARCH64 "Aarch64")
DumpMachine(CRYPTOPP_ARMHF "armhf|arm7l|eabihf")
DumpMachine(CRYPTOPP_ARM "\\<arm\\>")
# Detecting PowerPC is only good with GCC. IBM XLC compiler is
# a little different and I don't know how to ask to the triplet
# XLC is targeting. Below we punt by setting CRYPTOPP_POWERPC64
# if we detect the compiler is XLC.
DumpMachine(CRYPTOPP_POWERPC "ppc|powerpc")
DumpMachine(CRYPTOPP_POWERPC64 "ppc64")
###############################################################################
# Test SunCC for a string like 'CC: Sun C++ 5.13 SunOS_i386'
if (NOT CRYPTOPP_SOLARIS)
execute_process(COMMAND sh -c "${CMAKE_CXX_COMPILER} -V 2>&1"
COMMAND ${GREP_CMD} -i -c "SunOS"
OUTPUT_VARIABLE CRYPTOPP_SOLARIS
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif ()
# Test GCC for a string like 'i386-pc-solaris2.11'
if (NOT CRYPTOPP_SOLARIS)
execute_process(COMMAND sh -c "${CMAKE_CXX_COMPILER} -dumpmachine 2>&1"
COMMAND ${GREP_CMD} -i -c "Solaris"
OUTPUT_VARIABLE CRYPTOPP_SOLARIS
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif ()
# Fixup PowerPC. If both 32-bit and 64-bit use 64-bit.
if (CRYPTOPP_POWERPC AND CRYPTOPP_POWERPC64)
unset(CRYPTOPP_POWERPC)
endif ()
# Fixup for xlC compiler. -dumpmachine fails so we miss PowerPC
# TODO: something better than proxying the platform via compiler
# Must use CMAKE_CXX_COMPILER here due to XLC 13.1 and LLVM front-end.
if (CMAKE_CXX_COMPILER MATCHES "xlC")
message ("-- Fixing platform due to IBM xlC")
set(CRYPTOPP_POWERPC64 1)
endif ()
# DumpMachine SunCC style
if (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
# SunCC is 32-bit, but it builds both 32 and 64 bit. Use
execute_process(COMMAND sh -c "${CMAKE_CXX_COMPILER} -V 2>&1"
COMMAND ${GREP_CMD} -i -c "Sparc"
OUTPUT_VARIABLE CRYPTOPP_SPARC
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND sh -c "${CMAKE_CXX_COMPILER} -V 2>&1"
COMMAND ${GREP_CMD} -i -c -E "i386|i86"
OUTPUT_VARIABLE CRYPTOPP_I386
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND isainfo -k
COMMAND ${GREP_CMD} -i -c "i386"
OUTPUT_VARIABLE KERNEL_I386
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND isainfo -k
COMMAND ${GREP_CMD} -i -c "amd64"
OUTPUT_VARIABLE KERNEL_AMD64
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND isainfo -k
COMMAND ${GREP_CMD} -i -c "Sparc"
OUTPUT_VARIABLE KERNEL_SPARC
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND isainfo -k
COMMAND ${GREP_CMD} -i -c -E "UltraSarc|Sparc64|SparcV9"
OUTPUT_VARIABLE KERNEL_SPARC64
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif ()
###############################################################################
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
execute_process(COMMAND sh -c "${CMAKE_CXX_COMPILER} --version 2>&1"
COMMAND ${GREP_CMD} -i -c "macports"
OUTPUT_VARIABLE MACPORTS
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (MACPORTS EQUAL 0)
# Get GAS version, add defs + set as appropriate
set(GAS_CMD sh -c "${CMAKE_CXX_COMPILER} -xc -c /dev/null -Wa,-v -o/dev/null 2>&1")
execute_process(COMMAND ${GAS_CMD}
OUTPUT_VARIABLE GAS_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(FIND "${GAS_STRING}" "GNU assembler" GAS_OUTPUT)
if (NOT GAS_OUTPUT EQUAL -1)
#.intel_syntax wasn't supported until GNU assembler 2.10
# TODO(unassigned): string() REGEX was not cooperating at time of writing. Re-implement as needed.
execute_process(COMMAND echo ${GAS_STRING}
COMMAND ${GREP_CMD} -i -c -E "GNU.[Aa]ssembler.*(2\\.[1-9][0-9]|[3-9])"
OUTPUT_VARIABLE GAS210_OR_LATER)
if (GAS210_OR_LATER EQUAL 0)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_ASM)
set(DISABLE_ASM 1)
endif ()
execute_process(COMMAND echo ${GAS_STRING}
COMMAND ${GREP_CMD} -i -c -E "GNU.[Aa]ssembler.*(2\\.1[7-9]|2\\.[2-9]|[3-9])"
OUTPUT_VARIABLE GAS217_OR_LATER)
if (GAS217_OR_LATER EQUAL 0)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SSSE3)
set(DISABLE_SSSE3 1)
endif ()
# OpenBSD and CentOS 5 needed this one due to ARIA and BLAKE2
execute_process(COMMAND echo ${GAS_STRING}
COMMAND ${GREP_CMD} -i -c -E "GNU.[Aa]ssembler.*(2\\.1[8-9]|2\\.[2-9]|[3-9])"
OUTPUT_VARIABLE GAS218_OR_LATER)
if (GAS218_OR_LATER EQUAL 0)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SSSE4)
set(DISABLE_SSE4 1)
endif ()
execute_process(COMMAND echo ${GAS_STRING}
COMMAND ${GREP_CMD} -i -c -E "GNU.[Aa]ssembler.*(2\\.19|2\\.[2-9]|[3-9])"
OUTPUT_VARIABLE GAS219_OR_LATER)
if (GAS219_OR_LATER EQUAL 0)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_AESNI)
set(DISABLE_AESNI 1)
endif ()
# Ubuntu 10 and Ubuntu 12 needed this one
execute_process(COMMAND echo ${GAS_STRING}
COMMAND ${GREP_CMD} -i -c -E "GNU.[Aa]ssembler.*(2\\.2[3-9]|2\\.[3-9]|[3-9])"
OUTPUT_VARIABLE GAS223_OR_LATER)
if (GAS223_OR_LATER EQUAL 0)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SHA)
set(DISABLE_SHA 1)
endif ()
endif ()
endif ()
endif ()
# TODO: what about ICC and LLVM on Windows?
if (MSVC)
if (CMAKE_SYSTEM_VERSION MATCHES "10\\.0.*")
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS "_WIN32_WINNT=0x0A00")
endif ()
list(APPEND CRYPTOPP_COMPILE_OPTIONS "/FIwinapifamily.h")
endif ()
# Enable PIC for all target machines except 32-bit i386 due to register pressures.
if (NOT CRYPTOPP_I386)
SET(CMAKE_POSITION_INDEPENDENT_CODE 1)
endif ()
# IBM XLC compiler options for AIX and Linux.
# Must use CMAKE_CXX_COMPILER here due to XLC 13.1 and LLVM front-end.
if (CMAKE_CXX_COMPILER MATCHES "xlC")
#CheckCompileLinkOption("-qxlcompatmacros" CRYPTOPP_XLC_COMPAT "${TEST_CXX_FILE}")
#if (CRYPTOPP_XLC_COMPAT)
# list(APPEND CRYPTOPP_COMPILE_OPTIONS "-qxlcompatmacros")
#endif ()
CheckCompileLinkOption("-qrtti" CRYPTOPP_PPC_RTTI "${TEST_CXX_FILE}")
if (CRYPTOPP_PPC_RTTI)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-qrtti")
endif ()
CheckCompileLinkOption("-qmaxmem=-1" CRYPTOPP_PPC_MAXMEM "${TEST_CXX_FILE}")
if (CRYPTOPP_PPC_MAXMEM)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-qmaxmem=-1")
endif ()
CheckCompileLinkOption("-qthreaded" CRYPTOPP_PPC_THREADED "${TEST_CXX_FILE}")
if (CRYPTOPP_PPC_THREADED)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-qthreaded")
endif ()
endif ()
# Solaris specific
if (CRYPTOPP_SOLARIS)
# SunCC needs -template=no%extdef
if (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-template=no%extdef")
endif ()
# SunCC needs -xregs=no%appl on Sparc (not x86) for libraries (not test program)
# TODO: wire this up properly
if (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro" AND (CRYPTOPP_SPARC OR CRYPTOPP_SPARC64))
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-xregs=no%appl")
endif ()
# GCC needs to enable use of '/' for division in the assembler
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-Wa,--divide")
endif ()
endif ()
#============================================================================
# Sources & headers
#============================================================================
# Library headers
file(GLOB cryptopp_HEADERS ${SRC_DIR}/*.h)
# Remove headers used to build test suite
list(REMOVE_ITEM cryptopp_HEADERS
${SRC_DIR}/bench.h
${SRC_DIR}/validate.h
)
# Test sources. You can use the GNUmakefile to generate the list: `make sources`.
set(cryptopp_SOURCES_TEST
${SRC_DIR}/test.cpp
${SRC_DIR}/bench1.cpp
${SRC_DIR}/bench2.cpp
${SRC_DIR}/bench3.cpp
${SRC_DIR}/validat0.cpp
${SRC_DIR}/validat1.cpp
${SRC_DIR}/validat2.cpp
${SRC_DIR}/validat3.cpp
${SRC_DIR}/validat4.cpp
${SRC_DIR}/validat5.cpp
${SRC_DIR}/validat6.cpp
${SRC_DIR}/validat7.cpp
${SRC_DIR}/validat8.cpp
${SRC_DIR}/validat9.cpp
${SRC_DIR}/validat10.cpp
${SRC_DIR}/regtest1.cpp
${SRC_DIR}/regtest2.cpp
${SRC_DIR}/regtest3.cpp
${SRC_DIR}/regtest4.cpp
${SRC_DIR}/datatest.cpp
${SRC_DIR}/fipsalgt.cpp
${SRC_DIR}/fipstest.cpp
${SRC_DIR}/dlltest.cpp
#${SRC_DIR}/adhoc.cpp
)
# Library sources. You can use the GNUmakefile to generate the list: `make sources`.
# Makefile sorted them at http://github.com/weidai11/cryptopp/pull/426.
file(GLOB cryptopp_SOURCES ${SRC_DIR}/*.cpp)
list(SORT cryptopp_SOURCES)
list(REMOVE_ITEM cryptopp_SOURCES
${SRC_DIR}/cryptlib.cpp
${SRC_DIR}/cpu.cpp
${SRC_DIR}/integer.cpp
${SRC_DIR}/pch.cpp
${SRC_DIR}/simple.cpp
${SRC_DIR}/adhoc.cpp
${cryptopp_SOURCES_TEST}
)
set(cryptopp_SOURCES
${SRC_DIR}/cryptlib.cpp
${SRC_DIR}/cpu.cpp
${SRC_DIR}/integer.cpp
${cryptopp_SOURCES}
)
set(cryptopp_SOURCES_ASM)
if (MSVC AND NOT DISABLE_ASM)
if (${CMAKE_GENERATOR} MATCHES ".*ARM")
message(STATUS "Disabling ASM because ARM is specified as target platform.")
else ()
enable_language(ASM_MASM)
list(APPEND cryptopp_SOURCES_ASM
${SRC_DIR}/rdrand.asm
)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND cryptopp_SOURCES_ASM
${SRC_DIR}/x64dll.asm
${SRC_DIR}/x64masm.asm
)
set_source_files_properties(${cryptopp_SOURCES_ASM} PROPERTIES COMPILE_DEFINITIONS "_M_X64")
else ()
set_source_files_properties(${cryptopp_SOURCES_ASM} PROPERTIES COMPILE_DEFINITIONS "_M_X86" COMPILE_FLAGS "/safeseh")
endif ()
set_source_files_properties(${cryptopp_SOURCES_ASM} PROPERTIES LANGUAGE ASM_MASM)
endif ()
endif ()
#============================================================================
# Architecture flags
#============================================================================
# TODO: Android, AIX, IBM xlC, iOS and a few other profiles are missing.
# New as of Pull Request 461, http://github.com/weidai11/cryptopp/pull/461.
# Must use CMAKE_CXX_COMPILER here due to XLC 13.1 and LLVM front-end.
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR CMAKE_CXX_COMPILER MATCHES "xlC")
if (CRYPTOPP_AMD64 OR CRYPTOPP_I386 OR CRYPTOPP_X32)
CheckCompileLinkOption("-msse2" CRYPTOPP_IA32_SSE2
"${TEST_PROG_DIR}/test_x86_sse2.cxx")
CheckCompileLinkOption("-mssse3" CRYPTOPP_IA32_SSSE3
"${TEST_PROG_DIR}/test_x86_ssse3.cxx")
CheckCompileLinkOption("-msse4.1" CRYPTOPP_IA32_SSE41
"${TEST_PROG_DIR}/test_x86_sse41.cxx")
CheckCompileLinkOption("-msse4.2" CRYPTOPP_IA32_SSE42
"${TEST_PROG_DIR}/test_x86_sse42.cxx")
CheckCompileLinkOption("-mssse3 -mpclmul" CRYPTOPP_IA32_CLMUL
"${TEST_PROG_DIR}/test_x86_clmul.cxx")
CheckCompileLinkOption("-msse4.1 -maes" CRYPTOPP_IA32_AES
"${TEST_PROG_DIR}/test_x86_aes.cxx")
CheckCompileLinkOption("-mavx" CRYPTOPP_IA32_AVX
"${TEST_PROG_DIR}/test_x86_avx.cxx")
CheckCompileLinkOption("-mavx2" CRYPTOPP_IA32_AVX2
"${TEST_PROG_DIR}/test_x86_avx2.cxx")
CheckCompileLinkOption("-msse4.2 -msha" CRYPTOPP_IA32_SHA
"${TEST_PROG_DIR}/test_x86_sha.cxx")
CheckCompileLinkOption("" CRYPTOPP_MIXED_ASM
"${TEST_PROG_DIR}/test_mixed_asm.cxx")
# https://github.com/weidai11/cryptopp/issues/756
if (NOT CRYPTOPP_MIXED_ASM)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_MIXED_ASM")
endif ()
if (NOT CRYPTOPP_IA32_SSE2 AND NOT DISABLE_ASM)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_ASM")
elseif (CRYPTOPP_IA32_SSE2 AND NOT DISABLE_ASM)
set_source_files_properties(${SRC_DIR}/sse_simd.cpp PROPERTIES COMPILE_FLAGS "-msse2")
set_source_files_properties(${SRC_DIR}/chacha_simd.cpp PROPERTIES COMPILE_FLAGS "-msse2")
set_source_files_properties(${SRC_DIR}/donna_sse.cpp PROPERTIES COMPILE_FLAGS "-msse2")
endif ()
if (NOT CRYPTOPP_IA32_SSSE3 AND NOT DISABLE_SSSE3)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_SSSE3")
elseif (CRYPTOPP_IA32_SSSE3 AND NOT DISABLE_SSSE3)
set_source_files_properties(${SRC_DIR}/aria_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3")
set_source_files_properties(${SRC_DIR}/cham_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3")
set_source_files_properties(${SRC_DIR}/keccak_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3")
set_source_files_properties(${SRC_DIR}/lea_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3")
set_source_files_properties(${SRC_DIR}/simeck_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3")
set_source_files_properties(${SRC_DIR}/simon128_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3")
set_source_files_properties(${SRC_DIR}/speck128_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3")
if (NOT CRYPTOPP_IA32_SSE41 AND NOT DISABLE_SSE4)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_SSE4")
elseif (CRYPTOPP_IA32_SSE41 AND NOT DISABLE_SSE4)
set_source_files_properties(${SRC_DIR}/blake2s_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.1")
set_source_files_properties(${SRC_DIR}/blake2b_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.1")
set_source_files_properties(${SRC_DIR}/simon64_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.1")
set_source_files_properties(${SRC_DIR}/speck64_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.1")
endif ()
if (NOT CRYPTOPP_IA32_SSE42 AND NOT DISABLE_SSE4)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_SSE4")
elseif (CRYPTOPP_IA32_SSE42 AND NOT DISABLE_SSE4)
set_source_files_properties(${SRC_DIR}/crc_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.2")
if (NOT CRYPTOPP_IA32_CLMUL AND NOT DISABLE_AES)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_CLMUL")
elseif (CRYPTOPP_IA32_CLMUL AND NOT DISABLE_AES)
set_source_files_properties(${SRC_DIR}/gcm_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3 -mpclmul")
set_source_files_properties(${SRC_DIR}/gf2n_simd.cpp PROPERTIES COMPILE_FLAGS "-mpclmul")
endif ()
if (NOT CRYPTOPP_IA32_AES AND NOT DISABLE_AES)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_AESNI")
elseif (CRYPTOPP_IA32_AES AND NOT DISABLE_AES)
set_source_files_properties(${SRC_DIR}/rijndael_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.1 -maes")
set_source_files_properties(${SRC_DIR}/sm4_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3 -maes")
endif ()
#if (NOT CRYPTOPP_IA32_AVX AND NOT DISABLE_AVX)
# list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_AVX")
#elseif (CRYPTOPP_IA32_AVX AND NOT DISABLE_AVX)
# set_source_files_properties(${SRC_DIR}/XXX_avx.cpp PROPERTIES COMPILE_FLAGS "-mavx")
#endif ()
if (NOT CRYPTOPP_IA32_AVX2 AND NOT DISABLE_AVX2)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_AVX2")
elseif (CRYPTOPP_IA32_AVX2 AND NOT DISABLE_AVX2)
set_source_files_properties(${SRC_DIR}/chacha_avx.cpp PROPERTIES COMPILE_FLAGS "-mavx2")
endif ()
if (NOT CRYPTOPP_IA32_SHA AND NOT DISABLE_SHA)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_SHANI")
elseif (CRYPTOPP_IA32_SHA AND NOT DISABLE_SHA)
set_source_files_properties(${SRC_DIR}/sha_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.2 -msha")
set_source_files_properties(${SRC_DIR}/shacal2_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.2 -msha")
endif ()
endif ()
endif ()
elseif (CRYPTOPP_AARCH32 OR CRYPTOPP_AARCH64)
CheckCompileOption("-march=armv8-a" CRYPTOPP_ARMV8A_ASIMD)
CheckCompileOption("-march=armv8-a+crc" CRYPTOPP_ARMV8A_CRC)
CheckCompileOption("-march=armv8-a+crypto" CRYPTOPP_ARMV8A_CRYPTO)
CheckCompileOption("-march=armv8-a" CRYPTOPP_ARMV8A_NATIVE)
if (CRYPTOPP_ARMV8A_ASIMD)
set_source_files_properties(${SRC_DIR}/aria_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/blake2s_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/blake2b_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/chacha_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/cham_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/lea_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/neon_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/simeck_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/simon64_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/simon128_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/speck64_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/speck128_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
endif ()
if (CRYPTOPP_ARMV8A_CRC)
set_source_files_properties(${SRC_DIR}/crc_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a+crc")
endif ()
if (CRYPTOPP_ARMV8A_CRYPTO)
set_source_files_properties(${SRC_DIR}/gcm_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a+crypto")
set_source_files_properties(${SRC_DIR}/gf2n_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a+crypto")
set_source_files_properties(${SRC_DIR}/rijndael_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a+crypto")
set_source_files_properties(${SRC_DIR}/sha_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a+crypto")
set_source_files_properties(${SRC_DIR}/shacal2_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a+crypto")
endif ()
elseif (CRYPTOPP_ARM OR CRYPTOPP_ARMHF)
# Need to set floating point ABI to something, like "hard" of "softfp".
# Most Linux use hard floats.
CheckCompileLinkOption("-march=armv7-a -mfpu=neon" CRYPTOPP_ARMV7A_NEON
"${TEST_PROG_DIR}/test_arm_neon.cxx")
CheckCompileLinkOption("-march=armv7-a -mfloat-abi=hard -mfpu=neon" CRYPTOPP_ARMV7A_HARD
"${TEST_PROG_DIR}/test_arm_neon.cxx")
CheckCompileLinkOption("-march=armv7-a -mfloat-abi=softfp -mfpu=neon" CRYPTOPP_ARMV7A_SOFTFP
"${TEST_PROG_DIR}/test_arm_neon.cxx")
if (CRYPTOPP_ARMV7A_HARD)
set(CRYPTOPP_ARMV7A_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon")
elseif (CRYPTOPP_ARMV7A_SOFTFP)
set(CRYPTOPP_ARMV7A_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon")
else ()
AddCompileOption("-DCRYPTOPP_DISABLE_NEON")
endif()
if (CRYPTOPP_ARMV7A_HARD OR CRYPTOPP_ARMV7A_SOFTFP)
# Add ASM files for ARM
if (NOT MSVC)
list(APPEND cryptopp_SOURCES ${SRC_DIR}/aes_armv4.S)
set_source_files_properties(${SRC_DIR}/aes_armv4.S PROPERTIES LANGUAGE C)
endif ()
set_source_files_properties(${SRC_DIR}/aes_armv4.S PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/aria_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/blake2s_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/blake2b_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/chacha_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/cham_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/crc_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/lea_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/gcm_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/rijndael_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/neon_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/sha_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/simeck_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/simon64_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/simon128_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/speck64_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/speck128_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/sm4_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
endif ()
elseif (CRYPTOPP_POWERPC OR CRYPTOPP_POWERPC64)
if (CMAKE_CXX_COMPILER MATCHES "xlC")
set(CRYPTOPP_ALTIVEC_FLAGS "-qaltivec")
set(CRYPTOPP_POWER4_FLAGS "-qarch=pwr4 -qaltivec")
set(CRYPTOPP_POWER5_FLAGS "-qarch=pwr5 -qaltivec")
set(CRYPTOPP_POWER6_FLAGS "-qarch=pwr6 -qaltivec")
set(CRYPTOPP_POWER7_FLAGS "-qarch=pwr7 -qaltivec")
set(CRYPTOPP_POWER8_FLAGS "-qarch=pwr8 -qaltivec")
set(CRYPTOPP_POWER9_FLAGS "-qarch=pwr9 -qaltivec")
else ()
set(CRYPTOPP_ALTIVEC_FLAGS "-maltivec")
set(CRYPTOPP_POWER7_FLAGS "-mcpu=power7 -maltivec")
set(CRYPTOPP_POWER8_FLAGS "-mcpu=power8 -maltivec")
set(CRYPTOPP_POWER9_FLAGS "-mcpu=power9 -maltivec")
endif ()
CheckCompileLinkOption("${CRYPTOPP_ALTIVEC_FLAGS}" PPC_ALTIVEC_FLAG
"${TEST_PROG_DIR}/test_ppc_altivec.cxx")
# Hack for XLC
if (CMAKE_CXX_COMPILER MATCHES "xlC")
if (NOT PPC_ALTIVEC_FLAG)
CheckCompileLinkOption("${CRYPTOPP_POWER4_FLAGS}" PPC_POWER4_FLAG
"${TEST_PROG_DIR}/test_ppc_altivec.cxx")
if (PPC_POWER4_FLAG)
set(PPC_ALTIVEC_FLAG 1)
set(CRYPTOPP_ALTIVEC_FLAGS "${CRYPTOPP_POWER4_FLAGS}")
endif ()
endif ()
if (NOT PPC_ALTIVEC_FLAG)
CheckCompileLinkOption("${CRYPTOPP_POWER5_FLAGS}" PPC_POWER5_FLAG
"${TEST_PROG_DIR}/test_ppc_altivec.cxx")
if (PPC_POWER5_FLAG)
set(PPC_ALTIVEC_FLAG 1)
set(CRYPTOPP_ALTIVEC_FLAGS "${CRYPTOPP_POWER5_FLAGS}")
endif ()
endif ()
if (NOT PPC_ALTIVEC_FLAG)
CheckCompileLinkOption("${CRYPTOPP_POWER6_FLAGS}" PPC_POWER6_FLAG
"${TEST_PROG_DIR}/test_ppc_altivec.cxx")
if (PPC_POWER6_FLAG)
set(PPC_ALTIVEC_FLAG 1)
set(CRYPTOPP_ALTIVEC_FLAGS "${CRYPTOPP_POWER6_FLAGS}")
endif ()
endif ()
endif ()
CheckCompileLinkOption("${CRYPTOPP_POWER7_FLAGS}" PPC_POWER7_FLAG
"${TEST_PROG_DIR}/test_ppc_power7.cxx")
CheckCompileLinkOption("${CRYPTOPP_POWER8_FLAGS}" PPC_POWER8_FLAG
"${TEST_PROG_DIR}/test_ppc_power8.cxx")
CheckCompileLinkOption("${CRYPTOPP_POWER9_FLAGS}" PPC_POWER9_FLAG
"${TEST_PROG_DIR}/test_ppc_power9.cxx")
if (PPC_POWER9_FLAG AND NOT DISABLE_POWER9)
set_source_files_properties(${SRC_DIR}/ppc_power9.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER9_FLAGS})
endif ()
if (PPC_POWER8_FLAG AND NOT DISABLE_POWER8)
set_source_files_properties(${SRC_DIR}/ppc_power8.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/blake2b_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
#set_source_files_properties(${SRC_DIR}/crc_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/gcm_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/gf2n_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/rijndael_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/sha_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/shacal2_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/simon128_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/speck128_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
endif ()
if (PPC_POWER7_FLAG AND NOT DISABLE_POWER7)
set_source_files_properties(${SRC_DIR}/ppc_power7.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/aria_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/blake2s_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/chacha_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/cham_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/lea_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/simeck_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/simon64_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/speck64_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
endif ()
if (PPC_ALTIVEC_FLAG AND NOT DISABLE_ALTIVEC)
set_source_files_properties(${SRC_DIR}/ppc_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_ALTIVEC_FLAGS})
endif ()
# Drop to Power7 if Power8 unavailable
if (NOT PPC_POWER8_FLAG)
if (PPC_POWER7_FLAG)
set_source_files_properties(${SRC_DIR}/gcm_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
endif ()
endif ()
# Drop to Altivec if Power7 unavailable
if (NOT PPC_POWER7_FLAG)
if (PPC_ALTIVEC_FLAG)
set_source_files_properties(${SRC_DIR}/blake2s_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_ALTIVEC_FLAGS})
set_source_files_properties(${SRC_DIR}/chacha_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_ALTIVEC_FLAGS})
set_source_files_properties(${SRC_DIR}/simon64_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_ALTIVEC_FLAGS})
set_source_files_properties(${SRC_DIR}/speck64_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_ALTIVEC_FLAGS})
endif ()
endif ()
if (NOT PPC_ALTIVEC_FLAG)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_ALTIVEC")
elseif (NOT PPC_POWER7_FLAG)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_POWER7")
elseif (NOT PPC_POWER8_FLAG)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_POWER8")
elseif (NOT PPC_POWER9_FLAG)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_POWER9")
endif ()
endif ()
endif ()
# New as of Pull Request 461, http://github.com/weidai11/cryptopp/pull/461.
if (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
if (CRYPTOPP_AMD64 OR CRYPTOPP_I386 OR CRYPTOPP_X32)
CheckCompileLinkOption("-xarch=sse2" CRYPTOPP_IA32_SSE2
"${TEST_PROG_DIR}/test_x86_sse2.cxx")
CheckCompileLinkOption("-xarch=ssse3" CRYPTOPP_IA32_SSSE3
"${TEST_PROG_DIR}/test_x86_ssse3.cxx")
CheckCompileLinkOption("-xarch=sse4_1" CRYPTOPP_IA32_SSE41
"${TEST_PROG_DIR}/test_x86_sse41.cxx")
CheckCompileLinkOption("-xarch=sse4_2" CRYPTOPP_IA32_SSE42
"${TEST_PROG_DIR}/test_x86_sse42.cxx")
CheckCompileLinkOption("-xarch=aes" CRYPTOPP_IA32_CLMUL
"${TEST_PROG_DIR}/test_x86_clmul.cxx")
CheckCompileLinkOption("-xarch=aes" CRYPTOPP_IA32_AES
"${TEST_PROG_DIR}/test_x86_aes.cxx")
CheckCompileLinkOption("-xarch=avx" CRYPTOPP_IA32_AVX
"${TEST_PROG_DIR}/test_x86_avx.cxx")
CheckCompileLinkOption("-xarch=avx2" CRYPTOPP_IA32_AVX2
"${TEST_PROG_DIR}/test_x86_avx2.cxx")
CheckCompileLinkOption("-xarch=sha" CRYPTOPP_IA32_SHA
"${TEST_PROG_DIR}/test_x86_sha.cxx")
# Each -xarch=XXX options must be added to LDFLAGS if the option is used during a compile.
set(XARCH_LDFLAGS "")
if (CRYPTOPP_IA32_SSE2 AND NOT DISABLE_ASM)
set_source_files_properties(${SRC_DIR}/sse_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=sse2")
set_source_files_properties(${SRC_DIR}/chacha_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=sse2")
set(XARCH_LDFLAGS "-xarch=sse2")
endif ()
if (CRYPTOPP_IA32_SSSE3 AND NOT DISABLE_SSSE3)
set_source_files_properties(${SRC_DIR}/aria_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=ssse3")
set_source_files_properties(${SRC_DIR}/cham_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=ssse3")
set_source_files_properties(${SRC_DIR}/lea_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=ssse3")
set_source_files_properties(${SRC_DIR}/simeck_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=ssse3")
set_source_files_properties(${SRC_DIR}/simon128_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=ssse3")
set_source_files_properties(${SRC_DIR}/speck128_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=ssse3")
set(XARCH_LDFLAGS "${XARCH_LDFLAGS} -xarch=ssse3")
if (CRYPTOPP_IA32_SSE41 AND NOT DISABLE_SSE4)
set_source_files_properties(${SRC_DIR}/blake2s_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=sse4_1")
set_source_files_properties(${SRC_DIR}/blake2b_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=sse4_1")
set_source_files_properties(${SRC_DIR}/simon64_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=sse4_1")
set_source_files_properties(${SRC_DIR}/speck64_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=sse4_1")
set(XARCH_LDFLAGS "${XARCH_LDFLAGS} -xarch=sse4_1")
endif ()
if (CRYPTOPP_IA32_SSE42 AND NOT DISABLE_SSE4)
set_source_files_properties(${SRC_DIR}/crc_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=sse4_2")
set(XARCH_LDFLAGS "${XARCH_LDFLAGS} -xarch=sse4_2")
if (CRYPTOPP_IA32_CLMUL AND NOT DISABLE_CLMUL)
set_source_files_properties(${SRC_DIR}/gcm_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=aes")
set_source_files_properties(${SRC_DIR}/gf2n_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=aes")
endif ()
if (CRYPTOPP_IA32_AES AND NOT DISABLE_AES)
set_source_files_properties(${SRC_DIR}/rijndael_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=aes")
set_source_files_properties(${SRC_DIR}/sm4_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=aes")
set(XARCH_LDFLAGS "${XARCH_LDFLAGS} -xarch=aes")
endif ()
#if (CRYPTOPP_IA32_AVX AND NOT DISABLE_AVX)
# set_source_files_properties(${SRC_DIR}/XXX_avx.cpp PROPERTIES COMPILE_FLAGS "-xarch=avx2")
# set(XARCH_LDFLAGS "${XARCH_LDFLAGS} -xarch=avx")
#endif ()
if (CRYPTOPP_IA32_AVX2 AND NOT DISABLE_AVX2)
set_source_files_properties(${SRC_DIR}/chacha_avx.cpp PROPERTIES COMPILE_FLAGS "-xarch=avx2")
set(XARCH_LDFLAGS "${XARCH_LDFLAGS} -xarch=avx2")
endif ()
if (CRYPTOPP_IA32_SHA AND NOT DISABLE_SHA)
set_source_files_properties(${SRC_DIR}/sha_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=sha")
set_source_files_properties(${SRC_DIR}/shacal2_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=sha")
set(XARCH_LDFLAGS "${XARCH_LDFLAGS} -xarch=sha")
endif ()
endif ()
endif ()
# https://stackoverflow.com/a/6088646/608639
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${XARCH_LDFLAGS} -M${SRC_DIR}/cryptopp.mapfile")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${XARCH_LDFLAGS} -M${SRC_DIR}/cryptopp.mapfile")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${XARCH_LDFLAGS} -M${SRC_DIR}/cryptopp.mapfile")
# elseif (CRYPTOPP_SPARC OR CRYPTOPP_SPARC64)
endif ()
endif ()
# Attempt to determine a suitable native option
if (CRYPTOPP_NATIVE_ARCH)
CheckCompileOption("-march=native" NATIVE_ARCH)
if (NATIVE_ARCH)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-march=native")
else ()
CheckCompileOption("-native" NATIVE_ARCH)
if (NATIVE_ARCH)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-native")
endif ()
endif ()
if (NOT NATIVE_ARCH)
message(WARNING "CRYPTOPP_NATIVE_ARCH enabled, but failed to detect native architecture option")
endif ()
endif()
#============================================================================
# Compile targets
#============================================================================
# Work around the archaic versions of cmake that do not support
# target_compile_xxxx commands
# !!! DO NOT try to use the old way for newer version - it does not work !!!
function(cryptopp_target_compile_properties target)
if (NOT ${CMAKE_VERSION} VERSION_LESS "2.8.11")
target_compile_definitions(${target} PUBLIC ${CRYPTOPP_COMPILE_DEFINITIONS})
else()
string (REPLACE ";" " " PROP_STR "${CRYPTOPP_COMPILE_DEFINITIONS}")
set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS "${CRYPTOPP_COMPILE_DEFINITIONS}")
endif()
if (NOT ${CMAKE_VERSION} VERSION_LESS "2.8.12")
target_compile_options(${target} PUBLIC ${CRYPTOPP_COMPILE_OPTIONS})
else()
string (REPLACE ";" " " PROP_STR "${CRYPTOPP_COMPILE_OPTIONS}")
set_target_properties(${target} PROPERTIES COMPILE_FLAGS "${PROP_STR}")
endif()
endfunction()
set(cryptopp_LIBRARY_SOURCES ${cryptopp_SOURCES_ASM})
if (USE_INTERMEDIATE_OBJECTS_TARGET AND NOT ${CMAKE_VERSION} VERSION_LESS "2.8.8")
add_library(cryptopp-object OBJECT ${cryptopp_SOURCES})
cryptopp_target_compile_properties(cryptopp-object)
list(APPEND cryptopp_LIBRARY_SOURCES
$<TARGET_OBJECTS:cryptopp-object>
)
else ()
list(APPEND cryptopp_LIBRARY_SOURCES
${cryptopp_SOURCES}
)
endif ()
if (BUILD_STATIC)
add_library(cryptopp-static STATIC ${cryptopp_LIBRARY_SOURCES})
cryptopp_target_compile_properties(cryptopp-static)
if (NOT ${CMAKE_VERSION} VERSION_LESS "2.8.11")
target_include_directories(cryptopp-static PUBLIC $<BUILD_INTERFACE:${SRC_DIR}> $<INSTALL_INTERFACE:include>)
else ()
set_target_properties(cryptopp-static PROPERTIES INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${SRC_DIR}> $<INSTALL_INTERFACE:include>")
endif ()
endif ()
if (BUILD_SHARED)
add_library(cryptopp-shared SHARED ${cryptopp_LIBRARY_SOURCES})
cryptopp_target_compile_properties(cryptopp-shared)
if (NOT ${CMAKE_VERSION} VERSION_LESS "2.8.11")
target_include_directories(cryptopp-shared PUBLIC $<BUILD_INTERFACE:${SRC_DIR}> $<INSTALL_INTERFACE:include>)
else ()
set_target_properties(cryptopp-shared PROPERTIES INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${SRC_DIR}> $<INSTALL_INTERFACE:include>")
endif ()
endif ()
# Set filenames for targets to be "cryptopp"
if (NOT MSVC)
set(COMPAT_VERSION ${cryptopp_VERSION_MAJOR}.${cryptopp_VERSION_MINOR})
if (BUILD_STATIC)
set_target_properties(cryptopp-static
PROPERTIES
OUTPUT_NAME cryptopp)
endif ()
if (BUILD_SHARED)
set_target_properties(cryptopp-shared
PROPERTIES
SOVERSION ${COMPAT_VERSION}
OUTPUT_NAME cryptopp)
endif ()
endif ()
# Add alternate ways to invoke the build for the shared library that are
# similar to how the crypto++ 'make' tool works.
# see https://github.com/noloader/cryptopp-cmake/issues/32
if (BUILD_STATIC)
add_custom_target(static DEPENDS cryptopp-static)
endif ()
if (BUILD_SHARED)
add_custom_target(shared DEPENDS cryptopp-shared)
add_custom_target(dynamic DEPENDS cryptopp-shared)
endif ()
#============================================================================
# Third-party libraries
#============================================================================
if (WIN32)
if (BUILD_STATIC)
target_link_libraries(cryptopp-static ws2_32)
endif ()
if (BUILD_SHARED)
target_link_libraries(cryptopp-shared ws2_32)
endif ()
endif ()
# This may need to be expanded to "Solaris"
if (CRYPTOPP_SOLARIS)
if (BUILD_STATIC)
target_link_libraries(cryptopp-static nsl socket)
endif ()
if (BUILD_SHARED)
target_link_libraries(cryptopp-shared nsl socket)
endif ()
endif ()
find_package(Threads)
if (BUILD_STATIC)
target_link_libraries(cryptopp-static ${CMAKE_THREAD_LIBS_INIT})
endif ()
if (BUILD_SHARED)
target_link_libraries(cryptopp-shared ${CMAKE_THREAD_LIBS_INIT})
endif ()
#============================================================================
# Tests
#============================================================================
enable_testing()
if (BUILD_TESTING)
add_executable(cryptest ${cryptopp_SOURCES_TEST})
target_link_libraries(cryptest cryptopp-static)
# Setting "cryptest" binary name to "cryptest.exe"
if (NOT (WIN32 OR CYGWIN))
set_target_properties(cryptest PROPERTIES OUTPUT_NAME cryptest.exe)
endif ()
if (NOT TARGET cryptest.exe)
add_custom_target(cryptest.exe)
add_dependencies(cryptest.exe cryptest)
endif ()
file(COPY ${SRC_DIR}/TestData DESTINATION ${PROJECT_BINARY_DIR})
file(COPY ${SRC_DIR}/TestVectors DESTINATION ${PROJECT_BINARY_DIR})
add_test(NAME build_cryptest COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target cryptest)
add_test(NAME cryptest COMMAND $<TARGET_FILE:cryptest> v)
set_tests_properties(cryptest PROPERTIES DEPENDS build_cryptest)
endif ()
#============================================================================
# Doxygen documentation
#============================================================================
if (BUILD_DOCUMENTATION)
find_package(Doxygen REQUIRED)
set(in_source_DOCS_DIR "${SRC_DIR}/html-docs")
set(out_source_DOCS_DIR "${PROJECT_BINARY_DIR}/html-docs")
add_custom_target(docs ALL
COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING
WORKING_DIRECTORY ${SRC_DIR}
SOURCES ${SRC_DIR}/Doxyfile
)
if (NOT ${in_source_DOCS_DIR} STREQUAL ${out_source_DOCS_DIR})
add_custom_command(
TARGET docs POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${in_source_DOCS_DIR}" "${out_source_DOCS_DIR}"
COMMAND ${CMAKE_COMMAND} -E remove_directory "${in_source_DOCS_DIR}"
)
endif ()
endif ()
#============================================================================
# Install
#============================================================================
set(export_name "cryptopp-targets")
# Runtime package
if (BUILD_SHARED)
export(TARGETS cryptopp-shared FILE ${export_name}.cmake )
install(
TARGETS cryptopp-shared
EXPORT ${export_name}
DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif ()
# Development package
if (BUILD_STATIC)
export(TARGETS cryptopp-static FILE ${export_name}.cmake )
install(TARGETS cryptopp-static EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif ()
install(FILES ${cryptopp_HEADERS} DESTINATION include/cryptopp)
# CMake Package
if (NOT CMAKE_VERSION VERSION_LESS 2.8.8)
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake" VERSION ${cryptopp_VERSION_MAJOR}.${cryptopp_VERSION_MINOR}.${cryptopp_VERSION_PATCH} COMPATIBILITY SameMajorVersion)
install(FILES cryptopp-config.cmake ${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake DESTINATION "lib/cmake/cryptopp")
install(EXPORT ${export_name} DESTINATION "lib/cmake/cryptopp")
endif ()
# Tests
if (BUILD_TESTING)
install(TARGETS cryptest DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${SRC_DIR}/TestData DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cryptopp)
install(DIRECTORY ${SRC_DIR}/TestVectors DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cryptopp)
endif ()
# Documentation
if (BUILD_DOCUMENTATION)
install(DIRECTORY "${out_source_DOCS_DIR}" DESTINATION ${CMAKE_INSTALL_DOCDIR})
endif ()
# Print a configuration summary. We want CXX and CXXFLAGS, but they are not includd in ALL.
if (CRYPTOPP_I386)
message(STATUS "Platform: i386/i686")
elseif (CRYPTOPP_AMD64)
message(STATUS "Platform: x86_64")
elseif (CRYPTOPP_X32)
message(STATUS "Platform: x86_64-x32")
elseif (CRYPTOPP_ARMHF)
message(STATUS "Platform: armhf")
elseif (CRYPTOPP_ARM)
message(STATUS "Platform: arm")
elseif (CRYPTOPP_AARCH32)
message(STATUS "Platform: Aarch32")
elseif (CRYPTOPP_AARCH64)
message(STATUS "Platform: Aarch64")
elseif (CRYPTOPP_SPARC)
message(STATUS "Platform: Sparc")
elseif (CRYPTOPP_SPARC64)
message(STATUS "Platform: Sparc64")
elseif (CRYPTOPP_POWERPC)
message(STATUS "Platform: PowerPC")
elseif (CRYPTOPP_POWERPC64)
message(STATUS "Platform: PowerPC-64")
elseif (CRYPTOPP_MINGW32)
message(STATUS "Platform: MinGW-32")
elseif (CRYPTOPP_MINGW32)
message(STATUS "Platform: MinGW-64")
endif ()
if (CRYPTOPP_ARMV7A_NEON)
message(STATUS "NEON: TRUE")
endif ()
if (CRYPTOPP_NATIVE_ARCH)
message(STATUS "Native arch: TRUE")
else ()
message(STATUS "Native arch: FALSE")
endif ()
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER}")
message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS} ${CRYPTOPP_COMPILE_OPTIONS}")
message(STATUS "Compiler definitions: ${CRYPTOPP_COMPILE_DEFINITIONS}")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册