Merge pull request #852 from furkanusta/cmake-flags
CMake: Separate public and private compilation flags
This commit is contained in:
commit
73e27bdd48
|
@ -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)
|
||||
|
|
|
@ -40,7 +40,7 @@ if(ENABLE_FUZZING)
|
|||
else ()
|
||||
target_link_libraries(simdjson-fuzzer INTERFACE simdjson)
|
||||
endif ()
|
||||
target_link_libraries(simdjson-fuzzer INTERFACE simdjson-flags)
|
||||
target_link_libraries(simdjson-fuzzer INTERFACE simdjson-internal-flags)
|
||||
target_link_libraries(simdjson-fuzzer INTERFACE ${SIMDJSON_FUZZ_LDFLAGS})
|
||||
|
||||
# Define the fuzzers
|
||||
|
|
|
@ -35,39 +35,42 @@ 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)
|
||||
target_link_libraries(simdjson-internal-flags INTERFACE simdjson-flags)
|
||||
|
||||
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 +108,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)
|
||||
|
|
|
@ -93,7 +93,7 @@ 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)
|
||||
add_test(amalgamate_demo amalgamate_demo ${EXAMPLE_JSON} ${EXAMPLE_NDJSON})
|
||||
|
||||
install(FILES simdjson.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
|
|
@ -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-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-internal-flags simdjson-windows-headers)
|
||||
|
||||
add_executable(json2json json2json.cpp)
|
||||
add_executable(jsonstats jsonstats.cpp)
|
||||
|
|
Loading…
Reference in New Issue