CLion add static libary into a C++ project in CLion under Windows
Hello, i am trying to install a static library into a C++ Project under CLion. The Problem i face is that i get this error here: CMake Error at CMakeLists.txt:13 (target_link_libraries):
Cannot specify link libraries for target
"databaseC:/Users/aurel/database/libdatabase.a"
which is not built by this project. The Thing is that my directory is completly correct cause i can access the header file correctly. I also tried to access different static libraries but not any of them worked. This here is my file called FindTinyXML2.cmake:
set(FIND_LIB_PATHS
C:/Users/aurel/database)
find_path(LIB_INCLUDE_DIR SQL API.h
PATH_SUFFIXES include
PATHS ${FIND_LIB_PATHS})
#error
find_library(FIND_LIBRARY
NAMES libdatabase.a
PATHS ${FIND_LIB_PATHS})
And this here is my file CMakeLists.txt: cmake_minimum_required(VERSION 3.28)
project(database)
set(CMAKE_CXX_STANDARD 17)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
add_executable(database main.cpp)
include(FindPkgConfig)
find_package(Tinyxml2 REQUIRED)
include_directories(${LIB_INCLUDE_DIR})
#error
target_link_libraries(${PROJECT_NAME}${FIND_LIB})
I tried everything. Thank you for trying to help me!
Please sign in to leave a comment.
Hello!
To begin with, please add a space between
${PROJECT_NAME}
and${FIND_LIB}
so that the line becomestarget_link_libraries(${PROJECT_NAME} ${FIND_LIB})
and doTools | CMake | Reset Cache and Reload Project
.