c++ - CMake: Using the headers installed by an External Project -
i have read documentation on using external projects kitware here , attempting follow process use image-processing library leptonica external dependency. cross-compiling using different toolchains, not want install leptonica globally, rather have libraries , headers installed within build directory can deleted , reinstalled compilation toolchains change.
in other words, make cmakeprojecta dependent on installed headers , libraries of externalprojectb. here have cmakelists.txt
file.
cmake_minimum_required(version 3.2) project(cmakeprojecta) set(source_files main.cpp) set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11") include(externalproject) externalproject_add( leptonica-1.72 prefix leptonica url http://www.leptonica.com/source/leptonica-1.72.tar.gz url_md5 7581db29f8442197ce68e766c6047c4b configure_command <source_dir>/configure --prefix=<install_dir> ) externalproject_get_property( leptonica-1.72 install_dir ) set(leptonica_include_dir ${install_dir} cache string "location of leptonica header files") include_directories(${leptonica_include_dir}) add_executable(my_executable ${source_files}) add_dependencies(my_executable leptonica-1.72) target_link_libraries(my_executable leptonica-1.72)
when @ cached value of leptonica_include_dir
, value
/users/me/library/caches/clion10/cmake/generated/509e0c9e/509e0c9e/__default__/install`.
yet cmakeprojecta being built to:
/users/me/library/caches/clion10/cmake/generated/509e0c9e/509e0c9e/debug
as result, believe default in former's path not allow header files of leptonica found main project. how make project aware of different build variants (debug , release) of project, cmakeprojecta can use headers , libraries provided leptonica?
i did further research , decided follow example of openchemistry cmake-based project, since had similar requirements in including multiple external projects.
Comments
Post a Comment