|
| 1 | +if(${CMAKE_C_COMPILER_ID} MATCHES "Intel") # icc / icpc |
| 2 | + # prevent shared libraries from depending on Intel provided libraries |
| 3 | + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel") |
| 4 | +endif() |
| 5 | + |
| 6 | + |
| 7 | +# we default on a shared library. |
| 8 | +if(SIMDJSON_BUILD_STATIC) |
| 9 | + set(SIMDJSON_LIB_TYPE STATIC) |
| 10 | + MESSAGE( STATUS "Building a static library." ) |
| 11 | +else() |
| 12 | + MESSAGE( STATUS "Building a dynamic library (default)." ) |
| 13 | + set(SIMDJSON_LIB_TYPE SHARED) |
| 14 | +endif() |
| 15 | + |
| 16 | +MESSAGE( STATUS "SIMDJSON_LIB_TYPE: " ${SIMDJSON_LIB_TYPE}) |
| 17 | +set(SIMDJSON_SRC |
| 18 | + jsonioutil.cpp |
| 19 | + jsonminifier.cpp |
| 20 | + jsonparser.cpp |
| 21 | + stage1_find_marks.cpp |
| 22 | + stage2_flatten.cpp |
| 23 | + stage34_unified.cpp) |
| 24 | + |
| 25 | +add_library(${SIMDJSON_LIB_NAME} ${SIMDJSON_LIB_TYPE} ${SIMDJSON_SRC}) |
| 26 | +target_include_directories(${SIMDJSON_LIB_NAME} |
| 27 | + PUBLIC ${PROJECT_SOURCE_DIR}/include |
| 28 | +) |
| 29 | + |
| 30 | +install(TARGETS ${SIMDJSON_LIB_NAME} DESTINATION lib) |
| 31 | + |
| 32 | +if(NOT MSVC) |
| 33 | +## We output the library at the root of the current directory where cmake is invoked |
| 34 | +## This is handy but Visual Studio will happily ignore us |
| 35 | +set_target_properties(${SIMDJSON_LIB_NAME} PROPERTIES |
| 36 | + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) |
| 37 | +MESSAGE( STATUS "Library output directory (does not apply to Visual Studio): " ${CMAKE_BINARY_DIR}) |
| 38 | +endif() |
| 39 | + |
| 40 | +if(MSVC AND (SIMDJSON_LIB_TYPE STREQUAL "SHARED")) |
| 41 | + if (CMAKE_VERSION VERSION_LESS 3.4) |
| 42 | + MESSAGE( STATUS "To build a Windows DLL using Visual Studio, you may need cmake 3.4 or better." ) |
| 43 | + endif() |
| 44 | + MESSAGE( STATUS "Building a Windows DLL using Visual Studio, exporting all symbols automatically." ) |
| 45 | + set_target_properties(${SIMDJSON_LIB_NAME} |
| 46 | + PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 1) |
| 47 | +endif() |
0 commit comments