Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Z3Config.cmake.in when generating a static library #5555

Merged
merged 1 commit into from
Sep 17, 2021

Conversation

mrexodia
Copy link
Contributor

@mrexodia mrexodia commented Sep 17, 2021

If you use -DZ3_BUILD_LIBZ3_SHARED=OFF and then the following CMakeLists.txt to find the installed Z3:

cmake_minimum_required(VERSION 3.15)

project(z3_static_test)

find_package(Z3 REQUIRED CONFIG)

add_executable(z3_static_test src/main.cpp)

target_link_libraries(z3_static_test PRIVATE z3::libz3)

You will get the following error:

-- Configuring done
CMake Error at CMakeLists.txt:51 (add_executable):
  Target "z3_static_test" links to target "Threads::Threads" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?


-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

This is because the find_dependency calls for Threads (and GMP) are missing. When building a shared library this is no problem because these are not part of the IMPORTED target, but when you build a static library these dependencies will be propagated to the final executable you link.

@NikolajBjorner NikolajBjorner merged commit 91fb646 into Z3Prover:master Sep 17, 2021
@mrexodia mrexodia deleted the fix-z3config branch August 8, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants