I have a CMake configuration file building two libraries:
- a third-party library (here called ThirdPartyLib) containing a real-time OS / board support package from a supplier. It is built outside CMake using the autotools toolchain.
- an extended version of the former library (here called ExtendedThirdPartyLib)
Unfortunately, some source code that I need (various tools) are not built in the ordinary build script for (1). Since I don't want to mess with the suppliers build script I want to add another library (2), building the missing files and thus extending the library from the supplier.
I want to able to do something like this in CMakeFiles.txt:
cmake_minimum_required(VERSION 3.2) project(bsp) include(ExternalProject) ExternalProject_Add( ThirdPartyLib URL <http://some.url/bsp.tar.bz2 BUILD_COMMAND make -C ../external/ThirdPartyLib/src ) set_target_properties(ThirdPartyLib PROPERTIES EXCLUDE_FROM_ALL TRUE) add_library(ExtendedThirdPartyLib ${CMAKE_CURRENT_BINARY_DIR}/some/path/missing_file1.c ${CMAKE_CURRENT_BINARY_DIR}/some/path/missing_file2.c ) add_dependencies(ExtendedThirdPartyLib ThirdPartyLib) target_include_directories(ExtendedThirdPartyLib PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/some/path/include ) target_link_libraries(ExtendedThirdPartyLib ThirdPartyLib) The problem here is that the path to missing_file1.c and missing_file2.c are not valid when CMake is generating the build files (they are extracted from the tarball from the supplier). CMake exits with an error output saying: "Cannot find source file".
Is there a neat way to make this work? I.e. is it possible to convince CMake that certain non-existant input files will exist when building of the library begins? Or is there any other recommended way to solve this issue?
(I have temporary made local copies of the files I need to build from the suppliers tarball, but that is of course not a good solution. If those files are changed in future versions of the suppliers package and I forget to overwrite my local copies it could be a horrible mess...
Another "solution" would be to create a small makefile outside CMake and use another ExternalProject_Add in the CMakeFiles.txt somehow. But that's not a good solution either, e.g. if compile and linker flags are modified I need to remember to change the makefile too.)