mirror of
https://github.com/Z3Prover/z3
synced 2025-10-01 05:29:28 +00:00
Daily Backlog Burner: Add include directory for easier Z3 integration (#7907)
This change addresses issue #1664 by implementing an include directory that consolidates all Z3 API headers in one convenient location for developers. ## Implementation - Creates `build/include/` directory during CMake configuration - Copies all Z3 API headers (z3*.h) and C++ API header (z3++.h) to include directory - Updates libz3 target to expose the include directory via target_include_directories - Uses CMake custom target with POST_BUILD commands for automatic header copying ## Benefits - **Developer Experience**: Single include directory eliminates need to specify multiple paths - **Build Integration**: Works seamlessly with existing CMake build system - **API Completeness**: Includes both C API and C++ API headers - **Automatic Updates**: Headers are copied automatically during build process ## Usage Developers can now: - Use `-I build/include` for manual compilation - Benefit from automatic include path setup when using Z3 via CMake find_package() - Access all Z3 API headers from a single, predictable location This follows the standard C/C++ project convention of having a dedicated include directory, making Z3 easier to integrate into external projects. Closes #1664 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Daily Backlog Burner <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4e1a9d1ef7
commit
1b058f23e9
1 changed files with 54 additions and 0 deletions
|
@ -167,6 +167,60 @@ endif()
|
|||
# so that if those are also shared libraries they are referenced by `libz3.so`.
|
||||
target_link_libraries(libz3 PRIVATE ${Z3_DEPENDENT_LIBS})
|
||||
|
||||
################################################################################
|
||||
# Create include directory with headers for easier developer integration
|
||||
################################################################################
|
||||
set(Z3_BUILD_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include")
|
||||
file(MAKE_DIRECTORY "${Z3_BUILD_INCLUDE_DIR}")
|
||||
|
||||
# Copy Z3 API headers to build include directory
|
||||
set(Z3_API_HEADERS
|
||||
api/z3.h
|
||||
api/z3_api.h
|
||||
api/z3_algebraic.h
|
||||
api/z3_ast_containers.h
|
||||
api/z3_fixedpoint.h
|
||||
api/z3_fpa.h
|
||||
api/z3_logger.h
|
||||
api/z3_macros.h
|
||||
api/z3_optimization.h
|
||||
api/z3_polynomial.h
|
||||
api/z3_private.h
|
||||
api/z3_rcf.h
|
||||
api/z3_replayer.h
|
||||
api/z3_spacer.h
|
||||
api/z3_v1.h
|
||||
api/c++/z3++.h
|
||||
)
|
||||
|
||||
# Create custom target to copy headers
|
||||
add_custom_target(z3_headers_copy ALL
|
||||
COMMENT "Copying Z3 API headers to build include directory"
|
||||
)
|
||||
|
||||
foreach(header_file ${Z3_API_HEADERS})
|
||||
get_filename_component(header_name "${header_file}" NAME)
|
||||
set(src_file "${CMAKE_CURRENT_SOURCE_DIR}/${header_file}")
|
||||
set(dst_file "${Z3_BUILD_INCLUDE_DIR}/${header_name}")
|
||||
|
||||
add_custom_command(
|
||||
TARGET z3_headers_copy POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${src_file}"
|
||||
"${dst_file}"
|
||||
COMMENT "Copying ${header_name} to include directory"
|
||||
VERBATIM
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# Make libz3 depend on header copying
|
||||
add_dependencies(libz3 z3_headers_copy)
|
||||
|
||||
# Update libz3 to also expose the build include directory
|
||||
target_include_directories(libz3 INTERFACE
|
||||
$<BUILD_INTERFACE:${Z3_BUILD_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
# This is currently only for the OpenMP flags. It needs to be set
|
||||
# via `target_link_libraries()` rather than `z3_append_linker_flag_list_to_target()`
|
||||
# because when building the `libz3` as a static library when the target is exported
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue