diff --git a/CMakeLists.txt b/CMakeLists.txt index 06730c27c..86f4c01f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -316,6 +316,22 @@ include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/include ) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/CppInterOpConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/CppInterOpConfig.cmake + @ONLY) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/CppInterOpConfigVersion.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/CppInterOpConfigVersion.cmake + @ONLY) +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/ + DESTINATION lib/cmake + FILES_MATCHING + PATTERN "*.cmake" + ) + + install(DIRECTORY include/ DESTINATION include FILES_MATCHING diff --git a/cmake/CppInterOpConfig.cmake.in b/cmake/CppInterOpConfig.cmake.in new file mode 100644 index 000000000..29e3fb209 --- /dev/null +++ b/cmake/CppInterOpConfig.cmake.in @@ -0,0 +1,34 @@ +# This file allows users to call find_package(CppInterOp) and pick up our targets. + +# Compute the installation prefix from this CppInterOpConfig.cmake file location. +get_filename_component(CPPINTEROP_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(CPPINTEROP_INSTALL_PREFIX "${CPPINTEROP_INSTALL_PREFIX}" PATH) +get_filename_component(CPPINTEROP_INSTALL_PREFIX "${CPPINTEROP_INSTALL_PREFIX}" PATH) + +### build/install workaround + +if (IS_DIRECTORY "${CPPINTEROP_INSTALL_PREFIX}/include") + set(_include "${CPPINTEROP_INSTALL_PREFIX}/include") +else() + set(_include "@CMAKE_CURRENT_SOURCE_DIR@/include") +endif() + +if (IS_DIRECTORY "${CPPINTEROP_INSTALL_PREFIX}/cmake") + set(_cmake "${CPPINTEROP_INSTALL_PREFIX}/cmake") +else() + set(_cmake "@CMAKE_CURRENT_SOURCE_DIR@/cmake") +endif() + +### + +set(CPPINTEROP_EXPORTED_TARGETS "clangCppInterOp") +set(CPPINTEROP_CMAKE_DIR "${_cmake}") +set(CPPINTEROP_INCLUDE_DIRS "${_include}") + +# Provide all our library targets to users. +add_library(clangCppInterOp SHARED IMPORTED) +set_property(TARGET clangCppInterOp PROPERTY IMPORTED_LOCATION "${CPPINTEROP_DIR}/lib/libclangCppInterOp.so") +set_property(TARGET clangCppInterOp PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_include}") + +unset(_include) +unset(_cmake) diff --git a/cmake/CppInterOpConfigVersion.cmake.in b/cmake/CppInterOpConfigVersion.cmake.in new file mode 100644 index 000000000..5ba54a377 --- /dev/null +++ b/cmake/CppInterOpConfigVersion.cmake.in @@ -0,0 +1,11 @@ +set(PACKAGE_VERSION "1.1~dev") + +# LLVM is API-compatible only with matching major.minor versions +# and patch versions not less than that requested. +if("1.1" VERSION_EQUAL "${PACKAGE_FIND_VERSION_MAJOR}.${PACKAGE_FIND_VERSION_MINOR}" + AND NOT "0" VERSION_LESS "${PACKAGE_FIND_VERSION_PATCH}") + set(PACKAGE_VERSION_COMPATIBLE 1) + if("0" VERSION_EQUAL "${PACKAGE_FIND_VERSION_PATCH}") + set(PACKAGE_VERSION_EXACT 1) + endif() +endif()