Hello, If there is some libfoo that I want to use in my project, and this libfoo has it's own CMakeLists.txt I have 3 options to deal with such external dependency:
a) Treat it like every other external dependency and write cmake code like FindLibFoo.cmake to find libfoo on file system. b)Include this project as git submodule and use ExternalProject to invoke `cmake` and `cmake --build` c)Include this project as git submodule and use add_subdirectory(libfoo) Variant "c" has advantages that potentially in this case it is possible to have almost the same compiler flags for libfoo and main project, which may give the most robust solution in case of usage visual studio (release/debug/multi thread/single thread CRT problems), plus it is simplify a lot cross compilation. But usually "libfoo" CMakeLists.txt looks like this: ``` cmake_minimum_required(VERSION 3.10) #configure many things that important for standalone #project, but not requires for project as part of another project #for example in case of gcc we add some special flags like -Wall -Wextra -pedantic and so on add_library(foo SHARED sources) ``` and part between `cmake_minimum_required` and `add_library` is useless and sometime prevent cross compilation and usage of the same compiler flags. So question how should I organize CMakeListst.txt of libfoo help deals with "c"? Should I move all specific for standalone project code to: if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) # i am standalone endif() or may be I should use some other tricks? -- 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