I have a number of legacy Makefiles I am using through add_custom_command to produce libraries and executables as we slowly port to CMake. One issue I’m having is dealing with the CXX and CUDA target compile flags propagated through depenendent interface libraries that have been ported to CMake.
What I was hoping I can do to stage things is add a proxy CMake target that acts as a placeholder for the eventual library once it’s build can be ported to CMake by doing something like …
add_library(my_lib_proxy STATIC IMPORTED)
target_link_libraries(my_lib_proxy PRIVATE some_other_lib)
target_compile_definitions(my_lib_proxy PRIVATE FOO=1)
add_custom_command(
OUTPUT ./my_lib.a
COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR} CXXFLAGS=$<TARGET_PROPERTY:my_lib_proxy,*EXPANDED_CXX_FLAGS*>
The goal would be to pass the command-line arguments that CMake would pass to the compiler to my Makefile instead. Is there a way to extract the expanded flags from a target somehow?