0

I've gone through countless stackoverflow threads and the CMake wiki but I have no idea what I'm doing wrong. I'm trying to find a dll, specifically the assimp.dll that I generated, but the find_library macro is unable to find the dll no matter what I do. My CMakeLists.txt is

cmake_minimum_required(VERSION 3.17)
project(OpenGLBook)

set(CMAKE_CXX_STANDARD 20)
set(DLL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dll")
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")

list(APPEND CMAKE_FIND_ROOT_PATH "${DLL_DIR}/assimp") #these have been disabled and reenabled in all configurations possible I believe.
list(APPEND CMAKE_PREFIX_PATH "${DLL_DIR}/assimp")

set(SOURCE ${SRC_DIR}/main.cpp)

include_directories(${LIB_DIR}/learnopengl)
include_directories(${LIB_DIR}/stb_image)

add_executable(${PROJECT_NAME}
        ${INCLUDES}
        ${SOURCE})

target_include_directories(${PROJECT_NAME} PUBLIC "${SRC_DIR}")


# ASSIMP
set(ASSIMP_DIR "${LIB_DIR}/assimp")
set(ASSIMP_LIB_DIR "${DLL_DIR}/assimp")
message("-- Linking Assimp")
find_library(ASSIMP_LIB NAMES "assimp" HINTS "${ASSIMP_LIB_DIR}" REQUIRED)
target_link_libraries(${PROJECT_NAME} "assimp" ${ASSIMP_LIB})
include_directories(${ASSIMP_DIR})

#add_subdirectory("${DLL_DIR}/assimp")
#add_subdirectory("include/assimp")
#foreach(file "${ASSIMP_DIR}assimp")
#    message("${file}")
#endforeach()
#message(${ASSIMP_DIR})
#add_library(ASSIMP_LIB SHARED IMPORTED)
#set_target_properties(ASSIMP_LIB PROPERTIES IMPORTED_LOCATION "${DLL_DIR}/assimp/assimp.dll")
#target_link_libraries(${PROJECT_NAME} "assimp" ASSIMP_LIB)
#link_directories(${DLL_DIR}/assimp)
#set_property(TARGET ASSIMP_LIB PROPERTY IMPORTED_LOCATION "dll/assimp/assimp-vc142-mt.dll")
#target_link_libraries(${PROJECT_NAME} "assimp" ASSIMP_LIB)
#add_library(ASSIMP_LIB STATIC IMPORTED)
#set_property(TARGET ASSIMP_LIB PROPERTY IMPORTED_LOCATION "dll/assimp/assimp-vc142-mt.dll")
#target_link_libraries(${PROJECT_NAME} "assimp" ASSIMP_LIB)

Everything that is tagged out are the countless things I've tried, I had the lib with the name "assimp-vc142-mt.dll" before changing it to "assimp.dll" because I was out of ideas. All ideas are from the thread CMake link to external library. I get the error

-- Using Win32 for window creation
-- Linking Assimp
CMake Error at CMakeLists.txt:63 (find_library):
  Could not find ASSIMP_LIB using the following names: assimp


-- Configuring incomplete, errors occurred!
See also "C:/dev/OpenGLBookFixed/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "C:/dev/OpenGLBookFixed/cmake-build-debug/CMakeFiles/CMakeError.log".

[Failed to reload]

so reading that error I changed the "assimp" name to "-lassimp", renamed the lib to "libassimp" added and removed the "" countless times and tried many other things that I've forgotten but I still get the above error, or something similar. Printing the variable ${ASSIMP_LIB_DIR} returns the message

C:/coding/OpenGLBookFixed/dll/assimp

and plugging that directory into the file explorer puts me into where the lib is located so I know that I'm looking in the right place.

I've been trying to get this to work for a couple hours and I'm out of ideas so if someone could please tell me my, most likely, simple issue that would be appreciated.

  • Do you have the file `C:/coding/OpenGLBookFixed/dll/assimp/assimp.lib` or `C:/coding/OpenGLBookFixed/dll/assimp/libassimp.lib`? Exactly this file is searched by your `find_library` call. Note, that you need to have `.lib` file for link with the library, `.dll` cannot be used for that purposes. – Tsyvarev Jul 31 '21 at 18:31

0 Answers0