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

[feature-10] Add clean-headers target for build system #66

Merged
merged 3 commits into from
Oct 26, 2022
Merged
Changes from 2 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
24 changes: 15 additions & 9 deletions cmake/GenerateDiaHeader.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
# Global cmake target responsible for the generation of all the cpp headers
add_custom_target(generate-headers)

IF (WIN32)
add_custom_target(clean-headers
COMMAND cd ${CMAKE_BINARY_DIR} && del generate_header_*.stamp
)
ELSE ()
add_custom_target(clean-headers
COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_SOURCE_DIR}/src/*/*.hpp
COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_SOURCE_DIR}/src/*/*/*.hpp
COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_BINARY_DIR}/generate_header_*.stamp
)
ENDIF ()

# Fonction that generate cpp header files from dia files using dia2code.
# Dia files must contain only one namespace and must be named by this
# namespace.
Expand All @@ -21,15 +33,12 @@ function(generate_dia_header dia_file)
# Stamp file that take care of the dependency chain
set(stamp ${PROJECT_BINARY_DIR}/generate_header_${namespace}.stamp)

file(
REMOVE
${PROJECT_SOURCE_DIR}/src/*/${namespace}.hpp
${PROJECT_SOURCE_DIR}/src/*/${namespace}/*.hpp
)
# Custom command that generate the cpp headers and create the stamp file
IF (WIN32)
add_custom_command(
OUTPUT ${stamp}
COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_SOURCE_DIR}/src/*/${namespace}.hpp
COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_SOURCE_DIR}/src/*/${namespace}/*.hpp
COMMAND ${CMAKE_COMMAND} -E env "PATH=\"%PATH%;${CMAKE_BINARY_DIR}/lib\"" $<TARGET_FILE:dia2code> -d ${output_dir} -ext hpp -t cpp ${dia_file}
COMMAND ${CMAKE_COMMAND} -E touch ${stamp}
DEPENDS ${dia_file}
Expand All @@ -49,7 +58,4 @@ function(generate_dia_header dia_file)
# Add the intermediate target as a dependency of the global cmake target for header
# generation.
add_dependencies(generate-headers generate-header-${namespace})
endfunction()

# vim: set sw=2 sts=2 et:

endfunction()