Please see the below minimal example
cmake_minimum_required(VERSION 3.20)
project(sample)
add_library(libA A.cpp A.h)
add_library(libB B.cpp B.h)
add_executable(${PROJECT_NAME} main.cpp)
# Given it is known that libA and libB is incompatible,
# is it possible to write some extra cmake code to show error while doing cmake config,
# instead of having to compile to discover the error?
target_link_libraries(${PROJECT_NAME} libA libB) --> need to show error
# target_link_libraries(${PROJECT_NAME} libA) --> ok
# target_link_libraries(${PROJECT_NAME} libB) --> ok
Given that I can't alter the source of libA and libB to make them compatible, how can I discover the error earlier in the CMake configuration stage instead of having to compile the huge codebase to find out the error?