In the process of creating unit tests/cmake files.

This commit is contained in:
2016-07-04 16:45:04 +01:00
parent c419ef22d5
commit 5aba10efb7
4 changed files with 63 additions and 11 deletions
+61 -11
View File
@@ -3,28 +3,78 @@ set(CMAKE_CXX_STANDARD 11)
# Set the project name # Set the project name
project (concatenator) project (concatenator)
set(Boost_USE_STATIC_LIBS OFF) ###############################################################################
set(Boost_USE_MULTITHREADED ON) ### Boost Settings
set(Boost_USE_STATIC_RUNTIME OFF) find_package(Boost 1.60.0 COMPONENTS program_options log log_setup thread date_time filesystem system REQUIRED)
find_package(Boost 1.60.0 COMPONENTS program_options log log_setup thread date_time filesystem system)
if (NOT FO_BOOST_STATIC_LINK) if (NOT FO_BOOST_STATIC_LINK)
add_definitions(-DBOOST_ALL_NO_LIB -DBOOST_ALL_DYN_LINK -DBOOST_LOG_DYN_LINK) add_definitions(-DBOOST_ALL_NO_LIB -DBOOST_ALL_DYN_LINK -DBOOST_LOG_DYN_LINK)
endif() endif()
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
###############################################################################
# Set build flags # Set build flags
set(CMAKE_CXX_FLAGS "-g -Wall ") set(CMAKE_CXX_FLAGS "-g -Wall ")
# Set cmake to output executable to the bin directory # Set cmake to output executable to the bin directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Find all included header files.
include_directories(include) include_directories(include)
include_directories(${Boost_INCLUDE_DIRS})
# Find all the source fies in the src directory add_subdirectory(external)
file(GLOB SOURCES "src/*.cpp")
# Build the executable from the source files found # Build the executable from the source files found
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(concatenator ${SOURCES}) set(CONCATENATOR_SOURCE_DIR ${PROJECT_SOURCE_DIR}/src)
target_link_libraries(concatenator ${Boost_LIBRARIES}) set(CONCATENATOR_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
set(CONCATENATOR_TEST_DIR ${PROJECT_SOURCE_DIR}/tests)
set(CONCATENATOR_SOURCE_FILES
${CONCATENATOR_SOURCE_DIR}/Concatenator.cpp
)
set(CONCATENATOR_HEADER_FILES
${CONCATENATOR_INCLUDE_DIR}/config.hpp
)
set(CONCATENATOR_TEST_SOURCES
${CONCATENATOR_TEST_DIR}/Concatenator_Basic_Tests.cpp
)
add_executable(concatenator ${CONCATENATOR_SOURCE_DIR}/concatenator.cpp)
target_link_libraries(concatenator ${Boost_LIBRARIES})
# Test build options (this code adapted from: https://github.com/ComicSansMS/GhulbusBase/blob/master/CMakeLists.txt)
option(BUILD_TESTS "Determines whether to build tests." ON)
if(BUILD_TESTS)
enable_testing()
if(NOT TARGET Catch)
include(ExternalProject)
if(WIN32)
set(FETCH_EXTERNAL_CATCH
URL https://github.com/philsquared/Catch/archive/v1.2.1-develop.12.zip
URL_HASH MD5=cda228922a1c9248364c99a3ff9cd9fa)
else()
set(FETCH_EXTERNAL_CATCH
URL https://github.com/philsquared/Catch/archive/v1.2.1-develop.12.tar.gz
URL_HASH MD5=a8dfb7be899a6e7fb30bd55d53426122)
endif()
ExternalProject_Add(Catch-External
PREFIX ${CMAKE_BINARY_DIR}/external/Catch
${FETCH_EXTERNAL_CATCH}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/external/Catch/src/Catch-External/single_include/catch.hpp
${CMAKE_BINARY_DIR}/external/Catch/include/catch.hpp
)
add_library(Catch INTERFACE)
add_dependencies(Catch Catch-External)
target_include_directories(Catch INTERFACE ${CMAKE_BINARY_DIR}/external/Catch/include)
endif()
add_executable(Concatenator_Base_Test ${CONCATENATOR_TEST_SOURCES})
add_test(NAME TestBase COMMAND Concatenator_Base_Test)
endif() endif()
View File
View File
+2
View File
@@ -0,0 +1,2 @@
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"