I am new using cmake and qt. I was working on migrating a project I developed on visual studio and decided to use cmake. I had used .lib libraries in that project but I am having trouble adding the libraries in qt. My CMakeLists.txt file runs but when I build the project from qt it give me "undefined reference to ..."
Here is my CMakeLists.txt file
cmake_minimum_required(VERSION 3.14)
project(LibTest LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(LIB_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/)
set(LIB_TEST ${CMAKE_CURRENT_SOURCE_DIR}/lib/test.lib)
#find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
#find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
add_executable(LibTest main.cpp lib/test.lib)
target_include_directories(LibTest PUBLIC ${LIB_TEST_DIR})
add_library(test.lib STATIC IMPORTED ${LIB_TEST})
set_property(TARGET test.lib PROPERTY IMPORT_LOCATION ${LIB_TEST_DIR})
#target_link_libraries(LibTest Qt${QT_VERSION_MAJOR}::Core)
target_link_libraries(LibTest INTERFACE test.lib)
install(TARGETS LibTest
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
main.cpp
#include "libtest.hpp"
int main(int argc, char *argv[])
{
libtest test;
//QCoreApplication a(argc, argv);
return 0;
}
Error When I build the project:
:-1: error: /LibTest/main.cpp:9: undefined reference to `libtest::libtest()'