Skip to content

Commit

Permalink
updates to CMake installation and header. including googletest in the…
Browse files Browse the repository at this point in the history
… installation process, build lib -> test lib -> install
  • Loading branch information
akielaries committed Jan 3, 2023
1 parent 6232b29 commit 926b8b6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ include(GNUInstallDirs)


############################################################
# Run tests specified in Makefile
# Run Tests
############################################################
enable_testing()

#add_subdirectory(tests)

add_custom_target(TESTS COMMAND make run-tests
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
)
#add_subdirectory(tests)

############################################################
# Create a library
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ Keyword cipher:
``` cpp
#include <iostream>
#include <string>
#include <openMTPK/cipher.hpp>
#include <openMTPK/number_theory.hpp>

int main() {
// declare CIPHER class obj
Cipher cc;
mtpk::Cipher cc;

/* CAESAR CIPHER */
std::string text0 = "Plaintext";
Expand Down
9 changes: 7 additions & 2 deletions docs/source/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
Example C++ driver file for running Caesar Cipher & Mono-Alphabetic Substitution
Keyword cipher:
```cpp
/**
* Showing the Cipher Class functionalities
*/
#include <iostream>
#include <string>
#include <openMTPK/cipher.hpp>
#include <openMTPK/number_theory.hpp>


int main() {
// declare CIPHER class obj
Cipher cc;
mtpk::Cipher cc;

/* CAESAR CIPHER */
std::string text0 = "Plaintext";
Expand Down
31 changes: 31 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Download and install GoogleTest
include(ExternalProject)
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)

# TESTS
add_executable(test_openMTPK arith/t_arith.cpp)

# use googletest
add_dependencies(test_openMTPK gtest)
include_directories(${source_dir}/include)
target_link_libraries(test_openMTPK openMTPK gtest gtest_main pthread)

#target_link_libraries(test_openMTPK ${binary_dir}/libgtest_main.a)


enable_testing()

add_test(NAME test_openMTPK
COMMAND test_openMTPK)



0 comments on commit 926b8b6

Please sign in to comment.