开发者

How to find a package once the corresponding external project is compiled?

Is there a way to find a package only once an external project is compiled, since the package to find is created once this external project compiled ?

For now, I have:

include(ExternalProject)
externalproject_add(
  libantlr3c
  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3
  CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3/configure -prefix=${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3
  PREFIX ${CMAKE_开发者_如何转开发CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3
  BUILD_COMMAND make
  BUILD_IN_SOURCE 1
)

find_library(
  antlr3c
  libantlr3c.a
  HINTS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3
)

That fails, of course.

Thank you.


Since you control where the libraries are created, there's no need to use find_library. You can use link_directories directly. You'll probably want the same for the include directories to add the include paths to the compile line. Something like this ought to do it:

include(ExternalProject)
set(antlr3c_LIBRARIES
    ${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3)
set(antlr3c_INCLUDE_DIRS
    ${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3/include)
externalproject_add(
  libantlr3c
  ....
)
link_directories(${antlr3c_LIBRARIES})
include_directories(${antlr3c_INCLUDE_DIRS})
add_executable(my_exe ${SOURCES})
target_link_libraries(my_exe antlr) # or antlr3c or whatever -lantlr is needed
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜