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

Move private header in a private directory #3157

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 19 additions & 19 deletions api/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,36 +254,34 @@ foreach(header IN LISTS api_headers)
endforeach()

set(generated_headers
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_enums_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_enums.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_string_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_brush_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_sharedvector_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_properties_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_image_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_color_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_pathdata_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_qt_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_backend_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_generated_public.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_enums_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_enums.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_string_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_brush_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_sharedvector_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_properties_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_image_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_color_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_pathdata_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_qt_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_backend_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_generated_public.h
)

if(SLINT_FEATURE_INTERPRETER)
list(APPEND generated_headers
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_interpreter_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/slint_interpreter_generated_public.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_interpreter_internal.h
${CMAKE_CURRENT_BINARY_DIR}/generated_include/private/slint_interpreter_generated_public.h
)
endif()


foreach(header IN LISTS generated_headers)
set_property(TARGET Slint APPEND PROPERTY PUBLIC_HEADER ${header})
endforeach()

target_include_directories(Slint INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated_include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated_include/private>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/private>
Comment on lines +283 to +284
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this, this doesn't have the expected effect when using FetchContent_Declare, as the private is in the include path :-(

$<INSTALL_INTERFACE:include/slint>
)

Expand All @@ -297,6 +295,8 @@ export(TARGETS Slint slint-cpp
install(EXPORT SlintTargets NAMESPACE Slint:: DESTINATION lib/cmake/Slint)
install(TARGETS Slint slint-cpp
EXPORT SlintTargets LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/slint)
install(DIRECTORY include/private DESTINATION include/slint FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated_include/private DESTINATION include/slint FILES_MATCHING PATTERN "*.h")

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
Expand Down
17 changes: 9 additions & 8 deletions api/cpp/cbindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,23 +749,24 @@ impl EnabledFeatures {

/// Generate the headers.
/// `root_dir` is the root directory of the slint git repo
/// `include_dir` is the output directory
/// `out_dir` is the output directory
/// Returns the list of all paths that contain dependencies to the generated output. If you call this
/// function from build.rs, feed each entry to stdout prefixed with `cargo:rerun-if-changed=`.
pub fn gen_all(
root_dir: &Path,
include_dir: &Path,
out_dir: &Path,
enabled_features: EnabledFeatures,
) -> anyhow::Result<Vec<PathBuf>> {
proc_macro2::fallback::force(); // avoid a abort if panic=abort is set
std::fs::create_dir_all(include_dir).context("Could not create the include directory")?;
let gen_dir = out_dir.join("private");
std::fs::create_dir_all(&gen_dir).context("Could not create the include directory")?;
let mut deps = Vec::new();
enums(include_dir)?;
gen_corelib(root_dir, include_dir, &mut deps, enabled_features)?;
gen_backend_qt(root_dir, include_dir, &mut deps)?;
gen_backend(root_dir, include_dir, &mut deps)?;
enums(&gen_dir)?;
gen_corelib(root_dir, &gen_dir, &mut deps, enabled_features)?;
gen_backend_qt(root_dir, &gen_dir, &mut deps)?;
gen_backend(root_dir, &gen_dir, &mut deps)?;
if enabled_features.interpreter {
gen_interpreter(root_dir, include_dir, &mut deps)?;
gen_interpreter(root_dir, &gen_dir, &mut deps)?;
}
Ok(deps)
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions api/cpp/include/slint.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# pragma GCC diagnostic ignored "-Winvalid-offsetof"
#endif

#include "slint_internal.h"
#include "slint_size.h"
#include "slint_point.h"
#include "slint_backend_internal.h"
#include "slint_qt_internal.h"
#include "private/slint_internal.h"
#include "private/slint_size.h"
#include "private/slint_point.h"
#include "private/slint_backend_internal.h"
#include "private/slint_qt_internal.h"

#include <vector>
#include <memory>
Expand Down