Skip to content
Snippets Groups Projects
Commit a29a20dc authored by David Nieder's avatar David Nieder
Browse files

project skeleton

parents
No related branches found
No related tags found
No related merge requests found
build/
bin/
lib/
cmake_minimum_required(VERSION 3.12)
project(hashtable)
# set build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# set language standard
set(CMAKE_CXX_STANDARD 14)
# set some compile flags
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
# put build binaries and libraries into top-level folders
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
include_directories(src)
add_subdirectory(src)
# testing
enable_testing()
add_subdirectory(tests)
add_library(hashtable STATIC hashtable.cpp)
add_executable(main main.cpp)
target_link_libraries(main hashtable)
#include <iostream>
int main() {
std::cout << "Hello CMake." << std::endl;
}
# include google test source
add_subdirectory(/usr/src/gtest ${PROJECT_BINARY_DIR}/gtest)
# cmake testing package
include(CTest)
# the executables that run the tests
add_executable(test_main test_main.cpp)
add_executable(test_hashtable test_hashtable.cpp)
# link needed libraries
target_link_libraries(test_main gtest gtest_main)
target_link_libraries(test_hashtable hashtable gtest gtest_main)
# run with ctest
add_test(NAME test_main COMMAND ${EXECUTABLE_OUTPUT_PATH}/test_main)
add_test(NAME test_hashtable COMMAND ${EXECUTABLE_OUTPUT_PATH}/test_hashtable)
#include <gtest/gtest.h>
#include "hashtable.h"
#include <gtest/gtest.h>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment