Skip to content

Commit 293c104

Browse files
committed
CMake: Separate public and private compilation flags
simdjson-internal-flags for macros and warnings simdjson-flags for pthread, sanitizer, and libcpp
1 parent fa4ce6a commit 293c104

File tree

7 files changed

+21
-23
lines changed

7 files changed

+21
-23
lines changed

benchmark/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include_directories( . linux )
2-
link_libraries(simdjson simdjson-flags simdjson-windows-headers)
2+
link_libraries(simdjson simdjson-windows-headers)
33
# add_executable(benchfeatures benchfeatures.cpp) # doesn't presently compile at all
44
add_executable(get_corpus_benchmark get_corpus_benchmark.cpp)
55
add_executable(perfdiff perfdiff.cpp)

fuzz/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,10 @@ if(ENABLE_FUZZING)
3434

3535
# Fuzzer build flags and libraries
3636
add_library(simdjson-fuzzer INTERFACE)
37+
target_link_libraries(simdjson-fuzzer INTERFACE simdjson)
3738
if (SIMDJSON_FUZZ_LINKMAIN)
38-
target_link_libraries(simdjson-fuzzer INTERFACE simdjson-source)
3939
target_sources(simdjson-fuzzer INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/main.cpp)
40-
else ()
41-
target_link_libraries(simdjson-fuzzer INTERFACE simdjson)
4240
endif ()
43-
target_link_libraries(simdjson-fuzzer INTERFACE simdjson-flags)
4441
target_link_libraries(simdjson-fuzzer INTERFACE ${SIMDJSON_FUZZ_LDFLAGS})
4542

4643
# Define the fuzzers

simdjson-flags.cmake

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,39 +35,40 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
3535
# Flags used by exes and by the simdjson library (project-wide flags)
3636
#
3737
add_library(simdjson-flags INTERFACE)
38+
add_library(simdjson-internal-flags INTERFACE)
3839
if(MSVC)
39-
target_compile_options(simdjson-flags INTERFACE /nologo /D_CRT_SECURE_NO_WARNINGS)
40-
target_compile_options(simdjson-flags INTERFACE /WX /W3 /sdl)
40+
target_compile_options(simdjson-internal-flags INTERFACE /nologo /D_CRT_SECURE_NO_WARNINGS)
41+
target_compile_options(simdjson-internal-flags INTERFACE /WX /W3 /sdl)
4142
else()
42-
target_compile_options(simdjson-flags INTERFACE -fPIC)
43+
target_compile_options(simdjson-internal-flags INTERFACE -fPIC)
4344
if (NOT SIMDJSON_GOOGLE_BENCHMARKS) # Google Benchmark can't be compiled without warnings with -Weffc++
44-
target_compile_options(simdjson-flags INTERFACE -Weffc++)
45+
target_compile_options(simdjson-internal-flags INTERFACE -Weffc++)
4546
endif()
46-
target_compile_options(simdjson-flags INTERFACE -Werror -Wall -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wno-sign-conversion)
47+
target_compile_options(simdjson-internal-flags INTERFACE -Werror -Wall -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wno-sign-conversion)
4748
endif()
4849

4950
# Optional flags
5051
option(SIMDJSON_IMPLEMENTATION_HASWELL "Include the haswell implementation" ON)
5152
if(NOT SIMDJSON_IMPLEMENTATION_HASWELL)
52-
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_HASWELL=0)
53+
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_HASWELL=0)
5354
endif()
5455
option(SIMDJSON_IMPLEMENTATION_WESTMERE "Include the westmere implementation" ON)
5556
if(NOT SIMDJSON_IMPLEMENTATION_WESTMERE)
56-
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_WESTMERE=0)
57+
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_WESTMERE=0)
5758
endif()
5859
option(SIMDJSON_IMPLEMENTATION_ARM64 "Include the arm64 implementation" ON)
5960
if(NOT SIMDJSON_IMPLEMENTATION_ARM64)
60-
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_ARM64=0)
61+
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_ARM64=0)
6162
endif()
6263
option(SIMDJSON_IMPLEMENTATION_FALLBACK "Include the fallback implementation" ON)
6364
if(NOT SIMDJSON_IMPLEMENTATION_FALLBACK)
64-
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_FALLBACK=0)
65+
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_FALLBACK=0)
6566
endif()
6667

6768
option(SIMDJSON_EXCEPTIONS "Enable simdjson's exception-throwing interface" ON)
6869
if(NOT SIMDJSON_EXCEPTIONS)
6970
message(STATUS "simdjson exception interface turned off. Code that does not check error codes will not compile.")
70-
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_EXCEPTIONS=0)
71+
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_EXCEPTIONS=0)
7172
endif()
7273

7374
option(SIMDJSON_ENABLE_THREADS "Enable threaded operation" ON)
@@ -105,3 +106,4 @@ if(${CMAKE_C_COMPILER_ID} MATCHES "Intel") # icc / icpc
105106
endif()
106107

107108
install(TARGETS simdjson-flags EXPORT simdjson-config)
109+
install(TARGETS simdjson-internal-flags EXPORT simdjson-config)

singleheader/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if (MSVC)
3030
)
3131
endif()
3232

33-
else(MSVC)
33+
else(MSVC)
3434

3535
##
3636
# Important! The script amalgamate.sh is not generally executable. It
@@ -72,7 +72,7 @@ else(MSVC)
7272
# "make amalgamate" to generate the header files directly and update the original source
7373
#
7474
add_custom_target(amalgamate DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/simdjson.cpp ${CMAKE_CURRENT_SOURCE_DIR}/simdjson.h ${CMAKE_CURRENT_SOURCE_DIR}/amalgamate_demo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
75-
75+
7676
endif(MSVC)
7777

7878

@@ -94,5 +94,5 @@ add_dependencies(simdjson-singleheader-source amalgamate)
9494
# Test the generated simdjson.cpp/simdjson.h using the generated amalgamate_demo.cpp
9595
#
9696
add_executable(amalgamate_demo $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/amalgamate_demo.cpp>)
97-
target_link_libraries(amalgamate_demo simdjson-singleheader-include-source simdjson-flags)
97+
target_link_libraries(amalgamate_demo simdjson-singleheader-include-source simdjson-internal-flags simdjson-flags)
9898
add_test(amalgamate_demo amalgamate_demo ${EXAMPLE_JSON} ${EXAMPLE_NDJSON})

src/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ else()
4242
endif()
4343
endif()
4444

45-
target_link_libraries(simdjson INTERFACE simdjson-headers) # Only expose the headers, not sources
46-
47-
target_link_libraries(simdjson PRIVATE simdjson-source simdjson-flags)
45+
target_link_libraries(simdjson PUBLIC simdjson-headers simdjson-flags) # Only expose the headers, not sources
46+
target_link_libraries(simdjson PRIVATE simdjson-source simdjson-internal-flags)
4847

4948

5049
if(NOT MSVC)

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function(add_cpp_test TEST_NAME)
3535
endif()
3636
endfunction()
3737
# Most tests need test data, and many need windows headers.
38-
link_libraries(simdjson-flags test-data simdjson-windows-headers)
38+
link_libraries(simdjson-flags simdjson-internal-flags test-data simdjson-windows-headers)
3939

4040
include(${PROJECT_SOURCE_DIR}/tests/add_cpp_test.cmake)
4141

tools/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
link_libraries(simdjson simdjson-flags simdjson-windows-headers)
1+
link_libraries(simdjson simdjson-flags simdjson-internal-flags simdjson-windows-headers)
22

33
add_executable(json2json json2json.cpp)
44
add_executable(jsonstats jsonstats.cpp)

0 commit comments

Comments
 (0)