🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.9 KiB

  1. cmake_minimum_required (VERSION 2.8.11)
  2. project (dirent LANGUAGES C CXX)
  3. # User options
  4. option(DIRENT_BUILD_TESTS "Build bundled tests" ON)
  5. message(STATUS "Build test and example programs: ${DIRENT_BUILD_TESTS}")
  6. # Initialize C and C++ compilers
  7. enable_language (C CXX)
  8. # Compile in debug mode by default
  9. if (NOT CMAKE_BUILD_TYPE)
  10. set (CMAKE_BUILD_TYPE Debug
  11. CACHE STRING
  12. "Type of build: None Debug Release RelWithDebInfo MinSizeRel."
  13. FORCE
  14. )
  15. endif (NOT CMAKE_BUILD_TYPE)
  16. # Use the include directory only on Windows
  17. if (WIN32)
  18. include_directories (${CMAKE_SOURCE_DIR}/include)
  19. endif (WIN32)
  20. # Install dirent.h
  21. if (WIN32)
  22. install (FILES include/dirent.h DESTINATION include)
  23. endif (WIN32)
  24. # Add distclean target
  25. add_custom_target (distclean
  26. COMMAND ${CMAKE_BUILD_TOOL} clean
  27. COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/distclean.cmake
  28. )
  29. # Build example programs
  30. if(DIRENT_BUILD_TESTS)
  31. add_executable (find examples/find.c)
  32. add_executable (ls examples/ls.c)
  33. add_executable (locate examples/locate.c)
  34. add_executable (updatedb examples/updatedb.c)
  35. add_executable (scandir examples/scandir.c)
  36. add_executable (cat examples/cat.c)
  37. # Build test programs
  38. include (CTest)
  39. add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR})
  40. function (add_test_executable TEST_NAME)
  41. add_executable (${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN})
  42. add_test (NAME ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND $<TARGET_FILE:${TEST_NAME}>)
  43. add_dependencies (check ${TEST_NAME})
  44. endfunction (add_test_executable)
  45. add_test_executable (t-compile tests/t-compile.c)
  46. add_test_executable (t-dirent tests/t-dirent.c)
  47. add_test_executable (t-scandir tests/t-scandir.c)
  48. add_test_executable (t-unicode tests/t-unicode.c)
  49. add_test_executable (t-cplusplus tests/t-cplusplus.cpp)
  50. endif(DIRENT_BUILD_TESTS)