The source code and dockerfile for the GSW2024 AI Lab.
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

98 lines
3.3 KiB

2 months ago
  1. cmake_minimum_required(VERSION 3.0.0)
  2. project(carl-parser)
  3. option(BUILD_JAR "Built ANTLR jar file" OFF)
  4. set(DYNAMIC_EXT ".so")
  5. set(STATIC_EXT ".a")
  6. if(APPLE)
  7. set(DYNAMIC_EXT ".dylib")
  8. set(STATIC_EXT ".a")
  9. elseif (WIN32)
  10. set(DYNAMIC_EXT ".dll")
  11. set(STATIC_EXT ".lib")
  12. endif()
  13. if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # Matches "Clang" and "AppleClang"
  14. if (APPLE)
  15. message(STATUS "Using clang ${CMAKE_CXX_COMPILER_VERSION} on apple")
  16. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -stdlib=libc++")
  17. ## RPATH settings
  18. set(CMAKE_MACOSX_RPATH 1)
  19. # don't skip the full RPATH for the build tree
  20. SET(CMAKE_SKIP_BUILD_RPATH FALSE)
  21. # when building, don't use the install RPATH already (but only when installing)
  22. SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  23. # the RPATH to be used when installing
  24. SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
  25. # add the automatically determined parts of the RPATH
  26. # which point to directories outside the build tree to the install RPATH
  27. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  28. else()
  29. message(STATUS "Using clang ${CMAKE_CXX_COMPILER_VERSION}")
  30. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
  31. endif()
  32. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_RELEASE_FLAGS} -O3 -fomit-frame-pointer -msse -msse2 -funroll-loops")
  33. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_DEBUG_FLAGS} -O1")
  34. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  35. message(STATUS "Using g++ ${CMAKE_CXX_COMPILER_VERSION}")
  36. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wunknown-pragmas")
  37. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=5 -fdiagnostics-color=auto")
  38. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_RELEASE_FLAGS} -O3")
  39. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_DEBUG_FLAGS} -O1")
  40. else()
  41. message(WARNING "Possibly unsupported compiler ${CMAKE_CXX_COMPILER_ID}")
  42. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
  43. endif()
  44. # Require carl
  45. find_package(carl REQUIRED)
  46. # Output information about carl
  47. get_target_property(carlLOCATION lib_carl LOCATION)
  48. message(STATUS "Using carl ${carl_VERSION} from ${carlLOCATION}.")
  49. # External projects
  50. include(ExternalProject)
  51. SET_DIRECTORY_PROPERTIES(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/resources)
  52. set(ANTLR_VERSION "4.7.2")
  53. if (BUILD_JAR)
  54. message(STATUS "Built jar file of ANTLR ${ANTLR_VERSION}")
  55. else()
  56. message(STATUS "Use shipped jar file of ANTLR ${ANTLR_VERSION}")
  57. endif()
  58. include(resources/antlr4.cmake)
  59. # Add actual sources
  60. add_subdirectory(src)
  61. # tests
  62. enable_testing()
  63. add_subdirectory(test)
  64. # Add all targets to the build-tree export set
  65. set(EXPORT_TARGETS "carl-parser")
  66. export(TARGETS ${EXPORT_TARGETS} FILE "${PROJECT_BINARY_DIR}/carlparserTargets.cmake")
  67. message(STATUS "Registered with cmake")
  68. export(PACKAGE carlparser)
  69. set(INCLUDE_DIR include/)
  70. include(CMakePackageConfigHelpers)
  71. include(cmake/export_target.cmake)
  72. export_target(DEP_TARGETS antlr4shared)
  73. set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src")
  74. configure_package_config_file(
  75. cmake/carlparserConfig.cmake.in
  76. ${PROJECT_BINARY_DIR}/carlparserConfig.cmake
  77. INSTALL_DESTINATION ${PROJECT_BINARY_DIR}
  78. PATH_VARS INCLUDE_DIR
  79. )
  80. if (APPLE)
  81. message(WARNING "If tests are unsuccessful or errors occur, try running 'cmake ..' and 'make' once again.")
  82. endif()