-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic CMake project configuration (#8)
* Basic CMake project configuration
- Loading branch information
Showing
7 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
project(PasswordManager) | ||
|
||
set(FLAGS -Wall -Werror -Wpedantic -Wextra) | ||
|
||
enable_testing() | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE Debug) | ||
endif() | ||
|
||
if(CMAKE_BUILD_TYPE MATCHES Release) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Release/) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Release/) | ||
else() | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Debug/) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Debug/) | ||
endif() | ||
|
||
include_directories(headers) | ||
add_subdirectory(source) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
class PasswordManager { | ||
public: | ||
PasswordManager() = default; | ||
PasswordManager(const std::string& password); | ||
|
||
~PasswordManager(); | ||
private: | ||
std::string password_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
project(PasswordManager) | ||
|
||
add_executable(passwordManager main.cpp PasswordManager.cpp) | ||
|
||
add_subdirectory(test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <iostream> | ||
|
||
#include "PasswordManager.h" | ||
|
||
PasswordManager::PasswordManager(const std::string& password) | ||
: password_(password) | ||
{ | ||
std::cout << "Password is: " << password_ << '\n'; | ||
} | ||
|
||
PasswordManager::~PasswordManager() { | ||
std::cout << "Password manager destructor\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <string> | ||
|
||
#include "PasswordManager.h" | ||
|
||
int main() { | ||
std::string password = "haslo"; | ||
PasswordManager passwordManager(password); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
include(FetchContent) | ||
|
||
set(TEST_NAME ${PROJECT_NAME}-UT) | ||
|
||
FetchContent_Declare( | ||
googletest | ||
GIT_REPOSITORY "https://github.com/google/googletest.git" | ||
GIT_TAG release-1.11.0 | ||
) | ||
|
||
FetchContent_MakeAvailable(googletest) | ||
|
||
add_executable(${TEST_NAME} test.cpp) | ||
target_link_libraries(${TEST_NAME} gtest_main) | ||
set_target_properties(${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/test") | ||
|
||
include(GoogleTest) | ||
gtest_discover_tests(${TEST_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "gtest/gtest.h" | ||
#include "PasswordManager.h" | ||
|
||
TEST(CheckIfCMakeWorks, returnsTrue) { | ||
ASSERT_TRUE(true); | ||
} |