How do I tell CMake to link in a static library in the source directory?

前端 未结 3 401
囚心锁ツ
囚心锁ツ 2020-11-27 11:51

I have a small project with a Makefile which I\'m trying to convert to CMake, mostly just to get experience with CMake. For purposes of this example, the project contains a

3条回答
  •  [愿得一人]
    2020-11-27 12:34

    CMake favours passing the full path to link libraries, so assuming libbingitup.a is in ${CMAKE_SOURCE_DIR}, doing the following should succeed:

    add_executable(main main.cpp)
    target_link_libraries(main ${CMAKE_SOURCE_DIR}/libbingitup.a)
    

提交回复
热议问题