Skip to content

Commit

Permalink
Add CMakeLists and remove Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
matlo607 committed Feb 19, 2017
1 parent a634713 commit 9b329c7
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 31 deletions.
42 changes: 42 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
cmake_minimum_required (VERSION 2.8)
project (CRYPTOGRAPHIC_LIB)

set (crypto_VERSION_MAJOR 1)
set (crypto_VERSION_MINOR 0)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)

if(CMAKE_BUILD_TYPE MATCHES "Debug" OR CMAKE_BUILD_TYPE MATCHES "Release")
message(STATUS "CMake build type: ${CMAKE_BUILD_TYPE}")
else()
message(FATAL_ERROR "CMake build type \"${CMAKE_BUILD_TYPE}\" is not supported")
endif()

include (CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-std=c++14 COMPILER_SUPPORTS_CXX14)
if(COMPILER_SUPPORTS_CXX14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support.
Please use a different C++ compiler.")
endif()

if(CMAKE_COMPILER_IS_GNUCXX)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Werror -Wextra")
set (CMAKE_CXX_FLAGS_DEBUG "-g3 -O0 -fno-omit-frame-pointer -DDEBUG")
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
endif(CMAKE_COMPILER_IS_GNUCXX)

include (CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX ("gsl/span" HAVE_GSL_SPAN)
if(NOT HAVE_GSL_SPAN)
message(FATAL_ERROR "gsl library: <gsl/span> not found")
endif()

message(STATUS "CMAKE_SOURCE_DIR: " ${CMAKE_SOURCE_DIR})

add_subdirectory (src)
add_subdirectory (test)

18 changes: 18 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required (VERSION 2.8)
project (crypto-all)

include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../include")

set (SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/MD4.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/MD5.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/SHA1.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/SHA224.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/SHA256.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/SHA384.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/SHA512.cpp"
)

add_library (crypto_static STATIC ${SRC_FILES})
add_library (crypto SHARED ${SRC_FILES})

32 changes: 32 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cmake_minimum_required (VERSION 2.8)
project (test-crypto)

find_package (GTest REQUIRED)
include_directories (${GTEST_INCLUDE_DIRS})

set(THREADS_PREFER_PTHREAD_FLAG on)
find_package (Threads REQUIRED)

include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../include")

find_library (CRYPTO_LIBRARY
NAMES crypto #crypto_static
HINTS "${CMAKE_CURRENT_SOURCE_DIR}/../src"
)

link_directories("${CMAKE_CURRENT_BINARY_DIR}/../src")

set (SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/test_libcrypto.cpp"
)

add_executable (test-crypto ${SRC_FILES})
target_link_libraries (test-crypto
pthread
${GTEST_BOTH_LIBRARIES}
#crypto_static
crypto
)

include (CTest)
add_test (unit_tests "${CMAKE_CURRENT_BINARY_DIR}/test-crypto")
31 changes: 0 additions & 31 deletions test/Makefile

This file was deleted.

0 comments on commit 9b329c7

Please sign in to comment.