[CMake] Subdirectory can't find library made by another subdir

Manh Nguyen Tien manhnt.9 at outlook.com
Wed Nov 28 03:54:38 EST 2018


I solved it: https://gitlab.kitware.com/cmake/cmake/issues/18648

On 11/28/18 11:46 AM, Manh Nguyen Tien wrote:
> Hi everyone, I'm having a bug on CMake 3.12 (version and syntax).
>
> Here is my structure.
>
>
> RootFolder
>
>     CMakeLists.txt (C1)
>
>     library/
>
>         CMakeLists.txt (C2)
>
>     samples/
>
>         CMakeLists.txt (C3)
>
>
> In my C1, I add subdir library and samples. C2 builds a library target
> (LIB).
>
> My problem is that C3 can't find my LIB or my LIB's configuration is not
> visible.
>
> This code in C3 doesn't produce any warnings:
>
> target_link_libraries(sample1
>   PRIVATE LIB
> )
>
>
> When building sample1, my compiler couldn't find LIB's headers.
>
> I declared those headers for my LIB using target_sources command (PUBLIC
> and INTERFACE).
>
> Here is how I create the LIB:
>
> - Add LIB_OBJ library (object library)
>
> - target_sources for header and source files
>
> - target_include_directories
>
> - target_link_libraries for LIB's dependencies
>
> - add a static library LIB_STATIC
>
> - link LIB_STATIC with LIB_OBJ
>
> - create an alias LIB of LIB_STATIC
>
>
> My full source code is at:
> https://gitlab.com/InnerPieceOSS/Saga3D/tree/android
>
> To reproduce:
>
> - Clone project
>
> - Checkout branch android
>
> - mkdir build && cd build
>
> - cmake .. -DBUILD_SAMPLES=ON
>
> - make -j4
>
>
> Could you help me to identify the problem?
> Thank you!
>
> Manh Nguyen Tien.
>
>


More information about the CMake mailing list