Skip to content

Commit

Permalink
fixes #10 - fix header includes to allow cpm usage (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
d99kris authored Feb 27, 2022
1 parent 1685991 commit a61e1bb
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 70 deletions.
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

56 changes: 31 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
#
# URL: https://github.com/d99kris/spacy-cpp
#
# Copyright (C) 2017-2020 Kristofer Berggren
# Copyright (C) 2017-2022 Kristofer Berggren
# All rights reserved.
#
# spacy-cpp is distributed under the MIT license, see LICENSE for details.

# Project
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(spacy-cpp VERSION 1.04 LANGUAGES CXX)
project(spacy-cpp VERSION 1.05 LANGUAGES CXX)
set (CMAKE_CXX_STANDARD 11)
if(MSVC)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
Expand Down Expand Up @@ -41,7 +41,7 @@ add_library(spacy SHARED
)
install(TARGETS spacy LIBRARY DESTINATION lib)
set_target_properties(spacy PROPERTIES LINK_FLAGS "-fPIC")
include_directories(${PYTHON_INCLUDE_DIRS})
target_include_directories(spacy PUBLIC ${PYTHON_INCLUDE_DIRS})
target_link_libraries(spacy ${PYTHON_LIBRARIES})

# Headers
Expand All @@ -60,29 +60,35 @@ install(FILES
DESTINATION include/spacy)

# Tests
enable_testing()
include_directories("src")
set(LIB_HEADERS "src/spacy/spacy")
set(TEST_HEADERS "tests/unittest.h")
option(SPACYCPP_BUILD_TESTS "Build tests" OFF)
message(STATUS "Build tests: ${SPACYCPP_BUILD_TESTS}")
if(SPACYCPP_BUILD_TESTS)

function(add_spacy_test target)
# Tests init
enable_testing()
include_directories("src")
set(LIB_HEADERS "src/spacy/spacy")
set(TEST_HEADERS "tests/unittest.h")

add_executable(test_link_${target} tests/test_${target}.cpp)
target_link_libraries(test_link_${target} spacy)
add_test(test_link_${target} "${PROJECT_BINARY_DIR}/test_link_${target}")
macro(add_spacy_test target)
add_executable(test_link_${target} tests/test_${target}.cpp)
target_link_libraries(test_link_${target} spacy)
add_test(test_link_${target} "${PROJECT_BINARY_DIR}/test_link_${target}")

add_executable(test_header_${target} tests/test_${target}.cpp)
target_compile_definitions(test_header_${target} PRIVATE SPACY_HEADER_ONLY=1)
target_link_libraries(test_header_${target} ${PYTHON_LIBRARIES})
add_test(test_header_${target} "${PROJECT_BINARY_DIR}/test_header_${target}")

endfunction()
add_executable(test_header_${target} tests/test_${target}.cpp)
target_compile_definitions(test_header_${target} PRIVATE SPACY_HEADER_ONLY=1)
target_link_libraries(test_header_${target} ${PYTHON_LIBRARIES})
target_include_directories(test_header_${target} PRIVATE ${PYTHON_INCLUDE_DIRS})
add_test(test_header_${target} "${PROJECT_BINARY_DIR}/test_header_${target}")
endmacro()

add_spacy_test(spacy)
add_spacy_test(attrs)
add_spacy_test(nlp)
add_spacy_test(doc)
add_spacy_test(vocab)
add_spacy_test(stringstore)
add_spacy_test(span)
add_spacy_test(token)
add_spacy_test(spacy)
add_spacy_test(attrs)
add_spacy_test(nlp)
add_spacy_test(doc)
add_spacy_test(vocab)
add_spacy_test(stringstore)
add_spacy_test(span)
add_spacy_test(token)

endif()
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Technical Details
=================
Spacy-cpp uses cmake for its tests. Commands to build and execute the test suite:

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


License
Expand Down
4 changes: 2 additions & 2 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

# tests
Expand Down
1 change: 1 addition & 0 deletions src/spacy/spacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "spacy.h"

#include <memory>
#include <stdexcept>
#include <string>

#include "attrs.h"
Expand Down
1 change: 1 addition & 0 deletions tests/unittest.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#endif

#include <fstream>
#include <stdexcept>
#include <string>
#include <sstream>

Expand Down

0 comments on commit a61e1bb

Please sign in to comment.