Create & install a cmake package file (part 3)

The cargo target directory tree is now populated with a cmake package
file and that's also installed into the prefix specified with the cargo
cmake xtask.

As a consequence, the cpptest example can be built by first building the
cmake package:

    cargo xtask cmake

    or

    cargo xtask cmake --release --target some-triplet)

    or

    cargo xtask cmake --release --prefix /somewhere --install

and then run cmake in the cpptest example with a prefix path:

    -DCMAKE_PREFIX_PATH=/where/you/installed/it or simply
    -DCMAKE_PREFIX_PATH=../../target/debug for example.

Pending still is the sixtyfps compiler tool installation and discovery.
This commit is contained in:
Simon Hausmann 2020-06-04 15:27:27 +02:00
parent a2c5e66bee
commit 2e0a5ddb25
3 changed files with 67 additions and 39 deletions

View file

@ -0,0 +1,26 @@
@PACKAGE_INIT@
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()
foreach(internal_lib IN ITEMS @internal_libs@)
add_library(${internal_lib} STATIC IMPORTED)
set(fn "${internal_lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
# Don't look in lib when we're inside a cargo tree, as cargo doesn't use a lib/ sub-dir.
if(EXISTS "${_IMPORT_PREFIX}/${fn}")
else()
set(fn "lib/${fn}")
endif()
set_property(TARGET ${internal_lib} PROPERTY IMPORTED_LOCATION "${_IMPORT_PREFIX}/${fn}")
set(fn)
endforeach()
set(_IMPORT_PREFIX)
include("${CMAKE_CURRENT_LIST_DIR}/SixtyFPSTargets.cmake")