Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Commit

Permalink
Export json11Config.cmake on install
Browse files Browse the repository at this point in the history
So you can easily use installed builds from other CMake projects by
setting json11_DIR.
  • Loading branch information
fegorsch committed May 8, 2018
1 parent f90d36d commit 1b25055
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif()

add_library(json11 json11.cpp)
target_include_directories(json11 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(json11 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:.>
)
target_compile_options(json11
PRIVATE -fPIC -fno-rtti -fno-exceptions -Wall)

Expand Down Expand Up @@ -56,6 +59,11 @@ if (JSON11_BUILD_TESTS)
target_link_libraries(json11_test json11)
endif()

install(TARGETS json11 DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE})
install(TARGETS json11 EXPORT json11Config DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/json11.hpp" DESTINATION include/${CMAKE_LIBRARY_ARCHITECTURE})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/json11.pc" DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig)
install(EXPORT json11Config NAMESPACE json11:: DESTINATION cmake)

0 comments on commit 1b25055

Please sign in to comment.