My source tree looks like this:
To build a project MoonLandingin src/Moonlanding/, I do the following
cmake . -DGFLAGS_INCLUDE_DIR=${CBVR_DEPENDENCIES}/gflags/build/include \
-DGFLAGS_LIBRARY=${CBVR_DEPENDENCIES}/gflags/build/lib/libgflags.a \
-DAtlas_CBLAS_INCLUDE_DIR=${CBVR_DEPENDENCIES}/ATLAS-install/include \
-DAtlas_CBLAS_LIBRARY=${CBVR_DEPENDENCIES}/ATLAS-install/lib/libcblas.a \
-DAtlas_CLAPACK_INCLUDE_DIR=${CBVR_DEPENDENCIES}/ATLAS-install/include \
-DAtlas_LAPACK_LIBRARY=${CBVR_DEPENDENCIES}/ATLAS-install/lib/liblapack.a \
-DAtlas_BLAS_LIBRARY=${CBVR_DEPENDENCIES}/ATLAS-install/lib/libatlas.a \
-DLMDB_INCLUDE_DIR=${CBVR_DEPENDENCIES}/mdb/libraries/liblmdb \
-DLMDB_LIBRARIES=${CBVR_DEPENDENCIES}/mdb/libraries/liblmdb/liblmdb.so \
-DBOOST_ROOT=${CBVR_DEPENDENCIES}/boost_1_56_0/
The above cmake call works fine and MoonLandingcompiles.
However, I want to call cmake .under src/. For this, I defined src/CMakeLists.txtas follows:
set(GFLAGS_INCLUDE_DIR $ENV{CBVR_DEPENDENCIES}/gflags/build/include)
set(GFLAGS_LIBRARY $ENV{CBVR_DEPENDENCIES}/gflags/build/lib/libgflags.a)
set(Atlas_CBLAS_INCLUDE_DIR $ENV{CBVR_DEPENDENCIES}/ATLAS-install/include)
set(Atlas_CBLAS_LIBRARY $ENV{CBVR_DEPENDENCIES}/ATLAS-install/lib/libcblas.a)
set(Atlas_CLAPACK_INCLUDE_DIR $ENV{CBVR_DEPENDENCIES}/ATLAS-install/include)
set(Atlas_LAPACK_LIBRARY $ENV{CBVR_DEPENDENCIES}/ATLAS-install/lib/liblapack.a)
set(Atlas_BLAS_LIBRARY $ENV{CBVR_DEPENDENCIES}/ATLAS-install/lib/libatlas.a)
set(LMDB_INCLUDE_DIR $ENV{CBVR_DEPENDENCIES}/mdb/libraries/liblmdb)
set(LMDB_LIBRARIES $ENV{CBVR_DEPENDENCIES}/mdb/libraries/liblmdb/liblmdb.so)
set(BOOST_ROOT $ENV{CBVR_DEPENDENCIES}/boost_1_56_0/)
add_subdirectory(Moonlanding)
Then CMake gives me an error:
CMake Error at /usr/local/share/cmake-3.0/Modules/FindPackageHandleStandardArgs.cmake:136 (message):
Could NOT find LMDB (missing: LMDB_INCLUDE_DIR LMDB_LIBRARIES)
If I call again cmake, the error will disappear. In general, I need to call cmake .three times src/Moonlandingto compile from src/. Why is this and is there a cleaner way to achieve the project?
(The reason I want to separate GFLAGS_INCLUDE_DIR and other directives is to help automate the build process for the user.)