Skip to content

Commit 081feff

Browse files
authored
Merge pull request wyyrepo#1 from paceholder/master
update
2 parents 87f0d38 + d4b8395 commit 081feff

File tree

13 files changed

+100
-56
lines changed

13 files changed

+100
-56
lines changed

.appveyor.yml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ environment:
55
- GENERATOR : "Visual Studio 14 2015 Win64"
66
QTDIR: C:\Qt\5.6.3\msvc2015_64
77
PLATFORM: x64
8-
BUILD_TESTING: ON
98
- GENERATOR : "Visual Studio 14 2015"
109
QTDIR: C:\Qt\5.6.3\msvc2015
1110
PLATFORM: Win32
12-
BUILD_TESTING: ON
1311
- GENERATOR : "MinGW Makefiles"
1412
QTDIR: C:\Qt\5.6\mingw49_32
1513
PLATFORM: x86
16-
BUILD_TESTING: OFF
14+
CMAKE_CXX_FLAGS_INIT: -DCATCH_CONFIG_NO_CPP11_TO_STRING
1715

1816
image: Visual Studio 2015
1917

@@ -29,39 +27,24 @@ install:
2927
- set Qt5_DIR=%QTDIR%\lib\cmake\Qt5
3028
- set PATH=C:\MinGW\bin;C:\MinGW\msys\1.0;%PATH%
3129
- set PATH=%PATH:C:\Program Files\Git\usr\bin=% # trick to remove sh.exe
32-
- mkdir dependencies
33-
- cd dependencies
34-
- mkdir install
35-
- set CMAKE_INSTALL_PREFIX=%cd%\install
36-
- set DEPENDENCIES=%cd%\install
37-
- git clone https://github.com/catchorg/Catch2.git
38-
- cd Catch2
39-
- mkdir build
40-
- cd build
41-
- cmake "-G%GENERATOR%" -DBUILD_TESTING=OFF ..
42-
- cmake --build . --target install
43-
- set Catch2_DIR=%DEPENDENCIES=%cd%\install\lib\cmake\Catch2
44-
- cd ..
45-
- cd ..
46-
- cd ..
4730

4831
before_build:
4932
- mkdir build
5033
- cd build
5134
- mkdir bin
5235
- set OUTPUT_DIR=%cd%\bin
53-
- echo %BUILD_TESTING%
54-
- cmake "-G%GENERATOR%" -DBUILD_TESTING=%BUILD_TESTING%
36+
- cmake "-G%GENERATOR%"
5537
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG="%OUTPUT_DIR%"
5638
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE="%OUTPUT_DIR%"
39+
-DCMAKE_CXX_FLAGS_INIT="%CMAKE_CXX_FLAGS_INIT%"
5740
..
5841

5942

6043
build_script:
6144
- cmake --build .
6245

6346
test_script:
64-
- if "%BUILD_TESTING%" == "ON" .\bin\test_nodes.exe
47+
- ctest --output-on-failure -C Debug
6548

6649

6750
after_build:

.travis.yml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ matrix:
3131
- os: osx
3232
osx_image: xcode8.3
3333
compiler: clang
34-
env: CMAKE_PREFIX_PATH=/usr/local/Cellar/qt/5.11.0:$CMAKE_PREFIX_PATH
34+
env: CMAKE_PREFIX_PATH=/usr/local/Cellar/qt/5.11.2:$CMAKE_PREFIX_PATH
3535

3636
git:
3737
depth: 10
@@ -43,27 +43,12 @@ before_install:
4343
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install build-essential libgl1-mesa-dev ; fi
4444
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -yy install qtbase5-dev ; fi
4545

46-
install:
47-
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
48-
- |
49-
mkdir -p ${DEPS_DIR}
50-
pushd ${DEPS_DIR}
51-
- travis_retry git clone https://github.com/catchorg/Catch2.git # Install Catch2
52-
- |
53-
pushd Catch2
54-
git checkout tags/v2.2.2
55-
mkdir build && cd build
56-
- cmake .. -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX="${DEPS_DIR}/install"
57-
- cmake --build . -- install
58-
- export CMAKE_PREFIX_PATH="${DEPS_DIR}/install/:$CMAKE_PREFIX_PATH"
59-
- popd; popd
60-
6146
script:
6247
- mkdir build
6348
- cd build
6449
- cmake -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_BUILD .. && make -j
65-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then xvfb-run --server-args="-screen 0 1024x768x24" ./test/test_nodes; fi
66-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./test/test_nodes; fi
50+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then xvfb-run --server-args="-screen 0 1024x768x24" ctest --output-on-failure; fi
51+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ctest --output-on-failure; fi
6752

6853
notifications:
6954
email: false

CMakeLists.txt

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,31 @@ project(NodeEditor CXX)
66
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
77
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
88

9-
include(CTest)
9+
get_directory_property(_has_parent PARENT_DIRECTORY)
10+
if(_has_parent)
11+
set(is_root_project OFF)
12+
else()
13+
set(is_root_project ON)
14+
endif()
15+
16+
set(NE_DEVELOPER_DEFAULTS "${is_root_project}" CACHE BOOL "Turns on default settings for development of NodeEditor")
17+
18+
option(BUILD_TESTING "Build tests" "${NE_DEVELOPER_DEFAULTS}")
19+
option(BUILD_EXAMPLES "Build Examples" "${NE_DEVELOPER_DEFAULTS}")
20+
option(NE_FORCE_TEST_COLOR "Force colorized unit test output" OFF)
21+
22+
enable_testing()
1023

11-
option(BUILD_EXAMPLES "Build Examples" ON)
24+
if(NE_DEVELOPER_DEFAULTS)
25+
set(CMAKE_CXX_STANDARD 14)
26+
set(CMAKE_CXX_EXTENSIONS OFF)
27+
28+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
29+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
30+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
31+
endif()
32+
33+
add_subdirectory(external)
1234

1335
# Find the QtWidgets library
1436
find_package(Qt5 COMPONENTS
@@ -57,7 +79,7 @@ add_library(nodes SHARED
5779
add_library(NodeEditor::nodes ALIAS nodes)
5880

5981
target_include_directories(nodes
60-
PUBLIC
82+
PUBLIC
6183
$<INSTALL_INTERFACE:include>
6284
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
6385
PRIVATE

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,27 @@ Each change in the source node is immediately propagated through all the connect
3333
* JSON-based interface styles
3434
* Saving scenes to JSON files
3535

36+
### Building
37+
38+
#### Linux
39+
40+
~~~
41+
git clone git@github.com:paceholder/nodeeditor.git
42+
cd nodeeditor
43+
mkdir build
44+
cd build
45+
cmake ..
46+
make -j && make install
47+
~~~
48+
49+
#### Qt Creator
50+
51+
1. Open `CMakeLists.txt` as project.
52+
2. If you don't have the `Catch2` library installed, go to `Build Settings`, disable the checkbox `BUILD_TESTING`.
53+
3. `Build -> Run CMake`
54+
4. `Build -> Build All`
55+
5. Click the button `Run`
56+
3657
### Roadmap
3758

3859
1. Extend set of examples

external/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if(BUILD_TESTING)
2+
find_package(Catch2 2.3.0 QUIET)
3+
4+
if(NOT Catch2_FOUND)
5+
add_subdirectory(Catch2)
6+
endif()
7+
endif()
8+
9+
macro(find_package pkg)
10+
if(NOT TARGET "${pkg}")
11+
_find_package(${ARGV})
12+
endif()
13+
endmacro()

external/Catch2/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/single_include/catch2/catch.hpp")
2+
file(DOWNLOAD https://raw.githubusercontent.com/catchorg/Catch2/v2.4.1/single_include/catch2/catch.hpp
3+
"${CMAKE_CURRENT_BINARY_DIR}/single_include/catch2/catch.hpp"
4+
EXPECTED_HASH SHA256=a4b90030cb813f0452bb00e97c92ca6c2ecf9386a2f000b6effb8e265a53959e
5+
)
6+
endif()
7+
8+
add_library(Catch2 INTERFACE)
9+
add_library(Catch2::Catch2 ALIAS Catch2)
10+
target_include_directories(Catch2
11+
INTERFACE
12+
"${CMAKE_CURRENT_BINARY_DIR}/single_include"
13+
)

src/ConnectionGraphicsObject.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,15 @@ mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
207207
auto node = locateNodeAt(event->scenePos(), _scene,
208208
_scene.views()[0]->transform());
209209

210-
NodeConnectionInteraction interaction(*node, _connection, _scene);
211-
212-
if (node && interaction.tryConnect())
213-
{
214-
node->resetReactionToConnection();
210+
if (node) {
211+
NodeConnectionInteraction interaction(*node, _connection, _scene);
212+
if (interaction.tryConnect()) {
213+
node->resetReactionToConnection();
214+
return;
215+
}
215216
}
216-
else if (_connection.connectionState().requiresPort())
217+
218+
if (_connection.connectionState().requiresPort())
217219
{
218220
_scene.deleteConnection(_connection);
219221
}

test/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
find_package(Catch2 REQUIRED)
1+
find_package(Catch2 2.3.0 REQUIRED)
22
find_package(Qt5 COMPONENTS Test)
33

44
add_executable(test_nodes
@@ -18,8 +18,13 @@ target_include_directories(test_nodes
1818
target_link_libraries(test_nodes
1919
PRIVATE
2020
NodeEditor::nodes
21-
Catch2::Catch
21+
Catch2::Catch2
2222
Qt5::Test
2323
)
2424

25-
add_test(test_nodes test_nodes)
25+
add_test(
26+
NAME test_nodes
27+
COMMAND
28+
$<TARGET_FILE:test_nodes>
29+
$<$<BOOL:${NE_FORCE_TEST_COLOR}>:--use-colour=yes>
30+
)

test/include/Stringify.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <QtCore/QPoint>
44
#include <QtCore/QPointF>
55

6-
#include <catch.hpp>
6+
#include <catch2/catch.hpp>
77

88
#include <QtTest>
99

test/src/TestDataModelRegistry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <nodes/DataModelRegistry>
22

3-
#include <catch.hpp>
3+
#include <catch2/catch.hpp>
44

55
#include "StubNodeDataModel.hpp"
66

0 commit comments

Comments
 (0)