user1618465
user1618465

Reputation: 1941

cmake find_library without "lib" prefix name

I have a library called mylib.a in the path /home/test/libs/.

How can I add it to the project??

find_library(IDA_LIB
                 NAMES "mylib.a"
                 PATHS "/home/test/libs"
                 NO_DEFAULT_PATH)

Since it does not have the prefix lib cmake does not find it. If I change the library name to libmylib.a if finds it fine.

Upvotes: 6

Views: 4145

Answers (2)

Ted
Ted

Reputation: 1611

Try this:

add_library(mylib STATIC IMPORTED)
set_target_properties(mylib PROPERTIES IMPORTED_LOCATION /home/test/mylib.a)

then you can use "mylib" in:

target_link_libraries(myapp
        mylib )

Upvotes: 0

NP Rooski  Z
NP Rooski Z

Reputation: 3657

Use following command with absolute file path of your library

target_link_libraries(IDA_LIB /home/test/libs/mylib.a)

Upvotes: 2

Related Questions