Click here to Skip to main content
15,898,588 members

Comments by twhall (Top 1 by date)

twhall 3-Apr-23 22:19pm View    
[I hope that a "Comment" preserves formatting. We shall see. Apologies if it does not.]

Thanks Peter_in_2780. Yes, I'm trying something like that. If "A" builds A.dll, it sets cache variables for A_RUNTIME and A_INCLUDE_DIR with the full pathnames for A.dll and A/include. When "B" configures, it tests for the existence of ${A_RUNTIME}. If it exists, it adds a compile_definition and an include_directory, with the intention that "B" will dynamically load and use A:


if (EXISTS "${A_RUNTIME}")
target_compile_definitions(B PRIVATE A_RUNTIME="${A_RUNTIME}")
target_include_directories(B PRIVATE "${A_INCLUDE_DIR}")
endif()


B.cpp then uses #ifdef A_RUNTIME to conditionally include A's headers and dynamically load A_RUNTIME

If ${A_RUNTIME} doesn't exist, B should fall back to some alternative implementation or graceful failure, without a hard dependence on "A".

Still trying to get CMake to try to build A and determine the existence of A.dll before configuring "B" to use it or not.