CMakeLists.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ################################################################################
  2. # This file is part of the argtable3 library.
  3. #
  4. # Copyright (C) 2016-2019 Tom G. Huang
  5. # <tomghuang@gmail.com>
  6. # All rights reserved.
  7. #
  8. # Redistribution and use in source and binary forms, with or without
  9. # modification, are permitted provided that the following conditions are met:
  10. # * Redistributions of source code must retain the above copyright
  11. # notice, this list of conditions and the following disclaimer.
  12. # * Redistributions in binary form must reproduce the above copyright
  13. # notice, this list of conditions and the following disclaimer in the
  14. # documentation and/or other materials provided with the distribution.
  15. # * Neither the name of STEWART HEITMANN nor the names of its contributors
  16. # may be used to endorse or promote products derived from this software
  17. # without specific prior written permission.
  18. #
  19. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  20. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. # ARE DISCLAIMED. IN NO EVENT SHALL STEWART HEITMANN BE LIABLE FOR ANY DIRECT,
  23. # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. ################################################################################
  30. file(GLOB EXAMPLES_SOURCES RELATIVE ${PROJECT_SOURCE_DIR}/examples *.c)
  31. if(UNIX)
  32. set(ARGTABLE3_EXTRA_LIBS m)
  33. endif()
  34. foreach(examples_src ${EXAMPLES_SOURCES})
  35. string(REPLACE ".c" "" examplename ${examples_src})
  36. add_executable(${examplename} ${PROJECT_SOURCE_DIR}/examples/${examples_src})
  37. target_include_directories(${examplename} PRIVATE ${PROJECT_SOURCE_DIR}/src)
  38. if(ARGTABLE3_BUILD_STATIC_EXAMPLES)
  39. target_link_libraries(${examplename} argtable3_static ${ARGTABLE3_EXTRA_LIBS})
  40. else()
  41. target_link_libraries(${examplename} argtable3 ${ARGTABLE3_EXTRA_LIBS})
  42. endif()
  43. endforeach()