p-ranav / argparse

Argument Parser for Modern C++
MIT License
2.67k stars 244 forks source link

Fix all samples building to "tests" binary #296

Closed cobyj33 closed 1 year ago

cobyj33 commented 1 year ago

There was a line in samples/CMakeLists.txt which built all samples to the same binary name "tests", which made all the samples override each other while building.

function(add_sample NAME)
  ADD_EXECUTABLE(ARGPARSE_SAMPLE_${NAME} ${NAME}.cpp)
  INCLUDE_DIRECTORIES("../include" ".")
  set_target_properties(ARGPARSE_SAMPLE_${NAME} PROPERTIES OUTPUT_NAME ${NAME})
  set_target_properties(ARGPARSE_SAMPLE_${NAME} PROPERTIES OUTPUT_NAME tests) # This line overrides the above line
  set_property(TARGET ARGPARSE_SAMPLE_${NAME} PROPERTY CXX_STANDARD 17)
endfunction()

Simply removing the line:

function(add_sample NAME)
  ADD_EXECUTABLE(ARGPARSE_SAMPLE_${NAME} ${NAME}.cpp)
  INCLUDE_DIRECTORIES("../include" ".")
  set_target_properties(ARGPARSE_SAMPLE_${NAME} PROPERTIES OUTPUT_NAME ${NAME})
  set_property(TARGET ARGPARSE_SAMPLE_${NAME} PROPERTY CXX_STANDARD 17)
endfunction()

causes all of the binaries to properly build to their respective files.