compilescript allows you to execute files from compiled languages as scripts.
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.

CMakeLists.txt 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. cmake_minimum_required (VERSION 3.2)
  2. project(compilescript
  3. VERSION 0.4.0
  4. LANGUAGES CXX
  5. )
  6. include(GNUInstallDirs)
  7. find_package(PkgConfig REQUIRED)
  8. pkg_check_modules(LIBXDG_BASEDIR REQUIRED libxdg-basedir)
  9. pkg_check_modules(LIBCONFIG REQUIRED libconfig++)
  10. set(CMAKE_CXX_STANDARD 14)
  11. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  12. set(CMAKE_CXX_EXTENSIONS OFF)
  13. set(CMAKE_CXX_FLAGS_DEBUG
  14. "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wpedantic -ftrapv -fsanitize=undefined -g -Og -fno-omit-frame-pointer")
  15. include_directories(${PROJECT_BINARY_DIR})
  16. include_directories(${LIBXDG_BASEDIR_INCLUDE_DIRS})
  17. include_directories(${LIBCONFIG_INCLUDE_DIRS})
  18. link_directories(${LIBXDG_BASEDIR_LIBRARY_DIRS})
  19. link_directories(${LIBCONFIG_LIBRARY_DIRS})
  20. # Write version in header
  21. configure_file(
  22. "${PROJECT_SOURCE_DIR}/src/version.hpp.in"
  23. "${PROJECT_BINARY_DIR}/version.hpp"
  24. )
  25. file(GLOB sources src/*.cpp)
  26. add_executable(${CMAKE_PROJECT_NAME} "${sources}")
  27. target_link_libraries(${CMAKE_PROJECT_NAME}
  28. "${LIBXDG_BASEDIR_LDFLAGS} ${LIBCONFIG_LDFLAGS}"
  29. "-lstdc++fs")
  30. install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
  31. set(WITH_MAN "YES" CACHE STRING "WITH_MAN defaults to \"YES\"")
  32. if (WITH_MAN)
  33. add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.1"
  34. WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
  35. DEPENDS "${CMAKE_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.1.adoc"
  36. COMMAND ${CMAKE_SOURCE_DIR}/build_manpage.sh
  37. ARGS ${PROJECT_VERSION})
  38. add_custom_target(run ALL
  39. DEPENDS "${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.1")
  40. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.1
  41. DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
  42. endif()