]> git.lizzy.rs Git - irrlicht.git/commitdiff
Export targets to build tree (#49)
authorJosiahWI <41302989+JosiahWI@users.noreply.github.com>
Sat, 31 Jul 2021 11:04:06 +0000 (06:04 -0500)
committerGitHub <noreply@github.com>
Sat, 31 Jul 2021 11:04:06 +0000 (13:04 +0200)
It is insecure and inconvenient to necessitate installing IrrlichtMt to access the target export. A copy of the export is now placed in the build tree during configuration so that it can be directly accessed from any project by pointing find_package() to look at the IrrlichtMt source directory.

.gitignore
CMakeLists.txt
README.md

index 044c55db92bd10bcf5ffb1b099e0cf599359f15a..d3bb6408263ee91a5e07677c43d524cd64d1e041 100644 (file)
@@ -1,8 +1,10 @@
 CMakeFiles
 CMakeCache.txt
 cmake_install.cmake
+install_manifest.txt
 IrrlichtMtConfig.cmake
 IrrlichtMtConfigVersion.cmake
+IrrlichtMtTargets.cmake
 Makefile
 libs/*
 *.so*
index 89f962be40d75bb9af7488cec5951d456c2b7c85..6552ef70cc64cd508da54dc5c9165fe79dcc0b68 100644 (file)
@@ -36,6 +36,14 @@ if(BUILD_EXAMPLES)
        add_subdirectory(examples)
 endif()
 
+# Export a file that describes the targets that IrrlichtMt creates.
+# The file is placed in the location FILE points to, where CMake can easily
+# locate it by pointing CMAKE_PREFIX_PATH to this project root.
+export(EXPORT IrrlichtMt-export
+       FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtTargets.cmake"
+       NAMESPACE IrrlichtMt::
+)
+
 # Installation of headers.
 install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/"
        DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/irrlichtmt"
@@ -50,18 +58,18 @@ install(EXPORT IrrlichtMt-export
 
 include(CMakePackageConfigHelpers)
 configure_package_config_file("${PROJECT_SOURCE_DIR}/Config.cmake.in"
-       "${CMAKE_CURRENT_BINARY_DIR}/IrrlichtMtConfig.cmake"
+       "${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtConfig.cmake"
        INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IrrlichtMt"
        NO_SET_AND_CHECK_MACRO
        NO_CHECK_REQUIRED_COMPONENTS_MACRO
 )
 write_basic_package_version_file(
-       "${CMAKE_CURRENT_BINARY_DIR}/IrrlichtMtConfigVersion.cmake"
+       "${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtConfigVersion.cmake"
        COMPATIBILITY AnyNewerVersion
 )
 
 install(FILES
-       "${CMAKE_CURRENT_BINARY_DIR}/IrrlichtMtConfig.cmake"
-       "${CMAKE_CURRENT_BINARY_DIR}/IrrlichtMtConfigVersion.cmake"
+       "${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtConfig.cmake"
+       "${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtConfigVersion.cmake"
        DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IrrlichtMt"
 )
index 243cdea97ef0e72fe234677c077c87f954ece62f..ecd1d1059365313aa914bff61b514fe9681255ed 100644 (file)
--- a/README.md
+++ b/README.md
@@ -27,6 +27,8 @@ e.g. on a Linux system you might want to build for local use like this:
        cmake . -DBUILD_SHARED_LIBS=OFF
        make -j$(nproc)
 
+This will put an IrrlichtMtTargets.cmake file into a cmake/ directory in the current build directory, and it can then be imported from another project by pointing find_package() to the source directory of this project, or by setting the CMAKE_PREFIX_PATH variable to that same path.
+
 Platforms
 ---------