diff options
author | Mike Krus <mike.krus@kdab.com> | 2020-05-08 14:06:53 +0100 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2020-05-22 08:53:50 +0100 |
commit | 22dd30949938083aceda8267c41c920c61c0d388 (patch) | |
tree | a49704414a853624006b860d1a92689bc4f5ca88 /cmake | |
parent | 5596989f92fd36615e203215ef274bff80bb7e31 (diff) |
Add support for building with CMake
Change-Id: If6c887c6356a160a5f3fb906d38a341fff0c7b29
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindWrapAssimp.cmake | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/cmake/FindWrapAssimp.cmake b/cmake/FindWrapAssimp.cmake new file mode 100644 index 000000000..594a81b65 --- /dev/null +++ b/cmake/FindWrapAssimp.cmake @@ -0,0 +1,35 @@ +if(TARGET WrapAssimp::WrapAssimp) + set(WrapAssimp_FOUND TRUE) + return() +endif() + +set(WrapAssimp_FOUND FALSE) + +find_package(assimp ${WrapAssimp_FIND_VERSION} CONFIG QUIET) +if (assimp_FOUND AND TARGET assimp::assimp) + add_library(WrapAssimp::WrapAssimp INTERFACE IMPORTED) + target_link_libraries(WrapAssimp::WrapAssimp INTERFACE assimp::assimp) + + # The Assimp configuration file is broken, and sets only the Release location, without advertising + # that it's available via IMPORTED_CONFIGURATIONS. Thus when configuring with a different + # configuration, you get a assimp::assimp-NOTFOUND at build time. + # Make the release configuration be the default one. + get_target_property(_assimp_library_location assimp::assimp IMPORTED_LOCATION) + if(NOT _assimp_library_location) + get_target_property(_assimp_library_location_release assimp::assimp IMPORTED_LOCATION_RELEASE) + if(_assimp_library_location_release) + set_target_properties(assimp::assimp PROPERTIES + IMPORTED_LOCATION "${_assimp_library_location_release}") + endif() + endif() + + set(WrapAssimp_FOUND TRUE) +elseif(assimp_FOUND AND assimp_LIBRARIES AND assimp_INCLUDE_DIRS) + add_library(WrapAssimp::WrapAssimp INTERFACE IMPORTED) + target_link_libraries(WrapAssimp::WrapAssimp INTERFACE ${assimp_LIBRARIES}) + target_include_directories(WrapAssimp::WrapAssimp INTERFACE ${assimp_INCLUDE_DIRS}) + set(WrapAssimp_FOUND TRUE) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(WrapAssimp DEFAULT_MSG WrapAssimp_FOUND) |