Skip to content

Commit a61e1bb

Browse files
authored
fixes #10 - fix header includes to allow cpm usage (#12)
1 parent 1685991 commit a61e1bb

6 files changed

Lines changed: 36 additions & 70 deletions

File tree

.travis.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
#
33
# URL: https://github.com/d99kris/spacy-cpp
44
#
5-
# Copyright (C) 2017-2020 Kristofer Berggren
5+
# Copyright (C) 2017-2022 Kristofer Berggren
66
# All rights reserved.
77
#
88
# spacy-cpp is distributed under the MIT license, see LICENSE for details.
99

1010
# Project
1111
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
12-
project(spacy-cpp VERSION 1.04 LANGUAGES CXX)
12+
project(spacy-cpp VERSION 1.05 LANGUAGES CXX)
1313
set (CMAKE_CXX_STANDARD 11)
1414
if(MSVC)
1515
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
@@ -41,7 +41,7 @@ add_library(spacy SHARED
4141
)
4242
install(TARGETS spacy LIBRARY DESTINATION lib)
4343
set_target_properties(spacy PROPERTIES LINK_FLAGS "-fPIC")
44-
include_directories(${PYTHON_INCLUDE_DIRS})
44+
target_include_directories(spacy PUBLIC ${PYTHON_INCLUDE_DIRS})
4545
target_link_libraries(spacy ${PYTHON_LIBRARIES})
4646

4747
# Headers
@@ -60,29 +60,35 @@ install(FILES
6060
DESTINATION include/spacy)
6161

6262
# Tests
63-
enable_testing()
64-
include_directories("src")
65-
set(LIB_HEADERS "src/spacy/spacy")
66-
set(TEST_HEADERS "tests/unittest.h")
63+
option(SPACYCPP_BUILD_TESTS "Build tests" OFF)
64+
message(STATUS "Build tests: ${SPACYCPP_BUILD_TESTS}")
65+
if(SPACYCPP_BUILD_TESTS)
6766

68-
function(add_spacy_test target)
67+
# Tests init
68+
enable_testing()
69+
include_directories("src")
70+
set(LIB_HEADERS "src/spacy/spacy")
71+
set(TEST_HEADERS "tests/unittest.h")
6972

70-
add_executable(test_link_${target} tests/test_${target}.cpp)
71-
target_link_libraries(test_link_${target} spacy)
72-
add_test(test_link_${target} "${PROJECT_BINARY_DIR}/test_link_${target}")
73+
macro(add_spacy_test target)
74+
add_executable(test_link_${target} tests/test_${target}.cpp)
75+
target_link_libraries(test_link_${target} spacy)
76+
add_test(test_link_${target} "${PROJECT_BINARY_DIR}/test_link_${target}")
7377

74-
add_executable(test_header_${target} tests/test_${target}.cpp)
75-
target_compile_definitions(test_header_${target} PRIVATE SPACY_HEADER_ONLY=1)
76-
target_link_libraries(test_header_${target} ${PYTHON_LIBRARIES})
77-
add_test(test_header_${target} "${PROJECT_BINARY_DIR}/test_header_${target}")
78-
79-
endfunction()
78+
add_executable(test_header_${target} tests/test_${target}.cpp)
79+
target_compile_definitions(test_header_${target} PRIVATE SPACY_HEADER_ONLY=1)
80+
target_link_libraries(test_header_${target} ${PYTHON_LIBRARIES})
81+
target_include_directories(test_header_${target} PRIVATE ${PYTHON_INCLUDE_DIRS})
82+
add_test(test_header_${target} "${PROJECT_BINARY_DIR}/test_header_${target}")
83+
endmacro()
8084

81-
add_spacy_test(spacy)
82-
add_spacy_test(attrs)
83-
add_spacy_test(nlp)
84-
add_spacy_test(doc)
85-
add_spacy_test(vocab)
86-
add_spacy_test(stringstore)
87-
add_spacy_test(span)
88-
add_spacy_test(token)
85+
add_spacy_test(spacy)
86+
add_spacy_test(attrs)
87+
add_spacy_test(nlp)
88+
add_spacy_test(doc)
89+
add_spacy_test(vocab)
90+
add_spacy_test(stringstore)
91+
add_spacy_test(span)
92+
add_spacy_test(token)
93+
94+
endif()

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ Technical Details
227227
=================
228228
Spacy-cpp uses cmake for its tests. Commands to build and execute the test suite:
229229

230-
mkdir -p build && cd build && cmake .. && make && ctest --output-on-failure ; cd -
230+
mkdir -p build && cd build && cmake -DSPACYCPP_BUILD_TESTS=ON .. && make && ctest --output-on-failure ; cd -
231231

232232

233233
License

make.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# make.sh
44
#
5-
# Copyright (C) 2020 Kristofer Berggren
5+
# Copyright (C) 2020-2022 Kristofer Berggren
66
# All rights reserved.
77
#
88
# See LICENSE for redistribution information.
@@ -90,7 +90,7 @@ if [[ "${BUILD}" == "1" ]]; then
9090
elif [ "${OS}" == "Darwin" ]; then
9191
MAKEARGS="-j$(sysctl -n hw.ncpu)"
9292
fi
93-
mkdir -p build && cd build && cmake .. && make ${MAKEARGS} && cd .. || exiterr "build failed, exiting."
93+
mkdir -p build && cd build && cmake -DSPACYCPP_BUILD_TESTS=ON .. && make ${MAKEARGS} && cd .. || exiterr "build failed, exiting."
9494
fi
9595

9696
# tests

src/spacy/spacy.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "spacy.h"
1111

1212
#include <memory>
13+
#include <stdexcept>
1314
#include <string>
1415

1516
#include "attrs.h"

tests/unittest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#endif
1717

1818
#include <fstream>
19+
#include <stdexcept>
1920
#include <string>
2021
#include <sstream>
2122

0 commit comments

Comments
 (0)