Skip to content

Commit 2851ea4

Browse files
myd7349lemire
authored andcommitted
Export CMake targets (simdjson#96)
1 parent 6541682 commit 2851ea4

3 files changed

Lines changed: 23 additions & 8 deletions

File tree

benchmark/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
target_include_directories(${SIMDJSON_LIB_NAME}
2-
PUBLIC
3-
${PROJECT_SOURCE_DIR}/benchmark
4-
${PROJECT_SOURCE_DIR}/benchmark/linux
2+
INTERFACE
3+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/benchmark>
4+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/benchmark/linux>
55
)
66

77
add_cpp_benchmark(parse)

src/CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ if(${CMAKE_C_COMPILER_ID} MATCHES "Intel") # icc / icpc
33
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel")
44
endif()
55

6+
include(GNUInstallDirs)
67

78
# we default on a shared library.
89
if(SIMDJSON_BUILD_STATIC)
@@ -26,11 +27,25 @@ set(SIMDJSON_SRC
2627
)
2728

2829
add_library(${SIMDJSON_LIB_NAME} ${SIMDJSON_LIB_TYPE} ${SIMDJSON_SRC})
30+
2931
target_include_directories(${SIMDJSON_LIB_NAME}
30-
PUBLIC ${PROJECT_SOURCE_DIR}/include
32+
PUBLIC
33+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
34+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
35+
)
36+
37+
install(TARGETS ${SIMDJSON_LIB_NAME}
38+
EXPORT ${SIMDJSON_LIB_NAME}-config
39+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
40+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
41+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
3142
)
3243

33-
install(TARGETS ${SIMDJSON_LIB_NAME} DESTINATION lib)
44+
install(EXPORT ${SIMDJSON_LIB_NAME}-config
45+
FILE ${SIMDJSON_LIB_NAME}-config.cmake
46+
NAMESPACE ${SIMDJSON_LIB_NAME}::
47+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${SIMDJSON_LIB_NAME}
48+
)
3449

3550
if(NOT MSVC)
3651
## We output the library at the root of the current directory where cmake is invoked

tests/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
if(MSVC)
2-
target_include_directories(${SIMDJSON_LIB_NAME}
3-
PUBLIC ${PROJECT_SOURCE_DIR}/windows
4-
)
2+
target_include_directories(${SIMDJSON_LIB_NAME}
3+
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/windows>
4+
)
55
endif()
66

77
add_cpp_test(jsoncheck)

0 commit comments

Comments
 (0)