tomcrypt/CMakeLists.txt
2019-07-02 21:45:47 +02:00

68 lines
2.4 KiB
CMake

cmake_minimum_required(VERSION 3.0)
IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
ADD_DEFINITIONS(-DLTC_NO_ROLC)
ENDIF ()
ADD_DEFINITIONS(-DLTC_NO_PROTOTYPES)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-DLTC_SOURCE)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/headers)
SET (ALL_HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/headers/tomcrypt.h
${CMAKE_CURRENT_SOURCE_DIR}/src/headers/tomcrypt_cfg.h
${CMAKE_CURRENT_SOURCE_DIR}/src/headers/tomcrypt_custom.h
${CMAKE_CURRENT_SOURCE_DIR}/src/headers/tomcrypt_mac.h
${CMAKE_CURRENT_SOURCE_DIR}/src/headers/tomcrypt_math.h
${CMAKE_CURRENT_SOURCE_DIR}/src/headers/tomcrypt_pk.h
${CMAKE_CURRENT_SOURCE_DIR}/src/headers/tomcrypt_prng.h
${CMAKE_CURRENT_SOURCE_DIR}/src/headers/tomcrypt_argchk.h
${CMAKE_CURRENT_SOURCE_DIR}/src/headers/tomcrypt_cipher.h
${CMAKE_CURRENT_SOURCE_DIR}/src/headers/tomcrypt_hash.h
${CMAKE_CURRENT_SOURCE_DIR}/src/headers/tomcrypt_macros.h
${CMAKE_CURRENT_SOURCE_DIR}/src/headers/tomcrypt_misc.h
${CMAKE_CURRENT_SOURCE_DIR}/src/headers/tomcrypt_pkcs.h
)
file(GLOB_RECURSE ALL_SOURCE_FILES src/*.c)
if (MSVC)
message(STATUS "Detect MSVC compiler...")
SET(MSVC_LIKE_COMPILER ON)
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
elseif ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xIntel")
if(WIN32)
message(STATUS "Detect Intel compiler and handle it like MSVC...")
SET(MSVC_LIKE_COMPILER ON)
endif ()
endif ()
SET_SOURCE_FILES_PROPERTIES(ALL_HEADER_FILES PROPERTIES HEADER_FILE_ONLY TRUE)
LIST(APPEND ALL_SOURCE_FILES ${ALL_HEADER_FILES})
ADD_LIBRARY(libtomcrypt STATIC ${ALL_SOURCE_FILES})
INSTALL(TARGETS libtomcrypt
ARCHIVE DESTINATION "lib" CONFIGURATIONS Debug Release MinSizeRel RelWithDebInfo
LIBRARY DESTINATION "lib" CONFIGURATIONS Debug Release MinSizeRel RelWithDebInfo
RUNTIME DESTINATION "bin" CONFIGURATIONS Debug Release MinSizeRel RelWithDebInfo
)
INSTALL(FILES ${LIBTOMCRYPT_PUBLIC_HEADER_FILES} DESTINATION "includes/libtomcrypt")
SET(MSVC_LIKE_COMPILER OFF)