Hi, Nice post.
I use a different way to achieve this goal.
My tips is to write a single CMakeList.txt for my dependency. That CMakelist.txt only calls cmake / cmake --build on itself with a -DINSTALLPREFIX used later by findlibrary and a -DINSTALLING=TRUE, when INSTALLING is TRUE, it defines a single project with an ExternalProject_Add and a specified install prefix.
That CMakeList looks something like this :
```
if(NOT INSTALLING)
set(WORKING DIRECTORY "${CMAKECURRENTBINARYDIR}/Install")
file(MAKEDIRECTORY "${DIRECTORY}"")
executeprocess(
COMMAND "${CMAKECOMMAND}" -DINSTALLING=TRUE -DINSTALLPREFIX=${MYINSTALLPREFIX} "${CMAKECURRENTSOURCEDIR}"
WORKING_DIRECTORY "${DIRECTORY}"
)
Hi, Nice post.
I use a different way to achieve this goal.
My tips is to write a single CMakeList.txt for my dependency. That CMakelist.txt only calls cmake / cmake --build on itself with a -DINSTALLPREFIX used later by findlibrary and a -DINSTALLING=TRUE, when INSTALLING is TRUE, it defines a single project with an ExternalProject_Add and a specified install prefix.
That CMakeList looks something like this :
```
if(NOT INSTALLING)
set(WORKING DIRECTORY "${CMAKECURRENTBINARYDIR}/Install")
file(MAKEDIRECTORY "${DIRECTORY}"")
executeprocess(
COMMAND "${CMAKECOMMAND}" -DINSTALLING=TRUE -DINSTALLPREFIX=${MYINSTALLPREFIX} "${CMAKECURRENTSOURCEDIR}"
WORKING_DIRECTORY "${DIRECTORY}"
)
executeprocess(
COMMAND "${CMAKECOMMAND}" --build . --config Release
WORKING_DIRECTORY "${DIRECTORY}"
)
else()
project("<external_project>")
include(ExternalProject)
ExternalProjectAdd(
externalproject
GITREPOSITORY "<gitrepourl>"
INSTALLDIR "${INSTALLPREFIX}"
CMAKEARGS -DCMAKEINSTALLPREFIX:PATH=<INSTALL_DIR>
)
endif()
```