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
1111cmake_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 )
1313set (CMAKE_CXX_STANDARD 11)
1414if (MSVC )
1515 if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]" )
@@ -41,7 +41,7 @@ add_library(spacy SHARED
4141 )
4242install (TARGETS spacy LIBRARY DESTINATION lib)
4343set_target_properties (spacy PROPERTIES LINK_FLAGS "-fPIC" )
44- include_directories ( ${PYTHON_INCLUDE_DIRS} )
44+ target_include_directories ( spacy PUBLIC ${PYTHON_INCLUDE_DIRS} )
4545target_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 ()
0 commit comments