Skip to content

Commit beaa6a9

Browse files
committed
Create simdjson-windows-headers interface library
1 parent a9c8224 commit beaa6a9

6 files changed

Lines changed: 62 additions & 39 deletions

File tree

.appveyor.yml

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,41 @@ version: '{build}'
22
branches:
33
only:
44
- master
5-
image:
6-
- Visual Studio 2017
75
clone_folder: c:\projects\simdjson
8-
9-
platform:
10-
- x64
11-
6+
platform: x64
7+
image:
8+
- Visual Studio 2019
9+
- Visual Studio 2017
10+
configuration: Release
1211
environment:
1312
matrix:
14-
- SIMDJSON_BUILD_STATIC: "OFF"
15-
THREADS: "ON"
16-
- SIMDJSON_BUILD_STATIC: "OFF"
17-
THREADS: "OFF"
18-
- SIMDJSON_BUILD_STATIC: "ON"
19-
THREADS: "ON"
20-
# - SIMDJSON_BUILD_STATIC: "ON"
21-
# THREADS: "OFF"
22-
13+
- SIMDJSON_BUILD_STATIC: ON
14+
SIMDJSON_ENABLE_THREADS: OFF
15+
- SIMDJSON_BUILD_STATIC: OFF
16+
SIMDJSON_ENABLE_THREADS: ON
17+
2318
build_script:
19+
- set
2420
- mkdir build
2521
- cd build
26-
- ps: cmake -DSIMDJSON_BUILD_STATIC="$env:SIMDJSON_BUILD_STATIC" -DSIMDJSON_ENABLE_THREADS="$env:THREADS" -DCMAKE_BUILD_TYPE=Release -DCMAKE_GENERATOR_PLATFORM=x64 -DSIMDJSON_GOOGLE_BENCHMARKS=OFF ..
27-
- cmake --build .
28-
- ctest --verbose --output-on-failure
22+
- cmake -DSIMDJSON_BUILD_STATIC=%SIMDJSON_BUILD_STATIC% -DSIMDJSON_ENABLE_THREADS=%SIMDJSON_ENABLE_THREADS% -DCMAKE_BUILD_TYPE=%Configuration% -DCMAKE_GENERATOR_PLATFORM=x64 -DSIMDJSON_GOOGLE_BENCHMARKS=OFF ..
23+
- cmake --build . --config %Configuration%
2924

25+
test_script:
26+
- ctest --verbose --output-on-failure -C %Configuration%
27+
28+
# VS 2017 only: readme examples don't presently succeed, exclude
29+
for:
30+
- matrix:
31+
only:
32+
- image: Visual Studio 2017
33+
test_script:
34+
- ctest --verbose --output-on-failure -C %Configuration% -E readme
35+
36+
matrix:
37+
fast_finish: true
38+
exclude:
39+
# Don't build all variants on 2019, just running it to make sure readme_tests succeed
40+
- image: Visual Studio 2019
41+
SIMDJSON_BUILD_STATIC: ON
42+
SIMDJSON_ENABLE_THREADS: OFF

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cmake_minimum_required(VERSION 3.9) # CMP0069 NEW
22

3+
message(STATUS "cmake version ${CMAKE_VERSION}")
34
if (NOT CMAKE_BUILD_TYPE)
45
message(STATUS "No build type selected, default to Release")
56
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
@@ -52,6 +53,7 @@ find_package(Options)
5253
# Create the top level simdjson library (must be done at this level to use both src/ and include/
5354
# directories)
5455
#
56+
add_subdirectory(windows)
5557
add_subdirectory(include)
5658
add_subdirectory(src)
5759

src/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ set_target_properties(simdjson PROPERTIES
5555
MESSAGE( STATUS "Library output directory (does not apply to Visual Studio): " ${CMAKE_BINARY_DIR})
5656
endif()
5757

58-
if((SIMDJSON_LIB_TYPE STREQUAL "SHARED"))
59-
target_compile_definitions(${SIMDJSON_LIB_NAME} INTERFACE SIMDJSON_USING_LIBRARY=1)
58+
if(NOT SIMDJSON_BUILD_STATIC)
59+
target_compile_definitions(simdjson INTERFACE SIMDJSON_USING_LIBRARY=1)
6060
endif()
6161

62-
if(MSVC AND (SIMDJSON_LIB_TYPE STREQUAL "SHARED"))
62+
if(MSVC AND (NOT SIMDJSON_BUILD_STATIC))
6363
if (CMAKE_VERSION VERSION_LESS 3.4)
64-
MESSAGE( STATUS "To build a Windows DLL using Visual Studio, you may need cmake 3.4 or better." )
64+
MESSAGE( STATUS "To build a Windows DLL using Visual Studio, you may need cmake 3.4 or better." )
6565
endif()
6666
MESSAGE( STATUS "Building a Windows DLL using Visual Studio, exporting all symbols automatically." )
67-
set_target_properties(simdjson
67+
set_target_properties(simdjson
6868
PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 1)
6969
endif()
7070

tests/CMakeLists.txt

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,28 @@ function(add_cpp_test TEST_NAME TEST_FILE)
55
endfunction(add_cpp_test)
66

77
# Sets a target to only build when you run the test, and expect failure
8-
function(add_compile_fail_test TEST_NAME)
8+
function(add_compile_test TEST_NAME TEST_FILE EXPECT_SUCCESS)
9+
add_executable(${TEST_NAME} ${TEST_FILE})
910
set_target_properties(${TEST_NAME} PROPERTIES
1011
EXCLUDE_FROM_ALL TRUE
1112
EXCLUDE_FROM_DEFAULT_BUILD TRUE)
1213
add_test(NAME ${TEST_NAME}
13-
COMMAND ${CMAKE_COMMAND} --build . --target ${TEST_NAME} --config $<CONFIGURATION>
14-
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
15-
set_tests_properties(${TEST_NAME} PROPERTIES WILL_FAIL TRUE)
16-
endfunction(add_compile_fail_test)
14+
COMMAND ${CMAKE_COMMAND} --build . --target ${TEST_NAME} --config $<CONFIGURATION>
15+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
16+
if(NOT ${EXPECT_SUCCESS})
17+
set_tests_properties(${TEST_NAME} PROPERTIES WILL_FAIL TRUE)
18+
endif()
19+
endfunction(add_compile_test)
1720

1821
#
1922
# These test explicitly do #include "simdjson.cpp"
2023
#
21-
add_cpp_test(numberparsingcheck numberparsingcheck.cpp)
22-
target_link_libraries(numberparsingcheck simdjson-source)
23-
add_cpp_test(stringparsingcheck stringparsingcheck.cpp)
24-
target_link_libraries(stringparsingcheck simdjson-source)
24+
if (NOT MSVC) # Can't get simdjson-source to compile on Windows for some reason.
25+
add_cpp_test(numberparsingcheck numberparsingcheck.cpp)
26+
target_link_libraries(numberparsingcheck simdjson-source simdjson-windows-headers)
27+
add_cpp_test(stringparsingcheck stringparsingcheck.cpp)
28+
target_link_libraries(stringparsingcheck simdjson-source simdjson-windows-headers)
29+
endif()
2530

2631
#
2732
# All remaining tests link with simdjson proper
@@ -33,22 +38,19 @@ add_cpp_test(basictests basictests.cpp)
3338
add_cpp_test(errortests errortests.cpp)
3439
add_cpp_test(integer_tests integer_tests.cpp)
3540
add_cpp_test(jsoncheck jsoncheck.cpp)
41+
target_link_libraries(jsoncheck simdjson-windows-headers)
3642
add_cpp_test(parse_many_test parse_many_test.cpp)
43+
target_link_libraries(parse_many_test simdjson-windows-headers)
3744
add_cpp_test(pointercheck pointercheck.cpp)
3845

3946
# Compile-only tests
40-
add_executable(readme_examples readme_examples.cpp)
41-
add_executable(readme_examples_noexceptions readme_examples_noexceptions.cpp)
42-
target_compile_options(readme_examples_noexceptions PRIVATE -fno-exceptions)
43-
47+
add_compile_test(readme_examples readme_examples.cpp TRUE)
4448
# Test that readme_examples does NOT compile when SIMDJSON_EXCEPTIONS=0 (i.e. test that the define
4549
# works even if exceptions are on)
46-
add_executable(readme_examples_will_fail_with_exceptions_off readme_examples.cpp)
50+
add_compile_test(readme_examples_will_fail_with_exceptions_off readme_examples.cpp FALSE)
4751
target_compile_definitions(readme_examples_will_fail_with_exceptions_off PRIVATE SIMDJSON_EXCEPTIONS=0)
48-
add_compile_fail_test(readme_examples_will_fail_with_exceptions_off)
4952

5053
if(MSVC)
51-
include_directories($<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/windows>)
5254
add_custom_command(TARGET basictests POST_BUILD # Adds a post-build event
5355
COMMAND ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:simdjson>"
5456
COMMAND ${CMAKE_COMMAND} -E echo "$<TARGET_FILE_DIR:basictests>"

tools/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
link_libraries(simdjson)
2+
link_libraries(simdjson-windows-headers)
3+
24
add_executable(json2json json2json.cpp)
35
add_executable(jsonstats jsonstats.cpp)
46
add_executable(minify minify.cpp)

windows/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
add_library(simdjson-windows-headers INTERFACE)
2+
if(MSVC)
3+
target_include_directories(simdjson-windows-headers INTERFACE .)
4+
endif()

0 commit comments

Comments
 (0)