@@ -12,20 +12,6 @@ project(simdjson
1212 LANGUAGES CXX C
1313)
1414
15- # LTO seems to create all sorts of fun problems. Let us
16- # disable temporarily.
17- #include(CheckIPOSupported)
18- #check_ipo_supported(RESULT ltoresult)
19- #if(ltoresult)
20- # set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
21- #endif()
22-
23- set (CMAKE_CXX_STANDARD 17)
24- set (CMAKE_CXX_STANDARD_REQUIRED ON )
25- set (CMAKE_MACOSX_RPATH OFF )
26- set (CMAKE_THREAD_PREFER_PTHREAD ON )
27- set (THREADS_PREFER_PTHREAD_FLAG ON )
28-
2915set (PROJECT_VERSION_MAJOR 0)
3016set (PROJECT_VERSION_MINOR 3)
3117set (PROJECT_VERSION_PATCH 1)
@@ -35,19 +21,109 @@ set(SIMDJSON_LIB_SOVERSION "1" CACHE STRING "simdjson library soversion")
3521if (MSVC )
3622 option (SIMDJSON_BUILD_STATIC "Build a static library" ON ) # turning it on disables the production of a dynamic library
3723 option (SIMDJSON_COMPETITION "Compile competitive benchmarks" OFF )
38- else ()
24+ else ()
3925 option (SIMDJSON_BUILD_STATIC "Build a static library" OFF ) # turning it on disables the production of a dynamic library
4026 option (SIMDJSON_COMPETITION "Compile competitive benchmarks" ON )
4127endif ()
4228option (SIMDJSON_GOOGLE_BENCHMARKS "compile the Google Benchmark benchmarks" OFF )
4329
4430set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /tools/cmake" )
4531
32+ # We compile tools, tests, etc. with C++ 17. Override yourself if you need on a target.
33+ set (CMAKE_CXX_STANDARD 17)
34+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
35+ set (CMAKE_CXX_EXTENSIONS OFF )
36+ set (CMAKE_MACOSX_RPATH OFF )
37+ set (CMAKE_THREAD_PREFER_PTHREAD ON )
38+ set (THREADS_PREFER_PTHREAD_FLAG ON )
39+
40+ # LTO seems to create all sorts of fun problems. Let us
41+ # disable temporarily.
42+ #include(CheckIPOSupported)
43+ #check_ipo_supported(RESULT ltoresult)
44+ #if(ltoresult)
45+ # set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
46+ #endif()
47+
48+ #
49+ # Flags used by exes and by the simdjson library (project-wide flags)
50+ #
51+ add_library (simdjson-flags INTERFACE )
52+ if (MSVC )
53+ target_compile_options (simdjson-flags INTERFACE /nologo /D_CRT_SECURE_NO_WARNINGS )
54+ target_compile_options (simdjson-flags INTERFACE /W3 /wd4005 /wd4996 /wd4267 /wd4244 /wd4113 )
55+ else ()
56+ target_compile_options (simdjson-flags INTERFACE -fPIC )
57+ target_compile_options (simdjson-flags INTERFACE -Wall -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self )
58+ endif ()
59+
60+ # Optional flags
61+ option (SIMDJSON_IMPLEMENTATION_HASWELL "Include the haswell implementation" ON )
62+ if (NOT SIMDJSON_IMPLEMENTATION_HASWELL)
63+ target_compile_definitions (simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_HASWELL=0 )
64+ endif ()
65+ option (SIMDJSON_IMPLEMENTATION_WESTMERE "Include the westmere implementation" ON )
66+ if (NOT SIMDJSON_IMPLEMENTATION_WESTMERE)
67+ target_compile_definitions (simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_WESTMERE=0 )
68+ endif ()
69+ option (SIMDJSON_IMPLEMENTATION_ARM64 "Include the arm64 implementation" ON )
70+ if (NOT SIMDJSON_IMPLEMENTATION_ARM64)
71+ target_compile_definitions (simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_ARM64=0 )
72+ endif ()
73+ option (SIMDJSON_IMPLEMENTATION_FALLBACK "Include the fallback implementation" ON )
74+ if (NOT SIMDJSON_IMPLEMENTATION_FALLBACK)
75+ target_compile_definitions (simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_FALLBACK=0 )
76+ endif ()
77+
78+ option (SIMDJSON_EXCEPTIONS "Enable simdjson's exception-throwing interface" ON )
79+ if (NOT SIMDJSON_EXCEPTIONS)
80+ message (STATUS "simdjson exception interface turned off. Code that does not check error codes will not compile." )
81+ target_compile_definitions (simdjson-flags INTERFACE SIMDJSON_EXCEPTIONS=0 )
82+ endif ()
83+
84+ option (SIMDJSON_ENABLE_THREADS "Enable threaded operation" ON )
85+ if (SIMDJSON_ENABLE_THREADS)
86+ find_package (Threads REQUIRED )
87+ target_link_libraries (simdjson-flags INTERFACE Threads::Threads )
88+ endif ()
89+
90+ option (SIMDJSON_SANITIZE "Sanitize addresses" OFF )
91+ if (SIMDJSON_SANITIZE)
92+ # Not sure which
93+ target_compile_options (simdjson-flags INTERFACE -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all )
94+ target_link_libraries (simdjson-flags INTERFACE -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all )
95+
96+ # Ubuntu bug for GCC 5.0+ (safe for all versions)
97+ if (CMAKE_COMPILER_IS_GNUCC)
98+ target_link_libraries (simdjson-flags INTERFACE -fuse-ld=gold )
99+ endif ()
100+ endif ()
101+
102+ # prevent shared libraries from depending on Intel provided libraries
103+ if (${CMAKE_C_COMPILER_ID} MATCHES "Intel" ) # icc / icpc
104+ set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel" )
105+ endif ()
106+
107+ # Workaround for https://gitlab.kitware.com/cmake/cmake/issues/15415#note_633938:
108+ function (export_private_library NAME )
109+ install (TARGETS ${NAME}
110+ EXPORT ${NAME} -config
111+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
112+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
113+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
114+ )
115+ install (EXPORT ${NAME} -config
116+ FILE ${NAME} -config.cmake
117+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/simdjson-private
118+ )
119+ endfunction ()
120+
121+ export_private_library (simdjson-flags )
122+
46123#
47124# Create the top level simdjson library (must be done at this level to use both src/ and include/
48125# directories)
49126#
50- add_subdirectory (windows )
51127add_subdirectory (include )
52128add_subdirectory (src )
53129
@@ -60,10 +136,11 @@ add_library(test-data INTERFACE)
60136target_compile_definitions (test -data INTERFACE SIMDJSON_TEST_DATA_DIR= "${CMAKE_CURRENT_SOURCE_DIR} /jsonchecker/" )
61137target_compile_definitions (test -data INTERFACE SIMDJSON_BENCHMARK_DATA_DIR= "${CMAKE_CURRENT_SOURCE_DIR} /jsonexamples/" )
62138
139+ add_subdirectory (windows )
63140add_subdirectory (dependencies )
64- add_subdirectory (tools )
65141add_subdirectory (tests )
66142add_subdirectory (examples )
143+ add_subdirectory (tools )
67144add_subdirectory (benchmark )
68145
69146# for fuzzing, read the comments in the fuzz/CMakeLists.txt file
@@ -72,11 +149,9 @@ if(ENABLE_FUZZING)
72149 add_subdirectory (fuzz )
73150endif ()
74151
75- if (${CMAKE_C_COMPILER_ID} MATCHES "Intel" ) # icc / icpc
76- # prevent shared libraries from depending on Intel provided libraries
77- set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel" )
78- endif ()
79-
152+ #
153+ # CPack
154+ #
80155set (CPACK_PACKAGE_VENDOR "Daniel Lemire" )
81156set (CPACK_PACKAGE_CONTACT "lemire@gmail.com" )
82157set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Parsing gigabytes of JSON per second" )
@@ -91,5 +166,3 @@ set(CPACK_RPM_PACKAGE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
91166set (CPACK_SOURCE_GENERATOR "TGZ;ZIP" )
92167
93168include (CPack )
94-
95-
0 commit comments