CMake: Separate public and private compilation flags
simdjson-internal-flags for macros and warnings simdjson-flags for pthread, sanitizer, and libcpp
This commit is contained in:
parent
fa4ce6a8bc
commit
293c104cc4
|
@ -1,5 +1,5 @@
|
|||
include_directories( . linux )
|
||||
link_libraries(simdjson simdjson-flags simdjson-windows-headers)
|
||||
link_libraries(simdjson simdjson-windows-headers)
|
||||
# add_executable(benchfeatures benchfeatures.cpp) # doesn't presently compile at all
|
||||
add_executable(get_corpus_benchmark get_corpus_benchmark.cpp)
|
||||
add_executable(perfdiff perfdiff.cpp)
|
||||
|
|
|
@ -34,13 +34,10 @@ if(ENABLE_FUZZING)
|
|||
|
||||
# Fuzzer build flags and libraries
|
||||
add_library(simdjson-fuzzer INTERFACE)
|
||||
target_link_libraries(simdjson-fuzzer INTERFACE simdjson)
|
||||
if (SIMDJSON_FUZZ_LINKMAIN)
|
||||
target_link_libraries(simdjson-fuzzer INTERFACE simdjson-source)
|
||||
target_sources(simdjson-fuzzer INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/main.cpp)
|
||||
else ()
|
||||
target_link_libraries(simdjson-fuzzer INTERFACE simdjson)
|
||||
endif ()
|
||||
target_link_libraries(simdjson-fuzzer INTERFACE simdjson-flags)
|
||||
target_link_libraries(simdjson-fuzzer INTERFACE ${SIMDJSON_FUZZ_LDFLAGS})
|
||||
|
||||
# Define the fuzzers
|
||||
|
|
|
@ -35,39 +35,40 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|||
# Flags used by exes and by the simdjson library (project-wide flags)
|
||||
#
|
||||
add_library(simdjson-flags INTERFACE)
|
||||
add_library(simdjson-internal-flags INTERFACE)
|
||||
if(MSVC)
|
||||
target_compile_options(simdjson-flags INTERFACE /nologo /D_CRT_SECURE_NO_WARNINGS)
|
||||
target_compile_options(simdjson-flags INTERFACE /WX /W3 /sdl)
|
||||
target_compile_options(simdjson-internal-flags INTERFACE /nologo /D_CRT_SECURE_NO_WARNINGS)
|
||||
target_compile_options(simdjson-internal-flags INTERFACE /WX /W3 /sdl)
|
||||
else()
|
||||
target_compile_options(simdjson-flags INTERFACE -fPIC)
|
||||
target_compile_options(simdjson-internal-flags INTERFACE -fPIC)
|
||||
if (NOT SIMDJSON_GOOGLE_BENCHMARKS) # Google Benchmark can't be compiled without warnings with -Weffc++
|
||||
target_compile_options(simdjson-flags INTERFACE -Weffc++)
|
||||
target_compile_options(simdjson-internal-flags INTERFACE -Weffc++)
|
||||
endif()
|
||||
target_compile_options(simdjson-flags INTERFACE -Werror -Wall -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wno-sign-conversion)
|
||||
target_compile_options(simdjson-internal-flags INTERFACE -Werror -Wall -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wno-sign-conversion)
|
||||
endif()
|
||||
|
||||
# Optional flags
|
||||
option(SIMDJSON_IMPLEMENTATION_HASWELL "Include the haswell implementation" ON)
|
||||
if(NOT SIMDJSON_IMPLEMENTATION_HASWELL)
|
||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_HASWELL=0)
|
||||
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_HASWELL=0)
|
||||
endif()
|
||||
option(SIMDJSON_IMPLEMENTATION_WESTMERE "Include the westmere implementation" ON)
|
||||
if(NOT SIMDJSON_IMPLEMENTATION_WESTMERE)
|
||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_WESTMERE=0)
|
||||
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_WESTMERE=0)
|
||||
endif()
|
||||
option(SIMDJSON_IMPLEMENTATION_ARM64 "Include the arm64 implementation" ON)
|
||||
if(NOT SIMDJSON_IMPLEMENTATION_ARM64)
|
||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_ARM64=0)
|
||||
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_ARM64=0)
|
||||
endif()
|
||||
option(SIMDJSON_IMPLEMENTATION_FALLBACK "Include the fallback implementation" ON)
|
||||
if(NOT SIMDJSON_IMPLEMENTATION_FALLBACK)
|
||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_FALLBACK=0)
|
||||
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_FALLBACK=0)
|
||||
endif()
|
||||
|
||||
option(SIMDJSON_EXCEPTIONS "Enable simdjson's exception-throwing interface" ON)
|
||||
if(NOT SIMDJSON_EXCEPTIONS)
|
||||
message(STATUS "simdjson exception interface turned off. Code that does not check error codes will not compile.")
|
||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_EXCEPTIONS=0)
|
||||
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_EXCEPTIONS=0)
|
||||
endif()
|
||||
|
||||
option(SIMDJSON_ENABLE_THREADS "Enable threaded operation" ON)
|
||||
|
@ -105,3 +106,4 @@ if(${CMAKE_C_COMPILER_ID} MATCHES "Intel") # icc / icpc
|
|||
endif()
|
||||
|
||||
install(TARGETS simdjson-flags EXPORT simdjson-config)
|
||||
install(TARGETS simdjson-internal-flags EXPORT simdjson-config)
|
||||
|
|
|
@ -30,7 +30,7 @@ if (MSVC)
|
|||
)
|
||||
endif()
|
||||
|
||||
else(MSVC)
|
||||
else(MSVC)
|
||||
|
||||
##
|
||||
# Important! The script amalgamate.sh is not generally executable. It
|
||||
|
@ -72,7 +72,7 @@ else(MSVC)
|
|||
# "make amalgamate" to generate the header files directly and update the original source
|
||||
#
|
||||
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)
|
||||
|
||||
|
||||
endif(MSVC)
|
||||
|
||||
|
||||
|
@ -94,5 +94,5 @@ add_dependencies(simdjson-singleheader-source amalgamate)
|
|||
# Test the generated simdjson.cpp/simdjson.h using the generated amalgamate_demo.cpp
|
||||
#
|
||||
add_executable(amalgamate_demo $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/amalgamate_demo.cpp>)
|
||||
target_link_libraries(amalgamate_demo simdjson-singleheader-include-source simdjson-flags)
|
||||
target_link_libraries(amalgamate_demo simdjson-singleheader-include-source simdjson-internal-flags simdjson-flags)
|
||||
add_test(amalgamate_demo amalgamate_demo ${EXAMPLE_JSON} ${EXAMPLE_NDJSON})
|
||||
|
|
|
@ -42,9 +42,8 @@ else()
|
|||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(simdjson INTERFACE simdjson-headers) # Only expose the headers, not sources
|
||||
|
||||
target_link_libraries(simdjson PRIVATE simdjson-source simdjson-flags)
|
||||
target_link_libraries(simdjson PUBLIC simdjson-headers simdjson-flags) # Only expose the headers, not sources
|
||||
target_link_libraries(simdjson PRIVATE simdjson-source simdjson-internal-flags)
|
||||
|
||||
|
||||
if(NOT MSVC)
|
||||
|
|
|
@ -35,7 +35,7 @@ function(add_cpp_test TEST_NAME)
|
|||
endif()
|
||||
endfunction()
|
||||
# Most tests need test data, and many need windows headers.
|
||||
link_libraries(simdjson-flags test-data simdjson-windows-headers)
|
||||
link_libraries(simdjson-flags simdjson-internal-flags test-data simdjson-windows-headers)
|
||||
|
||||
include(${PROJECT_SOURCE_DIR}/tests/add_cpp_test.cmake)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
link_libraries(simdjson simdjson-flags simdjson-windows-headers)
|
||||
link_libraries(simdjson simdjson-flags simdjson-internal-flags simdjson-windows-headers)
|
||||
|
||||
add_executable(json2json json2json.cpp)
|
||||
add_executable(jsonstats jsonstats.cpp)
|
||||
|
|
Loading…
Reference in New Issue