Skip to content
This repository has been archived by the owner on Nov 25, 2021. It is now read-only.

Commit

Permalink
Preliminary Magick++ (ImageMagick7 support).
Browse files Browse the repository at this point in the history
Note: ImageMagick binary must be installed.  Magick++.h header will be found in the system include path under ImageMagick-7.

Unfortunately sub-includes expect the the ImageMagick-7 folder to be a part of the compiler search list.  Remedied with -I switch in root CMakeLists.txt file :(.

Temporarily had to hard-code OS X/Linux system include path :(:(.

Strict warnings disabled temporarily because tinyutf8 cannot compile under ultra-strict settings.  Laxifying #pragmas having no effect. :(:(:(.
  • Loading branch information
bRad committed Feb 4, 2017
1 parent 640dc92 commit 4958cd9
Show file tree
Hide file tree
Showing 16 changed files with 83 additions and 51 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,3 @@
[submodule "Sources/Modules/3rdParty/tinyutf8"]
path = Sources/Modules/3rdParty/tinyutf8
url = github:bradleygibson/tinyutf8.git
[submodule "Sources/Modules/3rdParty/ImageMagick"]
path = Sources/Modules/3rdParty/ImageMagick
url = git@github.com:ImageMagick/ImageMagick.git
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@ set(CMAKE_CXX_STANDARD_REQUIRED)
set(CMAKE_CXX_STANDARD 14)

set(CLANG_CXX_WALL "-Weverything -Werror -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-newline-eof -Wno-exit-time-destructors -Wno-weak-vtables")
set(CLANG_CXX_FLAGS "-std=${CXX_STANDARD} ${CLANG_CXX_WALL}")
#set(CLANG_CXX_FLAGS "-std=${CXX_STANDARD} ${CLANG_CXX_WALL} -I/usr/local/include/ImageMagick-7/")
set(CLANG_CXX_FLAGS "-std=${CXX_STANDARD} -I/usr/local/include/ImageMagick-7/")

set(GCC_CXX_WALL "-Wall -Wpedantic -Werror")
set(GCC_CXX_FLAGS "-std=${CXX_STANDARD} ${GCC_CXX_WALL}")
#set(GCC_CXX_FLAGS "-std=${CXX_STANDARD} ${GCC_CXX_WALL} -I/usr/local/include/ImageMagick-7/")
set(GCC_CXX_FLAGS "-std=${CXX_STANDARD} -I/usr/local/include/ImageMagick-7/")

set(MSVC_CXX_WALL "/W4")
set(MSVC_CXX_FLAGS "/std:${CXX_STANDARD} ${MSVC_CXX_WALL}")

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLANG_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLANG_CXX_FLAGS}")
elseif(CMAKE_CXX_COMPILER_ID matches "GCC")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_CXX_FLAGS}")
elseif(CMAKE_CXX_COMPILER_ID matches "MSVC")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_CXX_FLAGS}")
endif()

add_subdirectory(Sources)
4 changes: 4 additions & 0 deletions Sources/Modules/3rdParty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(THIRD_PARTY_SOURCE_FILES
../3rdParty/tinyutf8/tinyutf8.cpp
../3rdParty/tinyutf8/tinyutf8.h
PARENT_SCOPE)
1 change: 0 additions & 1 deletion Sources/Modules/3rdParty/ImageMagick
Submodule ImageMagick deleted from eea078
4 changes: 3 additions & 1 deletion Sources/Modules/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
add_subdirectory(CppGrapher)
add_subdirectory(3rdParty)
add_subdirectory(cpp-grapher)
add_subdirectory(CppGrapher)
add_subdirectory(Helpers)
24 changes: 9 additions & 15 deletions Sources/Modules/CppGrapher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@

set(SOURCE_FILES
CppGrapher.cpp
CppGrapher.h
Validation/Argument.cpp
Validation/DataFile.cpp
Graphing/Visualization.cpp
../3rdParty/tinyutf8/tinyutf8.cpp
../3rdParty/tinyutf8/tinyutf8.h
../Helpers/Unicode.h
)
${THIRD_PARTY_SOURCE_FILES}
${HELPERS_SOURCE_FILES})

add_library(CppGrapher ${SOURCE_FILES})

target_include_directories(CppGrapher
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/any/
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/ImageMagick/Magick++/lib/
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/Optional/
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/tinyutf8/
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/variant/
)
target_include_directories(CppGrapher PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/any/
${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/Optional/
${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/tinyutf8/
${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/variant/)
2 changes: 2 additions & 0 deletions Sources/Modules/CppGrapher/CppGrapher.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <vector>
#include <fstream>

//save compiler switches - external libs often can't handle ultra-strict compiler settings
#include "tinyutf8.h"

/// The application logic is written as a library to enable flexible packaging (static or dynamic linking) and
Expand Down
4 changes: 4 additions & 0 deletions Sources/Modules/CppGrapher/Graphing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(GRAPHING_SOURCE_FILES
Graphing/Visualization.cpp
PARENT_SCOPE)

4 changes: 4 additions & 0 deletions Sources/Modules/CppGrapher/Validation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(VALIDATION_SOURCE_FILES
Validation/Argument.cpp
Validation/DataFile.cpp
PARENT_SCOPE)
4 changes: 2 additions & 2 deletions Sources/Modules/CppGrapher/Validation/DataFile.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <iostream>
#include <Helpers/Filesystem.h>
#include <limits>
#include <vector>
#include <fstream>
#include <string>
#include <Helpers/Unicode.h>

#include "Helpers/Unicode.h"
#include "Helpers/Filesystem.h"
#include "Helpers/Resources.h"
#include "Helpers/Exceptions.h"
#include "Helpers/UserDefinedLiterals.h"
Expand Down
8 changes: 8 additions & 0 deletions Sources/Modules/Helpers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(HELPERS_SOURCE_FILES
../Helpers/AbbreviatedTypes.h
../Helpers/Exceptions.h
../Helpers/Filesystem.h
../Helpers/Resources.h
../Helpers/Unicode.h
../Helpers/UserDefinedLiterals.h
PARENT_SCOPE)
11 changes: 0 additions & 11 deletions Sources/Modules/cpp-grapher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
set(SOURCE_FILES cpp-grapher.cpp)
add_executable(cpp-grapher ${SOURCE_FILES})

target_include_directories(cpp-grapher
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../CppGrapher/
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/any/
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/Optional/
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/variant/
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/utf-8/
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/tinyutf8/
)

target_link_libraries (cpp-grapher PUBLIC CppGrapher)
15 changes: 8 additions & 7 deletions Sources/Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
add_subdirectory(Runner)
add_subdirectory(Unit)
add_subdirectory(Integration)
add_subdirectory(Performance)
add_subdirectory(System)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/Catch/include
)
add_subdirectory(Unit)

set(SOURCE_FILES
set(TEST_SOURCE_FILES
${UNIT_TEST_SOURCE_FILES}
${INTEGRATION_TEST_SOURCE_FILES}
${PERFORMANCE_SOURCE_FILES}
${SYSTEM_TEST_SOURCE_FILES}
)
add_executable(Tests ${SOURCE_FILES})
${TEST_RUNNER_SOURCE_FILES})

add_executable(Tests ${TEST_SOURCE_FILES})

target_include_directories(Tests PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/Catch/include/)

target_link_libraries (Tests PUBLIC Runner CppGrapher)
9 changes: 6 additions & 3 deletions Sources/Tests/Runner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/Catch/include)
set(SOURCE_FILES Runner.cpp)
add_library(Runner ${SOURCE_FILES})
set(TEST_RUNNER_SOURCE_FILES Runner.cpp)
add_library(Runner ${TEST_RUNNER_SOURCE_FILES})
target_include_directories(Runner PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/Catch/include)


Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
#include <regex>
#include "catch.hpp"
#include "CppGrapher.h"
#include "Helpers/Exceptions.h"
#include "Helpers/Filesystem.h"
#include "Magick++.h"

SCENARIO("Graphics tests")
{
GIVEN("an app instance")
{
auto app = CppGrapher();

WHEN("fed a data file rendering a single pixel at the origin (0, 0)")
{
auto filename = utf8_string( u8"cpp-grapher-test.one_pixel" );
auto fileContents = u8"pixel_one, 0 0";
auto fs = TemporaryFileStream( filename, fileContents );
auto args = std::vector<utf8_string> { u8"cpp-grapher_via-test-runner", filename };

//TODO suppress stdout output
app.Main( args );

THEN("a bitmap should be rendered with one pixel set at (0, 0)")
{
//TODO read image file
//generate 0-pixel image file
//diff images
//assert (count non-black pixels == 1)
}
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ SCENARIO("Parsing command line arguments")

AND_WHEN( "one argument is supplied" )
{
auto args = std::vector<utf8_string> { u8"sample-arg1" };
auto args = std::vector<utf8_string> { u8"cpp-grapher_via-test-runner" };

THEN( "it should throw an exception" )
{
Expand All @@ -49,7 +49,7 @@ SCENARIO("Parsing command line arguments")

AND_WHEN( "three arguments are supplied" )
{
auto args = std::vector<utf8_string> { u8"sample-arg1", u8"sample-arg2", u8"sample-arg3" };
auto args = std::vector<utf8_string> { u8"cpp-grapher_via-test-runner", u8"sample-arg2", u8"sample-arg3" };

THEN( "it should throw an exception" )
{
Expand Down

0 comments on commit 4958cd9

Please sign in to comment.