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

sync: from linuxdeepin/dtkcore #82

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions cmake/DtkDConfig/DtkDConfigConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,41 @@ if(NOT DEFINED DSG_DATA_DIR)
endif()

add_definitions(-DDSG_DATA_DIR=\"${DSG_DATA_DIR}\")

# Define the helper function
function(dtk_config_to_cpp JSON_FILE OUTPUT_VAR)
if(NOT EXISTS ${JSON_FILE})
message(FATAL_ERROR "JSON file ${JSON_FILE} does not exist.")
endif()

# Generate the output header file name
get_filename_component(FILE_NAME_WE ${JSON_FILE} NAME_WE)
if(DEFINED OUTPUT_FILE_NAME)
set(OUTPUT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_FILE_NAME}")
else()
set(OUTPUT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/${FILE_NAME_WE}.hpp")
endif()

# Check if CLASS_NAME is set
if(DEFINED CLASS_NAME)
set(CLASS_NAME_ARG -c ${CLASS_NAME})
else()
set(CLASS_NAME_ARG "")
endif()

# Add a custom command to run dconfig2cpp
add_custom_command(
OUTPUT ${OUTPUT_HEADER}
COMMAND ${TOOL_INSTALL_DIR}/dconfig2cpp -o ${OUTPUT_HEADER} ${CLASS_NAME_ARG} ${JSON_FILE}
DEPENDS ${JSON_FILE}
COMMENT "Generating ${OUTPUT_HEADER} from ${JSON_FILE}"
VERBATIM
)

# Add the generated header to the specified output variable
set(${OUTPUT_VAR} ${${OUTPUT_VAR}} ${OUTPUT_HEADER} PARENT_SCOPE)
endfunction()

# deploy some `meta` 's configure.
#
# FILES - deployed files.
Expand Down
1 change: 1 addition & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ add_subdirectory(deepin-os-release)
add_subdirectory(qdbusxml2cpp)
add_subdirectory(settings)
add_subdirectory(ch2py)
add_subdirectory(dconfig2cpp)
26 changes: 26 additions & 0 deletions tools/dconfig2cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set(TARGET_NAME dconfig2cpp)
set(BIN_NAME ${TARGET_NAME}${DTK_VERSION_MAJOR})

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)

add_executable(${BIN_NAME}
main.cpp
)

target_link_libraries(
${BIN_NAME} PRIVATE
Qt${QT_VERSION_MAJOR}::Core
)

set_target_properties(
${BIN_NAME} PROPERTIES
OUTPUT_NAME ${TARGET_NAME}
EXPORT_NAME dconfig2cpp
)

install(
TARGETS ${BIN_NAME}
EXPORT Dtk${DTK_VERSION_MAJOR}ToolsTargets
DESTINATION ${TOOL_INSTALL_DIR}
)
Loading
Loading