My current project requires a library that is built with a Makefile. I would like to compile this library during my project compilation time; this feature is the main selling point of FetchContent and it works pretty well with CMake dependencies. Nevertheless, I am unable to get it to work with Makefiles, nor can I find examples on how to do so.
FetchContent_Declare(
make_lib
URL http://url/library_code.tar.gz
BUILD_COMMAND ${CMAKE_COMMAND} -E env make -j 8
BUILD_IN_SOURCE true
BINARY_DIR ""
)
FetchContent_GetProperties(make_lib)
if (NOT make_lib_POPULATED)
FetchContent_Populate(make_lib)
# here I would like to declare imported libraries:
add_library(make_lib::libA STATIC IMPORTED GLOBAL)
target_include_directories(make_lib::libA INTERFACE ${make_lib_SOURCE_DIR}/include)
set_property(TARGET make_lib::libA PROPERTY IMPORTED_LOCATION <path to "to be built" lib>)
endif()
- Is a "compile-time" execution of
make
possible at all? - If so, could it be parallel?
- Is it possible to declare imported targets using the dependency-compiled library?