Fixing issue 99 (#163)

This commit is contained in:
Daniel Lemire 2019-05-09 21:20:14 -04:00 committed by GitHub
parent b98454d213
commit 871fd20ee5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 28 deletions

View File

@ -1,4 +1,10 @@
cmake_minimum_required(VERSION 3.8...3.13)
cmake_minimum_required(VERSION 3.9) # CMP0069 NEW
include(CheckIPOSupported)
check_ipo_supported(RESULT ltoresult)
if(ltoresult)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MACOSX_RPATH OFF)
@ -20,14 +26,12 @@ option(SIMDJSON_BUILD_STATIC "Build a static library" OFF) # turning it on disab
else()
option(SIMDJSON_BUILD_STATIC "Build a static library" ON) # turning it on disables the production of a dynamic library
endif()
option(SIMDJSON_BUILD_LTO "Build library with Link Time Optimization" OFF)
option(SIMDJSON_SANITIZE "Sanitize addresses" OFF)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")
find_package(CTargets)
find_package(Options)
find_package(LTO)
install(DIRECTORY include/${SIMDJSON_LIB_NAME} DESTINATION include)
set (TEST_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/jsonchecker/")

View File

@ -1,25 +0,0 @@
# gcc and clang require a special 'ar' and 'ranlib' to create a
# static libX.a that allows for further inlining, but icc does not.
macro(append var string)
set(${var} "${${var}} ${string}")
endmacro(append)
if(BUILD_LTO)
if ("${CMAKE_C_COMPILER_ID}" MATCHES "Intel") # icc
append(CMAKE_CXX_FLAGS "-ipo")
elseif("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC") # Microsoft
# TODO
elseif ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") # Clang or AppleClang
append(CMAKE_CXX_FLAGS "-flto")
append(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=gold -flto")
append(CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=gold -flto")
set(_LLVM_VERSION_STRING "3.8") # FIXME: determine version automatically
set(CMAKE_AR "llvm-ar-${_LLVM_VERSION_STRING}")
set(CMAKE_RANLIB "llvm-ranlib-${_LLVM_VERSION_STRING}")
else() # assume GCC compatible syntax if not matched
append(CMAKE_CXX_FLAGS "-flto")
set(CMAKE_AR "gcc-ar")
set(CMAKE_RANLIB "gcc-ranlib")
endif()
endif(BUILD_LTO)