Reputation: 5661
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.
Upvotes: 1
Views: 599
Reputation: 56468
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
Upvotes: 3