Subdirectory can't find library made by another subdir

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Subdirectory can't find library made by another subdir

Manh Nguyen Tien
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.


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Subdirectory can't find library made by another subdir

Manh Nguyen Tien
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.
>
>
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake