Trouble building Assimp in Visual Studio from CMake subdirectory

  assimp, c++, cmake, visual-studio

I have Assimp as a git submodule in my project and I’m trying to write a CMakeLists.txt that lets me build Assimp and link it with my application. Assimp builds successfully when I do an out-of-source build in the repo with the Visual Studio 16 2019 generator on Windows 10.

mkdir build
cd build
cmake -G "Visual Studio 16 2019" ..
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The C compiler identification is MSVC 19.28.29336.0
-- The CXX compiler identification is MSVC 19.28.29336.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Shared libraries enabled
-- Looking for ZLIB...
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
-- Could not locate ZLIB
-- compiling zlib from sources
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Found PythonInterp: C:/Users/bassp/AppData/Local/Programs/Python/Python39/python.exe (found version "3.9.1")
--- Running combined CXX flags test, flags: /W0;/W0
--- Passed combined CXX flags test
-- Enabled importer formats: AMF 3DS AC ASE ASSBIN B3D BVH COLLADA DXF CSM HMP IRRMESH IRR LWO LWS M3D MD2 MD3 MD5 MDC MDL NFF NDO OFF OBJ OGRE OPENGEX PLY MS3D COB BLEND IFC XGL FBX Q3D Q3BSP RAW SIB SMD STL TERRAGEN 3D X X3D GLTF 3MF MMD
-- Disabled importer formats:
-- Enabled exporter formats: OBJ OPENGEX PLY 3DS ASSBIN ASSXML M3D COLLADA FBX STL X X3D GLTF 3MF PBRT ASSJSON STEP
-- Disabled exporter formats:
-- Configuring done
-- Generating done
-- Build files have been written to: D:/projects/temp/new-meng/vendor/assimp/build

When I add the assimp repo as a subdirectory in CMakeLists.txt, CMake generates the VS project, but the build fails with the following errors. I simplified the CMakeLists.txt file here down to the minimum that reproduces the problem.

cmake_minimum_required(VERSION 3.15)
project(Project)

add_subdirectory(vendor/assimp)
mkdir build
cd build
cmake -G "Visual Studio 16 2019" ..
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The C compiler identification is MSVC 19.28.29336.0
-- The CXX compiler identification is MSVC 19.28.29336.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Shared libraries enabled
-- Looking for ZLIB...
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
-- Could not locate ZLIB
-- compiling zlib from sources
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Found PythonInterp: C:/Users/bassp/AppData/Local/Programs/Python/Python39/python.exe (found version "3.9.1")
--- Running combined CXX flags test, flags: /W0;/W0
--- Passed combined CXX flags test
-- Enabled importer formats: AMF 3DS AC ASE ASSBIN B3D BVH COLLADA DXF CSM HMP IRRMESH IRR LWO LWS M3D MD2 MD3 MD5 MDC MDL NFF NDO OFF OBJ OGRE OPENGEX PLY MS3D COB BLEND IFC XGL FBX Q3D Q3BSP RAW SIB SMD STL TERRAGEN 3D X X3D GLTF 3MF MMD
-- Disabled importer formats:
-- Enabled exporter formats: OBJ OPENGEX PLY 3DS ASSBIN ASSXML M3D COLLADA FBX STL X X3D GLTF 3MF PBRT ASSJSON STEP
-- Disabled exporter formats:
-- Configuring done
-- Generating done
-- Build files have been written to: D:/projects/temp/new-meng/build
Error   C1083   Cannot open include file: 'draco/draco_features.h': No such file or directory (compiling source file D:projectstempnew-mengvendorassimpcodeAssetLibglTF2glTF2Importer.cpp) assimp  D:projectstempnew-mengvendorassimpcontribdracosrcdracocoremacros.h   19
Error   C1083   Cannot open include file: 'draco/draco_features.h': No such file or directory (compiling source file D:projectstempnew-mengvendorassimpcodeAssetLibglTF2glTF2Exporter.cpp) assimp  D:projectstempnew-mengvendorassimpcontribdracosrcdracocoremacros.h   19
Error   LNK1104 cannot open file '....libDebugassimp-vc142-mtd.lib' assimp_cmd  D:projectstempnew-mengbuildvendorassimptoolsassimp_cmdLINK 1
Error   LNK1104 cannot open file '..libDebugassimp-vc142-mtd.lib'    unit    D:projectstempnew-mengbuildvendorassimptestLINK 1   

My initial guess is that some kind of relative directory path issue because my CMake source tree is rooted in my project instead of the assimp repo, but I’m new to CMake and feeling really stumped about where to even start.

Any ideas on what’s wrong or where to start looking? Thanks!

Source: Windows Questions C++

LEAVE A COMMENT