Use absolute path to link z3 to allow builds both on windows and linux since the library name is platform dependent for Z3 (libz3 on Windows and z3 on Linux) and MSVC does not recognized -L and -l options.
Fix CMAKE_CROSSCOMPILING that does not work correctly since it uses Z3_BUILD_VERSION instead of Z3_BUILD_NUMBER
Fix building with the static version of z3 library (supersedes D80227).
- Build the Z3 version detection code as C++, since the static library brings in libstdc++ symbols
- Detect threading support and link against threading, in the (likely) case Z3 was built with threads
Exposed compilation error from building a program that is used to detect z3 version in the warning message, to simplify troubleshooting.
I was curious why you're checking CMAKE_THREAD_LIBS_INIT instead of Threads_FOUND . Maybe include a comment saying that CMAKE_THREAD_LIBS_INIT may be empty if the thread functions are provided by the system libraries and no special flags are needed.