Export CMake targets (#96)

This commit is contained in:
myd7349 2019-03-05 05:07:06 +08:00 committed by Daniel Lemire
parent 6541682433
commit 2851ea490c
3 changed files with 23 additions and 8 deletions

View File

@ -1,7 +1,7 @@
target_include_directories(${SIMDJSON_LIB_NAME}
PUBLIC
${PROJECT_SOURCE_DIR}/benchmark
${PROJECT_SOURCE_DIR}/benchmark/linux
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/benchmark>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/benchmark/linux>
)
add_cpp_benchmark(parse)

View File

@ -3,6 +3,7 @@ if(${CMAKE_C_COMPILER_ID} MATCHES "Intel") # icc / icpc
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel")
endif()
include(GNUInstallDirs)
# we default on a shared library.
if(SIMDJSON_BUILD_STATIC)
@ -26,11 +27,25 @@ set(SIMDJSON_SRC
)
add_library(${SIMDJSON_LIB_NAME} ${SIMDJSON_LIB_TYPE} ${SIMDJSON_SRC})
target_include_directories(${SIMDJSON_LIB_NAME}
PUBLIC ${PROJECT_SOURCE_DIR}/include
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
install(TARGETS ${SIMDJSON_LIB_NAME} DESTINATION lib)
install(TARGETS ${SIMDJSON_LIB_NAME}
EXPORT ${SIMDJSON_LIB_NAME}-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(EXPORT ${SIMDJSON_LIB_NAME}-config
FILE ${SIMDJSON_LIB_NAME}-config.cmake
NAMESPACE ${SIMDJSON_LIB_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${SIMDJSON_LIB_NAME}
)
if(NOT MSVC)
## We output the library at the root of the current directory where cmake is invoked

View File

@ -1,6 +1,6 @@
if(MSVC)
target_include_directories(${SIMDJSON_LIB_NAME}
PUBLIC ${PROJECT_SOURCE_DIR}/windows
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/windows>
)
endif()