Hi
I'm learning how to use hierarchical directories in CMake and am trying to get an example to work that I saw on YouTube. The example isn't doing what I expect so I would be grateful for some help in understanding why. I am running CMake 3.10.2 on Ubuntu 18.04 (Microsoft WSL) and using make. I have a project called 'cmake-good' that should build library 'libsay-hello.a' and executable 'cmake-good'. Here's the directory tree (excluding CMake artifacts which I don't think I need to show): ├── CMakeLists.txt ├── build │ ├── CMakeCache.txt │ ├── CMakeFiles │ ├── Makefile │ ├── cmake_install.cmake │ ├── hello-exe │ │ ├── Makefile │ │ ├── cmake-good │ └── say-hello │ ├── Makefile │ └── libsay-hello.a ├── hello-exe │ ├── CMakeLists.txt │ └── main.cpp ├── say-hello ├── CMakeLists.txt └── src └── say-hello ├── hello.cpp └── hello.hpp Here are the CMakeLists.txt files: 1) Top level CMakeLists.txt: cmake_minimum_required(VERSION 3.10) project(MyProject VERSION 1.0.0) add_subdirectory(say-hello) add_subdirectory(hello-exe) 2) hello_exe/CMakeLists.txt: add_executable(cmake-good main.cpp ) target_link_libraries(cmake-good PRIVATE say-hello) 3) say-hello/CMakeLists.txt: add_library( say-hello src/say-hello/hello.hpp src/say-hello/hello.cpp ) target_include_directories(say-hello PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src") My problem is that I expect to see: hello-exe/cmake-good say-hello/libsay-hello.a but I see: build\hello-exe\cmake-good build\say-hello\libsay-hello.a Why is that?
-- 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