Skip to content

Commit

Permalink
fixed duplication error in CMake build target names
Browse files Browse the repository at this point in the history
  • Loading branch information
fktn-k committed Jan 6, 2025
1 parent f9de43d commit 5c3d5c0
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 60 deletions.
4 changes: 1 addition & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ target_compile_options(
>
)

# FIXME: change build instructions according to the changes in their paths.

###############################
# Build tutorial projects #
###############################
Expand All @@ -37,4 +35,4 @@ add_subdirectory(tutorials)
# Build example codes #
###########################


add_subdirectory(apis)
15 changes: 8 additions & 7 deletions examples/apis/basic_node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ file(GLOB_RECURSE EX_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(EX_SRC_FILE ${EX_SRC_FILES})
file(RELATIVE_PATH REL_EX_SRC_FILE ${CMAKE_CURRENT_SOURCE_DIR} ${EX_SRC_FILE})
string(REPLACE ".cpp" "" EX_SRC_FILE_BASE ${REL_EX_SRC_FILE})
add_executable(${EX_SRC_FILE_BASE} ${EX_SRC_FILE})
target_link_libraries(${EX_SRC_FILE_BASE} example_common_config)
set(TARGET_NAME "basic_node_${EX_SRC_FILE_BASE}")
add_executable(${TARGET_NAME} ${EX_SRC_FILE})
target_link_libraries(${TARGET_NAME} example_common_config)

add_custom_command(
TARGET ${EX_SRC_FILE_BASE}
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND $<TARGET_FILE:${EX_SRC_FILE_BASE}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND $<TARGET_FILE:${TARGET_NAME}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${TARGET_NAME}>
)
endforeach()
2 changes: 1 addition & 1 deletion examples/apis/basic_node/deserialize_docs_iterators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

int main() {
// deserialize a YAML string.
char input[] = R"(
std::string input = R"(
%YAML 1.2
---
foo: true
Expand Down
3 changes: 3 additions & 0 deletions examples/apis/basic_node/map_items.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
key: bar, value: true
key: foo, value: 123
type_error: map_items() cannot be called on a non-mapping node. type=SEQUENCE
15 changes: 8 additions & 7 deletions examples/apis/exception/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ file(GLOB_RECURSE EX_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(EX_SRC_FILE ${EX_SRC_FILES})
file(RELATIVE_PATH REL_EX_SRC_FILE ${CMAKE_CURRENT_SOURCE_DIR} ${EX_SRC_FILE})
string(REPLACE ".cpp" "" EX_SRC_FILE_BASE ${REL_EX_SRC_FILE})
add_executable(${EX_SRC_FILE_BASE} ${EX_SRC_FILE})
target_link_libraries(${EX_SRC_FILE_BASE} example_common_config)
set(TARGET_NAME "exception_${EX_SRC_FILE_BASE}")
add_executable(${TARGET_NAME} ${EX_SRC_FILE})
target_link_libraries(${TARGET_NAME} example_common_config)

add_custom_command(
TARGET ${EX_SRC_FILE_BASE}
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND $<TARGET_FILE:${EX_SRC_FILE_BASE}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND $<TARGET_FILE:${TARGET_NAME}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${TARGET_NAME}>
)
endforeach()
15 changes: 8 additions & 7 deletions examples/apis/macros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ file(GLOB_RECURSE EX_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(EX_SRC_FILE ${EX_SRC_FILES})
file(RELATIVE_PATH REL_EX_SRC_FILE ${CMAKE_CURRENT_SOURCE_DIR} ${EX_SRC_FILE})
string(REPLACE ".cpp" "" EX_SRC_FILE_BASE ${REL_EX_SRC_FILE})
add_executable(${EX_SRC_FILE_BASE} ${EX_SRC_FILE})
target_link_libraries(${EX_SRC_FILE_BASE} example_common_config)
set(TARGET_NAME "macros_${EX_SRC_FILE_BASE}")
add_executable(${TARGET_NAME} ${EX_SRC_FILE})
target_link_libraries(${TARGET_NAME} example_common_config)

add_custom_command(
TARGET ${EX_SRC_FILE_BASE}
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND $<TARGET_FILE:${EX_SRC_FILE_BASE}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND $<TARGET_FILE:${TARGET_NAME}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${TARGET_NAME}>
)
endforeach()
15 changes: 8 additions & 7 deletions examples/apis/node_type/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ file(GLOB_RECURSE EX_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(EX_SRC_FILE ${EX_SRC_FILES})
file(RELATIVE_PATH REL_EX_SRC_FILE ${CMAKE_CURRENT_SOURCE_DIR} ${EX_SRC_FILE})
string(REPLACE ".cpp" "" EX_SRC_FILE_BASE ${REL_EX_SRC_FILE})
add_executable(${EX_SRC_FILE_BASE} ${EX_SRC_FILE})
target_link_libraries(${EX_SRC_FILE_BASE} example_common_config)
set(TARGET_NAME "node_type_${EX_SRC_FILE_BASE}")
add_executable(${TARGET_NAME} ${EX_SRC_FILE})
target_link_libraries(${TARGET_NAME} example_common_config)

add_custom_command(
TARGET ${EX_SRC_FILE_BASE}
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND $<TARGET_FILE:${EX_SRC_FILE_BASE}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND $<TARGET_FILE:${TARGET_NAME}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${TARGET_NAME}>
)
endforeach()
15 changes: 8 additions & 7 deletions examples/apis/node_value_converter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ file(GLOB_RECURSE EX_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(EX_SRC_FILE ${EX_SRC_FILES})
file(RELATIVE_PATH REL_EX_SRC_FILE ${CMAKE_CURRENT_SOURCE_DIR} ${EX_SRC_FILE})
string(REPLACE ".cpp" "" EX_SRC_FILE_BASE ${REL_EX_SRC_FILE})
add_executable(${EX_SRC_FILE_BASE} ${EX_SRC_FILE})
target_link_libraries(${EX_SRC_FILE_BASE} example_common_config)
set(TARGET_NAME "node_value_converter_${EX_SRC_FILE_BASE}")
add_executable(${TARGET_NAME} ${EX_SRC_FILE})
target_link_libraries(${TARGET_NAME} example_common_config)

add_custom_command(
TARGET ${EX_SRC_FILE_BASE}
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND $<TARGET_FILE:${EX_SRC_FILE_BASE}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND $<TARGET_FILE:${TARGET_NAME}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${TARGET_NAME}>
)
endforeach()
15 changes: 8 additions & 7 deletions examples/apis/operator_literal_yaml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ file(GLOB_RECURSE EX_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(EX_SRC_FILE ${EX_SRC_FILES})
file(RELATIVE_PATH REL_EX_SRC_FILE ${CMAKE_CURRENT_SOURCE_DIR} ${EX_SRC_FILE})
string(REPLACE ".cpp" "" EX_SRC_FILE_BASE ${REL_EX_SRC_FILE})
add_executable(${EX_SRC_FILE_BASE} ${EX_SRC_FILE})
target_link_libraries(${EX_SRC_FILE_BASE} example_common_config)
set(TARGET_NAME "operator_literal_yaml_${EX_SRC_FILE_BASE}")
add_executable(${TARGET_NAME} ${EX_SRC_FILE})
target_link_libraries(${TARGET_NAME} example_common_config)

add_custom_command(
TARGET ${EX_SRC_FILE_BASE}
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND $<TARGET_FILE:${EX_SRC_FILE_BASE}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND $<TARGET_FILE:${TARGET_NAME}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${TARGET_NAME}>
)
endforeach()
15 changes: 8 additions & 7 deletions examples/apis/ordered_map/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ file(GLOB_RECURSE EX_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(EX_SRC_FILE ${EX_SRC_FILES})
file(RELATIVE_PATH REL_EX_SRC_FILE ${CMAKE_CURRENT_SOURCE_DIR} ${EX_SRC_FILE})
string(REPLACE ".cpp" "" EX_SRC_FILE_BASE ${REL_EX_SRC_FILE})
add_executable(${EX_SRC_FILE_BASE} ${EX_SRC_FILE})
target_link_libraries(${EX_SRC_FILE_BASE} example_common_config)
set(TARGET_NAME "ordered_map_${EX_SRC_FILE_BASE}")
add_executable(${TARGET_NAME} ${EX_SRC_FILE})
target_link_libraries(${TARGET_NAME} example_common_config)

add_custom_command(
TARGET ${EX_SRC_FILE_BASE}
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND $<TARGET_FILE:${EX_SRC_FILE_BASE}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND $<TARGET_FILE:${TARGET_NAME}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${TARGET_NAME}>
)
endforeach()
15 changes: 8 additions & 7 deletions examples/apis/yaml_version_type/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ file(GLOB_RECURSE EX_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(EX_SRC_FILE ${EX_SRC_FILES})
file(RELATIVE_PATH REL_EX_SRC_FILE ${CMAKE_CURRENT_SOURCE_DIR} ${EX_SRC_FILE})
string(REPLACE ".cpp" "" EX_SRC_FILE_BASE ${REL_EX_SRC_FILE})
add_executable(${EX_SRC_FILE_BASE} ${EX_SRC_FILE})
target_link_libraries(${EX_SRC_FILE_BASE} example_common_config)
set(TARGET_NAME "yaml_version_type_${EX_SRC_FILE_BASE}")
add_executable(${TARGET_NAME} ${EX_SRC_FILE})
target_link_libraries(${TARGET_NAME} example_common_config)

add_custom_command(
TARGET ${EX_SRC_FILE_BASE}
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND $<TARGET_FILE:${EX_SRC_FILE_BASE}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${EX_SRC_FILE_BASE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INPUT_MULTI_YAML_PATH} $<TARGET_FILE_DIR:${TARGET_NAME}>
COMMAND $<TARGET_FILE:${TARGET_NAME}> > ${CMAKE_CURRENT_SOURCE_DIR}/${EX_SRC_FILE_BASE}.output
WORKING_DIRECTORY $<TARGET_FILE_DIR:${TARGET_NAME}>
)
endforeach()

0 comments on commit 5c3d5c0

Please sign in to comment.